How to use sudo in Fedora?

11,610

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.

Share:
11,610

Related videos on Youtube

huahsin68
Author by

huahsin68

Updated on September 18, 2022

Comments

  • huahsin68
    huahsin68 over 1 year

    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?

    • h3rrmiller
      h3rrmiller over 11 years
      it sounds like you dont have sudo installed. yum install sudo
    • midnightsteel
      midnightsteel over 11 years
      @huahsin68 What is the actual error you are seeing? This is important because in Fedora the user must be specified in the _'#/etc/sudoers' file
    • huahsin68
      huahsin68 over 11 years
      when I type the command, it shows me the user manual sample usage. It doesn't sound sudo is not install, just that the usage is wrong.
  • huahsin68
    huahsin68 over 11 years
    Great help. Thank you so much on your answer.