chsh: command not found

The chsh command is a utility in Linux that is used to change the default shell for a user. A shell is a command-line interface that allows a user to interact with the operating system and execute commands.

To use the chsh command, you will need to specify the user name of the user whose default shell you want to change, and the path to the new shell executable.

For example, to change the default shell for the user john to the bash shell, you can use the following command:

# chsh -s /bin/bash john

This will change the default shell for the user john to the bash shell.

If you encounter the below error while running the command chsh:

chsh : command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install passwd
Ubuntu apt-get install passwd
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install passwd
CentOS yum install util-linux-ng
Fedora dnf install util-linux-user
OS X brew install util-linux
Raspbian apt-get install passwd

chsh Command Examples

1. Change the current user’s login shell interactively:

# chsh

2. Change the login shell of the current user:

# chsh -s path/to/shell

3. Change the login shell for a given user:

# chsh -s path/to/shell username

4. List available shells:

# chsh --list-shells

Conclusion

The chsh command is useful for changing the default shell for a user, especially when you want to customize the command-line environment for a specific user. It is also useful for setting the default shell for new users, as it can be included in user creation scripts to set the default shell automatically.

Related Post