Digital Marketing

How to check/change a user's default login shell

$ getent passwd $LOGNAME | cut -d: -f7
OR
$ ps -p $$

$ returns the PID (process identification number) of the current process, and the current process is your shell. So running a ps on that number displays a process status listing of your shell. In that listing you will find the name of your shell (look for CMD column) .

Example:
$ getent passwd postfix | cut -d: -f7
/sbin/nologin Or /bin/false
$ which bash
/bin/bash
$ sudo chsh -s /bin/bash postfix
Changing shell for postfix.
Shell changed.
$ getent passwd postfix | cut -d: -f7
/bin/bash
sudo chsh -s /sbin/nologin postfix
Changing shell for postfix.
Shell changed.
$ getent passwd postfix | cut -d: -f7
/sbin/nologin
$

Comments

Popular posts from this blog

MySQL Sandbox with the Sakila sample database