Setting up TCSH

I've got a Digital Ocean droplet running FreeBSD which I shell into.

I can locate tcsh under /bin/tcsh but using setenv in my local .cshrc file doesn't cause this shell to be used on next login.

Env reports the shell as sh and the prompt hasn't changed to >

Editing master.passwd to use tcsh doesn't change to tcsh on next login

where do I need to edit to move to Tcsh?
 
Your login shell is stored in /etc/passwd. There are many tools that can be used to modify it. I personally like vipw, which edits that file directly. Swegen above likes pw, another fine choice. It will be instructive to read that file, while looking at the documentation in passwd(5).
 
The best way to do this is using chsh which is short for "Change Shell" and an alias for chpass(1): adds or changes user database information.

The reason why I consider this command to be the best option is because you don't have to be root to use this. Better yet: there can be absolutely no doubt what you need to change either, something which doesn't necessarily apply if you edit /etc/passwd directly:

Code:
#Changing user information for peter.
Shell: /usr/local/bin/ksh
Full Name: Peter <bleep>
Office Location: xx
Office Phone: xx
Home Phone: xx
Other information:
So in your case all you'd have to do is know where csh is located (probably /usr/csh or /bin/tcsh) and then change this accordingly.
 
Why not just?:
Code:
chsh -s tcsh <username>
Like in any Unix-like system, including OS X, any *BSD, and GNU/Linux

see chpass(1), as well as chsh on wikipedia ;)
 
Code:
$ sudo pw usermod freebsd -s /bin/tcsh
pw: entry inconsistent
pw: pw_copy(): Invalid argument
$ sudo chsh -s tcsh freebsd
chsh: entry inconsistent
chsh: pw_copy: Invalid argument
 
You've edited master.passwd by hand and made a mistake in there. Never, ever, edit that file by hand.
 
and, after editing as sudo when I :
Code:
tail /etc/passwd


freebsd:*:1001:1001:FreeBSD:/usr/home/freebsd:/bin/tcsh
 
You've edited master.passwd by hand and made a mistake in there. Never, ever, edit that file by hand.

I don't see any edits in there:
Code:
# $FreeBSD: releng/11.1/usr.sbin/pw/tests/master.passwd 272445 2014-10-02 19:53:
37Z brd $
#
root:*:0:0::0:0:Charlie &:/root:/bin/csh
toor:*:0:0::0:0:Bourne-again Superuser:/root:
 
Well, you did something to it, because it's out of sync with /etc/passwd. The passwd file still has the freebsd user and master.passwd doesn't.

Code:
# $FreeBSD: releng/11.1/usr.sbin/pw/tests/master.passwd 272445 2014-10-02 19:53:
37Z brd $
This might be due to a copy/paste error but this should all be on one line.

I would try to delete the account: pw userdel freebsd and recreate it using the same UID/GID.
 
Well, you did something to it, because it's out of sync with /etc/passwd. The passwd file still has the freebsd user and master.passwd doesn't.

Code:
# $FreeBSD: releng/11.1/usr.sbin/pw/tests/master.passwd 272445 2014-10-02 19:53:
37Z brd $
This might be due to a copy/paste error but this should all be on one line.

I would try to delete the account: pw userdel freebsd and recreate it using the same UID/GID.

EDIT - I am not sure that I have edited that file. I've just checked the stamps on that directory:
Code:
$ ls -l /usr/src/usr.sbin/pw/tests/
total 92
-rw-r--r--  1 root  wheel   1758 Jul 20 23:42 crypt.c
-rw-r--r--  1 root  wheel     99 Jul 20 23:42 group
-rwxr-xr-x  1 root  wheel    992 Jul 20 23:42 helper_functions.shin
-rw-r--r--  1 root  wheel    640 Jul 20 23:42 Makefile
-rw-r--r--  1 root  wheel    261 Jul 20 23:42 Makefile.depend
-rw-r--r--  1 root  wheel    179 Jul 20 23:42 master.passwd
- all same date

I'm not sure that deleting the user isn't a possibility as they are setup by digital ocean as a default - authentication for these accounts is via an agreed ssh.

I could modify the etc/passwd back to csh - which is the change I've made?
 
That's the source of the files, not the actual files. These get installed during a make installworld and mergemaster(8). They are not the "real" files the OS actually uses.
 
If you edited /etc/master.passwd by hand (which you should NEVER do as already said), you'd have to manually update the passwd-db file which is the actual file that is used.
The db can be updated with pwd_mkdb(8): pwd_mkdb -p /etc/master.passwd

But as said: never edit any of the /etc/[master.]passwd files by hand unless absolutely necessary. Either use the vipw(8) tool if you _really_ want to edit the file by hand (and possibly introducing errors) or use the chsh(8) tool. Both are available on all BSDs and a varying subsets of other UNIX-derived systems and some Linux variants. On Solaris/illumos you can use passwd -e (IIRC most Linux systems also have this option for passwd).
 
That's the source of the files, not the actual files. These get installed during a make installworld and mergemaster(8). They are not the "real" files the OS actually uses.

Okay, but as this system is from an image (presumably, from the Digital Ocean droplet) and I didn't run either of those commands - can I restore without removing the user?
 
I would take a long hard look at /etc/master.passwd, you most likely introduced an error there when you first edited it.
 
I checked the date -r for the edit, and it was edited, but there wasn't any entry for my user.
Ran pwd_mkdb -p /etc/master.passwd
used pw usermod name -s /bin/tcsh

got tcsh.

Thanks all
 
toor:*:0:0::0:0:Bourne-again Superuser:/root:

If it was me, the first thing I would do after getting these password issues ironed out would be to delete toor from /etc/passwd and reboot.

Your login shell is stored in /etc/passwd. There are many tools that can be used to modify it. I personally like vipw, which edits that file directly. Swegen above likes pw, another fine choice. It will be instructive to read that file, while looking at the documentation in passwd(5).

I use editors/leafpad to delete toor from /etc/passwd as one of the first things I do after rebuilding my system and have never had a problem with it.

I never edit master.passwd.
 
Good. The pwd_mkdb(8) probably fixed the 'inconsistent' error messages you had. Added bonus, you learned a bunch of new commands during this exercise :D
 
I use editors/leafpad to delete toor from /etc/passwd as one of the first things I do after rebuilding my system and have never had a problem with it.
The /etc/passwd file is generated from master.passwd. Any time pwd_mkdb(8) is run that user will re-appear in passwd again. The passwd file itself is actually rarely used, it's mainly there for compatibility reasons. The user would still be in /etc/spwd.db and /etc/pwd.db (the actual user databases) and would still exist. Use pw userdel toor instead, that will remove the account from everything.
 
I can use editors/vim, poorandunlucky, but I'm a lot quicker with editors/leafpad. It works just as well for me and is what I've always used to edit files.

I don't have anything but editors/vi, editors/vim or editors/leafpad (except EE which I Iove) on any of my machines and have no use for anything but a text editor.

I could edit everything from the login terminal using ee and be more comfortable than with editors/vim as far as that goes.


And for the record, I watch files like /etc/passwd and is how I knew the toor line had reappeared.
 
This probably won't help you but this is what I use to do to make bash the default shell. Since tcsh is in /bin/tcsh... I just tried it to and it works.

Make tcsh(1) default shell:
Code:
chsh -s  /bin/tcsh
echo "/bin/tcsh" >> /etc/shells
chsh -s  /bin/tcsh
 
You don't need to add it to /etc/shells, it's already there by default.
 
Back
Top