I use to be a fans of Ubuntu, when I want to execute a command as root user, I do this sudo blah_blah_blah
. But in Fedora 16, it doesn't seem recognize this command. Any clue on this?
1 Answer
If your shell tells you it can't find sudo
then it's not installed and you will need to install it using yum install sudo
. If it is installed, then it's likely you are not in the admin group, which you can solve that by doing adduser <username> admin
. If you don't want to do that, then go ahead and add yourself to /etc/sudoers
. Be sure to edit it with visudo
.
Edit
When using visudo
you need to just add the following if you want to be able to run all the commands that root
runs.
sparticvs ALL=(ALL) ALL
To understand the format it goes a little like this <username> <machine>=(<allowed-euids>) <commands>
and ALL is a keyword wildcard here. The allowed-euids are not required, but they basically help restrict who you can run as. For instance you can define a group of users like User_Alias DB = mysql, psql
and then use the command sparticvs ALL=(DB) /usr/bin/mysql, /usr/bin/psql
which would allow me to run the mysql and psql commands as the service accounts that own them by doing sudo -u psql /usr/bin/psql
. Just so I don't completely leave you wondering why there is a machine requirement, you can require that the source of the user that is connected comes from a trusted network. For instance, I have sudo
rules that only allow sudo
to be done by someone from a trusted host and all other calls to sudo
are disallowed.
yum install sudo