su

su的作用是变更为其它使用者的身份,超级用户除外,需要键入该使用者的密码

替换用户和组id的命令,允许一个用户临时成为另一个用户。它使用实际有效的用户id、组id和给定用户的补充组运行命令(通常是交互式shell)

语法

  su [options]... [user [arg]...]

选项


-c COMMAND
--command=COMMAND
     使用-c选项将命令(要运行的单个命令行)传递给shell,
     而不是启动交互式shell。
-f
--fast
     将'-f'选项传递给shell。
     这可能只有在shell运行为' csh'或' tcsh'时才有意义,
     因为'-f'选项阻止读取启动文件('.cshrc'),对于类bourne的shell, 
     '-f'选项禁用文件名模式扩展(globbing),这可能不会有用
-
-l
--login
    让shell成为登录shell。
    这意味着以下内容,
    取消设置除“TERM”、“HOME”和“SHELL”(如上所述设置)、
    “USER”和“LOGNAME”(即使是为超级用户设置,如上所述)之外的所有环境变量,
    并将“PATH”设置为一个已编译的默认值。
    更改为用户的主目录。
    将'-'放在shell名称的前面,目的是让它读取它的登录启动文件。
-m
-p
--preserve-environment
     不要更改环境变量“HOME”、“USER”、“LOGNAME”或“SHELL”。
     运行环境变量“shell”中给出的shell,
     而不是用户的passwd条目中的shell,除非运行“su”的用户不是超级用户,并且用户的shell受到限制。
     “受限shell”是指不在“/etc/shell”文件中列出的shell,如果文件不存在,则在编译后的列表中列出的shell。
     这个选项的部分功能可以被`--login' and `--shell'覆盖.

-s SHELL
--shell=SHELL
    从用户的passwd条目中运行SHELL而不是SHELL,除非运行' su'的用户不是超级用户,
    并且用户的SHELL受到限制(请参阅上面的' -m')。


如果没有给出用户,则默认为“root”,即超级用户.

要使用的shell是从用户的“passwd”条目中提取的,如果没有指定的话,则从/bin/sh中提取.

如果用户有密码,“su”会提示输入密码,除非用户的有效id为0(超级用户)

默认情况下,su不更改当前目录。它从用户的密码条目中设置环境变量‘HOME’和‘SHELL’,如果用户不是超级用户,则将‘USER’和‘LOGNAME’设置为USER.

默认情况下,shell不是登录shell。任何额外的ARGs都作为额外的参数传递给shell.

GNU su不专门处理’/bin/sh’或任何其他shell(例如,通过将’ argv[0]‘设置为-su,仅将’ -c’传递给某些shell,等等)。可以选择编译su,以便使用syslog报告失败或成功的su尝试。(如果系统支持syslog)。但是,GNU su不检查用户是否是“wheel”组的成员;参见上面的选项

su 命令实例:

linux命令:sudo blktrace -d /dev/sda -o - | blkparse -i - - -i blkparse | - -o /dev/sda -d blktrace sudo sudo blktrace -d /dev/sda -o - | blkparse -i -rootopen.com
linux命令:sudo blktrace -d /dev/sda -o - | blkparse -i - - -i blkparse | - -o /dev/sda -d blktrace sudo sudo blktrace -d /dev/sda -o - | blkparse -i -rootopen.com
2019-07-09 21:11:35

linux命令:sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p') //p') 's/^timezone: -n sed | worldtimeapi.org/api/ip.txt -s $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p')rootopen.com
linux命令:sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p') //p') 's/^timezone: -n sed | worldtimeapi.org/api/ip.txt -s $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p')rootopen.com
2019-06-05 22:27:26

linux命令:sudo synogear install && sudo su su sudo && install synogear sudo sudo synogear install && sudo surootopen.com
linux命令:sudo synogear install && sudo su su sudo && install synogear sudo sudo synogear install && sudo surootopen.com
2019-06-04 22:34:02

linux命令:sudo timedatectl set-timezone $(curl worldtimeapi.org/api/ip/$(curl ifconfig.io/ip)|cut -d\" -f16) -f16) -d\" ifconfig.io/ip)|cut worldtimeapi.org/api/ip/$(curl $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl worldtimeapi.org/api/ip/$(curl ifconfig.io/ip)|cut -d\" -f16)rootopen.com
linux命令:sudo timedatectl set-timezone $(curl worldtimeapi.org/api/ip/$(curl ifconfig.io/ip)|cut -d\" -f16) -f16) -d\" ifconfig.io/ip)|cut worldtimeapi.org/api/ip/$(curl $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl worldtimeapi.org/api/ip/$(curl ifconfig.io/ip)|cut -d\" -f16)rootopen.com
2019-03-23 18:57:56

linux命令:sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p') //p') 's/^timezone: -n sed | worldtimeapi.org/api/ip.txt -s $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p')rootopen.com
linux命令:sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p') //p') 's/^timezone: -n sed | worldtimeapi.org/api/ip.txt -s $(curl set-timezone timedatectl sudo sudo timedatectl set-timezone $(curl -s worldtimeapi.org/api/ip.txt | sed -n 's/^timezone: //p')rootopen.com
2019-03-23 18:55:02

linux命令:sudo tcpdump -nn -v port ftp or ftp-data ftp-data or ftp port -v -nn tcpdump sudo sudo tcpdump -nn -v port ftp or ftp-datarootopen.com
linux命令:sudo tcpdump -nn -v port ftp or ftp-data ftp-data or ftp port -v -nn tcpdump sudo sudo tcpdump -nn -v port ftp or ftp-datarootopen.com
2019-02-12 21:07:49

linux命令:sudo tcpdump -s 0 -A -n -l | egrep -i "POST /|pwd=|passwd=|password=|Host:" /|pwd=|passwd=|password=|Host:" "POST -i egrep | -l -n -A 0 -s tcpdump sudo sudo tcpdump -s 0 -A -n -l | egrep -i "POST /|pwd=|passwd=|password=|Host:"rootopen.com
linux命令:sudo tcpdump -s 0 -A -n -l | egrep -i "POST /|pwd=|passwd=|password=|Host:" /|pwd=|passwd=|password=|Host:" "POST -i egrep | -l -n -A 0 -s tcpdump sudo sudo tcpdump -s 0 -A -n -l | egrep -i "POST /|pwd=|passwd=|password=|Host:"rootopen.com
2019-02-12 21:07:28

linux命令:sudo tcpdump -nn -l port 25 | grep -i 'MAIL FROM\|RCPT TO' TO' FROM\|RCPT 'MAIL -i grep | 25 port -l -nn tcpdump sudo sudo tcpdump -nn -l port 25 | grep -i 'MAIL FROM\|RCPT TO'rootopen.com
linux命令:sudo tcpdump -nn -l port 25 | grep -i 'MAIL FROM\|RCPT TO' TO' FROM\|RCPT 'MAIL -i grep | 25 port -l -nn tcpdump sudo sudo tcpdump -nn -l port 25 | grep -i 'MAIL FROM\|RCPT TO'rootopen.com
2019-02-12 21:06:41

linux命令:sudo !! !! sudo sudo !!rootopen.com
linux命令:sudo !! !! sudo sudo !!rootopen.com
2018-12-13 23:08:43

linux命令:sudo mlabel -i /dev/sdd1 ::NewLabel ::NewLabel /dev/sdd1 -i mlabel sudo sudo mlabel -i /dev/sdd1 ::NewLabelrootopen.com
linux命令:sudo mlabel -i /dev/sdd1 ::NewLabel ::NewLabel /dev/sdd1 -i mlabel sudo sudo mlabel -i /dev/sdd1 ::NewLabelrootopen.com
2018-11-26 23:22:59

linux命令:sudo halt halt sudo sudo haltrootopen.com
linux命令:sudo halt halt sudo sudo haltrootopen.com
2018-11-22 22:36:25

linux命令:sudo dmesg > messages.txt messages.txt > dmesg sudo sudo dmesg > messages.txtrootopen.com
linux命令:sudo dmesg > messages.txt messages.txt > dmesg sudo sudo dmesg > messages.txtrootopen.com
2018-09-20 06:32:03

linux命令:sum output file.txt file.txt output sum sum output file.txt rootopen.com
linux命令:sum output file.txt file.txt output sum sum output file.txt rootopen.com
2018-09-11 09:55:30

linux命令:sudo rdiff-backup / etc /media/tecmint/Backup/server_etc.backup /media/tecmint/Backup/server_etc.backup etc / rdiff-backup sudo sudo rdiff-backup / etc /media/tecmint/Backup/server_etc.backuprootopen.com
linux命令:sudo rdiff-backup / etc /media/tecmint/Backup/server_etc.backup /media/tecmint/Backup/server_etc.backup etc / rdiff-backup sudo sudo rdiff-backup / etc /media/tecmint/Backup/server_etc.backuprootopen.com
2018-09-11 09:55:30

linux命令:sudo debsums debsums sudo sudo debsumsrootopen.com
linux命令:sudo debsums debsums sudo sudo debsumsrootopen.com
2018-09-11 09:55:30

linux命令:sudo login login sudo sudo loginrootopen.com
linux命令:sudo login login sudo sudo loginrootopen.com
2018-09-11 09:55:30

linux命令:sudo iptables -L -n -v -v -n -L iptables sudo sudo iptables -L -n -vrootopen.com
linux命令:sudo iptables -L -n -v -v -n -L iptables sudo sudo iptables -L -n -vrootopen.com
2018-09-11 09:55:30

linux命令:sudo ip addr add 192.168.56.10 dev eth1 eth1 dev 192.168.56.10 add addr ip sudo sudo ip addr add 192.168.56.10 dev eth1rootopen.com
linux命令:sudo ip addr add 192.168.56.10 dev eth1 eth1 dev 192.168.56.10 add addr ip sudo sudo ip addr add 192.168.56.10 dev eth1rootopen.com
2018-09-11 09:55:30

linux命令:sudo apt-get install grep #Debian / Ubuntu sudo yum install grep #RHEL / CentOS / Fedora Fedora / CentOS / grep #RHEL install yum Ubuntu sudo / grep #Debian install apt-get sudo sudo apt-get install grep #Debian / Ubuntu sudo yum install grep #RHEL / CentOS / Fedorarootopen.com
linux命令:sudo apt-get install grep #Debian / Ubuntu sudo yum install grep #RHEL / CentOS / Fedora Fedora / CentOS / grep #RHEL install yum Ubuntu sudo / grep #Debian install apt-get sudo sudo apt-get install grep #Debian / Ubuntu sudo yum install grep #RHEL / CentOS / Fedorarootopen.com
2018-09-11 09:55:30

linux命令:sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7 /usr/bin/python2.7 CAP_NET_BIND_SERVICE=+eip setcap sudo sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7rootopen.com
linux命令:sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7 /usr/bin/python2.7 CAP_NET_BIND_SERVICE=+eip setcap sudo sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7rootopen.com
2018-09-11 09:55:30

linux命令:sudo dmidecode -t processor processor -t dmidecode sudo sudo dmidecode -t processorrootopen.com
linux命令:sudo dmidecode -t processor processor -t dmidecode sudo sudo dmidecode -t processorrootopen.com
2018-08-29 21:58:54

linux命令:sudo dmidecode -t bios bios -t dmidecode sudo sudo dmidecode -t biosrootopen.com
linux命令:sudo dmidecode -t bios bios -t dmidecode sudo sudo dmidecode -t biosrootopen.com
2018-08-29 21:58:04

linux命令:sudo dmidecode -t memory memory -t dmidecode sudo sudo dmidecode -t memoryrootopen.com
linux命令:sudo dmidecode -t memory memory -t dmidecode sudo sudo dmidecode -t memoryrootopen.com
2018-08-29 21:57:05

linux命令:sudo fdisk -l -l fdisk sudo sudo fdisk -l rootopen.com
linux命令:sudo fdisk -l -l fdisk sudo sudo fdisk -l rootopen.com
2018-08-29 21:55:54

linux命令:sudo hdparm /dev/sda1 /dev/sda1 hdparm sudo sudo hdparm /dev/sda1rootopen.com
linux命令:sudo hdparm /dev/sda1 /dev/sda1 hdparm sudo sudo hdparm /dev/sda1rootopen.com
2018-08-29 21:55:15

linux命令:sudo lshw -html > lshw.html lshw.html > -html lshw sudo sudo lshw -html > lshw.htmlrootopen.com
linux命令:sudo lshw -html > lshw.html lshw.html > -html lshw sudo sudo lshw -html > lshw.htmlrootopen.com
2018-08-29 21:47:22

linux命令:sudo lshw -short -short lshw sudo sudo lshw -shortrootopen.com
linux命令:sudo lshw -short -short lshw sudo sudo lshw -shortrootopen.com
2018-08-29 21:46:06

linux命令:sudo lshw lshw sudo sudo lshwrootopen.com
linux命令:sudo lshw lshw sudo sudo lshwrootopen.com
2018-08-29 21:44:57

linux命令:sudo dmidecode - type system system type - dmidecode sudo sudo dmidecode - type systemrootopen.com
linux命令:sudo dmidecode - type system system type - dmidecode sudo sudo dmidecode - type systemrootopen.com
2018-08-29 21:35:34

linux命令:sudo echo "shutdown -h now" | at -m 23:55 23:55 -m at | now" -h "shutdown echo sudo sudo echo "shutdown -h now" | at -m 23:55rootopen.com
linux命令:sudo echo "shutdown -h now" | at -m 23:55 23:55 -m at | now" -h "shutdown echo sudo sudo echo "shutdown -h now" | at -m 23:55rootopen.com
2018-08-20 22:21:24

linux命令:sudo arp-scan --interface = enp2s0 --localnet --localnet enp2s0 = --interface arp-scan sudo sudo arp-scan --interface = enp2s0 --localnet rootopen.com
linux命令:sudo arp-scan --interface = enp2s0 --localnet --localnet enp2s0 = --interface arp-scan sudo sudo arp-scan --interface = enp2s0 --localnet rootopen.com
2018-08-20 22:18:47

linux命令:sudo aptitude update update aptitude sudo sudo aptitude updaterootopen.com
linux命令:sudo aptitude update update aptitude sudo sudo aptitude updaterootopen.com
2018-08-20 22:17:15

linux命令:sudo apt-get autoremove vsftpd vsftpd autoremove apt-get sudo sudo apt-get autoremove vsftpdrootopen.com
linux命令:sudo apt-get autoremove vsftpd vsftpd autoremove apt-get sudo sudo apt-get autoremove vsftpdrootopen.com
2018-08-19 23:02:55

linux命令:sudo apt-get autoclean autoclean apt-get sudo sudo apt-get autocleanrootopen.com
linux命令:sudo apt-get autoclean autoclean apt-get sudo sudo apt-get autocleanrootopen.com
2018-08-19 23:01:49

linux命令:sudo apt-get build-dep netcat netcat build-dep apt-get sudo sudo apt-get build-dep netcatrootopen.com
linux命令:sudo apt-get build-dep netcat netcat build-dep apt-get sudo sudo apt-get build-dep netcatrootopen.com
2018-08-19 23:00:44

linux命令:sudo apt-get check check apt-get sudo sudo apt-get checkrootopen.com
linux命令:sudo apt-get check check apt-get sudo sudo apt-get checkrootopen.com
2018-08-19 22:59:52

linux命令:sudo apt-get changelog vsftpd vsftpd changelog apt-get sudo sudo apt-get changelog vsftpdrootopen.com
linux命令:sudo apt-get changelog vsftpd vsftpd changelog apt-get sudo sudo apt-get changelog vsftpdrootopen.com
2018-08-19 22:59:03

linux命令:sudo apt-get download nethogs nethogs download apt-get sudo sudo apt-get download nethogsrootopen.com
linux命令:sudo apt-get download nethogs nethogs download apt-get sudo sudo apt-get download nethogsrootopen.com
2018-08-19 22:58:25

linux命令:sudo apt-get --compile source goaccess goaccess source --compile apt-get sudo sudo apt-get --compile source goaccessrootopen.com
linux命令:sudo apt-get --compile source goaccess goaccess source --compile apt-get sudo sudo apt-get --compile source goaccessrootopen.com
2018-08-19 22:57:35

linux命令:sudo apt-get source vsftpd vsftpd source apt-get sudo sudo apt-get source vsftpdrootopen.com
linux命令:sudo apt-get source vsftpd vsftpd source apt-get sudo sudo apt-get source vsftpdrootopen.com
2018-08-19 22:56:26

linux命令:sudo apt-get --download-only source vsftpd vsftpd source --download-only apt-get sudo sudo apt-get --download-only source vsftpdrootopen.com
linux命令:sudo apt-get --download-only source vsftpd vsftpd source --download-only apt-get sudo sudo apt-get --download-only source vsftpdrootopen.com
2018-08-19 22:55:53

linux命令:sudo apt-get clean clean apt-get sudo sudo apt-get cleanrootopen.com
linux命令:sudo apt-get clean clean apt-get sudo sudo apt-get cleanrootopen.com
2018-08-19 22:55:01

linux命令:sudo apt-get purge vsftpd vsftpd purge apt-get sudo sudo apt-get purge vsftpdrootopen.com
linux命令:sudo apt-get purge vsftpd vsftpd purge apt-get sudo sudo apt-get purge vsftpdrootopen.com
2018-08-19 22:54:16

linux命令:sudo apt-get remove vsftpd vsftpd remove apt-get sudo sudo apt-get remove vsftpdrootopen.com
linux命令:sudo apt-get remove vsftpd vsftpd remove apt-get sudo sudo apt-get remove vsftpdrootopen.com
2018-08-19 22:53:51

linux命令:sudo apt-get install vsftpd=2.3.5-3ubuntu1 vsftpd=2.3.5-3ubuntu1 install apt-get sudo sudo apt-get install vsftpd=2.3.5-3ubuntu1rootopen.com
linux命令:sudo apt-get install vsftpd=2.3.5-3ubuntu1 vsftpd=2.3.5-3ubuntu1 install apt-get sudo sudo apt-get install vsftpd=2.3.5-3ubuntu1rootopen.com
2018-08-19 22:52:24

linux命令:sudo apt-get install netcat netcat install apt-get sudo sudo apt-get install netcatrootopen.com
linux命令:sudo apt-get install netcat netcat install apt-get sudo sudo apt-get install netcatrootopen.com
2018-08-19 22:50:53

linux命令:sudo apt-get dist-upgrade dist-upgrade apt-get sudo sudo apt-get dist-upgraderootopen.com
linux命令:sudo apt-get dist-upgrade dist-upgrade apt-get sudo sudo apt-get dist-upgraderootopen.com
2018-08-19 22:50:19

linux命令:sudo apt-get upgrade upgrade apt-get sudo sudo apt-get upgraderootopen.com
linux命令:sudo apt-get upgrade upgrade apt-get sudo sudo apt-get upgraderootopen.com
2018-08-19 22:49:27

linux命令:sudo apt-get update update apt-get sudo sudo apt-get updaterootopen.com
linux命令:sudo apt-get update update apt-get sudo sudo apt-get updaterootopen.com
2018-08-19 22:48:53

linux命令:sudo apt-get update update apt-get sudo sudo apt-get updaterootopen.com
linux命令:sudo apt-get update update apt-get sudo sudo apt-get updaterootopen.com
2018-08-19 22:40:10

Linux的Bash命令行(A-Z排序)