World's most basic Unix/Linux question.

Hello all,

I've been scouring my $60 "Unix System Administration Handbook (3rd ed)," read the Linux and Debian FAQs, rooted around in the bash documentation, Googled and Google Groupd, and still can't figure this out:

How do I view and edit the default paths used on a systemwide basis to locate binaries?

For example, to use grep you just type "grep pattern file", not "/bin/grep pattern file". I want to do that with apachectl, which is in /usr/local/apache2/bin. What is the definitive method of controlling this, and the best practice for actually doing it?

I know about individual .bashrc files, but in some cases I want systemwide program aliases.

Thanks for any help!

7 Replies

I don't believe there is such an animal as a systemwide path. You can modify the /etc/skel/.bashrc file to have a certain path get to newly created users.

You could also make up a file describing a path, and have everybody's .bashrc refer to that file. That's a pretty good simulation of a systemwide path.

Rather than having aliases in your .bashrc files you could link the program into a bin directory. This is ok for the odd program, but probably not if you wanted a full directory to be processed in this way (in which case you would probably want to add the directory to the PATH variable - however this can be dangerous if not done correctly :)).

In simple terms, if a programs name can simply be typed in at the command line (such as grep rather than /bin/grep) - it is usually because it is in a ./bin directory (such as /bin, /usr/local/bin), or some directory that is in the PATH variable. – if you want the same feature for programs which are in strange directories (such as that of /usr/local/apache2/bin/apachectl), then your best bet is probably to simply create a symbolic link to this executable in your /usr/local/bin directory, for example in your case:

ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/apachectl

this will enable you to simply type 'apachectl' at the command line to execute the command.

Forgive me if this is not what you are asking - I'm very tired hehe… but it seems a simple solution to your problem :)

Thanks,

Shaun

Interesting. The reason I thought something must be setting paths systemwide is that my own rootly .bashrc file contains no special attempt to set $PATH or any aliases.

Something must be setting $PATH, right??

Thanks for the link suggestion, that seems to be working well! /usr/local/bin seems like the appropriate place. If mysql can dump a bunch of random scripts in there, so can I! ;->

Look for /etc/profile and edit the PATH variable that is set therein.

I'm surprised RJP's post wasn't the first reply…

Learn something new every day. Thanks for the tip, rjp!

/etc/profile. brilliant, thanks.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct