简体   繁体   English

用于切换用户的Bash脚本

[英]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服务器: developeruser1user2user3user4 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.shuser2.shuser3.shuser4.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 ,他切换到user1cd到的主目录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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM