8 Efficient Linux Terminal commands

Source: Internet
Author: User

1. Command line daily shortcut keys

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

CTRL + U The content before the cursor is clipped

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

CTRL + y – Paste

CTRL + e – Move cursor to end of line

CTRL + A – moves the cursor to the beginning of the line

ALT + F – jumps down a space

ALT + b – jumps back to the previous space

ALT + backspace– Delete the previous word

CTRL + W – cut the previous word of the cursor

Shift + insert– pasting text inside the terminal

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

Sudoapt-get Intall ProgramName

As you can see, there is a spelling error in the command, and "Intall" needs to be replaced with "install" for normal execution.

Sudoapt-get^intall ProgramName

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 (here with the position of the finger cursor)

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. Pausing and running commands in the background

CTRL + z – Pause application

fg– the program to the front desk again.

How do you use this technique?

Imagine you are editing a file with nano:

sudo nano abc.txt

File editing in 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".

3. 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/

4. ' 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.

The above command can run the 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.

5. 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

6. 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 is similar to 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, while 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.

7. 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

It is important to note that if the shutdown has started it may be too late to stop the shutdown.

Here is another command that you can try:

Pkill shutdown

8. 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.

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.

8 Efficient Linux Terminal commands

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.