Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interesting and useful commands in Linux

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what are the interesting and practical commands in Linux, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.

1. Command line daily shortcut key

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

Content in front of CTRL + U cut 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 one after Words Shift + Insert paste text into the terminal

So to make the above easier to understand, take a 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" needs to be replaced with "install" in order to execute properly.

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

I can press ALT+B twice so that the cursor will be in the following position (here refers to the location of the cursor).

Sudo apt-get install programname now you can press the arrow keys twice and insert the "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!!

Sudo this command authority delegation, in their usual practice environment may encounter less, but in the enterprise environment often encounter this command. Because if you don't know, it will be painful every time you see "permission denied" after entering a long list of commands. How to use sudo!? It's simple. Imagine that you just entered the following command:

Apt-get install ranger

There is bound to be a "Permission denied" unless you have logged in to a highly privileged account.

Sudo!! The last command is run in the form of sudo. So the last order went like this:

Sudo apt-get install ranger3. Pause and run the command in the background

CTRL + Z\ pause the application

Fg\ call the program back to the front desk

Examples of use:

Suppose you are in the middle of editing with "sudo nano abc.txt" and you realize that you need to type some commands on the terminal immediately, but nano runs in the foreground so that you cannot type. You may think that the only way is to save the file, exit nano, and reopen nano after running the command.

In fact, as long as you press CTRL + Z, the command of the front desk will be paused and the screen will switch back to the command line. You can then run the command you want, and type "fg" in the terminal window after the command has been run to return to the previously paused task.

4. Use nohup to still run commands after logging out of a SSH session

The nohup command is really useful if you log in to another machine with ssh. So how do you use nohup?

For example, for testing, I used raspberry pie to download the distribution. I usually use SSH to connect to raspberry pie from my laptop. If I use raspberry pie to download large files without nohup, I have to wait until the download is complete before I can log out of the ssh session and turn off my laptop. But if so, why would I use raspberry pie to send down documents?

The method of using nohup is also simple, as in the following example, enter the command to be executed after nohup:

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 use SSH to connect to the server and keep performing pre-SSH logout tasks. Think about what happens if you need to execute the same command at a specific time. The command 'at'' will solve the situation properly. The following is an example of the use of at'.

# at 10:38 PM Friatat > cowsay 'hello'at > CTRL + D

The above command runs the program cowsay at 10:38 on Friday afternoon.

The syntax used is to append date and 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 also many date and time formats that you need to flip through 'at' 's man manual to find more ways to use it.

6. Man manual

The Man manual will outline the use of commands and parameters and teach you how to use them. The Man manual looks dull and dull. But that doesn't mean 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 set the specified governor for the man manual with the following command: export MANWIDTH=80 finally, if you have an available browser, 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 did you use to find out which process is running on the computer? I bet it's' ps' and add different parameters to it to get the different output you want.

Install 'htop'! It's definitely too late for you to meet.

Htop presents processes as lists 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 and run it.

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 command-line browsing of file systems.

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

Ranger in the command line window ranger and some other file managers are very similar, but compared to the upper and lower structure layout, it is left and right structure, which means that you press the left arrow key you will move to the previous folder, while the right arrow key will switch to the next one.

Ranger's man manual is worth reading before using it, so you can use keyboard shortcuts to manipulate ranger.

9. Cancel the shutdown

It was only after shutting down the command line or the graphical user interface that I realized that I didn't really want to turn it off.

Shutdown-c, pkill shutdown

10. A simple way to kill a pending process-xkill

When you find that the running application is dead for some unknown reason. You can use'ps-ef''to find the process and kill it or use the 'htop'' command.

There is a faster and 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 kills the process, what if the system is stuck? Simple command:

Hold down 'alt'' and 'sysrq'' on the keyboard, and then slowly type the following key: REISUB so your computer can restart without pressing the power button.

11. Download Youtube video

Generally speaking, most of us like to watch Youtube videos and stream Youtube through our favorite players. Let's share the video of watching Youtube offline, where you need to install youtube-dl. You can click the sharing link on the Youtubu video page to get the url of the video. Just simply copy the link and paste it to the command line on ok.

Youtube-dl url-to-video thank you for reading this article carefully. I hope the article "what are the interesting and practical commands in Linux" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report