基础命令学习目录首页
su switch user, 用于切换用户用
su 常见命令参数
用法: su [选项]... [-] [用户 [参数]... ]
- Change the effective user id and group id to that of USER.
- -, -l, --login make the shell a login shell
- -c, --command=COMMAND pass a single COMMAND to the shell with -c
- --session-command=COMMAND pass a single COMMAND to the shell with -c
- and do not create a new session
- -f, --fast pass -f to the shell (for csh or tcsh)
- -m, --preserve-environment do not reset environment variables
- -p same as -m
- -s, --shell=SHELL run SHELL if /etc/shells allows it
--help 显示此帮助信息并退出
--version 显示版本信息并退出
单独的 "-" 选项隐含了 - l. 如果不指定用户, 则假设其为 root.
常用的命令展示
切换 omd 用户
su - omd # root 切换其他用户不用输密码, 普通用户直接切换密码需要知道那个用户的登录密码
不切换用户而直接执行命令:
omd 用户下: su - root -c "ifconfig" 需要输入密码
来源: http://www.bubuko.com/infodetail-2945324.html