Creating sudo user for root

 Creating sudo user for root 

This is useful if you forget the root password.  Password of root user can be changed using this sudo user

Creating one user called raj

# useradd raj

# passwd raj 

 
#visudo  ( to edit the file /etc/sudoers  just type this and give enter , then automatically opens the same) 
 
#visudo   -- this opens the sudoers file , the contents are shown below
 

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

 # Defaults specification

# User privilege specification

root    ALL=(ALL) ALL

#oracle  ALL=(ALL) ALL

raj  ALL=(ALL) /usr/bin/passwd  --- >  added this line  

oracle  ALL=(ALL) /bin/tar, /dev/st0

 
# Uncomment to allow people in group wheel to run all commands

# %wheel        ALL=(ALL)       ALL

# Same thing without a password

# %wheel        ALL=(ALL)       NOPASSWD: ALL


# Samples

# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom

# %users  localhost=/sbin/shutdown -h now

 
Note :- do not use #vi /etc/sudoers

Now changing the password of oracle using the sudo user
 

# su - raj

$ sudo passwd oracle

Password: (enter password for raj )

Changing password for user oracle.

New UNIX password:

Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post