Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the *nix command to view a user's default login shell

Tags:

linux

shell

unix

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 
like image 217
k107 Avatar asked Jun 15 '12 22:06

k107


People also ask

What is the command used to find the default login shell?

grep "^$USER" /etc/passwd – Print the default shell name. The default shell runs when you open a terminal window.

How do I find my login shell?

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.

What is the default login shell in Redhat?

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 .

Which command allow to define user login shell in Linux?

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.


1 Answers

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 
like image 83
Todd A. Jacobs Avatar answered Sep 21 '22 21:09

Todd A. Jacobs