How to add a user in linux and give the user the root permission, linuxroot

Source: Internet
Author: User

How to add a user in linux and give the user the root permission, linuxroot

1. Add a user. First, use the adduser command to add a common user. The command is as follows: # adduser tommy // Add a user named tommy # passwd tommy // change password Changing password for user tommy. new UNIX password: // enter the new password Retype New UNIX password: // enter the new password passwd: all authentication tokens updated successfully.2 again. Method 1: modify the/etc/sudoers file, find the following line, and remove the comment (#) # Allows people in group wheel to run all commands % wheel ALL = (ALL) ALL and then modify the user to make it belong to the root group (wheel). The command is as follows: # usermod-g ro After modifying ot tommy, you can log on to the system using the tommy account and run the su-command to obtain the root permission. Method 2: Modify the/etc/sudoers file, find the following line, and add a line under root, as shown below: # Allow root to run any commands anywhereroot ALL = (ALL) ALLtommy ALL = (ALL) ALL is modified. Now you can log on with the tommy account and run the su-command to obtain the root permission for the operation. Method 3: Modify the/etc/passwd file, find the following line, and change the user ID to 0, as shown below: tommy: x: 500: 500: tommy:/home/tommy: after/bin/bash is modified, save it as follows: tommy: x: 0: 500: tommy:/home/tommy:/bin/bash. After you log on to the tommy account, the root account permission is obtained directly. Friendly reminder: Although method 3 looks simple and convenient, it is generally not recommended. method 2 is recommended.

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.