[英]Execute combine multiple linux commands in one line for different user
Is it possible to combine multiple linux commands for different users?是否可以为不同的用户组合多个 linux 命令? I mean, I'm logged on
root
.我的意思是,我已登录
root
。 From root
user I would like to log in on jaworows
user and execute some command on jaworows
.从
root
用户我想记录在jaworows
用户和执行一些命令jaworows
。
&&
seems not working, because it is executing only first command. &&
似乎不起作用,因为它只执行第一个命令。
root@jaworows:~# su jaworows && echo "hi"
jaworows@jaworows:/root$
I would like to see "hi" when I log in on jaworows.当我登录jaworows时,我想看到“嗨”。
su jaworows
starts a new shell; su jaworows
启动一个新的shell; the command does not complete until you exit that shell.在您退出该 shell 之前,该命令不会完成。 At that point, if the shell exists with status 0, the
echo "hi"
will execute.此时,如果 shell 以状态 0 存在,则将执行
echo "hi"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.