I need to bypass sudo
for a group of commands for a certain user so the command is just executed without using the sudo

- 2,445
- 4
- 25
- 41
3 Answers
You want to allow a user to reboot without using the sudo cammand, add the command to /etc/sudoers
file : add this line to the file :
your-username ALL=NOPASSWD: reboot
A more detailed description can be found here: How do I run specific sudo commands without a password?
This is an old post but it came up first in my google search of "command to bypass sudo" You should really use visudo instead of editing /etc/sudoers directly. visudo checks to make sure you didn't enter anything wrong in the sudoers file...which could potentially break something.
See, e.g., Why I must use 'visudo' to edit the '/etc/sudoers' file?
Not sure what was wrong with this post, please clarify.

- 557
Since you want to bypass sudo, I assume you do not want to type sudo each time you execute certain commands. su
will change the user session to root, making all further commands executed as root, hence no need for sudo
.
try:
sudo su
paul@test-machine:~$ sudo su
[sudo] password for paul:
root@test-machine:/home/paul#
root@test-machine:/home/paul# exit
exit
paul@test-machine:~$
This command executes the change of session as root (sudo
), to the root user (su root
). su assumes you want to be root, so you don't need to tell it the user.
Information found here: http://www.linfo.org/su.html
su is usually the simplest and most convenient way to change the ownership of a login session to root or to any other user.
Syntax
A simplified expression of the syntax of the su command is:
su [options] [commands] [-] [username]
The square brackets indicate that the enclosed item is optional. Thus, the simplest way to use the su command is to just type:
su
The operating system assumes that, in the absence of a username, the user wants to change to a root session, and thus the user is prompted for the root password as soon as the ENTER key is pressed. This produces the same result as typing:
su root
If the correct password is provided, ownership of the session is changed to root.

- 66
-
this will enable the user to do any thing he needs , i just want to do this for a group of commands – Fat Mind May 01 '14 at 13:08
-
Can you explain your use in a little more detail. – Paul K May 01 '14 at 13:34
-
i need to enable the reboot command for a user so he writes reboot without sudo – Fat Mind May 01 '14 at 14:49