Uncategorized

Unix SUDO

You can elevate privileges via sudo as a named user. This is configured by admin/root user.  You can view sudo’s list / functions via :-

Type : more /etc/sudoers

Edit SUDO list

Type : visudo, this will allow you to edit /etc/sudoers

You may see content such as

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)

#includedir /etc/sudoers.d

%ADMINS ALL=(ALL) NOPASSWD: ALL

opc    ALL=(ALL)   NOPASSWD: ALL

otools    ALL=(ALL)   NOPASSWD: ALL

zeppelin  ALL=(ALL)  NOPASSWD: ALL

 

SUDO to Root

So the above we can see user “opc” can become a root/admin user via :-

Type : sudo su –

Run as Elevated User

To run a command as another user via sudo, the following command will allow a user to run a command as if it were the “hive” user.

sudo su – hive sh -c “hive -f $HOME/export_hive_ddl.hql” > $HOME/export_hive_ddl.log

Type : sudo -l < this will list the commands you are able to run i.e. granted via sudoers file )

Leave a Reply

Your email address will not be published. Required fields are marked *