[FreeBSD] add new directory to PATH

 

On FreeBSD, to permanently add /home/euler/.bin to your PATH, you need to modify your shell’s configuration file. The exact file depends on the shell you are using. Assuming you are using sh/bash/zsh, here’s how to do it:


1. For sh or bash (~/.profile or ~/.bash_profile):

Edit your profile file with a text editor:

nano ~/.profile

Add the following line at the end:

export PATH="$HOME/.bin:$PATH"

Then save and exit. To apply immediately without logging out:

source ~/.profile

2. For bash only (~/.bashrc):

nano ~/.bashrc

Add:

export PATH="$HOME/.bin:$PATH"

Then apply changes:

source ~/.bashrc

Note: .bashrc is loaded for interactive non-login shells. .profile or .bash_profile is loaded for login shells.


3. For csh or tcsh:

Edit ~/.cshrc:

setenv PATH $HOME/.bin:$PATH

Then apply:

source ~/.cshrc

After this, /home/euler/.bin will be included in your PATH permanently, and executables inside it will be accessible from any shell session.

If you want, I can give a FreeBSD-specific method using /etc/rc.conf or login.conf for a system-wide setup, which is more idiomatic for FreeBSD. Do you want that?

 

posted @ 2025-11-14 12:14  profesor  阅读(11)  评论(0)    收藏  举报