From d8be3f35a37a5654563ef5238d6b9ea8eb46eecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Inderm=C3=BChle?= Date: Sat, 30 Jan 2021 22:04:40 +0100 Subject: [PATCH] sudo: add --login, --shell and --list examples (#5202) add more information link --- pages/common/sudo.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pages/common/sudo.md b/pages/common/sudo.md index 8a85014dc2..1298333709 100644 --- a/pages/common/sudo.md +++ b/pages/common/sudo.md @@ -1,6 +1,7 @@ # sudo > Executes a single command as the superuser or another user. +> More information: . - Run a command as the superuser: @@ -8,16 +9,28 @@ - Edit a file as the superuser with your default editor: -`sudo -e {{/etc/fstab}}` +`sudo --edit {{/etc/fstab}}` - Run a command as another user and/or group: -`sudo -u {{user}} -g {{group}} {{id -a}}` +`sudo --user={{user}} --group={{group}} {{id -a}}` -- Repeat the last command prefixed with "sudo" (only in bash, zsh, etc.): +- Repeat the last command prefixed with "sudo" (only in `bash`, `zsh`, etc.): `sudo !!` -- Launch the default shell with superuser privileges: +- Launch the default shell with superuser privileges and run login-specific files (`.profile`, `.bash_profile`, etc.): -`sudo -i` +`sudo --login` + +- Launch the default shell with superuser privileges without changing the environment: + +`sudo --shell` + +- Launch the default shell as the specified user, loading the user's environment and reading login-specific files (`.profile`, `.bash_profile`, etc.): + +`sudo --login --user={{user}}` + +- List the allowed (and forbidden) commands for the invoking user: + +`sudo --list`