linux su建立游客账户,linux 命令之 su 切换到指定账户

执行 su --help ,命令描述如下:

用法:su [选项]... [-] [用户 [参数]... ]

Change the effective user id and group id to that of USER.

-, -l, --login               make the shell a login shell,

clears all envvars except for TERM,

initializes HOME, SHELL, USER, LOGNAME and PATH

-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 HOME, SHELL, USER, LOGNAME

environment variables

-p                           same as -m

-s, --shell=SHELL            run SHELL if /etc/shells allows it

--help        显示此帮助信息并退出

--version        显示版本信息并退出

单独的"-"选项隐含了-l。如果不指定用户,则假设其为root。

例子如下:

su man -c catman

Runs the command catman as user man.  You will be asked for man's password unless your real UID is 0.

su man -c 'catman /usr/share/man /usr/local/man'

Same as above, but the target command consists of more than a single word and hence is quoted for use with the -c option being

passed to the shell.  (Most shells expect the argument to -c to be a single word).

su -l foo

Simulate a login for user foo.

su - foo

Same as above.

su -   Simulate a login for root.

注意:-或者-l  选项会重置HOME, SHELL, USER, LOGNAME and PATH环境

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值