J
john2025
Guest
Aliases allows you to do a mapping between a command and other. They allow to shorten long commands. Most shells like Zsh and Bash support bash aliases.
I. Bash Shell
The best method to make a separate aliases file, so you won't have to put them in ~/.bashrc, but to a file of your choice.
First, edit your ~/.bashrc file and add the following lines if they don't already exist, or uncomment them if they do:
- By default ~/.bashrc contains that inclusion -
Edit ~/.zshrc and add the following lines if they don't already exist, or uncomment them if they do:
ii- for Zsh Shell: run
In that new file add your aliases. Here are some practical aliases developers and sysadmins often use:
save and exit. Once you save your edits, they won’t take effect immediately. For this, you must reload the configuration using the source command, by running:
source ~/.bash_aliases
or
source ~/.zsh_aliases
I. Bash Shell
The best method to make a separate aliases file, so you won't have to put them in ~/.bashrc, but to a file of your choice.
First, edit your ~/.bashrc file and add the following lines if they don't already exist, or uncomment them if they do:
- By default ~/.bashrc contains that inclusion -
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
II. Zsh ShellEdit ~/.zshrc and add the following lines if they don't already exist, or uncomment them if they do:
if [ -f ~/.zsh_aliases ]; then
. ~/.zsh_aliases
fi
i- for Bash Shell: runsudo gedit ~/.bash_aliases
orii- for Zsh Shell: run
sudo gedit ~/.zsh_aliases
In that new file add your aliases. Here are some practical aliases developers and sysadmins often use:
# My custom aliases
# Highlight the current day in cal
alias cal='ncal -C'
alias cls='clear'
alias dir='dir --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -lha'
alias ld='sudo systemctl daemon-reload'
alias ll='ls -alF'
alias ls='ls --color=auto'
# restart linux
alias res='sudo shutdown -r now'
# shutdown linux
alias shut='sudo shutdown -h now'
# To see the status of all services, run this command
alias all='sudo systemctl list-units --type=service'
# Possible values for --state= are active, running, stopped, enabled, disabled and failed.
alias act='sudo systemctl list-units --type=service --state=active'
alias fail='sudo systemctl list-units -all --state=failed'
alias test='sudo systemctl --failed || sudo systemctl list-units --state failed'
# For daily tasks aptitude update and aptitude upgrade should be all you need. If you're upgrading to a major release aptitude full-upgrade will do what you want.
alias un='sudo aptitude update && sudo aptitude full-upgrade -y'
alias unlock='sudo dpkg --configure -a || sudo service packagekit restart'
alias up='sudo apt clean && sudo apt update'
alias upev='sudo apt clean && sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y'
alias vdir='vdir --color=auto'
# Navigate up a parent directory using cd followed by number
alias cd1='cd ..'
alias cd2='cd ../..'
alias cd3='cd ../../..'
alias cd4='cd ../../../..'
alias cd5='cd ../../../../..'
save and exit. Once you save your edits, they won’t take effect immediately. For this, you must reload the configuration using the source command, by running:
source ~/.bash_aliases
or
source ~/.zsh_aliases

