Check out a free preview of the full Complete Intro to Linux and the Command-Line course

The "CLI Shortcuts" Lesson is part of the full, Complete Intro to Linux and the Command-Line course featured in this preview video. Here's what you'd learn in this lesson:

Brian demonstrates shortcuts using the CTRL key within the CLI useful for developers every day.


Transcript from the "CLI Shortcuts" Lesson

>> The next thing that we're going to get into is a section on the power of control. Or the Ctr L key. So Signals and the Power of CTR is where we are. So the Ctrl key, which is like the yeah, it's one of the keys on your keyboard right CTRL or control is used quite a bit within the terminal.

It's actually used so much and I never use my Caps Lock key that I've actually remapped my Caps Lock key to be control, because then I don't have to reach all the way to the bottom left of my keyboard. That's like an extra like quarter calorie that I don't have to spend.

So I remapped my caps lock to that and I also accidentally hit caps lock all the time, so I actually have a little tip at the end. If you want to see how to do that. I'll show you how to do that at the very end of the course.

No I actually have it right here. I have it on there twice. Okay, so for Mac, I have the tip there and Windows there, you can just click on that and it'll show you how to do that. So I'm gonna show you a few of them. Some of these are more important than the other.

But let's go ahead and get started with some of these. So one of them if I start typing and I wanna go to the very beginning, I can hit Control A and that'll actually take my cursor all the way to the beginning. And I can start going from there.

And by the same token, if I hit Control E, that'll take me all the way to the end. I'm sure you could use like home and end keys if you have those, I don't have those on my keyboard. So but if you had those, you could definitely use those as well.

But Ctrl+A and Ctrl+E will do that within the command line. There's another one here called which I use it mostly as a delete, so if I hit control K, it's actually going to delete everything after the cursor, right? It's actually doing something called yank, which people don't really use as much anymore.

But before there was really a clipboard and copy and paste, there was yank. So I can actually can hit Ctrl y, and that's actually going to paste back everything I yanked and it's not copy and paste because it does not go to your clipboard. It's a separate buffer called the yank buffer.

I don't know if it's called the yank buffer, but that's what I call it. So Ctrl k will yank everything before and Ctrl u, I believe what yank everything before. And again Ctrl y is the paste for that yank buffer. Now you might ask like, when would I actually use that?

I only really use it to delete right? Like I'm sure some of you have used cut to delete things right? It's kind of the same idea of why I use yank here. There's more granular ways of doing doing yank as well. You can like yank words, you can do characters at a time.

But I really only use K and U to delete everything to the end or everything to the beginning. We talked about before, but if you hit Ctrl L that clears the screen. And then CTRL R is what does the reverse search, right? There's more than what I just showed you right there, but I just showed you all the ones that I personally use on some cadence that I actually use enough to remember, okay?

So those are just shortcuts. They're not doing really anything special. They're just simple shortcuts for you to get going. And the reason why I like yank in particular as useful is like, I can't actually like, highlight all this and hit delete. The highlight delete doesn't work because it doesn't track your mouse position within the terminal.

So that's why I actually bothered to learn Ctrl U to delete everything on the line.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now