Alias Command Improve Productivity – Best Short Form Linux Commands

Alias command will help you to improve command execution faster and more faster as you make best practice out of it. Best short form Linux Commands you can make, long command short easy to type and faster to execute.

Alias Command

How did i make best short form Linux Commands using aliases.? Aliases are two types

  • Global Alias
  • Local Alias

Does it make any difference Global and Local Alias, I can say Yes, Because global level applicable for all the users including root user, whereas Local aliases are particular to that particular user only

Configure Global Aliases.?

Careful when your adding global level aliases do not use already exists command names for alias names. To configure global edit /etc/profile file and add alias at the end of the file.

[root@ArkitServer ~]# cat /etc/profile |grep ravi
alias ravi='df -h'

[root@ArkitServer ~]# ravi
bash: ravi: command not found...

[root@ArkitServer ~]# source /etc/profile

[root@ArkitServer ~]# ravi
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 15G 4.1G 11G 28% /

Local Alias configuration

User level aliases are called local alias to particular user. /home/USERNAME/.bashrc file you can use to add local aliases.

[root@ArkitServer ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
 . /etc/bashrc
fi

Adding alias is very easy on local level, using alias command 

alias p='pwd'

type p will execute pwd this is how command can be reduced and increase typing speed

As you can think how this feature is useful for you.? you can add number of aliases into .bashrc file, see below example when you type scan command will automatically scan for new devices

alias scan='ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done'

List Existing Aliases

[root@ArkitServer ~]# alias -p
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

as shown in above command alias -p will list all aliases 

How to Remove Aliases

It’s so simple to remove alias just type unalias ALIASNAME

[root@ArkitServer ~]# unalias which

In case of global alias you have to edit /etc/profile file and remove the entry from that file

That’s it about alias command short form Linux commands

Related Articles

25 commonly used commands

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

1 Response

  1. Starfall 3 says:

    Amazing! Its truly amazing piece of writing, I have got much clear idea on the topic of from this post.

Leave a Reply

Your email address will not be published. Required fields are marked *