terminal.cab

All commands

sudo

Topic: Permissions and ownership

Program: sudo

Runs a command as root.

Package: sudo

Usage

sudo [-u USER] [-i | -s] [COMMAND [ARG]...]

Description

Run COMMAND as another user, root unless -u says otherwise, after checking /etc/sudoers and the caller's password.

Options in the simulator

27 more options of the real program, not in the simulator yet
  • -A, --askpass not in the simulator yet

    The simulator cannot do this sudo option.

  • -b, --background not in the simulator yet

    The simulator cannot do this sudo option.

  • -B, --bell not in the simulator yet

    The simulator cannot do this sudo option.

  • -C, --close-from needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -D, --chdir needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -E, --preserve-env not in the simulator yet

    Explanation to come

  • -e, --edit not in the simulator yet

    sudo -e (sudoedit) edits files in an editor; the simulator gets an editor later.

  • -g, --group needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -H, --set-home not in the simulator yet

    The simulator cannot do this sudo option.

  • --host needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -i, --login not in the simulator yet

    Explanation to come

  • -K, --remove-timestamp not in the simulator yet

    Explanation to come

  • -k, --reset-timestamp not in the simulator yet

    Explanation to come

  • -l, --list not in the simulator yet

    Explanation to come

  • -n, --non-interactive not in the simulator yet

    Explanation to come

  • -P, --preserve-groups not in the simulator yet

    The simulator cannot do this sudo option.

  • -p, --prompt needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -R, --chroot needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -r, --role needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -S, --stdin not in the simulator yet

    Explanation to come

  • -s, --shell not in the simulator yet

    Explanation to come

  • -t, --type needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -T, --command-timeout needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -U, --other-user needs a value not in the simulator yet

    The simulator cannot do this sudo option.

  • -u, --user needs a value not in the simulator yet

    Explanation to come

  • -V, --version not in the simulator yet

    Explanation to come

  • -v, --validate not in the simulator yet

    Explanation to come

Examples

From the lesson Root for a moment
id -un
lerner
sudo id -un
root
sudo -l
Matching Defaults entries for lerner on web-01:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User lerner may run the following commands on web-01:
    (ALL : ALL) ALL
    (ALL) NOPASSWD: ALL
sudo chown root handover.txt
ls -l handover.txt
-rw-r--r-- 1 root lerner 33 Oct 17 08:30 handover.txt

Try it in the terminal

From the lesson Users and groups
sudo useradd -m -s /bin/bash -G adm anna
id anna
uid=1002(anna) gid=1002(anna) groups=1002(anna),4(adm)
getent passwd anna
anna:x:1002:1002::/home/anna:/bin/bash

Try it in the terminal

Where you learn it

Lessons

All commands