Create user commands under Linux

Source: Internet
Author: User

How do I create a new user using the Linux command line?

I'm doing it under Ubuntu, for example by adding a new user named Test:

The simplest of commands:
sudo adduser test
The user is automatically added to the group with the same name, the/home/test/is created, the file is copied from the etc/skel/, and the password and associated initial identity information is set.

command of the original point:
sudo useradd-mk/home/test-s/bin/bash test
sudo passwd test

(This is useradd and not adduser)


Give the user root access

Modify the/etc/sudoers file, locate the following line, and add a line below root as follows:
# allow ROOT to run any commands anywhere
Root all= (All) all
Test all= (All) all


Finally, if you want to delete a user:

To delete a user:
sudo userdel test
Rm-rf/home/test


To switch users at the command line:

You can use the SU command to switch users, and SU is the abbreviation for switch User Switching users. It can be switched from a normal user to a root user, or from a root user to a normal user. Switch from normal user to root user needs to enter a password, switch from root user to normal user does not need to enter password.

Command format: su [parameter] [-] [user name]
The default value for the user name is root.

Usage examples:
Su Test #切换到test用户
Su #切换到root用户

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Create user commands under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.