DEV Community

Hayatudeen Abdulrahman
Hayatudeen Abdulrahman

Posted on • Updated on • Originally published at Medium

The Linux Alias command: Making Your Own Custom Shell Command Shortcuts

Are you tired of using the same set of Linux commands repeatedly? Or find it difficult to navigate to a frequently visited file? There’s an easy solution — the alias command.

Photo by [卡晨]( on [Unsplash](

The alias command is a shell command that allows users to create a shortcut in place of another command. It’s useful for simplifying command names, replacing commands with preferred names, and allowing easy navigation around the shell.

The created shortcut can be temporary or permanent, and is removable either way.

In this tutorial, I will show you how to create, remove, and make aliases permanent.

Requirements: Bash Shell, any Linux text editor, and a basic understanding of the shell terminal.

Let’s get started!

The Alias Command Syntax

alias: It calls the alias command.

  • option: Alias has only two options:

i. -p: *displays all current aliases (created shortcuts)

ii. -a: removes all current aliases.

  • name: preferred shortcut (alias) name

  • value: the command/syntax


Creating a shortcut for the clear command

This enables the user to use c in place of the clear command.

Assigning a shortcut to a command and its frequently used option

The ls command allows users to list files, while ls -la list files in long format including hidden files. A user might prefer the second command. By assigning the ls command to ls -la, invoking ls will list all files in long format.

Navigating to a directory/file

The above command allows the user to navigate to root/my_very_long_directory using just ct.

This is the power of the alias command. Instead of having to remember the name of the directory or typing the directory name (of course you can use the Tab key to auto complete the directory name), you can set the path of the directory to an alias.

Creating a permanent alias

The above examples only allow you to use the aliases for the time you’re working on your shell. Once you close the shell, the aliases are cleared from the terminal’s memory.

To create a permanent alias follow these steps:

  • Use your favorite editor (vi, nano e.t.c) to create a file called ~/.bash_aliases.

  • Type the alias command into the file.

  • Save and exit.

  • The shell will execute on restarting or logging in to your terminal. To execute immediately, type “..bash_aliases”.

  • You can now use your alias command permanently. Note: if “..bash_aliases” does not work, use "source .bash_aliases".

Removing Aliases

The unalias command is used to remove aliases.

  • To remove all aliases

This removes all the aliases.

  • To remove a specific alias


Removes the created shortcut for the clear command.


The Linux alias command enables you to create useful and powerful shortcuts that make your work easier on the shell terminal. You’ve learnt what an alias is, how to create one, make it permanent and remove it. You can now create your own shell command shortcuts.

Discussion (0)