use-case
let say there is one long command you often use, may be ssh to server with certificate ip and user
so either you go from history to connect or you type every time.
for history, that may be clean some time or you working on multiple terminal window at once and close them.
so what is the good alternative?
use alias , type once, and use every time from anywhere
like
1) command : /usr/bin/php7.0 -d memory_limit=-1 /var/www/html/bin/phar/php7cc.phar
either I type every time this command or can make an alias like
>>> /usr/bin/php7.0 -d memory_limit=-1 /var/www/html/bin/phar/php7cc.phar
make an entry in ~/.bash_aliases
alias php7cc='/usr/bin/php7.0 -d memory_limit=-1 /var/www/html/bin/phar/php7cc.phar'
reload it with
>>> source ~/.bashrc
now i just need to type php7cc inn command prompt to run this whole command
>>> php7cc
Note : if it is first time you are creating the .bash_aliases file,
then you may need to add the code in .bashrc to include .bash_aliases
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
2) alias sdu=’du -hs * | sort -hr’