In case your system doesn’t have sudo set up and enabled, you need to do the following steps:

First of all, you need to make modifications as the administrative or super user, root. While sudo will become the preferred method of doing this, we don’t have it set up yet, so we will use su instead. At the command line prompt, type su and press Enter. You will then be prompted for the root password, so enter it and press Enter. You will notice that nothing is printed; this is so others cannot see the password on the screen. You should end up with a different looking prompt, often ending with ‘#’. For example:

$ su Password: 

Now you need to create a configuration file to enable your user account to use sudo. Typically, this file is created in the /etc/sudoers.d/ directory with the name of the file the same as your username. For example, for this demo, let’s say your username is “howtoit”. After doing step 1, you would then create the configuration file for “howtoit” by doing this:

# echo “howtoit ALL=(ALL) ALL” > /etc/sudoers.d/howtoit

Finally, some Linux distributions will complain if you don’t also change permissions on the file by doing:

# chmod 440 /etc/sudoers.d/howtoit

When using sudo, by default you will be prompted to give a password (your own user password) at least the first time you do it within a specified time interval.

It is possible (though very insecure) to configure sudo to not require a password or change the time window in which the password does not have to be repeated with every sudo command.

(Visited 243 times, 1 visits today)
How to use “sudo” command in Linux
Tagged on: