An annoyance with $PATH on Red Hat

February 21, 2006

In the spirit of equal opportunity annoyance:

One of the things that never fails to irritate me with Red Hat is that when you do '/bin/su root' on a stock system, you get a shell whose $PATH doesn't include /sbin or /usr/sbin.

This trips me up all the time, and every time it's an nngh moment. And it's not as if Red Hat doesn't already have a ~root/.bashrc that does quite a lot, so they could perfectly well also have it fix up $PATH to have everything it would if you just logged in as root.

(Yes, yes, 'use sudo'. Frankly, no; if I'm starting up a general root shell, I'm going to be honest about it. And I don't like 'su - root', because that has other effects.)

On my own systems, I've long since customized root's .bashrc so that when I su, it switches to my preferred shell; other bits then insure that I get a sensible root environment (including sanitizing $PATH). This may be evil, but it is convenient.

(There's an argument that Red Hat's default root .bashrc is already evil since it aliases cp, mv, and rm to their -i forms, but I'm not going to go there. Especially since I do it myself.)

Sidebar: a pop usage conundrum

In the above, is the right usage 'a nngh moment' or 'an nngh moment'?


Comments on this page:

From 128.6.229.146 at 2006-05-18 14:35:31:

Use 'su -'. su defaults to root, - makes it a login shell.

By cks at 2006-05-18 15:16:43:

I dislike 'su -', because it scrubs my environment and resets the current directory. (Plus, it runs root's login stuff; that is usually harmless, but I am reluctant to count on it always being so.)

From 128.6.229.146 at 2006-05-23 13:41:05:

`su -p` will preserve your environment.

By cks at 2006-05-23 15:16:44:

I took a look at 'su -p', and it does really whacky and dangerous things, like ignoring the target account's configured shell in favour of starting $SHELL (even if that shell isn't in /etc/shells).

Plus, I don't think of it as solving the problem. If anything, it makes it worse; 'su -pl' resets the current directory, scrubs most of the environment, and still doesn't add /usr/sbin and /sbin to $PATH on a stock system. (Once you start making a system non-stock, you might as well just change /root/.bashrc to do the right thing.)

Written on 21 February 2006.
« More on regular expression performance
Peter Drucker on the Five Deadly Business Sins »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Tue Feb 21 03:13:09 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.