Setting Alias or PATH variable
Basics of altering the `~/.bashrc` or `~/.bash_profile` file
Reason
Often times you may need to run a command from a downloaded piece of software, but would like to avoid the inconvience of including the entire path as part of the command. This can be avoided by updating you ~/.bashrc
or ~/.bash_profile
with either an alias for a particular pathway/file or by amending you $PATH variable to include the specific folder in which your command is located. The later may be particularly useful if the software contains multiple commands you need to call.
Disclaimer
- This tutorial is intended for those that are using bash shell, so if you are working with another shell (i.e. zsl) these specific files we are modifying will be different.
Creating an Alias
Open your bashrc
(or bash_profile
) file
nano ./bash_profile
Add an alias
alias new_command="/absolute/path/to/actual/command.sh"
Source your bash file (or restart terminal) to make the changes active
source(~/.bash_profile)
Updating your $PATH
variable
Open your bashrc
(or bash_profile
) file
nano ./bash_profile
Add to existing items of $PATH
PATH=$PATH:/path/to/folderWith/Commands
- Generally good idea to add this line after where you see other
$PATH
variable entries, but before the line that exports the entries (i.e.export PATH
)
Source your bash file (or restart terminal) to make the changes active
source(~/.bash_profile)
Example of a bash_profile
file
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=/shared_lab/scripts:/shared_lab/scripts/bin:$PATH:$HOME/.local/bin
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/RNA/scripts/salmon_scripts/
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/RNA/scripts/software/RSEM/RSEM-1.3.1
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/RNA/scripts/software/gffread
PATH=$PATH:$HOME/downey-wall.a_remote/scripts
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/RNA/scripts/software/gffcompare
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/RNA/scripts/STAR_scripts
PATH=$PATH:/home/downey-wall.a/software/hisat2-2.1.0
PATH=$PATH:/home/downey-wall.a/software/Bismark-0.22.1
PATH=$PATH:/home/downey-wall.a/software/TrimGalore-0.6.0
PATH=$PATH:/shared_lab/20180226_RNAseq_2017OAExp/DNAm/scripts
PATH=$PATH:/usr/local/programs/R/3.6.0/bin
PATH=$PATH:/home/downey-wall.a/software/bowtie2-2.3.5.1-linux-x86_64
PATH=$PATH:/home/downey-wall.a/downey-wall.a_remote/software
export PATH
# Aliases
alias python='/home/downey-wall.a/python_3.5.2/bin/python3.5'