LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 01-08-2008, 08:09 AM   #1
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Rep: Reputation: 62
Lost path when su'ing to root from user GUI terminal


Usually, I log in to my Linux box with a user account in GNOME. However, when I su to root from a terminal window, I don't get the path to many of the standard command directories like /sbin and such. My /etc/profile seems to be saying that unless you actually initially login as root (which I assume is what the "EUID = 0" bit means), you won't get certain directories in your path: -

# Path manipulation
if [ "EUID" = "0"]; then
pathmunge /sbin
pathmunge /usr/bin
pathmunge /usr/local/sbin
fi

How can I execute stuff from a user GUI terminal window when su'ing to root, not having to fully login as root to start with? And should I be doing this in the first place?
 
Old 01-08-2008, 09:28 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
To get root rights with root environment: su -
To get another user rights with his/her environment: su - anotheruser
 
Old 01-08-2008, 09:29 AM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Have you consider looking at man su to see the command line parameters? Or even a
Code:
$ su --help
Usage: su [OPTION]... [-] [USER [ARG]...]
Change the effective user id and group id to that of USER.

  -, -l, --login               make the shell a login shell
  -c, --command=COMMAND        pass a single COMMAND to the shell with -c
  --session-command=COMMAND    pass a single COMMAND to the shell with -c
                               and do not create a new session
  -f, --fast                   pass -f to the shell (for csh or tcsh)
  -m, --preserve-environment   do not reset environment variables
  -p                           same as -m
  -s, --shell=SHELL            run SHELL if /etc/shells allows it
      --help     display this help and exit
      --version  output version information and exit

A mere - implies -l.   If USER not given, assume root.

Report bugs to <bug-coreutils@gnu.org>.
Of course the brief --help output above assumes that you understand that a "login shell" means that the shell is started as though it was a de novo login.

Bottom line: Try su - instead of a simple su.

Last edited by PTrenholme; 01-08-2008 at 09:32 AM.
 
Old 01-08-2008, 09:30 AM   #4
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Original Poster
Rep: Reputation: 62
Ah, thanks very much!
 
Old 01-08-2008, 09:32 AM   #5
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Original Poster
Rep: Reputation: 62
Quote:
Originally Posted by PTrenholme View Post
Have you consider looking at man su to see the command line parameters? Or even a[code]$ su --help
I would have if I'd known that the problem was with my usage of the su command and not something else altogether. As far as I was concerned, it could have been anything. Thanks, though - sorted now.
 
  


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
Just lost GUI root access Urza9814 Mandriva 4 06-05-2007 06:43 AM
unable to open apps when 'su'ing to root from user account ganja_guru Linux - Software 3 06-03-2005 10:51 AM
Lost my KDE GUI in root barkingpenguin Red Hat 2 01-21-2004 07:29 PM
Lost Root User Michael2003 Mandriva 4 12-13-2003 08:20 AM
Launch program as root, without su'ing glock19 Linux - General 15 01-31-2002 05:16 PM

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

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