Execute commands with root privileges as an ordinary user.

Execute commands with root privileges as an ordinary user.

When logging in as a regular user, use the sudo command to use commands with root privileges.
By specifying the command you want to execute as the argument of the sudo command, you can execute the root command. As a prerequisite, when executing the sudo command, it is necessary to set the user you want to allow to execute in the /etc/sudoers file in advance.
Also, the log of sudo command execution is written in a log file via the syslog daemon, and you can know in detail who used what command and when with the sudo command.

[root@lion root]# visudo  ←Run the command to edit the /etc/sudoers file
————————————————————
# sudoers file.
#
# This file MUST be edited with the ‘visudo’ command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
………..(abbreviation)………..
# Defaults specification
# Runas alias specification
# User privilege specification
root ALL=(ALL) ALL
nuy ALL=(ALL) ALL ←Add the user name “nuy” that you want to allow
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password …………(abbreviation)……….
————————————————————
Finish saving with “:wq”

 

[nuy@lion nuy]$ sudo su –     ←Run su command as general user nuy
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.Password: ←Enter the password for general user nuy.
[root@lion root]#   ←Become root privilege
タイトルとURLをコピーしました