image
Rerun a Command Starting with a String

Contents

Linux Administration Bootcamp
Installing and Connecting to a Linux System
2
Linux Boot Process and System Logging
33
Disk Management in Linux
36
Partitions
PREVIEW6m 50s
38
User Management in Linux
Shell Scripting with Linux
54
55
Start course
Difficulty
Beginner
Duration
7h 28m
Students
324
Ratings
3.6/5
starstarstarstar-halfstar-border
Description

In this course, you will learn how to install a Linux system and connect to it, whether that be on Mac or Windows.

Transcript

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.

About the Author
Students
38702
Labs
161
Courses
1557
Learning Paths
39

A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.