Latest web development tutorials

commande sudo Linux

Linux commande Daquan Linux commande Daquan

Linux commande sudo comme un administrateur système pour l'exécution d'instructions, qui est, par l'intermédiaire d'une commande sudo exécutée est comme root personnellement exécuté.

Accès: Les utilisateurs sont apparus dans le fichier / etc / sudoers dans.

grammaire

sudo -V
sudo -h
sudo -l
sudo -v
sudo -k
sudo -s
sudo -H
sudo [ -b ] [ -p prompt ] [ -u username/#uid] -s
sudo command

Description Paramètre:

  • -V Afficher le numéro de version
  • -h affiche le numéro de version et les instructions pour les instructions d'utilisation
  • spectacles -l dans leur propre droit (pour effectuer les utilisateurs de sudo)
  • Parce que sudo pas -v lors de la première exécution ou exécutés dans les N minutes (N par défaut est de cinq) demandera le mot de passe, ce paramètre est une nouvelle fois confirmé que, si plus de N minutes, demandera le mot de passe
  • -k demandera le mot de passe (ou sans plus de N minutes) La prochaine fois que vous exécutez les utilisateurs de la force sudo
  • instruction -b pour être exécuté en arrière-plan
  • invite -p peut demander de changer l'invite de mot de passe, où% u sera remplacé par le nom du compte d'un utilisateur,% h affichera le nom d'hôte
  • -u username / # uid sans ce paramètre, le représentant d'exécuter des commandes en tant que root, et ajoutez ce paramètre, vous pouvez exécuter des commandes avec l'identité de nom d'utilisateur (#uid pour le nom d'utilisateur du nombre d'utilisateurs)
  • les variables -s exécution d'environnement spécifiées dans la coque SHELL, ou / etc / passwd dans le shell spécifié
  • -H Dans la variable HOME (répertoire personnel) de l'environnement est spécifié comme pour changer l'identité du répertoire personnel de l'utilisateur (sinon ajouter -u paramètre est la racine de l'administrateur système)
  • Pour commander l'identité de l'administrateur système (ou -u changer pour d'autres) les instructions à exécuter

Exemples

commande sudo

$ sudo ls
[sudo] password for hnlinux: 
hnlinux is not in the sudoers file. This incident will be reported.

Indique à l'utilisateur d'exécuter des commandes

# sudo -u userb ls -l

paramètres d'affichage sudo

$ sudo -L //显示sudo设置
Available options in a sudoers ``Defaults'' line:

syslog: Syslog facility if syslog is being used for logging
syslog_goodpri: Syslog priority to use when user authenticates successfully
syslog_badpri: Syslog priority to use when user authenticates unsuccessfully
long_otp_prompt: Put OTP prompt on its own line
ignore_dot: Ignore '.' in $PATH
mail_always: Always send mail when sudo is run
mail_badpass: Send mail if user authentication fails
mail_no_user: Send mail if the user is not in sudoers
mail_no_host: Send mail if the user is not in sudoers for this host
mail_no_perms: Send mail if the user is not allowed to run a command
tty_tickets: Use a separate timestamp for each user/tty combo
lecture: Lecture user the first time they run sudo
lecture_file: File containing the sudo lecture
authenticate: Require users to authenticate by default
root_sudo: Root may run sudo
log_host: Log the hostname in the (non-syslog) log file
log_year: Log the year in the (non-syslog) log file
shell_noargs: If sudo is invoked with no arguments, start a shell
set_home: Set $HOME to the target user when starting a shell with -s
always_set_home: Always set $HOME to the target user's home directory
path_info: Allow some information gathering to give useful error messages
fqdn: Require fully-qualified hostnames in the sudoers file
insults: Insult the user when they enter an incorrect password
requiretty: Only allow the user to run sudo if they have a tty
env_editor: Visudo will honor the EDITOR environment variable
rootpw: Prompt for root's password, not the users's
runaspw: Prompt for the runas_default user's password, not the users's
targetpw: Prompt for the target user's password, not the users's
use_loginclass: Apply defaults in the target user's login class if there is one
set_logname: Set the LOGNAME and USER environment variables
stay_setuid: Only set the effective uid to the target user, not the real uid
preserve_groups: Don't initialize the group vector to that of the target user
loglinelen: Length at which to wrap log file lines (0 for no wrap)
timestamp_timeout: Authentication timestamp timeout
passwd_timeout: Password prompt timeout
passwd_tries: Number of tries to enter a password
umask: Umask to use or 0777 to use user's
logfile: Path to log file
mailerpath: Path to mail program
mailerflags: Flags for mail program
mailto: Address to send mail to
mailfrom: Address to send mail from
mailsub: Subject line for mail messages
badpass_message: Incorrect password message
timestampdir: Path to authentication timestamp dir
timestampowner: Owner of the authentication timestamp dir
exempt_group: Users in this group are exempt from password and PATH requirements
passprompt: Default password prompt
passprompt_override: If set, passprompt will override system prompt in all cases.
runas_default: Default user to run commands as
secure_path: Value to override user's $PATH with
editor: Path to the editor for use by visudo
listpw: When to require a password for 'list' pseudocommand
verifypw: When to require a password for 'verify' pseudocommand
noexec: Preload the dummy exec functions contained in 'noexec_file'
noexec_file: File containing dummy exec functions
ignore_local_sudoers: If LDAP directory is up, do we ignore local sudoers file
closefrom: File descriptors >= %d will be closed before executing a command
closefrom_override: If set, users may override the value of `closefrom' with the -C option
setenv: Allow users to set arbitrary environment variables
env_reset: Reset the environment to a default set of variables
env_check: Environment variables to check for sanity
env_delete: Environment variables to remove
env_keep: Environment variables to preserve
role: SELinux role to use in the new security context
type: SELinux type to use in the new security context
askpass: Path to the askpass helper program
env_file: Path to the sudo-specific environment file
sudoers_locale: Locale to use while parsing sudoers
visiblepw: Allow sudo to prompt for a password even if it would be visisble
pwfeedback: Provide visual feedback at the password prompt when there is user input
fast_glob: Use faster globbing that is less accurate but does not access the filesystem
umask_override: The umask specified in sudoers will override the user's, even if it is more permissive

Avec les privilèges root pour exécuter des commandes sur un

$ sudo !!

Comme un utilisateur spécifique pour modifier le texte

$ sudo -u uggc vi ~www/index.html
//以 uggc 用户身份编辑  home 目录下www目录中的 index.html 文件

Listes ont la permission

sudo -l

Liste les informations de version pour sudo

sudo -V

Linux commande Daquan Linux commande Daquan