LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-05-2007, 06:58 AM   #16
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492

USER doesn't keep the login username after "su -":
Code:
-bash-2.05b$ who am i
jlliagre console      Jun  5 07:55         
-bash-2.05b$ cat /etc/redhat-release 
CentOS release 3.7 (Final)
-bash-2.05b$ echo $USER
jlliagre
-bash-2.05b$ su -
-bash-2.05b# who am i
jlliagre console      Jun  5 07:55         
-bash-2.05b# echo $USER
root
 
Old 06-05-2007, 07:00 AM   #17
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
thats very strange it has for me??

i think let me just double check on that
 
Old 06-05-2007, 07:04 AM   #18
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
thats interesting if i use "su" i can use the $USER and it will stay as origional user, if i "su -" then use $USER it will change to root. And if i kdesu like i am now i guess it must keep origional user as well because my script works properly so it must keep $USER as origional, you try it with "su" and not "su -"

let me know
 
Old 06-05-2007, 04:04 PM   #19
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
"su -" is clearing all the environment variables by design and setting some of them like USER.

"info su" will tell you.
 
Old 06-05-2007, 04:15 PM   #20
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
thanks for that, it is interesting.

Thanks for everything everyone STARS
 
Old 10-12-2007, 04:51 AM   #21
doc.nice
Member
 
Registered: Oct 2004
Location: Germany
Distribution: Debian
Posts: 274

Rep: Reputation: 34
this variable is set by bash, so if you use #!/bin/bash as first line of your script, everything should be fine. see "man bash" for other builtin variables...
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
return the username in a command matthewhardwick Linux - General 6 10-12-2007 06:30 AM
GCC inserts my username in command line rickthemick Solaris / OpenSolaris 4 03-19-2007 10:54 AM
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 01:21 AM
useradd: invalid username username$ engyeow Fedora 5 12-05-2004 04:35 AM
command prompt - username@mac address? ryedunn Linux - Newbie 5 03-16-2004 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:04 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