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.
To run the most recent command that begins with a given string, use an exclamation mark followed by that string. For example, to run the last command that started with a D, type exclamation mark D enter. Specify as much of the string as required to make it unique. If you have several commands in your recent history that began with the letter D you can add additional characters, like exclamation mark D U or exclamation mark D F.
I find myself using this technique to get a status, perform some work that might affect that status. and then to recheck that status again. Here's an example where data is being copied to a file system that where the disc usage is being checked. Let's change into a directory of our plan to restore some data. I'll check the disc usage with a df command and now I will extract some data into this directory. And then using exclamation mark D, I will recheck the status. You can see that about 400 megabytes of data was extracted into this file system.
Here's an example that demonstrates a situation where more than just one character of a string is required to recall the desired command. Let's create a directory for my fictitious application called myapp. Let's create a user for this application. And we'll make that application owner the owner of the directory here. And if I run an exclamation mark M, the most recent command that begins with M is mkdir. So it will run mkdir myapp.
Now, if I want to run C H O W N to change the ownership I will have to specify C H O if I just specify C, cd will execute. I specify C H, chmod will execute. So to run chown I need to specify exclamation mark C H O and then if I want to run the chmod command I will specify just enough as required to make that unique. I could specify more if I wanted, for instance.
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.