As the title suggests, this course looks at intermediate-level skills for those who already know a bit about Linux but want to enhance that knowledge. In this course, we build upon some of the topics covered in our Linux Fundamentals course, including files and shell scripting.
- Learn what wildcards are and how and when to use them
- Understand input, output, and redirection
- Work with files and shell scripting
- Anyone with basic knowledge of Linux who wants to learn more
- Professionals who want to learn more about Linux to enhance their career prospects
This is an intermediate-level course so some knowledge of Linux is expected. If you're just starting out, then try our Linux Fundamentals course first.
This lesson covers creating, deleting and persisting aliases. If you find yourself typing the same command over and over again, you can create a shortcut for it called an alias. An alias can be thought of as a text expander, creating aliases for commands that are really long, or that you use often is a common practice. For example, if you type ls-l frequently, you may want to abbreviate it to ll. As a matter of fact, this alias often comes predefined on many Linux distributions.
The alias command can list or create aliases. If you run alias without any additional information on the command line, it displays the list of current aliases that are set. If you wanna create an alias, use alias space the alias name = and the value for that alias. Aliases don't have to be used for just shortcuts, they can be used to fix common typing errors. For example, if you end up typing grpe, and you mean to type grep, you can create an alias. And whenever you accidentally type grpe, alias will fix that for you, and spell it grep. You can also use aliases to make your work environment similar to that of another platform.
For instance, in Windows, cls clears the screen, but in Linux, the equivalent command is clear. You can create these shortcuts to make you feel more at home. To remove an alias, type unalias and the name of the alias. Or, to remove all aliases, use unalias -a. If you were to create some aliases and logout and back in, your aliases would be lost.
To make them persist between sessions, add them to your dot files, such as .bash_profile. The downside to creating several aliases is that when you're on a system that does not have your aliases, you might feel lost. If you wanna be able to work effectively on any Linux system that you have access to, keep your alias usage to a minimum.
Another way to handle this situation is to simply copy your configuration files to each Linux system that you're going to work on. Let's say you run ls -l a lot, let's make this an alias, make it shorter. Let's alias ll to be ls -l. So now when you type ll, you'll get the same result as ls -l.
Let's say you like to type cls because you come from a Windows background. Cls is not available on Linux, the equivalent command is clear. You could create an alias for cls that equals clear. So now when you type cls it will clear the screen. To list aliases just use the alias command. To make them persist, you can add it to your bash_profile file. Let's do this, let's add mycls.
You can see that that's not set. Let's logout and log back in. And you can see that mycls is set. The alias command lists and creates aliases, while the unalias command deletes aliases. To persist your aliases between logins, add them to your dot files.
Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.