You are not logged in.

#1 2013-02-03 19:51:23

Registered: 2012-11-27
Posts: 100

su problem

Hi, I recently needed to use su to run a program that requires privilege (doesn't work with sudo) and I realized that all my settings were set for my main account, so when I run su I don't have any colored windows, alias, etc... Is there a way to create alias and color settings for root account without conflict with my main account ?

Also I couldn't start gedit after typing su...why is that? I don't understand...

thank you.


#2 2013-02-03 19:56:17

From: New York, USA
Registered: 2009-10-22
Posts: 4,094

Re: su problem

If you need to run graphical apps as root, you need to use gksu, kdesu, pkexec, or similar. Morever, using 'su' along without creating a new login session is broken, for reasons like you're seeing here.


#3 2013-02-03 19:59:06

Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,805

Re: su problem

Presumably you are referring to your shell settings; create a rc file for root.

gedit is a graphical programme, you need to use gksu, or something like that.

# edit: too slow: falcon in NC!

Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438


#4 2013-02-03 21:58:19

Registered: 2009-05-06
Posts: 25,428


#5 2013-02-04 02:34:49

Registered: 2013-02-03
Posts: 12

Re: su problem

Hi trixrabbit,

basically, there's two ways of invoking su:

$ su

will spawn a non-login root shell

$ su -

will spawn a login root shell.

Check out the man page for your shell to see how login and non-login invocation scenarios differ. If you are using GNU bash, for example, you should carefully read the "INVOCATION" section of the man page. You'll see that when invoked as a login shell, bash (citing manpage) "looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in  that order, and reads and executes commands from the first one that exists and is readable." If it is not invoked as a login shell, it reads and executes commands from ~/.bashrc.

Common practice is to source ~/.bashrc from ~/.profile or ~/.bash_profile, and you can find such an example of bash config in Arch's /etc/skel/ directory. You could do something like:

# cp /etc/skel/.bash* /root

then edit /root/.bashrc and add set your custom environment, aliases, etc. for the root user there.

For GUI apps: when using "su -" under X, it will forget your DISPLAY variable, so you have to set it again manually, and probably use xhost(1) to allow X clients that you start as root to connect to your (regular user's) X server, but I guess it's better to use sudo or gksu or something. Everything else about running X apps as superuser is explained on the wiki page karol pointed to.


Board footer

Powered by FluxBB