Sign in to follow this  
m0nk1337

Aliases in Shell scripting

Recommended Posts

In this post i will explain these as follows :

what is alias

how to create alias

 

what is an alias?

It is a simple way to create new commands by wrapping existing commands. They are best if you have a very long command and you are too lazy to type it again and again.

 

how to create an alias?

alias has a syntax like this :

 

alias name='command'

 

for example if i have a command to start lxde "DISPLAY=:1 startlxde&" and this is too long to type again and again so i will create an alias with name runlxde to automate this like this :

 

alias runlxde='DISPLAY=:1 startlxde&'

 

then the next time if i want to start lxde then i will simply type the command runlxde and hit enter and then it will execute my command.

 

how to remove a alias?

to remove an alias simply use this command :

unalias alias_name

 

bonus

sometimes it happens that you may want to bypass an alias temporarily without unaliasing it, for that you can use this trick :

use command builtin before your command like this :

 

command ls

 

use \ anywhere between the command like this :

 

\ls or l\s 

 

alright guys this is it. thankyou for reading bye.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this