Thursday, May 18, 2023

Adding Users to Sudoers in Linux

 

Adding Users to Sudoers in Linux



Login as root user : visudo and check wheel (group) details should be there 

## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.


## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL



Login as root user to add user (atharv) in wheel group (sudoers)

[root@0.0.0.0~]# usermod -aG wheel atharv

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]# id atharv

uid=1002(atharv) gid=1002(dba) groups=1002(dba),10(wheel)

[root@0.0.0.0~]#


Login as atharv user 


[atharv@0.0.0.0 ~]$ su - atharv

Password:

Last login: Thu May 18 11:50:13 UTC 2023 on pts/1

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$ sudo fdisk -l

Disk /dev/xvda: 60 GiB, 64424509440 bytes, 125829120 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: gpt

Disk identifier: 2E431796-24CD-41A3-A4CB-7987FFF67072


Device     Start       End   Sectors Size Type

/dev/xvda1  2048      4095      2048   1M BIOS boot

/dev/xvda2  4096 125829086 125824991  60G Linux filesystem

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$ sudo ls -la /root

total 260816

dr-xr-x---.  9 root root      4096 May 18 11:12  .

dr-xr-xr-x. 21 root root      4096 Jan 13 14:03  ..

-rw-------.  1 root root      6953 May  4  2021  anaconda-ks.cfg

drwx------   4 root root        27 Apr 14 10:20  .ansible

drwxr-xr-x   3 root root        22 Apr 14 10:14  ansible

-rw-r--r--   1 root root  77218345 Jan  9 18:30 'AutoDL?BundleId=247937_0ae14417abb444ebb02b9815e2103550'

-rw-r--r--   1 root root    137320 Feb 18 13:07  aws_replication_agent_installer.log

-rw-r--r--   1 root root     25289 Feb  6 10:25  aws-replication-installer-init.py

-rw-------.  1 root root     17257 May 18 11:12  .bash_history

-rw-r--r--.  1 root root        18 Aug 12  2018  .bash_logout

-rw-r--r--.  1 root root       176 Aug 12  2018  .bash_profile

-rw-r--r--.  1 root root       176 Aug 12  2018  .bashrc

drwx------   3 root root        20 Sep 21  2022  .config

drwxr-xr-x   6 root root        95 Sep 21  2022  .cpan

drwxr-xr-x   3 root root        55 Sep 21  2022  .cpanm

-rw-r--r--.  1 root root       100 Aug 12  2018  .cshrc

-rw-r--r--   1 root root 189609546 Dec  7 23:14  jdk-19_linux-x64_bin.rpm

drwxr-xr-x   3 root root       105 Feb 18 13:01  mgn18022023

-rw-------.  1 root root         0 May 16 17:02  original-ks.cfg

-rw-------   1 root root      3167 Nov  8  2022  .psql_history

drwx------.  2 root root        48 Apr 14 10:25  .ssh

-rw-r--r--.  1 root root       129 Aug 12  2018  .tcshrc

-rw-r--r--   1 root root       111 May 18 10:44  test.txt

-rw-------   1 root root      1047 May 18 08:41  .viminfo

-rw-------   1 root root       518 May 18 05:50  .Xauthority

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

No comments:

Post a Comment