![]() User2 would also need to have permissions to execute as root, which may or may not be the case in the sudoers configuration. Note though this is not typically how things should be run and that this could lead to possibly undefined behavior or weirdness. This is what the file looks like currently when i use the visudo command. My goal is basically that when I am logged in as user maint and run 'testSudo', the output of the whoami command will be 'user1'. 9 Answers Sorted by: 37 Assuming that you have sudo privileges the following command will do. (Don't laugh, we don't need anything fancy.) I tried login tina and that didn't work. I would like to be able to login as another user, like 'tina', so I can test her sudoer permissions. file 'sudoTest' lives in /home/user1/ file 'testSudo' lives in /home/maint. 2 Redhat Enterprise Linux 5.10 (No we can't upgrade.) This is related to my other question. You can specify a user with -u, for example sudo -u root command is the same as sudo command. To do what you are trying to do would need two sudo commands chained (untested by the way): sudo -u user2 sudo apt-get -y install PACKAGENAME Here is a demo of what I have tried and am trying to accomplish. To run a command as the root user, use sudo command. If user2 is not in sudoers they can't execute that command. Therefore if user1 is running sudo apt-get they would be allowed to. It does not grant the privileges that apt-get needs to operate as that needs the effective root permissions that just running sudo apt-get would provide. Sudoers privilege only permits a user that is logged in to use sudo and to define what they can or cannot do with the sudo command. Many of the actual directories maintained by apt for package information need root to maintained as well, if a package is installing to /bin or similar it needs root. In order to temporarily sign on as another user, you can use the su command. sudo is an efficient way to access the root privileges and execute the command as. You must run apt-get as root via sudo, not as another user. System administration root (super) user, su and sudo in Linux for computer. It allows you to execute a command as another user, including the superuser.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |