Categories
Linux Tutorial Series

Linux Tutorial Series – 66 – The alias command

Here is the video version, if you prefer it:

The alias command is used to construct your own commands which are made out of existing commands. (Shotts, 2019)⁠ Here is an example of how it is used:

mislav@mislavovo-racunalo:~$ alias ll='ls -l'

mislav@mislavovo-racunalo:~$ ll

total 76

drwxr-xr-x 27 mislav mislav 4096 Sep 19 14:00 anaconda3

drwxr-xr-x 26 mislav mislav 4096 Dec 30 00:40 'Calibre Library'

drwxr-xr-x 2 mislav mislav 4096 Aug 25 12:21 Desktop

drwxr-xr-x 26 mislav mislav 4096 Jan 16 09:38 Documents

Its syntax is as follows:

alias name='string'

Be wary of the spaces – there are no spaces between name, = and ‘ ‘!

As you can see, you can create your own commands with alias. More specifically, you are creating an alias for an existing (or a sequence of existing) commands – hence the name.

Some notes: make sure not to alias an existing command name (check if the command name is used already with the type command). Also, the alias you create will vanish when you exit your Terminal session. That is a topic for another post.

Hope you learned something useful!

References

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 74-76

NewsletterUpdates on interesting things I am doing

Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.

Leave a Reply

Your email address will not be published.