Linux users get administrator privileges

Source: Internet
Author: User
This article describes how to obtain administrator permissions for common linux users. the Test environment is CentOS5.5.

1. add a user. First, use the adduser command to add a common user. the command is as follows:

Copy codeThe code is as follows:
# Adduser tommy

// Add a user named tommy
# Passwd tommy // change the password
Changing password for user tommy.
New UNIX password: // enter the New password here
Retype new UNIX password: // enter the new password again
Passwd: all authentication tokens updated successfully.

2. Grant root permissions

Method 1: modify the/etc/sudoers file, find the following line, and remove the comment (#).

Copy codeThe code is as follows:
# Allows people in group wheel to run all commands
% Wheel ALL = (ALL) ALL

Then modify the user and make it belong to the root group (wheel). The command is as follows:

Copy codeThe code is as follows:
# Usermod-g root tommy

After modification, 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:

Copy codeThe code is as follows:
# Allow root to run any commands anywhere
Root ALL = (ALL) ALL
Tommy ALL = (ALL) ALL

After modification, you can log on to the system using the tommy account and run the su-command to obtain the root permission.

Method 3: modify the/etc/passwd file, find the following line, and change the user ID to 0, as shown below:

Copy codeThe code is as follows:
Tommy: x: 500: 500: tommy:/home/tommy:/bin/bash

After modification

Copy codeThe code is as follows:
Tommy: x: 0: 500: tommy:/home/tommy:/bin/bash

Save. after you log on with the tommy account, you can directly obtain the permissions of the root account.

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.