LinuxQuestions.org
Review your favorite Linux distribution.
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 12-03-2015, 10:05 PM   #1
kb2tfa
Member
 
Registered: Oct 2006
Location: Philadelphia PA
Distribution: Fedora
Posts: 175

Rep: Reputation: 18
Confused as to when to use the dash with su


I am confused. I see some tutorials that show using the dash with su to incorporate the users' path with the root path. That's how I understood it, but when I print them out, it's not the case. It appears the "su -" is the root path with no user paths.

Code:
PLAIN SU PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/ron/.local/bin:/home/ron/bin

RON PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/ron/.local/bin:/home/ron/bin

SU DASH PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
 
Old 12-03-2015, 10:32 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,465

Rep: Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606
that dash is a keybord shortcut for this command
Code:
" su - " 
is the same as 
" su -l root "
su is root BUT!!!! with your normal user $PATH and in the same folder
"su -" is root BUT a log in AS!!! root and you are in the root HOME folder ( /root)

to install software you build you use "su" NO DASH , because you need to still be in the same folder

but to say launch Gedit AS ROOT you will NEED the dash
-- try it --
Code:
su 
gedit
and open a new terminal
Code:
su -
gedit
both fedora and cent use /usr/sbin
this folder IS NOT !!! in the normal users system path
but it is in root's

so for all the programs in that folder you need to be loged in as root ( use the dash )

Last edited by John VV; 12-03-2015 at 10:36 PM.
 
1 members found this post helpful.
Old 12-03-2015, 10:58 PM   #3
kb2tfa
Member
 
Registered: Oct 2006
Location: Philadelphia PA
Distribution: Fedora
Posts: 175

Original Poster
Rep: Reputation: 18
Thank you I see the difference
 
Old 12-03-2015, 10:59 PM   #4
kb2tfa
Member
 
Registered: Oct 2006
Location: Philadelphia PA
Distribution: Fedora
Posts: 175

Original Poster
Rep: Reputation: 18
I ran pwd from both, and I see the difference. I didn't notice before the folder changed.
 
Old 12-03-2015, 11:51 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,705

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
... and of course you can specify any target user if you know their passwd eg
Code:
su - fred
will log you in as fred, with HIS env, home dir etc.

Note also that if you are starting from the root acct, the above will not require specifying fred's passwd; useful for starting processes as another user during eg boot.
 
Old 12-04-2015, 12:58 AM   #6
jheengut
Member
 
Registered: Sep 2006
Location: Providence, Moka Mauritius
Distribution: Slackware, Lubuntu
Posts: 315
Blog Entries: 16

Rep: Reputation: 47
I thought the ~/.profile or ~/.bashrc files are not run when su is specified without dash.
 
  


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
[SOLVED] From Dash to Bash Zimo Linux From Scratch 15 10-02-2012 02:26 PM
[SOLVED] Have sh Be Something Other That Bash/Dash. Zssfssz Debian 5 03-15-2012 09:48 AM
[SOLVED] How to configure dash jdkaye Debian 4 08-06-2009 12:05 PM
Need help with BASH and DASH cosmicbrat Linux - Software 1 03-12-2009 09:39 PM
Type en-dash r-t Linux - General 5 04-04-2008 02:57 PM

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

All times are GMT -5. The time now is 09:12 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration