Allow a normal user all privileges like root
To give root privileges to user add a line by using
sudoers file as shown below.
- Type Command VISUDO to open sudoers file.
#visudo
(save the sudoers file as we save a vim file using “wq!”)
## user
MACHINE=COMMANDS
##
##
The COMMANDS section may have other options added to it.
##
##
Allow root to run any commands anywhere
root ALL=(ALL) ALL
pooja ALL=(ALL) ALL
##
Allows members of the 'sys' group to run networking, software,
##
service management apps and more.
#
%sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES,
LOCATE, DRIVERS
|
- Now logged in as normal user like pooja and run admin commands like fdisk –l etc
- First try to run fdisk command normally and see what happens.
[root@linuxelearn
~]# su pooja
[pooja@linuxelearn
~]$ fdisk -l
[pooja@linuxelearn
~]$ fdisk /dev/sa
Unable
to open /dev/sa
[pooja@linuxelearn
~]$
|
It
will not allow a normal user to run privileged user’s command
Now run the same command using sudo before command
#
sudo fdisk –l or
# sudo fdisk /dev/sda
[pooja@linuxelearn
~]$ sudo fdisk -l
We
trust you have received the usual lecture from the local System
Administrator.
It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great
responsibility.
[sudo]
password for pooja:
Disk
/dev/sda: 17.2 GB, 17179869184 bytes
255
heads, 63 sectors/track, 2088 cylinders
Units
= cylinders of 16065 * 512 = 8225280 bytes
Sector
size (logical/physical): 512 bytes / 512 bytes
I/O
size (minimum/optimal): 512 bytes / 512 bytes
Disk
identifier: 0x000efa3d
Device Boot Start End Blocks
Id System
/dev/sda1 *
1 26 204800
83 Linux
Partition
1 does not end on cylinder boundary.
/dev/sda2 26 1301 10240000
83 Linux
/dev/sda3 1301 1562 2097152
82 Linux swap / Solaris
/dev/sda4 1562 2088
4228884 5 Extended
/dev/sda5 1562 1626 517837+
82 Linux swap / Solaris
/dev/sda6 1627 1691 522081
8e Linux LVM
/dev/sda7 1692 1756 522081
8e Linux LVM
/dev/sda8 1757 1821 522081
82 Linux swap / Solaris
[pooja@linuxelearn
~]$
|
Note:
Only for the first time of the session it will prompt for user’s password to
continue, but for rest of the process it will continue normally as shown below.
[pooja@linuxelearn
~]$ sudo fdisk /dev/sda
[sudo]
password for pooja:
WARNING:
DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c')
and change display units to
sectors (command 'u').
Command
(m for help): ^C
[pooja@linuxelearn
~]$
|
It is all about Sudo privilege …
I Hope you enjoy reading this article….
Post a Comment