Questions tagged [sudo]

The sudo command is a program for some Unix and Unix-Like operating systems, that allows a user to execute programs with the security privileges of another user. Typically those of a superuser or the root user.

Sudo Command

The sudo command is a program for some Unix and Unix-like operating systems that allow a user to execute programs with the security privileges of another user. Typically those of a superuser or the root user.

Through a configuration file, usually known as a sudoers file, an administrator of the system can delegate authority to certain users and give them the ability to run the specified commands as a root or as another user. The sudoers configuration file can also be configured to provide a log those commands usage and what their arguments were.

Example

Users typically execute a command to which they want to have elevated privileges by prefixing their command with the sudo command:

allan@company$ sudo vim /etc/group

If the user allan has been configured on the sudoers file to gain access to the /etc/group file, a password prompt will be shown and once allan introduces his password, vim will launch and allan can edit the /etc/group file with the same privileges of the root user.

If allan isn't a part of the sudoers configuration file, he will instead receive an error indicating he does not have access to /etc/group and cannot perform the command vim /etc/group.

On both cases the system will log the occurrences. A system administrator can later review these logs and audit all uses of the sudo command.

Links

Sudo Official Website.

Sudo Manual (Man) Page.

Sudoers Manual (Man) Page.

1120 questions
325
votes
9 answers

How to append to a file as sudo?

I want to do: echo "something" >> /etc/config_file But, since only the root user has write permission to this file, I can't do that. But the following also doesn't work. sudo echo "something" >> /etc/config_file Is there a way to append to a file…
agentofuser
  • 7,247
  • 11
  • 38
  • 34
203
votes
12 answers

sudo with password in one command line?

On busy days, I'd like to run $ ./configure && make && sudo make install && halt on the night and go to bed, hoping the application would automatically be installed. But what I see the next day is the screen where sudo asks me for the password. So…
Jichao
  • 7,145
  • 12
  • 52
  • 62
190
votes
6 answers

Why won't "sudo cd" work?

Why typing sudo cd whatever won't change the directory?
sri prasanna
  • 2,003
  • 2
  • 13
  • 4
143
votes
12 answers

How to check if I have sudo access?

I recently got into trouble because of this. $sudo vim /etc/motd [sudo] password for bruce: bruce is not in the sudoers file. This incident will be reported. Is there a way to check if I have sudo access or not?
Bruce
  • 3,037
  • 5
  • 31
  • 28
131
votes
7 answers

scp to remote server with sudo

I have a file on server A (which is behind a NAT so not directly addressable). The file needs to be copied to server B in a directory restricted to root. I have an account on server B with sudo privileges. What is the syntax for the scp command?
Neil
  • 1,435
  • 2
  • 10
  • 9
82
votes
5 answers

Why does the system have /etc/sudoers.d? How should I edit it?

Last time, I asked about the risk of these (in /etc/sudoers): user_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf %group_name ALL=(ALL) /usr/bin/vim /etc/httpd/confs/httpd.conf While I was thinking about this problem, I found…
aob
  • 955
  • 1
  • 6
  • 8
77
votes
4 answers

How to set path for sudo commands

If I issue sudo my-command how does Linux look for that my-command? The my-command is in my PATH. I can invoke it without any problem. However, when I invoke it with sudo, I'll get command not found. How to overcome it? EDIT: That "Possible…
xpt
  • 8,261
  • 38
  • 102
  • 156
77
votes
7 answers

Can I install Homebrew without sudo privileges?

Homebrew nicely allows package installations without sudo privileges, but it seems that I need admin privileges to install Homebrew itself. I'd like to install Homebrew in a Mac environment where I don't have sudo or admin privileges. Is this…
BenjaminGolder
  • 967
  • 2
  • 8
  • 13
71
votes
5 answers

How can I switch back normal mode from sudo mode in Linux and Mac OS X?

I use sudo su command to do something in Mac OS X but don't know how to switch back. Hope you guy can do me a favour.
Hillman
  • 811
  • 1
  • 6
  • 4
61
votes
3 answers

Command: sudo su -

I understand what su - does logs you into root with the root environment (as opposed to su which logs you into root with your environment) And I understand what sudo does you are root for one command But I am unsure what this does: sudo su…
sixtyfootersdude
  • 8,049
  • 16
  • 52
  • 71
60
votes
6 answers

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in /tools/noarch/apache-maven-3.1.1 and I have added the following lines…
Ivaylo Strandjev
  • 753
  • 1
  • 7
  • 12
59
votes
3 answers

Keeping the fancy sudo warning forever

The first time I do sudo on openSUSE I'm always warned with a someway fancy message We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of…
usr-local-ΕΨΗΕΛΩΝ
  • 4,592
  • 16
  • 67
  • 103
59
votes
11 answers

Run rsync with root permission on remote machine

I want to sync a folder from my machine with a folder on a remote machine. The remote folder can only be manipulated by root. I have an account on the remote machine which can use sudo. How can I run rsync such that it has root permissions on the…
Peter
  • 903
  • 1
  • 7
  • 12
55
votes
2 answers

What does the command "sudo !!" mean?

I saw the command sudo !! in a video. What does this mean?
mko
  • 959
  • 3
  • 9
  • 13
54
votes
2 answers

Where did the term "superuser" originate?

Where did the term "superuser" originate? Is it a shortening of "supervisory user", or is it just an indicator of the level of power one such user holds in a system?
VortixDev
  • 1,194
  • 2
  • 13
  • 22
1
2 3
74 75