Linux uses the SU, sudo command to enable user Switching, right

Source: Internet
Author: User
Tags aliases

Overview

Most Linux servers do not recommend that users log on directly to the root user. On the one hand can greatly reduce the damage caused by misoperation, on the other hand, it also reduces the risk of privileged passwords being compromised in insecure networks. For these reasons, you need to provide an identity switch or privilege or privilege elevation mechanism for ordinary users to perform administrative tasks when necessary. At this point, you need to use the SU, sudo two commands that Linux provides to us to elevate execution permissions.

Three ways to allocate power

1. For users

2. For group

3. Aliases for users, groups, commands

Experimental objectives

1, familiar with Su, sudo usage, skilled use of sudoers related configuration

2, experience the user switch and the right to bring the operation convenience

Build steps

⑴ Viewing host names

[Email protected] ~]# hostname

⑵ for User Configuration

[Email protected] ~]# vim/etc/sudoers

[Email protected] ~]# Su-xiaoyu
[email protected] ~]$ sudo ifconfig eth0:0 10.10.10.10 #在第一块网卡上添加第一块子网卡 (Virtual network card) to set the IP. sudo to add!!!
[sudo] password for Xiaoyu: #提示要输入密码

[email protected] ~]$ sudo reboot

⑵ Configuration for Wheel Group (security group)

[Email protected] ~]# useradd Zhangsan #添加测试用户
[Email protected] ~]# passwd Zhangsan
[Email protected] ~]# Useradd Lisi
[Email protected] ~]# passwd Lisi
[[email protected] ~]# gpasswd-m zhangsan,lisi wheel #将张三, John Doe users added to the wheel group, note-m must be used with caution, is to cover
[Email protected] ~]# vim/etc/sudoers

[Email protected] ~]# Su-zhangsan
[email protected] ~]$ sudo useradd Wangwu
[[email protected] ~]$ ID WANGWU

⑶ configuration for users, groups, command aliases

[Email protected] ~]# vim/etc/sudoers

[Email protected] ~]# Su-zhangsan
[email protected] ~]$ sudo ifconfig eth0:0 12.12.12.12 #在子网卡中添加IP

Linux uses the SU, sudo command to enable user Switching, right

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.