Linux Command-Line Tips & Tricks: Over 15 Examples!

preview_player
Показать описание
The number of command combinations you can come up with on the Linux command-line is seemingly endless, and there are some real gems out there that you might not know about. In this video, Jay goes over some of his favorite command combos, time-saving tricks, and other various tips he wish he learned sooner. In this video, you'll find all kinds of things to add to your command-line toolbox!

*🎓 CROWDSTRIKE CRASH SURVIVOR T-SHIRT*
Commemorate the largest outage in history with the latest addition to the LLTV merch shop.

*🎓 BRAND NEW UDEMY COURSES AVAILABLE!*
Check out my new courses on Udemy and learn something new!

*Support Learn Linux Learning!*

_Note: Royalties and/or commission is earned from each of the above links_

#*⏰ TIME CODES*
00:00 - Intro
02:24 - Returning to the previous working directory
03:46 - A simple keyboard shortcut for clearing your screen
05:30 - The pushd and popd commands
07:29 - Sending apps to the background, then back to the foreground
10:21 - What to do when you forget to sudo
11:37 - Searching through command history
13:00 - Re-executing a specific item from your command history
14:47 - Viewing the date and time within the command history
18:35 - Matrix-style falling text
19:27 - Making your terminal full-screen
20:45 - Increasing/Decreasing text in your terminal window
21:45 - Emptying text from your command-line
22:19 - Jumping to the beginning or end of the current command
23:39 - Chaining commands together
27:00 - Following log files
28:13 - Emptying the content of text files
29:34 - Formatting command output with columns

-- Official *🌐 LEARN LINUX TV ON THE WEB* --

Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. The person viewing Learn Linux TV's content is expected to follow their best judgement and to make their best decisions while working with any related technology. Always make sure you have written permission before working with any infrastructure. Also, be sure that you're compliant with all company rules, change control procedures, and local laws.

#Linux #LinuxTutorial #Bash
Рекомендации по теме
Комментарии
Автор

Been using Linux for decades and I still learned some things from this. Thank you. Now I want to share the world changing CLI tip I learned within the last decade.
tail -F
The capitol F will "follow" Log files that roll over. For example if your tailing syslog and it gets rolled to syslog.1 the tail -F will continue tailing the new syslog file.
I work on apps that write lots of data to their log files and roll them rapidly. The tail -F option saved me from missing things and or having to go back and grep through he log files.

PanSatyr
Автор

26:50
Also, when you chain commands with ||, you make sure that the second command runs only if the first one fails (for example: "command1 || command2" will only run command2 if command1 failed). You can then make a construction like this:
(command && echo "success") || echo "failure" - this will "tell you" if the command was a success or not. If you redirect the output and perhaps include some timestamps, you have simple logging that comes in handy in scripts, for example :)

SMJSmoK
Автор

just write "cd" will take you to home

MartinCode
Автор

This is currently my favourite video on this channel, for which there has been a lot of competition. A lot of the tips in here are 100% going to be applied at work after the holidays. This channel has been fantastic for ramping myself up in a lot of skills I'm using in my current role. That and I want to start up a homelab, so even more mileage to be had on this channel. Top quality content, Jay, thank you for all of this.

davemeech
Автор

22:11 Ctrl+U will not necessarily delete everything on a line. It will delete everything to the left of the cursor. (Ctrl+K will delete from the cursor to the end of the line.)

To delete an entire line regardless of where the cursor is located, use Ctrl+C.

stuartm
Автор

15:30 - %Y-%m-%d is the same as %F in bash. Thus HISTTIMEFORMAT='%F %T ' gives the same results in fewer keystrokes.

RickJohnson
Автор

Ctrl + y will paste whatever you yanked with Ctrl + u, Ctrl + k, or Ctrl + w.
One use for this is when you forget to type sudo in the beginning of a line. So you would Ctrl + u the line then type in sudo then Ctrl + u to bring back the commands you just yanked.

Thanks for the awesome tips in the video!

_yourNameHere__
Автор

The reason why CTRL-z sometimes does not work with nano is that it often is disabled in the settings of nano e.g. by editing /etc/nanorc and commenting the line "set suspend". The reason for doing this is, is that people with a windows background often start pressing CTRL-z in nano thinking that would undo something, but of course it doesn't. If you are teaching linux beginners, this is a nice feature to have.

hugocoolens
Автор

To cd to your home, just use `cd`. The tilde is only needed if you need to address a subdirectory of your home, like `cd ~/proj/scala/mini`.
To exit cmatrix, just hit the q key. Many other programs use the q=quit too, like man, less, ...
Beside Ctrl-a for the beginning of the line, you may use the HOME key as well, and respectively the END key for end of line.

unbekannter_Nutzer
Автор

Hi Jay, This will take me some time to wrap my head around all of this. Little by little I will work on this. Thank you so much for this video.

ricklakes
Автор

I have learned so much since discovering your channel! This video all in his own is like an excellent little cheat sheet that you might have with you for a final exam. If there is not a text / transcript version of this already available I may have to get on that myself even if it is just for myself, a lot of these were very useful, thank you 😮👍🏽

pyrokamileon
Автор

As someone relatively new to Linux, watching this video was like scratching an itch, or finally remember who the actor was in that movie you were talking about a week ago. Such a relief to have these in my toolkit now. Thanks for the video!

knjohnson
Автор

In the last example, 'mount' is used to illustrate the 'column' command. 20 years ago, the output of 'mount' was quite easy to read. Nowadays, this is a mess because even the most basic Linux installation creates at least 20 virtual filesystems and nothing is sorted.
Here are 2 good alternatives to 'mount' that are probably installed by default on all modern linux systems:
The first is 'findmnt' which basically prints the same information but nicely formatted in a tree. As its name indicates, the real purpose of findmnt is to find which filesystems are matching a set of criteria but its default output matches everything.
The second is 'lsblk' which prints information about the physical block devices (so no virtual filesystems). By default, the output is formatted as a tree representing the device hierarchy (LVM, LUKS, raid, ...) and the columns can also be configured (see the options -o, -f, ...)

cynodont
Автор

Thanks for all your help Jay. You are a true blessing for those of us who are new to Linux. Keep up the good work my friend it is truly appreciated.

glendubie
Автор

I just want to say thanks Jay for al your content, I've been using Linux for quite a few years alongside MacOS, ( I use Arch btw ) and I learn and discover something new every week with your videos. It was your Arch install video that got me started with that, and I've not looked back.

PoodlePlugins
Автор

Thanks for the video. Most of the tricks were already known, but I found some new ones.

You asked for what you missed, well here you go: xargs command, splitting long commands in multiple lines with backslash, grepping stuff, watch command, searching for recently modified files with find command

name_ne
Автор

The Ctrl + Left or Right arrow, allowing you to go to the previous/next word within a command, is pretty useful too.

nicolasrenard
Автор

Linode is the best sponsor on Youtube :)
I need to spend more time in Linux console/ terminal.
Thank you for this video. I need to watch it again with pen and paper.

cyberpet
Автор

Wonderful video and the comments are gold.
I remember a couple of command/shortcuts that I'm use daily.

!$: Calls the last parameter of the previous command.
Example:
Touch anyfile.txt
Nano !$

||: Double pipe works like "OR".
Only if the first command fails, run the second.

Ctrl+x, ctrl +e: For long commands, open the default editor so you can write a very long command, save and it's ready in your prompt.

joelynott
Автор

Thanks so much!!! I'm brand new to Linux and fairly new to your channel, so the beginner material is perfect for me!

liquidmobius