![]() In Linux and Unix-like operating systems, users are identified by unique UID and username. Here is an example showing how to create a new user named username with a home directory of /opt/username: sudo useradd -m -d /opt/username username Creating a User with Specific User ID # If you want to create the user’s home directory in other location, use the d ( -home) option. Creating a User with Specific Home Directory #īy default useradd creates the user’s home directory in /home. Within the home directory, the user can write, edit and delete files and directories. In the /home/username directory, you will see the initialization files: ls -la /home/username/ drwxr-xr-x 2 username username 4096 Dec 11 11:23. The command above creates the new user’s home directory and copies files from /etc/skel directory to the user’s home directory. Use the -m ( -create-home) option to create the user home directory as /home/username: sudo useradd -m username On most Linux distributions, when creating a new user account with useradd, the user’s home directory is not created. How to Add a New User and Create Home Directory # Passwd: all authentication tokens updated successfully. ![]() You will be prompted to enter and confirm the password. To do that run the passwdĬommand followed by the username: sudo passwd username To be able to log in as the newly created user, you need to set the user password. The command adds an entry to the /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow files. When executed without any option, useradd creates a new user account using the default settings specified in the /etc/default/useradd file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |