Set the PATH in a Session on UNIX-like Operating Systems

export PATH=$PATH:/some/other/directory

This appends /some/other/directory to the executable search path for the current shell and all its children. The change vanishes when the shell exits — nothing is written to .bashrc, .profile, or /etc/environment.

Variants

# Prepend instead of append (searched first)
export PATH=/some/other/directory:$PATH
 
# Make it persistent for future Bash sessions
echo 'export PATH=$PATH:/some/other/directory' >> ~/.bashrc
 
# POSIX-compliant (works in sh, dash, ksh)
PATH=$PATH:/some/other/directory; export PATH

Security relevance

  • Utility: On a foothold, adding a tools directory to PATH lets you call dropped binaries by bare name without typing full paths.
  • Attack surface: UNIX resolves unqualified commands by searching PATH in order. A writable directory early in PATH is a classic binary-planting vector — the UNIX cousin of windows-dll-search-order hijacking. If /tmp or a user-writable directory appears before /usr/bin in a service account’s PATH, that’s a privesc finding.
  • Persistence vs. stealth: A session-only export PATH leaves no trace in dotfiles; appending to .bashrc persists but is easily discovered.

Sources