
lchsh Command in Linux
lchsh is a command used in Linux to change a userâs login shell. When you run this command, it allows you to specify a new shell for a user. In case you donât provide a username, it will change the shell for the user who is currently logged in.
The lchsh command is pretty useful for customizing the environment in which a user operates. The command can be run with various options to interactively ask questions or to specify the shell directly.
Table of Contents
Here is a comprehensive guide to the options available with the lchsh command −
Syntax of lchsh Command
The basic syntax to use the lchsh command on Linux is as follows −
lchsh [options] [username]
Where,
- [options] are additional flags that adjust how the command behaves.
- [username] refers to the account's username for which you wish to change the shell. If left unspecified, it defaults to the current user's account.
lchsh Command Options
The command lchsh has only one option, which is -i or --interactive, apart from -h (help) and --usage. Using this command, you can interactively change the login shell for a user on your Linux system.
Examples of lchsh Command in Linux
Letâs explore basic examples of Linux lchsh command −
- Interactively Change the Login Shell
- Change the Login Shell for a Specific User
- Display Help Information
Interactively Change the Login Shell
To change the login shell interactively, you can use the -i or --interactive option. This will prompt you to enter the username and the new shell. For example −
sudo lchsh -i
Once you run the above command, you will be prompted to enter the new shell for the root user −

You can enter /bin/zsh or simply skip if you have changed your mind adding a new shell for the root user.
Change the Login Shell for a Specific User
If you want to change the login shell for a specific user, you can specify the username directly. This is useful when you know the user for whom you want to change the shell. For example, to change the login shell for the user ubuntu, use −
sudo lchsh -i ubuntu
You will be prompted to enter the new shell for the user ubuntu −

Display Help Information
To display help information about the lchsh command, you can use the -h or --help option. This will show you all the available options and their descriptions.
sudo lchsh --help
The output will display the help information −

Conclusion
The lchsh command is a vital tool for Linux users looking to customize their login environment. This tutorial has covered the command's syntax, options, and practical usage examples.
Whether you're changing the shell interactively or for specific users, lchsh provides an effective method to tailor user experiences and ensure a secure and user-friendly system environment.