[英]Bash script to switch the user
I am having a cent-OS server with 5 accounts: developer
, user1
, user2
, user3
and user4
. 我有一个包含5个帐户的
user4
OS服务器: developer
, user1
, user2
, user3
和user4
。 All the user home directories are under /home
like /home/developer
, /home/user1
, /home/user2
, /home/user3
and /home/user4
. 所有用户主目录都位于
/home
类的/home/developer
, /home/user1
, /home/user2
, /home/user3
和/home/user4
。 I want to create a 4 scripts: user1.sh
, user2.sh
, user3.sh
and user4.sh
inside the /home/developer
folder. 我想在
/home/developer
文件夹中创建4个脚本: user1.sh
, user2.sh
, user3.sh
和user4.sh
。 When the user developer
run the script user1.sh
, he switches to the user1
and cd
to the home directory of user1
( /home/user1
) and so on for the remaining scripts. 当用户
developer
运行该脚本user1.sh
,他切换到user1
和cd
到的主目录user1
( /home/user1
)等为剩余的脚本。 The idea behind is to keep the developer from the root access and allow switch to other user's home directory by simple executing a command with that user's name. 其背后的想法是通过简单地执行具有该用户名的命令,使开发人员不受root访问,并允许切换到其他用户的主目录。 Is it possible?
可能吗?
I suppose you're looking at su - otherUser
我想你正在看
su - otherUser
Of course, you'll have to provide the password of the other user. 当然,您必须提供其他用户的密码。
I suppose that something like sudo su - otherUser
could work but I haven't tried 我
sudo su - otherUser
这样的东西可以工作,但我还没试过
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.