alias and sudo


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users alias and sudo
# 1  
Old 05-09-2006
alias and sudo

I'm using personal user to enter telnet session then manually connecting to a generic user using the following :

sudo -H -u $1 ksh -c ". ~$1/.profile && cd ~$1 && ksh" ;

where $1 is the generic user.

It works but in the ".profile" execution , the alias are not working

when the generic connection is ok , i'm forced to type ". .profile" to read it again , then the alias are ok.

I don't understand why all the ".profile" is ok but the alias no !

Somebody can help ?

regards
Christian
# 2  
Old 05-10-2006
.profile is been read by login program/process. sudo is not ment for that. man sudo
NAME
sudo - execute a command as another user
So its merely a command execution shell
# 3  
Old 05-10-2006
OK i understand that but the sudo i ran is supposed (and he does) to read the ".profile" but the alias contained in this ".profile" are not executed as alias command when the others lines are red (PATH...)

Christian
# 4  
Old 05-10-2006
You are not able to differerentiate b/w alias and environment variables here ;-)
# 5  
Old 05-10-2006
So can i change the line :
"sudo -H -u $1 ksh -c ". ~$1/.profile && cd ~$1 && ksh" ;"

to have an alias file red at the same time without to do it manually after the prompt ?

Christian
# 6  
Old 05-10-2006
If I were you then I'd have gone with your approach only
# 7  
Old 05-10-2006
I don't understand what you're trying to say !

Christian
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SUDO help with command alias

Hi there, I'm trying to setup sudo privileges for a user, Oracle in this case, to run Unix commands like mv,chmod, chown, mkdir, rmdir against their own set of commands or scripts. Is there an easier way to do this than to give Unix commands for each of their respective commands as shown below... (2 Replies)
Discussion started by: mbak
2 Replies

2. Shell Programming and Scripting

sudo: sorry, you must have a tty to run sudo

Hi, Have a need to run the below command as a "karuser" from a java class which will is running as "root" user. When we are trying to run the below command from java code getting the below error. Command: sudo -u karuser -s /bin/bash /bank/karunix/bin/build_cycles.sh Error: sudo: sorry,... (8 Replies)
Discussion started by: Satyak
8 Replies

3. Shell Programming and Scripting

sudo: sorry, you must have a tty to run sudo

Hi All, I running a unix command using sudo option inside shell script. Its working well. But in crontab the same command is not working and its throwing "sudo: sorry, you must have a tty to run sudo". I do not have root permission to add or change settings for my userid. I can not even ask... (9 Replies)
Discussion started by: Apple1221
9 Replies

4. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

5. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

6. AIX

sudo log and sudo auditing

Sudo In AIX, how to find out what commands have been run after a user sudo to another user? for example, user sam run 'sudo -u robert ksh' then run some commands, how can I (as root) find what commands have been run? sudo.log only contains sudo event, no activity logging. (3 Replies)
Discussion started by: jalite19
3 Replies

7. Cybersecurity

sudo /bin/sh or sudo su -

we are looking at changing the way we get root on our network. in our current system if an admin needs root access he just gets the root password and uses an su. some of our staff have decided that a sudo to "/bin/sh" will be easer. some of our staff think a sudo to "su -" will be better. I... (0 Replies)
Discussion started by: robsonde
0 Replies

8. UNIX for Dummies Questions & Answers

Unable to use the Sudo command. "0509-130 Symbol resolution failed for sudo because:"

Hi! I'm very new to unix, so please keep that in mind with the level of language used if you choose to help :D Thanks! When attempting to use sudo on and AIX machine with oslevel 5.1.0.0, I get the following error: exec(): 0509-036 Cannot load program sudo because of the following errors:... (1 Reply)
Discussion started by: Chloe123
1 Replies

9. UNIX for Dummies Questions & Answers

Problems with Alias, /bin/sh and sudo

'exec /bin/sh' breaks alias -------------------------------------------------------------------------------- I have an application that requires su to root in order to run some commands. Unfortunately, my corporate policy only allows sudo so I created an alias in .profile as "alias su="su... (0 Replies)
Discussion started by: stulincoln
0 Replies
Login or Register to Ask a Question