Introduction
The Linux command line is a powerful tool that allows users to perform a variety of tasks, including adding new users. In this tutorial, we will show you how to add a new user with username “john”, password “password”, and home directory “/home/john” using the Linux command line. We will also discuss the various options available when creating a new user. By the end of this tutorial, you will have a better understanding of how to add a new user in Linux.
Examples
useradd -m -d /home/john -p password john
To add a new user with username “john”, password “password”, and home directory “/home/john”, use the following Linux command:
useradd -d /home/john -m -s /bin/bash john
This will create the user account with the specified home directory. To set the password for the user, use the following command:
echo "john:password" | chpasswd
This will set the password for the user. To verify that the user has been created, use the following command:
cat /etc/passwd
This will list all the users on the system. The newly created user should be listed at the bottom of the list.
Discover more from Jassweb
Subscribe to get the latest posts sent to your email.
