Tag Info

Hot answers tagged

57

palmer's GUI info is correct, but there is a more maintainable way to modify the path seen by the shell. Like mediaslave said you can edit /etc/paths, but even better you can drop a text file in /etc/paths.d/ that has a path in it and all shells will construct the path correctly. For example, on my system: $ cat /etc/paths /usr/bin /bin /usr/sbin /sbin ...


42

It's not a good idea to edit /etc/profile for things like this, because you'll lose all your changes whenever CentOS publishes an update for this file. This is exactly what /etc/profile.d is for: # echo 'pathmunge /usr/lib/ruby-enterprise/bin' > /etc/profile.d/ree.sh # chmod +x /etc/profile.d/ree.sh Log back in and enjoy your (safely) updated PATH: # ...


33

/etc/launchd.conf The launchd.conf is the only complete solution that will work for both command line and GUI applications on OS X 10.8, one that will work with GUI and console applications, for all users. sudo touch /etc/launchd.conf sudo nano /etc/launchd.conf Add setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin In the example above I added ...


32

%~p0 Will return the path only. %~dp0 Will return the drive+path. More info on the subject can be found on Microsofts site


24

Use the -R or --relative option to preserve the full path.


24

The command cd - will allow you to quickly return to the last directory. You may also be interested in the pushd and popd commands which allow even more control over your directory navigation.


19

It's a bad idea to put the current directory into your path. Move your scripts that you want to frequently run into ~/bin and then add ~/bin to your path. To do this, add: export PATH=$PATH:~/bin to ~/.bash_profile.


18

Try using the command su -. The - means the new shell will get a environment of the user you have changed to. If you don't use it most of your environment will remain the same. The man page for su says: The optional argument - may be used to provide an environment similar to what the user would expect had the user logged in directly.


13

you can edit /etc/ld.so.conf and /usr/local/lib or create /etc/ld.so.conf/usrlocal.conf and put only the line /usr/local/lib Then run ldconfig -v as root, and you're done.


12

which is telling the truth. Your shell is lying to you. git is hashed (/usr/bin/git) means that your shell has cached this location of "git" and is using the cached path rather than searching $PATH again. Use hash -r to clear the cache and make the shell search $PATH for the new git at /usr/local/bin/git


11

One more thing - once you install xCode 4.3 from the OS X App Store, launch xCode, then go to Preferences -> Downloads and install "Command Line Tools". Restart Terminal and you will be able to use Make.


10

SSH with a single, simple command argument will not start a shell, which means .bashrc does not get executed. SSH with a compound command argument such as your second example should start a shell, but it will be a non-interactive one, so that won't run .bashrc by default. See Bash Startup Files in the Bash manual for more information. However, calling ...


10

Is explorer simply not starting? have you tried typing explorer.exe in the command prompt window? I guess this isn't the case you wouldn't normally get a command prompt when logging in. It sounds like somehow the shell has been removed, effectively giving you a server core install, in which case try issuing the following from the command prompt. This should ...


9

By far, the easiest way to go about this is through the use of the setx command, which is included in Windows 7/Server 2008 and up, or as part of the Windows Server 2003 Resource Kit for XP and Server 2003 systems. You can use the setx command to either specify an entirely new set of directories in the %PATH% variable, or append a value, using a little ...


9

Have you upgraded the Mac OS since installing XCode? System updates, major ones anyway like 10.5 to 10.6, may remove those programs from /usr/bin. Download the latest Xcode and reinstall. It should put them back.


9

After following fmonk's advice I checked out /etc/bashrc, where I noticed it said that "Environment stuff goes in /etc/profile." I proceeded to look in /etc/profile, I saw this: pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi ...


8

According to Microsoft: The traditional Windows API limits path names to 260 characters, even for applications developed for the latest version. Applications using the Unicode-aware API can use a form of path that allows up to 32767 characters. The file name has to be prefixed with \\?\, and must be an absolute path, e.g., \\?\c:\dir\file or ...


7

Use the pathmunge() function available in most distro's /etc/profile: pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } edit: For zsh users, typeset -U <variable_name> will deduplicate path entries.


7

Bash maintains a cache of locations of executables in $PATH. You had hg in /usr/bin at some point, and ran it from that shell. Now you've removed /usr/bin/hg. You need to tell your running shell to forget this location: hash hg A new shell wouldn't have this problem, since the cache isn't shared between shell instances.


7

You can use 3 backslashes as mentioned by Jed Daniels or you can wrap it in single quotes (') and use a single backslash. Example of both are below. $ touch dir/'`rik' $ ls -l dir total 1865376 -rw-r--r-- 1 rik staff 0 Jul 1 09:51 `rik $ scp localhost:dir/\\\`rik ./ `rik 100% 0 0.0KB/s 00:00 $ scp localhost:dir/'\`rik' ...


7

At the top of your crontab file put SHELL and PATH declaration like: SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin See this SE post for more details. The default SHELL and PATH for cron are SHELL=/bin/sh, PATH=/usr/bin:/bin (From man 5 crontab man page).


6

PATH=$PATH:. ... is easy for taking care of the ./ part... which you focused on, but paying more attention isn't really the meat of it. Besides that, many of us frown on it for security reasons. See Adding current directory to path for more discussion that aspect. In case I've mis-interpreted (I have), I'll expand on what @DavidShwartz is saying. Your ...


6

For development work: If your shell is bash (echo $SHELL -> /bin/bash) you may want to add a JAVA_HOME entry in /home/<user>/.bashrc. However, note that if you only work with one Java version, you should install the package and no explicit JAVA_HOME setting should be necessary for most scenarios. Also, it is sometimes convenient to do something like ...


6

You can make a symbolic link yourself: which make (to be sure it's there) cd /usr/bin ln -s /Developer/usr/bin/make make


6

You can add . to the path, but as MikeyB says, it is a bad idea. The reason it is a dangerous thing to do is that if a malicious bit of software with the same name as an executable you are running exists in the current directory, that will be run instead.


6

You're going to have to set it on a shell by shell basis; bash and csh-like shells do not share the same configuration files and syntax for adjusting the PATH. Trying to do this in launchctl will not work because environment variables are set on login; they do not exist system wide in Unix outside of a shell session. So you're going to want to add ...


5

You'll have to recycle the IIS process to get it to update, I'm afraid. Global environment is inherited when the process starts and for most apps the only way to get it to update is to restart the process. It's a pain, but at least it is something you can plan for.


5

Virtual Server and Shared Hosting tend to be different things although it doesn't affect my answer. A single server (physical or virtual, it doesn't matter) can host websites for many different domains. Each domain name will resolve to the same IP address, that of the server in question. So www.example.com resolves to 198.51.100.21, but so does ...


5

/etc/paths does not exist on my Ubuntu system, so it may not be a GNU standard way of setting your PATH. Another thing to consider is that changing /etc/paths will change the PATH of every user on the system. By putting it into your .bash_profile, you limit the change to one user, and only when that user uses bash as his shell.



Only top voted, non community-wiki answers of a minimum length are eligible