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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
07-31-2003, 11:50 AM
|
#1
|
Member
Registered: Jul 2003
Location: Silver Spring, MD
Distribution: Xubuntu
Posts: 167
Rep:
|
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?
|
|
|
07-31-2003, 11:52 AM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194
Rep:
|
Yeah, but don't forget the - (su -).
|
|
|
07-31-2003, 12:06 PM
|
#3
|
Member
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987
Rep:
|
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
|
|
|
07-31-2003, 12:08 PM
|
#4
|
Member
Registered: Jul 2003
Location: Silver Spring, MD
Distribution: Xubuntu
Posts: 167
Original Poster
Rep:
|
What's the "-" in "su -"?
|
|
|
07-31-2003, 12:10 PM
|
#5
|
Member
Registered: Jul 2003
Location: Dallas, TX
Distribution: Ubuntu 10.04 LTS
Posts: 987
Rep:
|
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)
|
|
|
07-31-2003, 12:14 PM
|
#6
|
LQ Guru
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194
Rep:
|
Compare using "su" and "su -". You'll notice a difference.
|
|
|
07-31-2003, 12:24 PM
|
#7
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep:
|
'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.
|
|
|
07-31-2003, 12:25 PM
|
#8
|
Senior Member
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185
Rep:
|
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..
|
|
|
07-31-2003, 12:25 PM
|
#9
|
Senior Member
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044
Rep:
|
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
|
|
|
07-31-2003, 12:29 PM
|
#10
|
Member
Registered: Jul 2003
Location: Salt Lake City, UT and Spokane, WA
Distribution: Mandrake 10.0, Gentoo, FreeSBIE 1.0
Posts: 345
Rep:
|
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.
|
|
|
07-31-2003, 12:47 PM
|
#11
|
Senior Member
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571
Rep:
|
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...
|
|
|
07-31-2003, 12:51 PM
|
#12
|
Senior Member
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571
Rep:
|
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.
|
|
|
07-31-2003, 01:28 PM
|
#13
|
Member
Registered: Jan 2003
Location: Canada
Distribution: Ubuntu, Mepis, Debian
Posts: 158
Rep:
|
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
|
|
|
07-31-2003, 01:35 PM
|
#14
|
Member
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209
Rep:
|
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
|
|
|
07-31-2003, 01:40 PM
|
#15
|
Senior Member
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571
Rep:
|
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...
|
|
|
All times are GMT -5. The time now is 07:08 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|