In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is about Linux practical but very small 11 cool terminal command is how, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.
Command Line Daily System Shortcuts
The following shortcuts are very useful and can greatly improve your productivity:
CTRL + U -Cuts the contents of the cursor
CTRL + K -Cuts 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 the previous word
CTRL + W -Cuts one word after the cursor
Shift + Insert -Paste text into terminal
To make this easier to understand, consider the following 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" for proper execution.
Now imagine that the cursor is at the end of the line. There are many ways to push it back to the word install and replace it.
I can press ALT+B twice so that the cursor will be in the following position.
sudo apt-get^intall programname
Now you can press the arrow keys twice and insert "s" into install.
If you want to copy text from the browser to the terminal, you can use the shortcut key "shift + insert."
SUDO !!
If you don't know this command, I think you should thank me, because if you don't, you're going to suffer every time you type a long command and see "permission denied."
sudo !!
How to use sudo !!? It's simple. Imagine that you have just typed the following command:
apt-get install ranger
"Permission denied" will appear unless you are logged into a sufficiently high-level account.
sudo !! The last command will be executed as sudo. So the last command went like this:
sudo apt-get install ranger
If you don't know what sudo is, poke here.
Pause and run commands in the background
I once wrote a guide on how to run commands in the background of a terminal.
CTRL + Z -Pause the application
fg -Recalls the program to the foreground
How to use this technique?
Imagine you are editing a file with nano:
Halfway through editing the sudo nano abc.txt file you realize you need to type something right away on the terminal, but nano is running in the foreground so you can't type.
You may feel that the only way to save the file is to exit nano, run the command, and then reopen nano.
In fact, you just press CTRL + Z, the foreground command will pause, the screen will switch back to the command line. Then you can run the command you want to run, and when it's done, type "fg" in the terminal window to go back to the task you suspended.
One interesting experiment is to open a file with nano, type something and pause the session. Open another file with nano, type something, and pause the session. If you type "fg" you will go back to the second file opened with nano. Only by exiting nano and typing "fg" will you return to *** files opened with nano.
Use nohup to run commands after logging out of an SSH session
The nohup command is really useful if you log in to another machine using ssh.
How to use nohup?
Imagine you use ssh to remotely log on to another computer, you run a very time-consuming command and exit the ssh session, but the command is still executing. Nohup can make this scenario a reality.
For example, for testing purposes, I used my raspberry pie to download the distribution. I would never give my Raspberry Pi an external monitor, keyboard or mouse.
Generally I always use SSH to connect from laptop to Raspberry Pi. If I download large files using my raspberry pi without nohup, I have to wait until the download is complete before logging out of the ssh session. But if so, why would I use Raspberry Pi for files?
The nohup method is also simple, just enter the command 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 &
Run Linux commands 'at' specific times
The 'nohup' command is useful when you connect to a server using SSH and keep performing SSH pre-log tasks on it.
Think about what you would do if you had to execute the same command at a certain time.
The command 'at' will resolve the situation properly. Here is an example of using 'at'.
at 10:38 PM Friat> cowsay 'hello' at> CTRL + D The command above runs cowsay on Friday at 10:38 PM.
The syntax used is to append the 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 Terminal.
There are also many date and time formats that require you to flip through the at man manual to find more ways to use them.
Man page
The Man manual will outline commands and parameters for you and teach you how to use them. The Man manual looks dull and dull. (I suppose they weren't designed to entertain us either.)
But that doesn't mean you can't do something to make them beautiful.
export PAGER=most You need to install 'most'; it will make your man manual more colorful.
You can set the specified line length for the man manual with the following command:
export MANWIDTH=80 *** 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.
View and manage processes with htop
Which command do you use to find out what processes are running on your computer? I bet it's 'ps' and add different parameters to it to get the different outputs you want.
Install 'htop'! Absolutely let you meet hate late.
htop presents processes as lists in the terminal, somewhat similar to Task Manager in Windows. You can use combinations of function keys to toggle the arrangement and items displayed. You can also kill processes directly in htop.
Simply enter htop in the terminal to run.
htop
Browse file systems using ranger
If htop is a good helper for command-line process control, ranger is a good helper for command-line browsing of file systems.
You may need to install it before you can use it, but once it is installed, you can start it by typing the following command on the command line:
Ranger is similar to other file managers in the command line window, but it has a left-right structure rather than a top-down structure, which means that if you press the left arrow key you will advance to the previous folder, while the right arrow key will switch to the next.
The ranger man manual is worth reading before you use it, so you can use shortcut keys to operate ranger.
Cancel shutdown
After shutting down either on the command line or in the graphical user interface, you realize you don't really want to shut down.
shutdown -c Note that if shutdown has already started, it may be too late to stop shutdown.
Here is another command you can try:
pkill shutdown
Easy way to kill a pending process
Imagine an application you're running dies for no apparent reason.
You can use 'ps -ef' to find the process and kill it or 'htop'.
There is a faster and easier command called xkill.
Simply type the following command into the terminal and click on the application you want to kill in the window.
Xkill What if the whole system crashes?
Press and hold 'alt' and 'sysrq' on the keyboard, then slowly type the following keys:
REISUB
This way you can restart your computer without pressing the power button.
download YouTube videos
In general, most of us like to watch YouTube videos and stream YouTube through our favorite players.
If you need to be offline for a while (say, flying from southern Scotland to southern England) then you might want to download some videos to your storage device for viewing at leisure.
All you have to do is install youtube-dl from the package manager.
You can use youtube-dl with:
youtube-dl url-to-video
You can click the share link on Youtubu's video page to get the url of the video. Simply copy the link and paste it to the command line (shift + insert).
The above is how the 11 cool terminal commands in Linux are practical but very small. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.