.bashrc File - Configure bash aliases functions commands... on Linux Unix and MacOSX
By editor, 13 June, 2016
Question
What is the .bashrc file and what does it do ?
How to add bash custom shortcuts on Linux , MacOSX and other Unix based operating systems?
The .bashrc file is a script that is executed whenever a new terminal session is started in interactive mode. It is just the shortcut to the commands allows the user to launch any command or group of commands.
The bashrc file is located in user's directory ( /home/$USER/.bashrc)
Examples:
alias name=value
alias name='command'
alias name='command arg1 arg2'
alias name='/path/to/script'
alias name='/path/to/script.pl arg1'
#Export Options
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
#Create the alias ll = ls -alh
alias ll='ls $LS_OPTIONS -al'
#Change user/group for few commands (Set group = www-data for drush, git, svn, ssh)
alias drush='sudo -u www-data drush'
alias svn='sudo -u www-data svn'
alias git='sudo -u www-data git'
alias ssh='sudo -u www-data ssh'
Add alias for all users
/home/$USER/.bashrc is an override of /etc/bash.bashrc or /etc/profile, If you want to add your custom shortcuts for all users, just add your custom alias to /etc/bash.bashrc file (Tested on debian based distributions).
Comments