Linux aliases for everyday

Evhenii Rvachov
3 min readSep 13, 2021

Unix and Linux aliases are cool! They allow you to define your own commands or keyboard shortcuts, so you can customize the command line and make it work the way you want.

I’m going to discuss automation work time and routine in the terminal. In programming languages have Classes and functions, in OS with GUI has shortcuts, in the terminal we can make shortcuts, it’s Aliases. I will try to explain how to use short and huge routine operations and burn it on one key name. And of course, you can use several aliases for your pipeline work.

You can find a place of aliases in your ~/.bashrc or ~/.zshrc file.

Syntax:

alias [-p] [name[=value] ... ]

I like python and I’ll show you the first alias that I use:

alias venv="virtualenv venv -p python3 && source venv/bin/activate"

If you love your life and want to save your work time this short article for you.

For your terminal:

alias c='clear'

For example…
How to define or create a bash shell alias (all aliases )
To create the alias use the following syntax:

alias name=value
alias name='command'
alias name='command arg1 arg2'
alias name='/path/to/script'
alias name='/path/to/script.pl arg1'

Of course, this is a quick and dirty way to create SSH aliases for faster communication. Aliases for each SSH connection one by one like here:

alias mywebserv='ssh root@192.168.0.35'
alias dns='ssh root@server.example.com'
alias dhcp='ssh user@192.168.0.35 -p 2233'
alias myubuntu='ssh user@192.168.0.35 -i ~/.ssh/id_rsa_remotesystem'

I recommend using the default SSH config file to create an SSH alias. But you can use the first method.

vi ~/.ssh/config
or
nano ~/.ssh/config

And edit your configuration:

Host mywebserv
HostName 192.168.0.35
User root

Host dns
HostName server.example.com
User root

Host dhcp
HostName 192.168.0.35
User yser
Port 2233
Host amazon
HostName amazon.....ip...com
User dev1
IdentityFIle ~/amazon_keys/root.pem

Replace the Host, Hostname, User, and Port values with your own. After adding the details of all remote hosts, save and exit the file. You can now log into systems using the commands:

ssh mywebserverssh dnsssh dhcp

Git

# gitalias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gca='git commit -a'
alias gcam='git commit -a -m'
alias gce='git commit -e'
alias gcm='git commit -m'
alias gco='git checkout'
alias gd='git diff'
alias gdc='git diff --cached'
alias gpom='git push origin master'
alias gr='git remote'
alias gs='git status'

Utils

# Utilsalias sub="open -a 'Sublime Text'"
alias console="bundle exec irb -r ./config/boot.rb"
alias dstore="find . -name '.DS_Store' -type f -delete"
alias loc="find lib -name '*.*' | xargs wc -l"
alias stuff="cat $SRC/stuff/text/stuff.txt"
alias rl="source $HOME/.zshrc"
alias update_assets='fund_site && cp -Rv ../fund/site/app/assets/ .'
alias img="$C img"
alias count="ls -l . | egrep -c '^-'"
alias sim="wapi && ruby scripts/simulator.rb"
alias nm="nodemon"
alias y="yarn"
alias ys="yarn start"
alias yt="yarn test"
alias ya="yarn add"
alias yr="yarn remove"
alias ka="killall"
alias kn="killall node"
alias mongodb="~/.mongodb/mongodb/bin/mongod --port 27017 --dbpath ~/.mongodb/data/db > /dev/null 2> ~/.mongodb/err.log &"

Docker

# Dockeralias d="docker"
alias ds="docker swarm"
alias drm="docker rm \$(docker ps -a -q)"
alias drmi="docker rmi \$(docker images -q)"
alias drmia="docker rmi \$(docker images -q -a)"
alias dc="docker-compose"

I’ve tried to show you how you can use abbreviation techniques to optimize your work. Now you can create your own shortcuts and make your job easier. I hope this short article was an incentive for you to evaluate your time and work.

A little bonus if use FFmpeg:

alias gvinf="ffmpeg -i video.avi" 
# Get video info
alias imtovid="ffmpeg -f image2 -i image%d.jpg video.mpg"
# Convert Image to Video
alias ctoimg="ffmpeg -i video.mpg image%d.jpg"
# Cut video to image

--

--

Evhenii Rvachov

I’m just a Human who likes hardware/software engineer.