Introduction
Exercise 1.1: Configuring the System for sudo
It is very dangerous to run a root shell unless absolutely necessary: a single typo or other mistake can cause serious (even fatal) damage.
Thus, the sensible procedure is to configure things such that single commands may be run with superuser privilege, by using the sudo mechanism. With sudo the user only needs to know their own password and never needs to know the root password.
To check if your system is already configured to let the user account you are using run sudo, just do a simple command like:
$ sudo ls
You should be prompted for your user password and then the command should execute. If instead, you get an error message you need to execute the following procedure.
Launch a root shell by typing su and then giving the root password, not your user password.
How to add users into sudo
$ su # then giving the root password
$ vi /etc/sudoers.d/
i.e vi /etc/sudoers.d/rajesh
# Content of file /etc/sudoers.d/rajesh
rajesh ALL=(ALL) ALL
$ chmod 440 /etc/sudoers.d/rajesh
# There are many other ways an administrator can configure sudo, including specifying only certain permissions for certain users, limiting searched paths etc. The /etc/sudoers file is very well self-documented.
$ vi ~/.bashrc # Add following
PATH=$PATH:/usr/sbin:/sbin
![]() |
