Linux Command - alias
alias
- Creates aliases. Alias are simple names for commands.
alias created with the current shell session are not permenent. Add alias to ~/.bashrc
to make it permanent.
To Remove an alias, use unalias alias_name
command.
Syntax
1 | alias alias_name="command_to_run" |
Examples
create alias for git add
and git commit
1 | alias gac="git add . && git commit -m" |
create an alias for searching processes
1 | alias psg="ps aux | grep -v grep | grep -i -e VSZ -e" |
Sample output for psg firefox
1 | $ ps aux | grep -v grep | grep -i -e VSZ -e firefox |
Note: grep command greps ‘VSZ’ so that the column names are displayed.
Bash Function
alias are limited in their scope. You can’t access arguments in an alias. The alternative is to create Bash functions in .bashrc
file.
Sample bash function in .bashrc
file. It is used to create directory and move to that directory immediately
1 | mcd () { |