Can I export the users environment using sudo?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can I export the users environment using sudo?
# 1  
Old 05-22-2008
Can I export the users environment using sudo?

I want the user to be able to commands as another user.. but when they do that.. I need them to have the environment variables of the other user. is this possible with sudo?

sudo -H -u user env

'env' is giving me the environment of the current user, not the user I want to run commands as.

Hope this makes sense (it does in my head Smilie )
# 2  
Old 05-22-2008
Try:
Code:
sudo su - <username> -c <command>

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to check sudo access of other users?

Hi, I always use "sudo -U user -l" as root and it gives me list of sudo access, that person have. But on one Solaris server, I can't run it. recently only I installed latest patchset on this server. Not sure, if that changed something on this. However, sudo package is showing old one. # id -a... (1 Reply)
Discussion started by: ron323232
1 Replies

2. Shell Programming and Scripting

Array - Export/Import in global environment variables.

Hello. During startup /etc/bash.bashrc.local generates some array ..... source /.../.../system_common_general_array_env_var ..... The file system_common_general_array_env_var contains : LEAP_VERSION='42.3' ARRAY_MAIN_REPO_LEAP=('zypper_local' 'openSUSE-Leap-'"$LEAP_VERSION"'-Non-Oss' ... (2 Replies)
Discussion started by: jcdole
2 Replies

3. Shell Programming and Scripting

How to sudo to multiple users?

Hi all, I have to create SSH public key for multiple users. Iam creating a script in which, through root, I have to switch to multiple accounts to create SSH keys and then transfer it to the respective servers. First I tried with single user id and everything worked fine. When I try to sudo... (1 Reply)
Discussion started by: deepakwins
1 Replies

4. Red Hat

SUDO: environment variables

Hi, I was wondering about this question today, After logging to a linux server (putty - ssh), I set environment variables like PATH etc. When I launch a command as sudo, is the environment variables that were set applicable to the command launched as sudo also? Please let me know what you... (2 Replies)
Discussion started by: jredx
2 Replies

5. UNIX for Advanced & Expert Users

sudo environment setting?

Hi, first post. As the nick suggests I'm a Unix noob, but I'm doing everything I can to learn fast...job requirement. These forums have been a huge help so far. I have a server running HP-UX 11.23b with Apache/2.0.59 HP-UX_Apache-based_Web_Server. Apache is not installed in the default... (3 Replies)
Discussion started by: nixnoob
3 Replies

6. Solaris

sudo for users

Hello gurus, Is there a flag or switch that you can added to sudoers file to always have users type 'sudo' prior to running a command? (5 Replies)
Discussion started by: em23
5 Replies

7. Solaris

Add environment variables for all users

hi I need to add environment variables for all users and make them available when they login. I don't know which file to edit. Also these variables should be displayed when "env" command is executed. Please help....which file is common for all users, without editing their specific .profile or... (2 Replies)
Discussion started by: ashish_uiit
2 Replies

8. UNIX for Advanced & Expert Users

[ Environment Variable ] Probleme with export JAVA_HOME

Hi, I want to create a new environment variable (JAVA_HOME), but when I open a new shell this varible is delete... to create the variable I do : export JAVA_HOME=/usr/java/jdk and I verify with : echo $JAVA_HOME and it's work... But When I open a new shell this variable is forget... ( It... (2 Replies)
Discussion started by: marcel_kobain
2 Replies

9. UNIX for Advanced & Expert Users

Managing Users in a Global Environment

Hello, I am interested in your strategy for handling engineers Unix accounts when the engineers must log in to resources in a variety of locals in a global environment. The engineers home directory and normal environment is local to where the engineer is sitting. When they log in to a remote... (0 Replies)
Discussion started by: Randal
0 Replies

10. Shell Programming and Scripting

Extracting a users environment variables

Hi Guys, I want to extract users environment variables via a sh script, and for some reason it is not working. According to the su man page: Example 3: Executing command with user bin's Environment and Permissions To execute command with the temporary environment and per-... (2 Replies)
Discussion started by: Tornado
2 Replies
Login or Register to Ask a Question