LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-13-2010, 03:14 AM   #1
ReeRD
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Rep: Reputation: 0
"su -" vs direct root login


What are the differences between "su -" in a GUI terminal and directly logging in as root in a text mode terminal (tty1-tty6)? Any environment, path or other functionality differences?
 
Old 05-13-2010, 04:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the - makes it a full login shell, so there should be no difference at all in your abilites.
 
Old 05-13-2010, 07:07 AM   #3
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
As an aside to your question - its not good practice to login as root directly.

For security/safety purposes always login as a "normal" user with sudoers priveleges and use a combination of sudo and su - to execute super user commands.

Many will say its a schlep to do the above but believe me you will not be happy once you do something by mistake that destroys your system
 
1 members found this post helpful.
Old 05-13-2010, 10:36 AM   #4
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
Quote:
Originally Posted by alli_yas View Post

Many will say its a schlep to do the above but believe me you will not be happy once you do something by mistake that destroys your system
if i run a command that destroys the system, whats the diff if its ran as root directly or via su - ???
 
Old 05-13-2010, 05:34 PM   #5
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
No difference, it's just safer to su - . If done properly, you execute whatever commands you have permissions to as a normal user, and when you need to, su - , execute the root commands, then exit. If you log in directly as root, the temptation is to run all commands as root, leaving yourself open to... well if you don't know now, you will remember it afterwards.
 
Old 05-13-2010, 07:40 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
the main problem lies in Xorg
running X and a gui( gnome,kde,xfce)as root opens up holes in xorg
-- Google it for a much longer and heated "discussion "

now one will be loged in as root for MUCH less time in the terminal than it one was to log in as root using a gui .Also gnome ( also not secure as root) will not be running .


NOW

there are not many ways for a auto script ( built for MS Windows) to do much
nor are there too many linux mal-ware programs . so the odds are ( for know ) are better at keeping a clean computer running linux -- even as root , than running Windows

but for the paranoid there is also a problem with sudo
-- this is not the place for that flaming war -- google it for more discussion .


su
root with NORMAL users $PATH ( stays in the folder you run this from)
su -
root with root $PATH ( auto goes to /root home folder)

most of the time there is not much of a difference
but for somethings there is a diff.
 
Old 05-14-2010, 01:30 PM   #7
ReeRD
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by John VV View Post
but for somethings there is a diff.
What are these things?

For everyone else: thanks for replying, but you are assuming too much about me - I am not a complete noob and I do not run my system as root constantly. The question is ONLY about the root's environment when using different login methods.
 
Old 05-14-2010, 03:17 PM   #8
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
Quote:
What are these things?
John VV answered this question already, albeit indirectly. The answer in implied here:
Quote:
su
root with NORMAL users $PATH ( stays in the folder you run this from)
su -
root with root $PATH ( auto goes to /root home folder)
The commands that will be different are the commands that are not found in both paths. This could mean no difference at all if, say, the user belongs to the group wheel (in which case user $PATH should be the same as root $PATH).

NB: With 3 posts we will assume you are a noob, because the potential consequences of assuming you know these things when you, in fact don't, are considerable. Be assured that no offense was meant.
 
Old 05-15-2010, 09:23 PM   #9
Cityscape
Member
 
Registered: Jan 2010
Location: British Columbia
Distribution: Debian 8
Posts: 140

Rep: Reputation: 15
If you are using Ubuntu you will not be able to log in as root user anyway. Ubuntu only uses su/sudo commands from terminal.

I don't know whether your using Ubuntu or not but I just thought I'd point it out. =)
 
Old 05-16-2010, 02:35 AM   #10
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
Originally Posted by Cityscape View Post
If you are using Ubuntu you will not be able to log in as root user anyway. Ubuntu only uses su/sudo commands from terminal.

I don't know whether your using Ubuntu or not but I just thought I'd point it out. =)
Sure you can, just
Code:
sudo passwd root
and it's set.
 
Old 05-17-2010, 09:23 AM   #11
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
It isn't just the $PATH variable that is changed to root's with 'su -'. ALL environment variables are set to root's. To see the differences, run the following:

Code:
% su
Password:
# printenv

<snip>

# exit
% su -
Password:
# printenv

<snip>

# exit
HTH

Forrest
 
Old 05-17-2010, 03:17 PM   #12
Cityscape
Member
 
Registered: Jan 2010
Location: British Columbia
Distribution: Debian 8
Posts: 140

Rep: Reputation: 15
Quote:
Originally Posted by b0uncer View Post
Sure you can, just
Code:
sudo passwd root
and it's set.
I meant log in as root user from the log in screen. By default you can't do that on Ubuntu.
 
Old 05-17-2010, 03:38 PM   #13
Mr-Bisquit
Member
 
Registered: Feb 2009
Distribution: FreeBSD, OpenBSD, NetBSD, Debian, Fedora
Posts: 770
Blog Entries: 52

Rep: Reputation: 68
The fact that by default Linux allows any user to be able to use the su command is in itself insecure. You only need to couple this with the blatant use of sudo in Ubuntu to understand the risk you take.

I'm taking a different approach here. I'd say, "If you want more security, then go for FreeBSD." Why? Because from the initial setup, you decide which account has access to wheel and to sudo- that is if you install it later. An unprivileged account that is compromised will not bring down the system. The same scenario on say... Ubuntu or Fedora or Mint, could result in a rooting.
 
Old 05-18-2010, 12:57 AM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by John VV View Post
the main problem lies in Xorg
running X and a gui( gnome,kde,xfce)as root opens up holes in xorg
-- Google it for a much longer and heated "discussion"
A netsearch for root and X and GUI (with and without xorg) found questions and HOWTOs etc. but nothing pertinent to security holes in the first page or so. Any other keywords to find the discussion?
 
Old 05-18-2010, 09:33 AM   #15
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
No, it's not insecure, it merely puts a certain piece of the responsibility to the administrator. su requires root knowledge, and there are plenty of uglier ways to achieve a similar thing with the login command itself and such, which arne't removed. su just makes it a more formal escalation of rights, and doesn't change the model itself.

And with a pedant hat on, Linux does NOT do this by default, only distributions. Linux does not contain su. It's a kernel, and in this specific context that distinction does matter more than usual.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
restrict direct login and only su jhonnyrip Red Hat 4 12-07-2009 10:55 PM
would like to disable direct root login using ssh/sftp rholme Linux - Newbie 4 05-17-2008 07:12 PM
diabling direct login venki Linux - Security 2 11-08-2006 06:05 PM
booting direct into Xwindows without login longnam Slackware 33 04-10-2005 08:01 AM
Direct login into GUI ninadb Slackware 4 04-27-2004 10:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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