11 Linux terminal commands let you use it even better

  
 1. Command Line Daily Shortcuts
The following shortcuts are very useful and can greatly improve your work efficiency:
CTRL + U - Cut the content before the cursor
CTRL + K - Cut Cursor To the end of the line
CTRL + Y - Paste
CTRL + E - Move the cursor to the end of the line
CTRL + A - Move the cursor to the beginning of the line
ALT + F - Jump to the next space
ALT + B - jump back to the previous space
ALT + Backspace - delete the previous word
CTRL + W - cut the cursor before the word
Shift + Insert - paste the text into the terminal
So Let the above content be more understandable to see the following line of commands.
sudo apt-get intall programname
As you can see, there is a spelling error in the command, and you need to replace “intall" with “install” for normal execution.
Imagine that the cursor is now at the end of the line, we have a lot of ways to return her to the word install and replace it.
I can press ALT+B twice so the cursor will be in the following position (here the position of the cursor is used).
sudo apt-get^intall programname
Now you can press the arrow key twice and insert “s” into the install.
If you want to copy the text from your browser to your terminal, you can use the shortcut "shift + insert".
2. SUDO !!
If you don't know this command yet, I think you should thank me very much, because if you don't know, then every time you enter a long string of commands, you will see <;permission denied&rdquo After that, it will be painful.
sudo !!
How to use sudo !!? is very simple. Imagine that you just typed the following command:
apt-get install ranger
There will be a "Permission denied" unless you have logged in to a sufficiently high-privileged account.
sudo !! will run the previous command in the form of sudo. So the previous command becomes like this:
sudo apt-get install ranger
If you don't know what sudo is, poke it here.
3. Pause and run commands in the background
I have written a guide on how to run commands in the background of the terminal.
CTRL + Z - Pause the application
fg - Recall the program to the foreground
How to use this trick?
Imagine you are editing a file with nano:
sudo nano abc.txt
Up to half of the file editing, you realize that you need to enter some commands at the terminal right away, but the nano is running in the foreground so you can't type it.
The only way you might think is to save the file, exit nano, and re-open the nano after running the command.
In fact, if you press CTRL + Z, the foreground command will be paused and the screen will be cut back to the command line. Then you can run the command you want to run, and when the command is finished running, type "ldg" in the terminal window to return to the previously suspended task.
It's very interesting to have a try to open a file with nano, type something and pause the session. Then use nano to open another file, enter something and then pause the session. If you type “fg” you will return to the second file opened with nano. You can only go back to the first file opened with nano by exiting nano and entering “fg”.
4. Use nohup to run commands after logging out of SSH session
The nohup command is really useful if you use ssh to log in to another machine.
So how do you use nohup?
Imagine that you use ssh to remotely log in to another computer
, you ran a very time-consuming command and then quit the ssh session, but the command still Executing. And nohup can turn this scene into reality.
For example, because of the need for testing, I used my Raspberry Pi to download the distribution. I will never send an external monitor, keyboard or mouse to my Raspberry.
Generally I always use SSH to connect to the Raspberry Pi from my laptop. If I use the Raspberry Pi to download large files without nohup, then I have to wait until the download is complete before I can log out of the ssh session and turn off the notebook. But if so, why should I use the Raspberry Pi file?
The method of using nohup is also very simple, just enter the command to be executed after nohup in the following example:
nohup wget http ://mirror.is.co.za/mirrors/linuxmint.com/iso//stable/17.1/linuxmint-17.1-cinnamon-64bit.iso &
5. ‘Run Linux at a specific time The command
‘nohup’ command is useful when you are using SSH to connect to the server and keep performing SSH login tasks.
Think about what to do if you need to execute the same command at a specific time?
Command ‘at’ will solve this situation properly. Here's an example of ‘at’
at 10:38 PM Fri
at> cowsay 'hello'
at> CTRL + D
The above command will run the program cowsay at 10:38 on Friday.
The syntax used is ‘at’ appended date and time. When the at> prompt appears, you can enter the command you want to run at that time.
CTRL + D Returns to the terminal.
There are also many date and time formats, and you need to flip through the <at’ man manual to find more ways to use it.
6. Man Manual
Man Manual will give you an outline of the use of commands and parameters to teach you how to use them. The Man manual looks dull and dull. (I don't think they are designed to entertain us).
But this does not mean that you can't do anything to make them beautiful.
export PAGER=most
You need to install ‘most’; she will make your man manual more colorful.
You can use the following command to set the specified line length for the man page:
export MANWIDTH=80
Finally, if you have a browser available, you can use -H to open it in your default browser. Any man page.
man -H <command>
Note that the above commands only work if you set the default browser to the environment variable $BROWSER.
7. Use htop to view and manage processes
Which command do you use to find out which process is running on your computer? I bet it is ‘ps’ and add different parameters to get what you want Different output required.
Install ‘htop’吧! definitely let you meet and hate late.
htop presents the process as a list in the terminal, somewhat similar to the task manager in Windows
. You can use a combination of function keys to switch between the arrangement and the items displayed. You can also kill the process directly in htop.
Simply type htop in the terminal to run.
htop
8. Use ranger to browse the file system
If htop is a good helper for command line process control, then ranger is a good helper for command line browsing file system.
You may need to install it before you use it, but once you have installed it, you can start her by typing the following command at the command line:
ranger
ranger is similar to some other file managers in the command line window. However, compared to the top and bottom structure, she is left and right structure, which means that you press the left arrow key and you will advance to the previous folder, and the right arrow key will switch to the next one.
The manipulator manual before using it is worth reading, so you can use the shortcut keys to operate the ranger.
9. Cancel the shutdown
Whether it is after the command line or graphical user interface shutdown, I found that I really do not want to shut down.
shutdown -c
It should be noted that if the shutdown has started, it may be too late to stop the shutdown.
The following is another command you can try:
pkill shutdown
10. An easy way to kill a suspended process
Imagine that the application you are running is deadlocked for unknown reasons.
You can use ‘ps -ef’ to find the process and kill or use ‘htop’.
There is a faster, easier command called xkill.
Simply enter the following command in the terminal and click on the application you want to kill in the window.
xkill
What if the whole system hangs up?
Press and keep ‘alt’ and ‘sysrq’ on the keyboard, then slowly enter the following key:
REISUB< Br> This way your computer can be restarted without pressing the power button.
11. Download Youtube Video
Generally speaking, most of us like to watch Youtube videos, and we can also play Youtube streaming media through our favorite player.
If you need to go offline for a while (for example: during a flight from southern Scotland to southern England) then you may want to download some videos to your storage device and watch them in your free time.
All you have to do is install youtube-dl from the package manager.
You can use youtube-dl with the following command:
youtube-dl url-to-video
You can get the url of the video by clicking the share link on the Youtubu video page. Just copy the link and paste it on the command line (use the shift + insert shortcut).
Summary
I hope you get help in this article, and find at least one of these 11 articles to make you marvel at the "this can be done" technique.

Copyright © Windows knowledge All Rights Reserved