What is the *nix command to view a user's default login shell?
I can change the default login shell with chsh
, but I don't know how to get what is the user's default shell.
Pseudocode
$ get-shell /usr/bin/zsh
grep "^$USER" /etc/passwd – Print the default shell name. The default shell runs when you open a terminal window.
Start a login shellPress the menu button in the top-right corner of the window and select Preferences. In the sidebar, select your current profile in the Profiles section. Select Command. Under the Command label, select Run command as a login shell.
Your default login shell is /bin/bash now. You must log out and log back in to see this change. This command will change the default login shell permanently. Note: If your user account is remote such as on Kerberos authentication (e.g. Enterprise RHEL) then you will not be able to use chsh .
The chsh command changes a user's login shell attribute. The shell attribute defines the initial program that runs after a user logs in to the system. This attribute is specified in the /etc/passwd file. By default, the chsh command changes the login shell for the user who gives the command.
The canonical way to query the /etc/passwd file for this information is with getent
. You can parse getent
output with standard tools such as cut
to extract the user's login shell. For example:
$ getent passwd $LOGNAME | cut -d: -f7 /bin/bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With