Questions tagged [path]

PATH (all upper case) is the name of an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are searched for.

The PATH(all upper case) is an environment variable in the UNIX and Linux(and many other) operating systems. It contains colon delimited list of directories, where the shell searches through when a command is executed. The executables are stored in different directories in the UNIX and Linux operating systems.

Examples

Simple way to show the $PATH variable is:

echo "$PATH"
printf "%s\n" "$PATH"

A typical PATH looks like:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Further reading

945 questions
1274
votes
12 answers

How to correctly add a path to PATH?

I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this. This way: export PATH=~/opt/bin:$PATH or this? export…
Paolo
  • 16,105
  • 10
  • 29
  • 40
232
votes
7 answers

What is the 'working directory' when cron executes a job?

I have a script that works when I run it from the command line, but when I schedule it with cron I get errors that it cannot find files or commands. My question is twofold: When I schedule a cron job using crontab -e, does it use my user ID as the…
ProfessionalAmateur
  • 2,985
  • 3
  • 16
  • 17
186
votes
9 answers

How to make `sudo` preserve $PATH?

I have a program that is installed in a custom directory under /opt. To make it easier to run it, I edited my bashrc to add said directory to my path: export PATH=$PATH:/opt/godi/bin:/opt/godi/sbin This works fine if I want to run the program…
hugomg
  • 5,243
  • 4
  • 31
  • 51
175
votes
4 answers

Where do executables look for shared objects at runtime?

I understand how to define include shared objects at linking/compile time. However, I still wonder how do executables look for the shared object (*.so libraries) at execution time. For instance, my app a.out calls functions defined in the lib.so…
rahmu
  • 18,727
  • 27
  • 81
  • 124
174
votes
6 answers

How do I set a user environment variable? (permanently, not session)

This is irritating me. I seen several suggestions (all using different files and syntax) and none of them worked. How do I set an environment variable for a specific user? I am on debian squeeze. What is the exact syntax I should put in the file to…
user4069
92
votes
2 answers

Which distributions have $HOME/.local/bin in $PATH?

For example, in Ubuntu, there is always a .local directory in the home directory and .profile includes this line: PATH="$HOME/bin:$HOME/.local/bin:$PATH" $HOME/.local/bin does not exist by default, but if it is created it's already in $PATH and…
Stoffe
  • 1,023
  • 1
  • 7
  • 6
73
votes
6 answers

Duplicate entries in $PATH a problem?

I source bashrc's of few of my friends. So I end up having duplicate entries in my $PATH variable. I am not sure if that is the problem for commands taking long to start. How does $PATH internally work in bash? Does having more PATHS slow my start…
balki
  • 4,157
  • 5
  • 27
  • 43
69
votes
5 answers

Show PATH in a human-readable way

I want to show my PATH environment variable in a more human-readable way. $ echo…
Arturo Herrero
  • 2,246
  • 2
  • 19
  • 17
62
votes
16 answers

Removing a directory from PATH

I'm trying to compile wxWidgets using MingW, and I have cygwin in my path, which seems to conflict. So I would like to remove /d/Programme/cygwin/bin from the PATH variable and I wonder if there is some elegant way to do this. The naive approach…
Devolus
  • 741
  • 1
  • 6
  • 7
61
votes
19 answers

Remove duplicate $PATH entries with awk command

I am trying to write a bash shell function that will allow me to remove duplicate copies of directories from my PATH environment variable. I was told that it is possible to achieve this with a one line command using the awk command, but I cannot…
Johnny Williem
  • 743
  • 3
  • 9
  • 6
55
votes
8 answers

Why are PATH variables different when running via sudo and su?

On my fedora VM, when running with my user account I have /usr/local/bin in my path: [justin@justin-fedora12 ~]$ env | grep PATH …
Justin Ethier
  • 16,416
  • 9
  • 41
  • 55
54
votes
7 answers

List all binaries from $PATH

Is there a one-liner that will list all executables from $PATH in Bash?
jcubic
  • 9,030
  • 15
  • 52
  • 73
53
votes
3 answers

Is it safe to add . to my PATH? How come?

I've seen people mention in other answers that it's a bad idea to include the current working directory ('.') in your $PATH environment variable, but haven't been able to find a question specifically addressing the issue. So, why shouldn't I add .…
Jander
  • 15,682
  • 5
  • 47
  • 66
53
votes
7 answers

How can I set all subdirectories of a directory into $PATH?

It looks like when adding a directory into $PATH, its subdirectories are not added recursively. So can I do that? Or is there a reason why this is not supported?
Tim
  • 92,534
  • 165
  • 512
  • 896
50
votes
5 answers

how to set crontab PATH variable

I had a problem running a script from crontab. After some research I understood the problem was because PATH parameter doesn't include /sbin. I looked what it does include in /etc/crontab: PATH=/sbin:/bin:/usr/sbin:/usr/bin As a test - simple cron…
csny
  • 1,385
  • 4
  • 13
  • 26
1
2 3
62 63