image
Repeat as Root
Repeat as Root
Difficulty
Advanced
Duration
18m
Students
496
Ratings
4.2/5
Description

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.

Learning Objectives

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

Intended Audience

  • Anyone with intermediate knowledge of Linux who wants to learn more!

Prerequisites

This is an advanced-level course so a good level of Linux knowledge is expected.

 

Transcript

If you ever forget to run a command with root privileges you can simply repeat it by using sudo, space, exclamation mark, exclamation mark. Let's say if we were to add a user and we get a permission denied error. That's because we need to run it with super user privileges. We can run sudo, space, exclamation mark, exclamation mark. Or as I like to say, sudo, space, bang, bang. And then you can see that Sam was added.

Here's another example. This exclamation mark syntax that I'm using is called an event designator. An event designator references a command in your shell history. Bang, bang references the most recent command. But one of my favorite uses of the event designator is to run the most recent command that starts with a given string. For example, if we run a few commands, and we want to run the previous command that starts with u, we could type bang u and hit enter. So we can also do this with sudo. Sudo, bang, w. And it shows that we're running with root privileges.

You can also use the su command. So let's do this. And my root password here. And then we'll get rid of this user using this way as well.

About the Author
Students
21076
Courses
61
Learning Paths
18

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.

Covered Topics