How to Create a User with Changed Login Shell
To create a user with a different login shell, we use the following command.
sudo useradd -s /bin/sh test_user
This will create a user named “test_user” with the default shell /bin/sh.
How to add User in Linux | useradd Command
useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the background. It makes changes to the following files:
- /etc/passwd
- /etc/shadow
- /etc/group
- /etc/gshadow
- creates a directory for new user in /home
Table of Content
- Syntax of `useradd` command in Linux
- Working with `useradd` Command
- 1. How to Add a User in Linux
- 2. How to Add User by Specifying a home directory path for the new user
- 3. How to Create a User with a Specific User ID (UID)
- 4. How to Create a User with a Specific Group ID (GID)
- 5. How to Create a User Without a Home Directory
- 6. How to Create User with an Expiry Date
- 7. How to Create User with a Comment
- 8. How to Create a User with Changed Login Shell
- 9. How to Set an Unencrypted Password for the User
- 10. Displaying Help