Sometimes when we execute sudo
XXX is not int the sudoers file
It tells us that the current user is not sudoer, so we need to add the current user as follows:
1. Modify the/etc/sudoers file and enter the Super User. Because there is no write permission, add the write permission to chmod U + w/etc/sudoers first.
2. Edit the/etc/sudoers file and find this line: "root all = (all) All" add "zhc all = (all) all "(here zhc is your user name), and then save.
3. Finally, the system restores the write permission mode and revokes the write permission for the file. chmod U-W/etc/sudoers.
Then we can use the zhc user to edit the root file, for example
VI/etc/sysconfig/network-scripts/ifcfg-eth0
After modification, it cannot be saved directly. because we do not have the permission, we can execute
: W! Sudo tee %
This command inputs the Current Buffer content to stdin, and then the tee command imports the content from the standard input to the standard output, and then another shunt to the file. Here % represents the current file.
Original article: http://blog.csdn.net/hongchangfirst/article/details/9044591
Author: hongchangfirst
Hongchangfirst home: http://blog.csdn.net/hongchangfirst