How to switch between non-root/root user in LINUX/UNIX?

Asked By 0 points N/A Posted on -
qa-featured

Why is it that when I added a non-root user and tried to make use of the "su" command to turn the user into root, it didn't work, instead I got the error message "permission denied". What else can I do to solve this problem?

SHARE
Best Answer by Schneider Matthew
Answered By 0 points N/A #98140

How to switch between non-root/root user in LINUX/UNIX?

qa-featured

If you have sudo facility in your system

you can do like this:

sudo "command"    #executed as root

"command"           #executed as normal user (if you log in as normal user)

"command"

sudo "command"    # again executed as root

 

Best Answer
Best Answer
Answered By 0 points N/A #197358

How to switch between non-root/root user in LINUX/UNIX?

qa-featured
Hi Cypress Hill,
 
Are you able to log in to the non-root user you created using "su -l 'username' " command. If possible, please try using "su -l" command to log in to root.
 
If the above method doesn't work, use the below method
 
You need to enter your user name into any of the group in /etc/group file. For this, please follow below steps.
 
Open /etc/group. 
 
It will look like this
 
 
Now, just enter your username into any of the group.
 
eg: wheel:x:10:root,new_user_name
 
You can use as many usernames under a group, but you need to keep them comma separated.
 
Hope it helps

Login/Register to Answer

Related Questions