Results 1 to 10 of 11
What's the difference between:
tar xvf - filename
and
tar xvf filename
and
su - username
and
su username
?
Thanks...
- 03-06-2007 #1Linux Newbie
- Join Date
- Dec 2004
- Location
- Portland, OR
- Posts
- 123
use of - character in tar, su commands?
What's the difference between:
tar xvf - filename
and
tar xvf filename
and
su - username
and
su username
?
Thanks
- 03-06-2007 #2For commands like tar, usually - is for options
Originally Posted by jwilliams
tar -zxfv
For su it's a bit different
su just logs you in as root
su - logs you in as root with roots path
Try it yourself, login as root with just su
issue this command:
modprobe
Then login as root with su - and modprobe againI do not respond to private messages asking for Linux help, Please keep it on the forums only.
All new users please read this.** Forum FAQS. ** Adopt an unanswered post.
- 03-06-2007 #3Banned
- Join Date
- Nov 2004
- Location
- Belgium
- Posts
- 1,121
"-"(stdout/stdin) will tar everyting to stdout, being already the default you shouldn't need this.
Originally Posted by jwilliams
same thing as above, "-" is already the default and will not do anything in this case
Originally Posted by jwilliams
see:
man stdout
man tar
man su
- 03-06-2007 #4"-" is not default in RedHat and Fedora.
Originally Posted by jens
try this
compare output of 'echo $PATH'.Code:su echo $PATH exit su - echo $PATH
CasperIt is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 03-06-2007 #5Banned
- Join Date
- Nov 2004
- Location
- Belgium
- Posts
- 1,121
A redhat thingy ...
Originally Posted by devils_casper 
It doesn't change anything for me:
jens@desktop:~$ su others
Password:
others@desktop:/home/jens$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
others@desktop:/home/jens$ exit
exit
jens@desktop:~$ su - others
Password:
others@desktop:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
others@desktop:~$
- 03-06-2007 #6
Normal users have 'common' path and "-" wont do anything but in case of root user, it will make a lot of difference.
as i suggested earlier, execute 'su' and 'su -' only.Last edited by devils casper; 03-06-2007 at 05:06 AM.
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 03-06-2007 #7
i think i am missing something. i am not in Fedora box right now and can't check myself.
i think "-" changes 'present working directory' too.
will you please execute 'pwd' command in both cases?It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 03-06-2007 #8Banned
- Join Date
- Nov 2004
- Location
- Belgium
- Posts
- 1,121
Isn't that all he asked ("su username" vs "su - username"?
Originally Posted by devils_casper
"su -" will dump you in / (not really what he asked for in his question though), but their's no standard rule as for why "echo $PATH" would change (as far as I know...).
Originally Posted by devils_casper
Do correct me if I'm missing something...jens@desktop:~$ su
Password:
desktop:/home/jens# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
desktop:/home/jens# exit
exit
jens@desktop:~$ su -
Password:
desktop:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
desktop:~#
EDIT: Oh... you just meant the default Redhat profile ...
I was under the impression your meant it was "root" that makes a difference (post6).
I couldn't see your edit and second post before refreshing this page!? (is this forum software supposed to work like this ?).
All I said is that it doesn't change anything in default (meaning you didn't alter your bash_profile).
RH/Fedora uses a modified one (also for normal users and not just root, that's what I meant with the redhat thingy).
- 03-06-2007 #9i didn't edit much in second post. there was typo only. i wrote 'hoot' instead of
Originally Posted by jens
'root'.
.
did you execute pwd command? i can't access Fedora box right now. i will check it in Fedora and post here soon.It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 03-06-2007 #10Linux Newbie
- Join Date
- Jan 2007
- Location
- Cupertino, CA
- Posts
- 157
Difference between 'su' and 'su -'
Plain 'su <user>' spawns a shell thats not a login shell. 'su - <user>' causes a shell to be spawned with first argument as '-' which indicates a login shell.
Most shells take the first arg as '-' to mean that a new login has been initiated i.e. as if the new user (root or otherwise) logged in afresh over a terminal or ssh or telnet link or whatever. Consequently, they run all the usual login scripts (.bashrc and /etc/bash_profile in case of bash) and so you might get a different PATH according to those files as well as get started with <pwd>=<home directory>.
Comparing this to plain 'su <user>' case, just a new shell is spawned and all the environment is inherited from the parent process, hence retaining the old PATH and pwd.
Hope this was not too muddled an explanation.


Reply With Quote