0

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

Fat Mind
  • 2,445
  • 4
  • 25
  • 41

3 Answers3

2

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?

Paul K
  • 66
0

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.

bvargo
  • 557
0

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.

Paul K
  • 66