
In Bash, the default Unix shell on most Linux systems, you can save yourself a little bit of time and typing effort by using the
These commands also apply to alternative shells as well, like zsh.
Let’s say you want to make the task of using Instead of typing There’s enormous flexibility and endless creative opportunities here, and no “best” way to go about creating aliases, especially if you’re a lone developer/administrator. Obviously, if you’re working with a team, you’ll want to make sure you’re all on the same page.
Here’s some other possibilities:
The contributors behind oh-my-zsh have a bunch of pre-built aliases for you to peruse.
If you want to ensure these aliases are persistent, in that they will you’ll be able to use them after a reboot, you should edit your alias
command to create some shortcuts. Typically, Linux admins set up some custom aliases for tasks they do repeatedly, or take a long time to type in.
cd
to move up one directory a little easier.
cd ..
every time, you can create an alias.
$ pwd
/home/dir1/dir2
$ alias ..='cd ..'
$ ..
$ pwd
/home/dir1
$ alias lt='ls -ltFh' # long list, sorted by date, show type, human readable
$ alias help='man' # for those who forget about man pages
$ alias ...='cd ...' # to move up two directory levels
$ alias gs='git status' # one of many git-related possibilities
$ alias please='sudo -E' # for the polite sudoers
~/.bashrc
, ~/.bash_aliases
, or ~/.zshrc
file, depending on your setup.
Like what you saw? Subscribe to our weekly newsletter.
You're subscribed!