• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Setting up TCSH

MaxRuse11

New Member


Messages: 9

#1
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?
 

ralphbsz

Daemon

Thanks: 647
Messages: 1,106

#3
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).
 

ShelLuser

Son of Beastie

Thanks: 1,260
Messages: 2,678

#4
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.
 

MaxRuse11

New Member


Messages: 9

#6
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
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#7
You've edited master.passwd by hand and made a mistake in there. Never, ever, edit that file by hand.
 

MaxRuse11

New Member


Messages: 9

#9
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:
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#10
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.
 

MaxRuse11

New Member


Messages: 9

#11
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?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#12
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.
 

sko

Well-Known Member

Thanks: 158
Messages: 350

#13
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).
 

MaxRuse11

New Member


Messages: 9

#14
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?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#15
I would take a long hard look at /etc/master.passwd, you most likely introduced an error there when you first edited it.
 

MaxRuse11

New Member


Messages: 9

#16
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
 

Trihexagonal

Daemon

Thanks: 499
Messages: 1,014

#17
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.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#18
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
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#19
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.
 

poorandunlucky

Well-Known Member

Thanks: 26
Messages: 359

#21
You really should use vipw to edit the password files by hand...

You should really learn vi, if you don't already know it, too... so...
 

Trihexagonal

Daemon

Thanks: 499
Messages: 1,014

#22
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.
 

max21

Well-Known Member

Thanks: 19
Messages: 412

#23
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
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,089
Messages: 26,977

#24
You don't need to add it to /etc/shells, it's already there by default.
 
Top