11 Linux terminal commands that surprise you

Source: Internet
Author: User
Tags manual ssh

I've been using Linux for 10 years, and I'm going to show you a series of commands, tools, and techniques from the beginning, and I hope someone tells me that from the start, not the way I've been growing.

1. command line daily system shortcuts

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

CTRL + U-cut content before the cursor

CTRL + K-cut the 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 down one space

ALT + B-Jump back to the previous space

ALT + Backspace-delete previous word

CTRL + W-cut a word before the cursor

Shift + Insert-paste text into the terminal

So to make this easier to understand, look at the following line of command.

sudo apt-get intall programname

As you can see, there is a spelling error in the command, and "Intall" should 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 referred to).

sudo apt-get^intall programname

Now you can press 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 key "SHIFT + Insert".

2. SUDO!!

If you do not know this command, I think you should thank me, because if you do not know, then every time you enter a long list of commands after the "permission denied" will be painful.

Sudo!!

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

Apt-get Install Ranger

There must be "Permission denied" unless you have logged in to an account with high enough privileges.

Sudo!! The previous command will be run in sudo. So the last command became 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 to how to run commands in the background of a terminal.

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 the nano:

sudo nano abc.txt

File edit to half you realize you need to enter some commands at the end of the terminal, but the Nano is running in the foreground so you can't type.

You might think the only way to do that 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 commands 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 is finished, enter FG in the terminal window to return to the previously paused task.

One of the most interesting attempts is to use the nano to open the file, enter something and pause the session. Then use Nano to open another file, enter something and pause the session. If you type "FG" you will go back to the second file opened with the Nano. Only by exiting the Nano and then entering "FG" will you return to the first file that was opened with the Nano.

4. Use Nohup to run commands after an SSH session has been logged

The nohup command is really useful if you are using SSH to log in to another machine.

So how do you use Nohup?

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

For example, I have sent my raspberry to download the release because of the testing needs. I would never give my raspberry pie an external monitor, keyboard or mouse.

I usually use SSH to connect to the raspberry pie from my laptop computer. If I use a raspberry pie to download a large file without nohup, I have to wait until the download is complete before I can log out of the SSH session and turn off my notebook. But if so, why would I use a raspberry to send a file?

The method of using Nohup is also simple, simply 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 the Linux command at a specific time

The ' nohup ' command is useful when you connect to the server with SSH and keep the task before the SSH logout.

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

Command ' at ' to properly resolve the situation. The following is an example of ' at ' usage.

At 10:38 PM Fri

at> cowsay ' Hello '

At> CTRL + D

The above command will run the program Cowsay in Friday 10:38 P.M..

The syntax you use is ' at ' to append the date time. When the at> prompt appears, you can enter commands that you want to run at that time.

CTRL + D returns to the terminal.

There are a lot of date and time formats that require you to flip through the man's manual at the ' at ' 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 either).

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

Export Pager=most

You need to install ' most '; she will make Your Man handbook more colourful.

You can set a designated president for the Man manual with the following command:

Export manwidth=80

Finally, if you have a browser available, you can use-H to open any man page 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. Use Htop to view and manage processes

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

Install ' Htop ' Bar! Absolutely let you encounter.

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

The simple input htop in the terminal can be run.

Htop

8. Browse the file system using Ranger

If Htop is a good helper of 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 installed you can start her at the command line by entering the following command:

Ranger

Ranger is similar to some other file managers in the Command Line window, but she is left and right compared to the upper and lower structure layouts, which means that you press the LEFT ARROW key and you move to the previous folder, and the right-hand key switches to the next one.

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

9. Cancel shutdown

Whether it's on the command line or the graphical user interface, it turns out that you're not really trying to turn off the computer.

Shutdown-c

It should be noted that if the shutdown has begun, it may be too late to stop the shutdown.

Here is another command that you can try:

Pkill shutdown

10. A simple way to kill a pending process

Imagine that you are running an application with unexplained zombie.

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

There is a quicker, easier command called Xkill.

Simply enter the following command in the terminal and click the application you want to kill in the window.

Xkill

What if the whole system hangs up?

Hold down the ' Alt ' and ' SYSRQ ' on the keyboard, and then slowly enter the following key:

Reisub

This way your computer can reboot without pressing the power button.

11. Download YouTube Video

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

If you need to go offline for a while (for example, by flying from southern Scotland to the south of England) then you may want to download some video to the storage device and watch it at your leisure 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 in the Youtubu video page. As long as a simple copy of the link in the paste to the command line on the line (to use SHIFT + Insert shortcuts yo).

Summarize

I hope you get help in this article, and find at least one of the 11 tips that you can marvel at.

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.