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.
|
|
01-08-2008, 09:09 AM
|
#1
|
Member
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397
Rep:
|
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?
|
|
|
01-08-2008, 10:28 AM
|
#2
|
LQ Sage
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,675
Rep:
|
To get root rights with root environment: su -
To get another user rights with his/her environment: su - anotheruser
|
|
|
01-08-2008, 10:29 AM
|
#3
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
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 10:32 AM.
|
|
|
01-08-2008, 10:30 AM
|
#4
|
Member
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397
Original Poster
Rep:
|
Ah, thanks very much!
|
|
|
01-08-2008, 10:32 AM
|
#5
|
Member
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397
Original Poster
Rep:
|
Quote:
Originally Posted by PTrenholme
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.
|
|
|
All times are GMT -5. The time now is 08:48 PM.
|
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
|
|