This course covers a selection of more advanced command-line skills that you can use to become a more proficient Linux user. This course is part of the Linux Administration Bootcamp learning path, designed to get you up and running with Linux.
In this course, you will learn about the following features:
- Tab completion
- Repeat as root
- Rerun a Command Starting with a String
- Reuse Arguments
- Strip Out Comments and Blank Lines
- Reuse the Last Item from the Previous Command
- Anyone with intermediate knowledge of Linux who wants to learn more!
This is an advanced-level course so a good level of Linux knowledge is expected.
Many times workflows can revolve around a single item. That item might be a file, a directory, a user or even something else. Time and time again, I find myself needing to run another command against the last item on the previous command line. To access that item in your current command, use bang dollar or exclamation mark dollar sign. Let's look at an example here. I create a directory and what I typically want to do after I create a directory is change into that directory. So I can access the last item on the command line, on the previous command line, by using bang dollar.
So now I'm in that directory that I created. Let's do this. I have a backup file here. I'm going to unzip. And then once I'm done with that, I want to delete it. So a shortcut again, is use bang dollar. And also, sometimes I find myself making mistakes so I could type a misspelling and I realized, Oh, that's not good. Let me get rid of that." And then, I can use that to correct my spelling as well. Here's an example where we're going to run multiple commands to create and configure a user account. I'll supply the user to this command here. I'll just call this account, Jimmy. That created the user.
Now, what I want to do is set a password for that user. And again, to access Jimmy, I just type bang dollar in this instance. I'll give him a really secure password of Jimmy. And then I want to make sure that he changes his password at least every 60 days. So I'll run this command. Oops, typo there. And let me make sure I got that right. Let me just list his properties on this account there.
To recap, you can use the last item on the previous command using bang dollar or exclamation mark dollar sign. This little shortcut comes in really handy when you're working on a particular item and you need to run multiple commands against that item.
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.