Home Blog Code
Sometimes programs that are distributed with programming language specific package managers (like pip, npm etc.) instruct users to install the program with sudo or as root. You can also install these programs without root, but that requires a little extra configuration.
With root permissions the package manager can place the program in
/usr/local/bin, by default this directory is part of your shell’s PATH
variable. If you run
echo $PATH at the command-line, you can see the full
PATH, for example:
This is a colon-separated list of directories where your shell looks for
commands when you enter a command. When you enter
ls in your shell, it looks
for the program called
ls in the directories listed in your PATH, finds it at
/bin/ls and then runs that program. When you install a program without root,
the executable is placed in a folder in your home directory. You need to add
this folder to your PATH in order for your shell to find the program.
In what follows we’ll add directories to your PATH in the
configuration file. Create this file if it doesn’t exist yet. Different package
managers use different locations to place executables, so each needs their own
configuration. Follow the instructions for the package manager(s) you’d like to
use, then skip to the activation section.
Cargo is Rust’s package manager. It places binaries in
the following to
Gem is used in the Ruby world. You need to pass the
to install a gem in your home directory, e.g.
gem install --user-install fpm.
It then places programs in
~/.gem/ruby/2.3.0/bin where the
depends on which version of Ruby you have installed. First install a gem, and
look at which version you have by running
ls ~/.gem/ruby/, then add to your
Where you replace
2.3.0 with your version.
Pip is the package manager used in the Python ecosystem. Pip places programs
~/.local/bin. Add this line to
For the changes to the PATH variable to take effect, the
~/.profile file needs
to be sourced. Sourcing a file means that your shell runs the commands in the
file in the current shell context, so variables that change or are defined stay
after the shell has finished sourcing the file. You source a file with the
~/.profile is sourced at the startup of your desktop environment. This
ensures that all applications have the updated PATH, including your terminal and
text editor. The method to do this differs per Linux distribution, follow the
instructions for your distro below. If that doesn’t work, you
can update your PATH for your shell only as a last resort.
The changes to your PATH should take effect the next time you login after this final configuration.
Debian users need to create a
~/.xsessionrc file, run:
echo '. ~/.profile' >> ~/.xsessionrc
You are done! Ubuntu automatically sources
~/.profile when you login.
For other distributions create a
echo '. ~/.profile' >> ~/.xinitrc
If this doesn’t work after a re-login, try a
echo '. ~/.profile' >> ~/.xprofile
Your shell has a configuration file it executes on startup. For Bash it’s
~/.bashrc. Place this line in there:
For Zsh you put that line in