Bash script to switch the user

Gopu

I am having a cent-OS server with 5 accounts: developer, user1 ,user2 ,user3 and user4. All the user home directories are under /home like /home/developer, /home/user1, /home/user2, /home/user3 and /home/user4. I want to create a 4 scripts: user1.sh, user2.sh, user3.sh and user4.sh inside the /home/developer folder. 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. 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. Is it possible?

Bruce

I suppose you're looking at 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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Howto switch / chage user id witin a bash script to execute commands in the same script?

From Dev

Switch user in a shell script without entering the password

From Dev

Why can I switch to a user but not run a script as it

From Dev

Change user AND environment in bash script

From Dev

Creating user with bash script with arguments

From Dev

Bash Script - Check if user is logged in or not

From Dev

Using chown $USER:$USER inside bash script

From Dev

Bash script with user defined functions in autocomplete

From Dev

To check if a bash script is run as root or a regular user?

From Dev

$user or $whoami not working in a bash shell script

From Dev

File permissions, root bash script, edit by user

From Dev

Bash: sourcing file as user from script

From Dev

Create mysql database and user in bash script

From Dev

creating a bash script to create database and user automatically

From Dev

Feeding User Input using bash script

From Dev

Getting user input during bash script

From Dev

Check user input for errors in bash script

From Dev

How to trim user input in bash script?

From Dev

Bash Script Display Remote Screen Session to User

From Dev

Bash script with user defined functions in autocomplete

From Dev

Inputting user input automatically through bash script?

From Dev

How to force bash script to wait for user answer?

From Dev

Need to pause bash script for user examination

From Dev

creating a bash script to create database and user automatically

From Dev

Bash script. Limit user input

From Dev

Loop through variable user names in a bash script

From Dev

Bash file script escaping user input

From Dev

How to add a unix/linux user in a bash script

From Dev

How to make passwordless switch to another user in a shell script

Related Related

  1. 1

    Howto switch / chage user id witin a bash script to execute commands in the same script?

  2. 2

    Switch user in a shell script without entering the password

  3. 3

    Why can I switch to a user but not run a script as it

  4. 4

    Change user AND environment in bash script

  5. 5

    Creating user with bash script with arguments

  6. 6

    Bash Script - Check if user is logged in or not

  7. 7

    Using chown $USER:$USER inside bash script

  8. 8

    Bash script with user defined functions in autocomplete

  9. 9

    To check if a bash script is run as root or a regular user?

  10. 10

    $user or $whoami not working in a bash shell script

  11. 11

    File permissions, root bash script, edit by user

  12. 12

    Bash: sourcing file as user from script

  13. 13

    Create mysql database and user in bash script

  14. 14

    creating a bash script to create database and user automatically

  15. 15

    Feeding User Input using bash script

  16. 16

    Getting user input during bash script

  17. 17

    Check user input for errors in bash script

  18. 18

    How to trim user input in bash script?

  19. 19

    Bash Script Display Remote Screen Session to User

  20. 20

    Bash script with user defined functions in autocomplete

  21. 21

    Inputting user input automatically through bash script?

  22. 22

    How to force bash script to wait for user answer?

  23. 23

    Need to pause bash script for user examination

  24. 24

    creating a bash script to create database and user automatically

  25. 25

    Bash script. Limit user input

  26. 26

    Loop through variable user names in a bash script

  27. 27

    Bash file script escaping user input

  28. 28

    How to add a unix/linux user in a bash script

  29. 29

    How to make passwordless switch to another user in a shell script

HotTag

Archive