Posted: . At: 1:08 PM. This was 8 years ago. Post ID: 8888
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Create aliases with the Linux command line to make commands easier to remember.


Creating an alias for bash makes remembering a command easier. This is how longer commands may be simplified.

Here is an example.

[jason@darknet:~] alias lseasy='ls -lAhF'

This is the output.

[jason@darknet:~/Videos] lseasy                                     
total 4.8G
-rw-r--r-- 1 jason jason   18 Mar 24 13:34 authrootseq.txt
-rw-r--r-- 1 jason jason  23K Mar 24 13:55 heap2.htm
-rw-r--r-- 1 jason jason  893 Mar 24 13:48 heap.html
-rw-r--r-- 1 jason jason  23K Mar 24 13:54 java.js
-rw------- 1 jason jason 624M Aug 17  2013 Microsoft.Windows.XP.Professional.SP3.x86.Integrated.August.2013.iso
-rw------- 1 jason jason 2.3G Jan 17 15:42 Pixels.2015.mp4
-rw------- 1 jason jason 331M Mar 17  2015 s13l43-the-subnet-maskmp4.mp4
-rw------- 1 jason jason 371M Mar 17  2015 s13l44-the-diagram-we-use-to-subnet-how-to-use-the-diagram-for-our-needsmp4.mp4
-rw------- 1 jason jason 180M Mar 17  2015 s13l45-class-full-subnettingmp4.mp4
-rw------- 1 jason jason 458M Mar 17  2015 s13l46-class-less-subnettingmp4.mp4
-rw------- 1 jason jason 413M Mar 17  2015 s13l47-route-summarizationmp4.mp4
-rw------- 1 jason jason 174M Mar 17  2015 s13l48-wildcard-maskingmp4.mp4
-rw-r--r-- 1 jason jason   33 Mar 24 09:40 windows-sp3-xp-key.txt

Run the alias command by itself to get a listing of the available aliases on your system for your current user.

jason@darknet:~/Videos] alias 
lseasy='ls -lAhF'
run-help=man
which-command=whence

It is also possible to specify parameters in an alias command.

jason@darknet:~/Videos] alias letc='ls -al /etc'

This of course works a treat.

[jason@darknet:~/Videos] letc                         
total 32
drwxr-xr-x   2 root root  4096 Apr  6 15:56 .
drwxr-xr-x 193 root root 12288 Apr 20 09:58 ..
-rw-r--r--   1 root root   220 Nov 13  2014 .bash_logout
-rw-r--r--   1 root root  3391 Apr  6 15:56 .bashrc
-rw-r--r--   1 root root  3526 Dec  2 20:34 .bashrc.original
-rw-r--r--   1 root root   675 Nov 13  2014 .profile

Aliases are a very useful Linux tool, making long and complex one-liners easy to use and remember.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.