16 useful Linux command line tips __linux

Source: Internet
Author: User
Tags cpu usage
16 useful Linux command line tips

We use the Linux command line every day, but we may forget some of the Linux command line tips because we don't have much practice. In this article, I'll show you some of the Linux command-line tips that you might forget or might be newer to you. Now let's get started.


1. Display the output as a table


Because the strings are too crowded and sometimes it's painful to read the output, such as the result of the Mount command, how do you view the output like a table? This is an easy job to use:






OK, in this example, we see that the output format is neat because they are separated by spaces. But what if the separator is something else, like a colon? The/etc/passwd document is a good example. At this point, just use the-s parameter to specify the separator:






2. Run until successful


If you search for this technique on Google, you will find a lot of questions about how to repeat the command until it returns to a successful and normal operation, such as pinging the server, Until it returns to normal or checks to see if a file with a specific extension has been uploaded to a specific directory or if a particular URL is available or does something that any geek would do, and so on. At this point, you can use the while true loop to implement it:




redirect normal output and errors to/dev/null using the >/dev/null 2>&1. Actually, it's one of the coolest Linux command-line tips for me.


3. Use (Memory-CPU) usage to sort processes


Sort by memory usage:




Sort by CPU Usage:




4. Check your architecture (or 64)




5. Monitor multiple log files simultaneously


You can use the tail command to view the log. This is good, but sometimes you may need to monitor multiple log files simultaneously to take some action. Use the Multitail command, which supports text highlighting, filtering, and many other features.




If your system is not on, you can install it in the following ways:




6. Return to previous directory


It's not a trick, but some people forget it, and some people use it all the time. Simply type cd– and you will return to the previous directory.


7. Make non-interactive into an interactive shell session


To do this, put our settings in the ~/.bash_profile file from ~/.BASHRC.


8. Observe the output of the command


With the Watch command, you can observe the output of any command, for example, observe the available space and its growth:




You can do more with variable data, because you can use the Watch command to observe them.


9. Operating procedures after closing a session


When you run the program in the background and close the shell, the program will definitely be killed. But what if the program continues to run after you close the shell? This can be resolved by the Nohup command, and the nohup represents no suspension.




This command is indeed one of the most useful Linux command-line tips for most webmasters.




Use this command to generate a file named Nohup.out in the same directory that contains the output of the running program.




That's a cool order, right.


10. Answering robot using the Yes&no command


For those who need the user to say yes to the command, it's like an answering robot. This can be achieved by using the Yes command:




If you want to automatically say no, you can also use the following command to implement it:






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.