LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-17-2010, 08:03 AM   #1
NoahJK
LQ Newbie
 
Registered: Mar 2010
Posts: 26

Rep: Reputation: 0
why to use su instead of working as root


Title says everything. I need a couple of reasons for it.

thanks
 
Old 04-17-2010, 08:13 AM   #2
LouRobytes
Member
 
Registered: Mar 2010
Location: Nova Scotia, Canada
Distribution: Ubuntu & Fedora
Posts: 189

Rep: Reputation: 44
Root power is absolute. Mistakes are inevitable. Root mistakes can be disastrous. Regular user mistakes are recoverable.

Lou

EDIT: Even admins are cautious about logging in as root.

Last edited by LouRobytes; 04-17-2010 at 08:19 AM.
 
Old 04-17-2010, 08:15 AM   #3
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 97
http://serverfault.com/questions/418...ing-in-as-root
 
Old 04-17-2010, 08:32 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I'm confused. In a terminal, if you enter "su", you will take on root powers. If this is what you are referring to, then it is the same as "working as root".
 
Old 04-17-2010, 10:12 AM   #5
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
What do you exactly mean by working as root ?
Login as root and use the GUI .
Personally I do not like that because the GUI hide a lot of system message .
Beside that becoming su has a time limit that you are root .
I thought it is about 5 min.
 
Old 04-17-2010, 10:27 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by ronlau9 View Post
Beside that becoming su has a time limit that you are root .
I thought it is about 5 min.
Never seen that before!!!???
 
Old 04-17-2010, 10:30 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by pixellany View Post
Never seen that before!!!???
I haven't either.

Maybe it's in some setting?
 
Old 04-17-2010, 12:23 PM   #8
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Sudo times out, depending on the settings. I thought su was forever, which is why you need to exit from it.
 
Old 04-17-2010, 01:18 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by NoahJK View Post
Title says everything. I need a couple of reasons for it.

thanks
Homework question, is it??

As others have said, root or even doing an SU to root (same thing), is bad on LOTS of levels. If you're in the / directory, and type in "rm -fR *", as root, EVERYTHING is deleted. If you do it as your own user, it'll not delete much, except YOUR files. You can still have a running system, and recover your data (maybe). There are very few times when you need to su or log in as root. SUDO is better, and as far as I know, to be used sparingly. It doesn't have a time limit (unless you set one), and lets you do things that root can do.
 
Old 04-17-2010, 05:09 PM   #10
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by XavierP View Post
Sudo times out, depending on the settings. I thought su was forever, which is why you need to exit from it.
Well, there's the TMOUT environment variable, but that's a feature of the shell rather than su itself.


Anyway, as for the why 'su' rather than work as root. I've always liked this quote:
Quote:
"If you picture using the root account as wearing a special magic hat that gives you lots of power, so that you can, by waving your hand, destroy entire cities, it is a good idea to be a bit careful about what you do with your hands. Since it is easy to move your hand in a destructive way by accident, it is not a good idea to wear the magic hat when it is not needed, despite the wonderful feeling."
 
Old 04-17-2010, 10:50 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
it is more of the fact that Xorg is NOT secure .
now a bit of "bad" code can not do much it it is ran as a NORMAL everyday user
BUT
That same bit of code being ran as ROOT in a root session of Gnome ...
very bad .

There are times when it is nice to be able to login ( or what i do - start a new root session of nautilus from the terminal IN a normal user session ) as root - sometimes ONLY

But this is a very special case . for a normal program install
this works just fine as a normal user
Code:
./configure --prefix=/usr 
make
su
( root password)
make install 
------------
yum search ????
su -
-- root pass--
yum install ???
----------------
packman -Ss ????
su -
packman -S ????
 
Old 04-19-2010, 01:07 PM   #12
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
sudo users can be limited as to the specific commands they can execute and logs can be easily kept of activity. Of course if you just open up sudo to a user, they may as well log in as root - sudo "rm -rf /*" will have the same effects as running rm -rf * as root!
 
Old 04-19-2010, 01:17 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by John VV View Post
Code:
packman -Ss ????
su -
packman -S ????
It's pacman, not packman
 
Old 04-19-2010, 06:44 PM   #14
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
a typo , what can i say.
 
Old 04-19-2010, 09:22 PM   #15
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
GazL, I like your magic hat quote. On the other hand, I violate that. I typically have a couple dozen open terminal sessions on a variety of servers, and they are typically in root sessions. I'm the principle sysadmin. On the other hand, I'm paranoidly careful about what I type. In certain cases, I'll even issue a prototype of a command listing output rather than executing the rm or whatever. Then, when I'm confident the find or selection is doing what I expected, I'll call back that command line and edit the listing to the rm or whatever. I backup critical files before editing them. I also have a log book for each of the servers and document everything I do. I don't bother if I'm just looking for something or checking logs, but if I'm changing or installing something I certainly document it.

However, on the Ubuntu server and on my Mac, I use sudo. It's easier to play the game as intended on those systems. Sudo has the advantage that it logs.

Also, we typically don't have graphical consoles on the Unix servers. On some of the older ones that do have graphical consoles, the rule is to never log in as root on the graphical console. Log in as yourself, and then su in a terminal window. Exit the su when done.

We typically don't give root access to anyone. We have 2 general sysadmins (my boss is the other), and we control access for others with sudo.
 
  


Reply



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
vsftpd not working for root davidlu766 Linux - Server 2 04-11-2010 01:05 PM
root=UUID or root=LABEL not working actmnophn Linux - Newbie 4 02-23-2009 06:37 PM
SU as root is not working asabaa Linux - General 4 10-20-2007 08:20 AM
Working under root hyphae Slackware 6 01-16-2007 09:02 PM
root not working??? yesterdays Linux - Security 14 02-11-2005 10:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:02 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
Open Source Consulting | Domain Registration