Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What are the differences between sudo, su, visudo, chroot, and gksu ?

share|improve this question
4  
Link 1, Link 2, Link 3 –  Evandro Silva Oct 8 '12 at 12:02
    
For sudo see: askubuntu.com/questions/135428/… –  david6 Oct 11 '12 at 7:32
add comment

3 Answers 3

up vote 17 down vote accepted
  • chroot is a way of entering a folder and 'faking' that folder being / to anything executed inside. This lets you run executables on a non-booting Ubuntu installation by mounting it somewhere other than / and using /bin/bash(the one inside the installation) to get a terminal prompt.

  • sudo - Lets certain accounts authenticate to run a program as root or another user. Some programs may not need a password as defined in the sudoers file. Whether the request is allowed or not depends on the user(and group) running sudo, and the command to be run, as defined in sudoers.

  • su - Also a way of elevation, but has differences as it performs a full interactive logon as root(or another user), and gives a bash prompt unless specified otherwise with arguments. It uses the target user's credentials as authentication.

  • visudo - Edits the sudoers file. This uses a special executable that checks the syntax of the file to ensure you are not locked out of sudo due to a corrupted sudoers file. If you attempt to save an invalid configuration it will stop you, and return you to the editor to fix it.

  • gksudo or gksu is the same as sudo except it is graphical and rewrites some paths so that graphical programs do not cause permission issues on the user's profile, especially with ~/.Xauthority.

share|improve this answer
1  
To be exact su and sudo allow to execute processes as another user, it doesn't have to be root. su can always be used to switch to any other user (authenticating with this users credentials). While sudo can be particularly configured to allow execution of specific programs in a specific user context by specific users. Most often though both are used to gain root privileges. –  Paul Hänsch Oct 28 '12 at 22:56
add comment

sudo:

Sudo (superuser do) allows a system administrator to give certain users (or groups of users) the ability to run some (or all) commands as root while logging all commands and arguments. Sudo operates on a per-command basis.

It is not a replacement for the shell.

Features include: the ability to restrict what commands a user may run on a per-host basis, copious logging of each command (providing a clear audit trail of who did what), a configurable timeout of the sudo command, and the ability to use the same configuration file (sudoers) on many different machines.

source

visudo

visudo is a command-line utility that allows editing of the /etc/sudoers file in a safe fashion. It opens /etc/sudoers, using the vi editor's interface by default (although this can be changed by setting the shell's EDITOR environment variable to a different text editor), prevents multiple simultaneous edits with locks, performs sanity checks and checks for parse errors.

source

SU

The su command, also referred to as substitute user, super user, or switch user, allows a computer operator to change the current user account associated with the running virtual console.

By default, and without any other command line argument, this will elevate the current user to the superuser of the local system.

When run from the command line, su asks for the target user's password, and if authenticated, grants the operator access to that account and the files and directories that account is permitted to access.

Additionally, one can switch to another user who is not the superuser

source

root

root is the user name or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user and the superuser.

The word root also has several additional, related meanings when used as part of other terms.

One of these is the root directory, which is the top level directory on a system. That is, it is the directory in which all other directories, including their subdirectories, and files reside. The root directory is designated by a forward slash ( / ).

Another is /root (pronounced slash root), which is the root user's home directory.

Also it may refers to the user root which is the adminstrator of the system with full privileges.

source

chroot

A chroot is an operation that changes the apparent root directory for the current running process and its children. for example if you chroot /mnt/chroot-test then the directory /mnt/chroot-test will be your virtual root that you could refer to by /.

source

Uses of chroots

The following are some possible uses of chroots:

  1. Isolating insecure and unstable applications

  2. Running 32-bit applications on 64-bit systems

  3. Testing new packages before installing them on the production system

  4. Running older versions of applications on more modern versions of Ubuntu

  5. Building new packages, allowing careful control over the dependency packages which are installed

source and more information about chroot

share|improve this answer
    
almost confusingly, on ubuntu, visudo uses nano. I find an easy way to remember which is which is 'su' = switch user (to root - yes, you can use it to switch to other users too), 'sudo' = switch user to root and do, and chroot as 'change root'. Not entirely accurate but close enough to remember. –  Journeyman Geek Oct 10 '12 at 0:28
1  
@JourneymanGeek A more accurate and, I think, just as easy extension of the su mneumonic to sudo is to say that sudo means "Switched User DO" (i.e., do as switched user) or "SuperUser DO" (i.e., do as superuser). This then makes sudoers elegangly associative (i.e., "Switched User DOERS" rather than just "(Switch User and DO)ers"). The reason these variants are more accurate is that sudo lets someone perform an action as an alternate user, but does not necessarily let them be that alternate user in general (depending on the contents of /etc/sudoers). –  Eliah Kagan Oct 10 '12 at 14:25
    
@maythux: That is only one meaning of chroot. (Don't just ask Wikipedia.) It more commonly means a secure (and locked down) sub-system, running within Unix/Linux, that allows only a small set of executables (or services) to be used. –  david6 Oct 11 '12 at 7:35
add comment

SU connects you as root.

The terminal will remain as root for the session.

With sudo (superuser do) you can perform operations as root while connected as a regular user.

share|improve this answer
add comment

protected by Braiam Mar 6 at 3:12

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.