Today, a group of servers added new users. After configuring the sudoers file used by The sudo command, I found that sudo on a server did not take effect. Why did sudo become invalid? The first occurrence occurs as follows:
$ Sudo ifconfig
Sudo: ifconfig: Command not found
$ Sudo fdisk-l
Sudo: fdisk: Command not found
How can I modify the configuration file and restart all servers? sudo does not work for common users. After a while, I finally found that it had something to do with environment variables. The solution is as follows:
1. When a single common user
(1) After logging on to a common user, find the. profile file. Be careful.
$ LS-Al
(2) edit the file. Profile
$ Vim. Profile # Add the following content:
Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Export path
(3) test: $ sudo ifconfig # Show OK
2. If your system has multiple common users
(1) Use the root user
# Vim/etc/profile # Add/sbin to the path variable after else
If ["'id-U'"-EQ 0]; then
Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Else
Path = "/usr/local/bin:/usr/local/games:/usr/games:/sbin"
Fi
Export path
# Source/etc/profile
(3) test. If the remote connection is required, log out and log on again.
### Description:Add/sbin because ifconfig fdisk and other commands are all here!
This article from the "old tile" blog, please be sure to keep this source http://laowafang.blog.51cto.com/251518/1433168