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

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


Solution 1:

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

Solution 2:

  • 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.

Solution 3:

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.