LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 10-26-2009, 12:54 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 605
Blog Entries: 2

Rep: Reputation: 36
What is different between su <username>and su - <username>


Hi guys,

What is different between su <username>and su - <username>

Is there any other options available to switch user.
 
Old 10-26-2009, 01:04 AM   #2
lhorace
Member
 
Registered: Aug 2009
Distribution: Fedora
Posts: 126

Rep: Reputation: 21
'su -' is a login shell, where you can assume the user environment of the target user
 
Old 10-26-2009, 01:09 AM   #3
pinga123
Member
 
Registered: Sep 2009
Posts: 605
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Even Su <username> has the same effect
Why do we use hyphen in between?
 
Old 10-26-2009, 01:35 AM   #4
lhorace
Member
 
Registered: Aug 2009
Distribution: Fedora
Posts: 126

Rep: Reputation: 21
su, without the hyphen, you continue to retain your current Environment. In simple terms, just the $USER and $HOME change to root. While the rest of bash Global variables stay the same. On certain distributions like OpenSuSe, even when I login as just su, I don't have access to 'fdisk' as opposed to su -.

Variable(s) are not the only thing that changes between su and su -.

Like 'su' is a emulated session and 'su -' is the real deal. Probably can start GUI applications in just 'su' and fail in 'su -', unable to connect to X server. Something to that effect.

Last edited by lhorace; 10-26-2009 at 01:38 AM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why "bash-2.05b$" in Terminal instead of "username@localhost username" jayelitumbiolo Linux - General 9 10-04-2009 04:16 AM
How can I match username from username/ ? abefroman Linux - Newbie 2 04-26-2009 10:10 PM
fedora 8 asking username but during installation i dint give any username ?? herevenku Linux - Newbie 2 08-25-2008 05:37 AM
Differance between su <username> and su <username> - guguma Linux - General 3 08-19-2007 02:01 PM
useradd: invalid username username$ engyeow Fedora 5 12-05-2004 05:35 AM


All times are GMT -5. The time now is 01:42 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration