LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-11-2009, 08:09 AM   #1
ukiome
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
login as other user using shell doesn't load the profile for that user


I am using the sudo command to log on locally as another user by the following command:

sudo -u theotheruser -s
or
sudo -u theotheruser sh

As I see it, this initiates a new shell with the mentioned other user.
However, this doesn't load that users profile from his home directory.

Is there a way to automatically read the users profile when login in with selected command? I am mostely interested in getting a working prompt when logged in.

Thankful for any suggestions.
 
Old 12-11-2009, 08:25 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Quote:
Originally Posted by ukiome
I am mostely interested in getting a working prompt when logged in.
Run this command and see the results !

Code:
cd /home/userName sudo -u userName -s
Is this what you want ?

Last edited by TheIndependentAquarius; 12-11-2009 at 08:30 AM.
 
Old 12-11-2009, 08:26 AM   #3
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 681

Rep: Reputation: 95
Quote:
Originally Posted by ukiome View Post
I am using the sudo command to log on locally as another user by the following command:

sudo -u theotheruser -s
or
sudo -u theotheruser sh

As I see it, this initiates a new shell with the mentioned other user.
However, this doesn't load that users profile from his home directory.

Is there a way to automatically read the users profile when login in with selected command? I am mostely interested in getting a working prompt when logged in.

Thankful for any suggestions.
su &USER -l would five you a login shell with all the profile scripts loaded.
 
0 members found this post helpful.
Old 12-11-2009, 08:29 AM   #4
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Quote:
Originally Posted by ozanbaba
su &USER -l would five you a login shell with all the profile scripts loaded.
I didn't understand how to run this command !!
 
Old 12-11-2009, 09:04 AM   #5
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 681

Rep: Reputation: 95
Quote:
Originally Posted by anishakaul View Post
I didn't understand how to run this command !!
sorry about that;

su $USER_NAME -l

su uses root by default, give it a user name, -l makes su the start login shell (a shell environment you would find if you log in as that user). login shell will run all the profile scripts including default ones in /etc/profile.d and in $HOME.
 
1 members found this post helpful.
Old 12-14-2009, 01:31 AM   #6
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Quote:
Originally Posted by ozanbaba
sorry about that;

su $USER_NAME -l

su uses root by default, give it a user name, -l makes su the start login shell (a shell environment you would find if you log in as that user). login shell will run all the profile scripts including default ones in /etc/profile.d and in $HOME.
__________________
オザン
I tried it, Yeah it works ! and it is given in the man page of su, I was lazy enough to read that

Thanks for the help !

Last edited by TheIndependentAquarius; 12-14-2009 at 01:32 AM.
 
Old 12-19-2009, 12:47 AM   #7
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Another way to login straightway to another user's /home

su - userName
 
Old 12-19-2009, 06:14 AM   #8
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 681

Rep: Reputation: 95
Quote:
Originally Posted by anishakaul View Post
Another way to login straightway to another user's /home

su - userName
but it won't run all of the profile script.

okey i will, never anwser questions while still having the day's first coffee

Last edited by ozanbaba; 12-19-2009 at 06:19 AM.
 
0 members found this post helpful.
Old 12-19-2009, 06:23 AM   #9
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Quote:
Originally Posted by ozanbaba
but it won't run all of the profile script.
Kindly explain more on this..through some examples ... What sort of profile scripts are u talking about ?
 
Old 12-19-2009, 06:46 AM   #10
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 681

Rep: Reputation: 95
Quote:
Originally Posted by anishakaul View Post
Kindly explain more on this..through some examples ... What sort of profile scripts are u talking about ?
did you catch the edit? sorry for wrong post
 
Old 12-19-2009, 06:52 AM   #11
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,711
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Quote:
Originally Posted by ozanbaba
did you catch the edit? sorry for wrong post
I am sorry, I still couldnt understand what u r talking about ?
 
Old 12-19-2009, 06:56 AM   #12
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 681

Rep: Reputation: 95
Quote:
Originally Posted by anishakaul View Post
I am sorry, I still couldnt understand what u r talking about ?
i was wrong, su - $USER will open a login shell with all the profile scripts run.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where to find .profile or .login for a specific user bopedibop Linux - Newbie 2 07-11-2006 11:23 AM
Load kde profile from /mnt/removable/user instead of /home/user preacher.ca Linux - General 3 12-02-2005 04:00 PM
how to - ftp user with no login shell hnad Red Hat 3 04-13-2004 04:22 AM
It is impossible to load the user login panel in SUSE jjay02 Linux - Distributions 6 02-03-2003 09:35 PM
shell script to find user(s) profile j-me Programming 2 01-31-2003 12:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration