11 Cool Linux Terminal commands

Source: Internet
Author: User

I've been using Linux for 10 years, and through this article I'm going to show you a series of commands, tools, and tricks, and I want someone to tell me that from the beginning, not to stumble on me on my way to growth.

1. Command line daily shortcut keys

The following shortcuts are very useful and can greatly improve your productivity:

CTRL + U-cut the content before the cursor

CTRL + K-cut the cursor to the end of the line

CTRL + Y-paste

CTRL + E-Move cursor to end of line

CTRL + A-Move the cursor to the beginning of the line

ALT + F-Jump down a space

ALT + B-jumps back to the previous space

ALT + Backspace-delete the previous word

CTRL + W-cut the cursor after a word

Shift + Insert-Pastes text inside the terminal

So in order to make the above content easier to understand, look at the following line of commands.

sudo apt-get intall programname as you can see, there are spelling errors in the command, and "Intall" needs to be replaced with "install" for normal execution.

Imagine now that the cursor is at the end of the line, we have many ways to return her to the word install and replace it.

I can press two times alt+b so the cursor will be in the following position (where the cursor is used to refer to).

sudo apt-get^intall programname Now you can double-click the arrow keys and insert "s" into the install.

If you want to copy the text from the browser to the terminal, you can use the shortcut "SHIFT + Insert".

2. SUDO!!

If you do not know this command, I think you should thank me, because if you do not know, every time you enter a long list of commands to see "Permission denied" after the pain will certainly be unbearable.

Sudo!!

How to use sudo! Very simple. Imagine you just entered the following command:

Apt-get Install Ranger must appear "Permission denied" unless you are already logged in to an account that is high enough to be privileged.

Sudo!! will run the previous command in the form of sudo. So the last command becomes this:

sudo apt-get install Ranger If you don't know what sudo is, poke it here.

3. Pausing and running commands in the background

I have written a guide to how to run commands in the terminal background.

CTRL + Z-Pause Application

FG-Re-call the program to the front desk

How do you use this technique?

Imagine you are editing a file with nano:

sudo nano abc.txt file edit to half you realize you need to enter some commands at the terminal right away, but the nano runs in the foreground so you can't enter.

You might think that the only way to do this is to save the file, exit the Nano, and then reopen the nano after running the command.

In fact you just press CTRL + Z, the front desk command will be paused, the screen will be cut back to the command line. Then you can run the command you want to run, and when the command finishes, enter "FG" in the terminal window to return to the previously paused task.

One of the most interesting attempts is to open a file with Nano, type something and then pause the session. Then use Nano to open another file, enter something and then pause the session. If you enter "FG" you will go back to the second file opened with Nano. You will only be back to the first file opened with Nano until you exit the Nano and enter "FG".

4. Use Nohup to still run commands after logging out of an SSH session

The nohup command is really useful if you are using SSH to log on to other machines.

So how do you use Nohup?

Imagine that you telnet to another computer using SSH, you run a very time-consuming command and then quit the SSH session, but the command is still executing. And Nohup can turn this scene into a reality.

For example, because of the need for testing, I sent my Raspberry Pi to download the release version. I will never give my Raspberry Pi an external monitor, keyboard, or mouse.

Generally I always use SSH to connect to the Raspberry Pi from my laptop computer. If I use Raspberry Pi to download large files without nohup, I have to wait until the download is complete before I log out of my SSH session and turn off my 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 you want to execute 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 the Linux command at a specific time '

The ' nohup ' command is useful when you are using SSH to connect to the server and keep the SSH logout task on top of it.

Think about what to do if you need to execute the same command at a specific time?

Command ' at ' to properly resolve the situation. The following are examples of ' at ' use.

At 10:38 PM friat> cowsay ' Hello ' at> CTRL + D above command to run program Cowsay on Friday 10:38 P.M..

The syntax used is the append date time after ' at '. 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 many date and time formats that require you to turn over the ' at ' manual to find more ways to use it.

6. Man Handbook

The Man handbook will give you an outline of the commands and parameters used to teach you how to use them. The man handbook looks dull and stiff. (I thought they were not designed to entertain us.)

But that doesn't mean you can't do anything to make them look beautiful.

Export Pager=most you need to install ' most '; she will make Your Man handbook more colorful.

You can use the following command to set the specified president for the man Manual:

Export MANWIDTH=80 Finally, if you have a browser available, you can use-H to open any of the man pages in the default browser.

Man-h Note that the above command only works if you set the default browser to the environment variable $browser.

7. Viewing and managing processes using Htop

Which command do you use to find out which processes are running on your computer? I bet it's ' ps ' and then add a different parameter to get the different output you want.

Install ' Htop '! Absolutely Brief Encounter you.

Htop renders the process as a list in the terminal, somewhat similar to Task Manager in Windows. You can use the combination of function keys to toggle the way you arrange and the items that are displayed. You can also kill the process directly in the htop.

Simple input htop in the terminal can be run.

Htop

8. Browse the file system using Ranger

If Htop is a good helper for command-line Process Control, then Ranger is a good helper for the command line to browse the file system.

You may need to install it before you use it, but once you install it, you can start her by typing the following command at the command line:

Ranger in the command-line window, ranger and some other file managers, but compared to the upper and lower structure layout, she is the left and right structure, which means that you press the LEFT ARROW key you will advance to the previous folder, and the arrow keys will switch to the next.

The Man manual Ranger before use is still worth reading, so you can use the shortcut key to operate the ranger.

9. Cancel shutdown

Whether the command line or graphical user interface is turned off, only to find that you do not really want to shut down the computer.

SHUTDOWN-C Note that it may be too late to stop the shutdown if the shutdown has started.

Here is another command that you can try:

Pkill shutdown

10. A simple way to kill a suspended process

Imagine that you are running an unknown cause of application zombie.

You can use ' ps-ef ' to find the process and then kill or use ' htop '.

There is a quicker, 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 So what if the whole system hangs up?

Press and hold the ' Alt ' and ' SYSRQ ' on the keyboard, then slowly enter the following keys:

Reisub

You can restart your computer without pressing the power button.

11. Download YouTube Video

In general, most of us like to watch YouTube videos and also play YouTube streaming through our favorite player.

If you need to go offline for a period of time (for example, a flight from southern Scotland to the south of England) then you might want to download some videos to your storage device and watch them at your leisure.

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 click the Share link on the Youtubu video page to get the URL of the video. As long as the simple copy link is glued to the command line (to use the SHIFT + Insert shortcut yo).

Summarize

Hopefully you'll get help in this article, and find at least one of these 11 tips that will amaze you.

11 Cool Linux Terminal commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.