LinuxQuestions.org
Visit Jeremy's Blog.
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 07-31-2003, 11:50 AM   #1
downinthemine
Member
 
Registered: Jul 2003
Location: Silver Spring, MD
Distribution: Xubuntu
Posts: 167

Rep: Reputation: 30
Question SU command question


Is using the su command in a console the exact same as if I had logged in as root to begin with? I.e., for applications that need to be installed by root, can I log is as my usual user and use the su command rather than continually logging out and back in?
 
Old 07-31-2003, 11:52 AM   #2
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
Yeah, but don't forget the - (su -).
 
Old 07-31-2003, 12:06 PM   #3
TheOneAndOnlySM
Member
 
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987

Rep: Reputation: 30
you don't ever have to continually log in and logout of root (in fact, i highly discourage your ever using root's graphical interface, DoN't Do It!)

just go into konsole or terminal, and when root is ever needed, type su and then enter your password when it asks, when u need to get out of su, i'm not sure if there is a command, but just exit the terminal window and start a new one
 
Old 07-31-2003, 12:08 PM   #4
downinthemine
Member
 
Registered: Jul 2003
Location: Silver Spring, MD
Distribution: Xubuntu
Posts: 167

Original Poster
Rep: Reputation: 30
What's the "-" in "su -"?
 
Old 07-31-2003, 12:10 PM   #5
TheOneAndOnlySM
Member
 
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987

Rep: Reputation: 30
there is no - as far as i know
just type su

then there will be a prompt for password and type it in (note that the password will not be shown in any way, just type it in and hit enter)
 
Old 07-31-2003, 12:14 PM   #6
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
Compare using "su" and "su -". You'll notice a difference.
 
Old 07-31-2003, 12:24 PM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
'The optional argument - may be used to provide an environment similiar to what the user would expect had the user logged in directly.'



-- How the hell did I miss your post, aaa? Oops.

Last edited by slakmagik; 07-31-2003 at 12:25 PM.
 
Old 07-31-2003, 12:25 PM   #8
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
when you use the "-" it tells you to use the path for the user that you are switching too...
so for instance if you have /sbin in your roots path and you are logged in as a normal user and just type su and then type your root password and then following by typing lets say "hdparm" it will say command not found...
but if you switch user to root using "su -" and type the password and then issue the command "hdparm" you will be able to use this command without having to specify the path, as you would have to type /sbin/hdparm if you only typed "su" to change users..
 
Old 07-31-2003, 12:25 PM   #9
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
su simply logs you in as root while su - Passes the environment along unchanged, as if the user actually logged in as the specified user
 
Old 07-31-2003, 12:29 PM   #10
sorrodos
Member
 
Registered: Jul 2003
Location: Salt Lake City, UT and Spokane, WA
Distribution: Mandrake 10.0, Gentoo, FreeSBIE 1.0
Posts: 345

Rep: Reputation: 30
You actually can go back from root to a normal user after using su to change to root. Just type logout or press ctrl+d.
 
Old 07-31-2003, 12:47 PM   #11
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 47
Quote:
Originally posted by TheOneAndOnlySM
there is no - as far as i know
just type su
Take a look at this thread.

Go down and look at the excerpt from the rute book.

regards...
 
Old 07-31-2003, 12:51 PM   #12
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 47
Quote:
Originally posted by sorrodos
You actually can go back from root to a normal user after using su to change to root. Just type logout or press ctrl+d.
Or, you can just type 'exit'.

Edit: Actually, on my red hat 8.0 system, I just tested that, and when I used 'logout' it said:
bash: logout: not login shell: use 'exit'


regards...



Last edited by itsjustme; 07-31-2003 at 12:53 PM.
 
Old 07-31-2003, 01:28 PM   #13
Steve Cronje
Member
 
Registered: Jan 2003
Location: Canada
Distribution: Ubuntu, Mepis, Debian
Posts: 158

Rep: Reputation: 31
To "go back" i.e. leave being root in a term, just type su <username>

eg: su barry

to get you back to where you came from

HTH
Steve
 
Old 07-31-2003, 01:35 PM   #14
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
There is also another way to run a command as root and you don't even need to login:
su -c 'command'

it will prompt for password and execute the command.

In example:
./configure
make
su
make install
exit

just takes more time typing. Instead:
./configure
make
su -c 'make install'

and it's done

Enjoy
 
Old 07-31-2003, 01:40 PM   #15
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 47
Quote:
Originally posted by Steve Cronje
To "go back" i.e. leave being root in a term, just type su <username>

eg: su barry

to get you back to where you came from
Are you sure that won't just launch an additional login for barry?

I tried that. I ran 'su -', logged in as root, and then simply ran 'su bsl1' to go back as you said, but that did create an additional login for bsl1. I was still in the root directory. I had to type exit twice to get back to my original login.

regards...
 
  


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
Question About a Command? carlosinfl Linux - General 4 10-28-2005 01:51 PM
Command question satimis Linux - Newbie 2 11-24-2004 09:59 AM
Command question satimis Linux - General 8 06-23-2004 03:43 AM
cp command question satimis Linux - Newbie 1 09-13-2003 09:31 PM
Command Question gauge73 Linux - Newbie 2 02-13-2003 09:18 PM

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

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