• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Create Shortcut Commands using Alias in Linux

Written by Rahul, Updated on April 13, 2020

In this tutorial you will learn, how to create shortcut commands on Linux. This is you can say a short name of any command. In you daily work, you use multiple commands very frequently. You can create a shortcut of those commands, which help you to use easier.

Alias is an Linux command provides ability to create customized commands. Using this you can create a sort name for a big command as an alias, which is easier to remember. When we uses a single command very frequently, we can alias them to a very short name. You can understand it as create shortcut commands on Linux.

Create Shortcut Command

For example, we use below command frequently to view the directory listing in human readable format.

ls -lh

Now, make it short with alias command.

alias lh="ls -lh"

All done, You have created the alias successfully. To verify the newly created alias, just type below command on terminal

lh

Create shortcut command linux

You will see the results on screen similar to command “ls -lh”.

Make Shortcut Permanent

When you create an alias on terminal, it is not available permanently. Once the terminal is closed, the aliase are lost. To make the aliases permanently you can write in login or non login shell script.

Add the aliases in /etc/profile.d/bash_aliases.sh (Use any name for this script) to make them available for all users. To configure aliases for specific user only, add them in ~/.bash_aliases file.

Create More Shortcut Commands

You can create multiple shortcut commands as much you need. Here is the aliases of some frequently used commands. Add these commands to shell script.

alias cd..='cd ..'
 
alias ..='cd ..'
alias ...='cd ../../../'

alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'

alias apache2restart='sudo sytemctl restart apache2.service'
alias apache2reload='sudo sytemctl reload apache2.service'

View all Shortcuts (Aliases)

You can simply type the “alias” command without any parameter to print all available aliases on your system.

alias

Linux show alias

Remove Shortcuts

You can use unalias command to disable any shortcut on your system. For example to disable ‘lh’ alias use following command.

unalias lh

You also need to remove any entry made in login or non login shell scripts.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy