Ubuntu Server is like any other variety of Linux, and has full multi user, and a common task on any server is adding users.
useraddThe useradd command will allow you to easily add a new user from the command line:
useradd <username>
This command allows the user to add, but no more options you will not have a password or a user directory.
You can use the-d option to set the home directory for the user. The-m option will force useradd to create the home directory. We will try to create a user account with these options, and then use the passwd command to set the password for the account. Alternatively, you can set a password with the command useradd-p, but I prefer to set the password with passwd.
sudo useradd-d / home / testuser-m testuser
sudo passwd testuser
This will create a user called testuser and give them their own home directory in / home / testuser. The files are copied into the new home directory from / etc / skel directory that contains your home directory by default. If you want to set default values for users, you should do it by modifying or adding files in that directory. If we look at the new home directory for the user:
fail @ ubuntuServ: / etc / skel $ ls-la / home / testuser
total 20
drwxr-xr-x 2 testuser testuser 4096 15/12/2006 11:34.
drwxr-xr-x 5 root root 4096 15/12/2006 11:37 ..
-Rw-r-r-1 testuser testuser 220 15/12/2006 11:34. Bash_logout
-Rw-r-r-1 testuser testuser 414 15/12/2006 11:34. Bash_profile
-Rw-rr-1 testuser testuser 2227 12/15/2006 11:34. Bashrc
You will notice that there are bash scripts in this directory. If you wanted to set the default route options for all new users, you should do this by editing the file / etc / skel, which would then be used to create these files with the command useradd.
adduser username
The adduser command is even easier than the useradd command, because it prompts you for any information. I find it a bit 'funny that there are two commands that virtually the same as doing the same thing, but this is Linux for you. Here is the syntax:
adduser <username>
No comments:
Post a Comment