Score:3

What happens when you chsh without a user name?

cn flag

One may: sudo chsh -s /bin/sh or sudo chsh -s /bin/sh user_name

It is understood that the second command changes the shell for the specified user_name but unclear what happens without specifying a user_name and where is that reflected?

Thank you!

Score:6
id flag

The command without a user changes the root user:

terrance@terrance-ubuntu:~$ sudo chsh -s /bin/sh
terrance@terrance-ubuntu:~$ cat /etc/passwd | grep "/bin/sh"
root:x:0:0:root:/root:/bin/sh
terrance@terrance-ubuntu:~$ sudo chsh -s /bin/bash
terrance@terrance-ubuntu:~$ cat /etc/passwd | grep "/bin/bash"
root:x:0:0:root:/root:/bin/bash
AturSams avatar
cn flag
So it is essentially like typing `sudo chsh -s /bin/bash root` ?
Terrance avatar
id flag
@AturSams Correct, it is the same as that. To run the command on your own user, sudo is not needed and neither is your username.
cn flag
Specifically, using `sudo` is a bad idea: normal users are limited to shells listed in `/etc/shells`, so users cannot accidentally lock themselves out by switching to something that isn't a working shell. As root, you can set anything, including something that doesn't work.
cn flag
The reason `sudo chsh` changes the shell for root is that `sudo` switches to root, and `chsh` changes the shell of the current user.
AturSams avatar
cn flag
@SimonRichter Thanks for clarifying. :)
Joshua avatar
cz flag
Which makes quite a bit of sense; `chsh` without `sudo` would change the user's own shell. I'm kind of disappointed that on too many linux systems, `chsh` without `sudo` yields an error.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.