FactorPad
Faster Learning Tutorials

Linux alias command summary with examples

alias allows you to customize a command.
  1. Purpose - Learn what alias is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with alias.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 8, 2016
Updated: July 26, 2018
In this tutorial, 12 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / alias command


The Linux alias command

Beginner

Learn to customize commands at the Linux command line.

Video Tutorial

Linux alias command summary with examples (3:38)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our twelth word, or command to memorize is alias from the category System.

alias allows you to customize a command. Recall from our last video that alias is a command type, and here we'll learn more.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The alias command has 1 option, and arguments you provide will either list, or create the alias.

The -p option will print aliases in a reusable form in case you want to create a file for a bunch of aliases.

So why is alias an important command? Well, alias will help you customize your system, and save you keystrokes. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go, type alias without options or arguments.

$ alias alias ls='ls --color=auto' $ ls video11.txt video5.txt

And look, one for the command from video 7, ls. To interpret, when ls is run, Linux runs text inside the quotes, and this sets the output colors.

Next, let's say we prefer to view ls in one column instead of several, but since this requires three extra keystrokes, space-dash-1, we could edit this alias, by adding the option -1. Saving, viewing and giving it a go.

$ alias ls='ls -1 --color=auto' $ ls video11.txt video5.txt

Now, we could create a new alias that also reminds us of the current directory. Pick a new name, lsd, and make sure it isn't taken by using the type command.

$ alias lsd -bash: type: lsd: not found

Good. It's free. Up-arrow to recycle, add a semi-colon, the pwd command, enter, and test lsd.

$ alias lsd='ls -1 --color=auto; pwd' $ lsd video11.txt video5.txt /home/paul

A Final Tip

Okay now you know how to use alias. And you know the syntax for commands, options and arguments.

One last tip about the alias command. Aliases expire each session unless saved in user configuration files, so I'll introduce users next.

Okay, thanks for visiting today. I hope this was a fun introduction to the alias command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Don't miss the next chance to expand your mind, click to subscribe.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the type command, hit Back.
  • To learn about users with the whoami command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / alias command



 
 
Keywords:
linux alias command
unix alias
bash alias
set alias
create alias linux
shell alias
rename alias
terminal alias
linux alias bashrc
make alias
linux show aliases
linux alias tutorial
modify commands with alias
customize commands with alias
list aliases