Tag Info

Hot answers tagged

53

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 ...


38

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: # ...


30

/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 ...


30

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


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.


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


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 ...


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 ...


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 ...


8

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 ...


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

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

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

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'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 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' ...


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.


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

It probably does not pick up your path since it's running from cron. There are several ways to make it know the path the easiest I have found is just hard code the path to which. Do a: locate which Mine returns this: [user@server ~]$ locate which |grep bin /usr/bin/which Then change your script to do: if [ $(/usr/bin/which ffmpeg | grep -c "ffmpeg") ...


4

My guess is that since MAX_PATH has been well-defined for a number of years, changing it to a bigger value now would be potentially detrimental to a lot of software that relies on it. There's a lot of ways they could attempt to "fix" this (including shim-libraries, and simply deprecating its use and changing it slowly over time), but they're not extremely ...


4

By far, the easiest way to go about this is through the use of Group Policy Preferences Client Side Extensions, (GPP) which is included in Windows 7/Server 2008 and up, or as part of an update for XP and Server 2003 systems. You can use the GPP settings to either specify an entirely new set of directories in the %PATH% variable, a "Replace", or append a ...


4

It goes into the environment for the current shell (stored in the RAM); you can see this by typing export. If you quit the shell, then any changes you've made to the environment are lost. If you want changes to persist, then you should add them to the files that your shell will execute on startup (e.g. one of ~/.bash_profile, ~/.bashrc, etc.).


4

Two things I might try. Run an sfc /scannow to see if that fixes any larger issues at play. Check the registry for the Path key in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. What's the type. It should say REG_EXPAND_SZ


4

Three backslashes should do it: jed@jed-osx:~$ ls -la \`foo ls: `foo: No such file or directory jed@jed-osx:~$ scp desk:\\\`foo . `foo 100% 0 0.0KB/s 00:00 jed@jed-osx:~$ ls -la \`foo -rw-r--r-- 1 jed staff 0 Jul 1 09:45 `foo jed@jed-osx:~$ rm \`foo The first backslash escapes the backtick so it ...


4

Have you tried altering the default bashrc? This should be located in either /etc/bashrc or /etc/bash.bashrc (I think it's the second one in Ubuntu). Then in your home directory, make sure your .bash_profile includes: if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi This will make sure that the variables defined system-wide are read into the ...


4

Unfortunately no. That must be a full physical path. As long as you don't plan to change your site path often, a static path shouldn't be a problem. If you change your path often to different site instances you may want to consider using appcmd to script the change so that it gets all subfolders.



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