I’ve updated the Terms and Conditions for using this website. Take a look!

How to Run a Command in Linux with Administrator Privileges

In this quick guide we will go over the process of running a command with super user privileges in a Linux shell. In some cases, such as a web server without a graphical desktop to control, using the Linux shell is required to manage or interact with your Linux system.

How to Run a Command in Linux with Administrator Privileges

Total Time: 5 minutes

  1. Use Sudo

    use sudo to update your server software

    In a terminal (called the Command Prompt in Windows), type the following command.

    sudo Command

    Command should be the command you wish to run with administrator privileges. You should be asked for your account password, and if you type it correctly the command should be then run.

    If this works, stop, this is the last step you need to take from these instructions.

    Otherwise if you get the response “sudo: command not found”, this means you don’t have the sudo program installed on your system. In this case you need to proceed to step 2. If you see a warning that says, “Username is not in the sudoers file.  This incident will be reported.”, proceed to step 3.

  2. Alternative: Switch to Root

    If you get the response “sudo: command not found”, switch to your primary administrator account by typing the following command.

    su -

    You will be asked for a password for this account before you can proceed.

    Once you switch over to the administrator user (usually named root), run the command you originally wanted to run, without using sudo.

  3. Alternative: Switch to Another User with Sudo Privileges

    If you see a warning that says, “Username is not in the sudoers file.  This incident will be reported.”, your account is not allowed to run any commands with sudo. You will need to log into a different account that has this permission, and then run the following command.

    sudo usermod -aG sudo YourAccount

    Where YourAccount is the name of your account you were logged into previously.

Comments on "How to Run a Command in Linux with Administrator Privileges"

Leave the first comment


X

Be in the Know

Subscribe to be in the know about new articles and giveaways, like free Bricks Builder templates. The most I will email you is once every two weeks.