Add a User on Ubuntu Server

Ubuntu Server is like any Linux variety, and has full multi-user capabilities, and a common task on any server is adding users.

useradd

The useradd command will let you add a new user easily from the command line:

useradd

This command adds the user, but without any extra options your user won’t have a password or a home 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’ll try creating a user account with those options, and then use the passwd command to set the password for the account. You can alternatively set a password using -p on the useradd command, but I prefer to set the password using passwd.

sudo useradd -d /home/testuser -m testuser
sudo passwd testuser

adduser

The adduser command is even easier than the useradd command, because it prompts you for each piece of information. I find it slightly funny that there are two virtually identically named commands that do the same thing, but that’s linux for you. Here’s the syntax:

adduser

Terminal or shell command to shutdown or reboot Ubuntu Linux

So how do you shutdown or reboot Ubuntu Linux from a terminal or a shell prompt? If GUI is working you can always click on a Quit button. If GUI is not working or if you are working remotely over ssh type the following command:

To shutdown / poweroff Ubuntu Linux
Type the command:
sudo halt
OR
sudo shutdown -h now

To reboot Ubuntu Linux
Type the command:
sudo reboot

More information can be found about these two commands by typing following commands (man page):
man reboot
man shutdown

add delete and switch user in ubuntu by command lines

First, I want to add a user. So how to do it?

+ To add user:

sudo adduser <username>

to add password for your user

sudo passwd <username>

+ How can i switch from one user to another one? In this example, i want to switch from one user to another one.

su <username>

and type in your password to login

after that, you will be at a ‘$’ prompt. type:

bash

to get to a normal prompt.

+ How can I delete a user?

sudo userdel <username>