< training | 11th day > Learn about processes in Linux, file lookups, file compression and IO redirection

Source: Internet
Author: User

[[Email protected]~]# Preface
In future work, the daily routine of operations engineers is to use free-m,top,uptime,df-h ...
Check the server every day to see if there are any exceptions. So today we will talk about the operations of the engineer's routine business knowledge!

The 11th day of the classes:

[email protected]~]# today's Course outline
    1. Viewing processes, interrupting processes, switching processes
    2. Memory and Swap partitions
    3. The basic method of file lookup in Linux
    4. How to unzip a file in Linux
    5. Knowledge points about I/O redirection
    6. Remote SCP Mate Pipeline

Detailed Explanation:

[[Email protected]~]# viewing processes, interrupting processes, switching processes
  
① View process, we generally use PS or top to view, PS can see the current terminal running process.
Ps-ef and PS aux can view all the processes of the current system, top can also view the running processes, by M to sort by memory, p according to CPU usage.

② interrupt process, when using top to view the current process, we can end a process with the Kill + PID. You can also use the Pkill/killall + process name,
However, this approach is minimal or not, as you will kill an important process that contains the name of your process, unless you are very sure of the situation.

It is necessary to say kill's understanding that the nature of kill is not to end the process, many people will understand to kill.

But that's what we're saying, kill is actually sending a signal to the process-1 signal restart,-15 signal is to let the process itself out,-9 signal is the system forces the end of a process. We generally try to be as cautious as possible-9, for reasons you can imagine.

③ background Task Process switch, if we use the command: Firefox &, this means that we start Firefox, but it is background boot, we can use jobs to view the current background running tasks, FG%num can put Firefox in the foreground to run, Use CTRL + C only to terminate Firefox. We can also use CTRL + Z to stop the current Firefox, you can use the BG%num to solve the stop state. The kill process, which we can also use kill +num to end a task.

[[Email protected]~]# memory and Swap partitions
In Linux, memory is also a very important aspect, and we can use FREE-M to see the current memory usage.
This is also an operations engineer must pay attention to every day.
We can see our memory usage, so do you know how much clean memory and total memory I can use in my system now?
Clean Memory =free=1392, a total of memory =free+cached=1392+177 can be used, this value is close to 1595,
So we can look at 1595 of that value every day to estimate the memory situation.

there is a swap partition, the existence of this partition is to alleviate our Linux system memory shortage situation, when the memory usage in our system is scarce, this time the system will be the swap partition temporarily as memory to use, About the size of the swap partition setting we can control according to the actual memory of the computer, generally is twice times the actual memory.

[[Email protected]~]# the basic method of file lookup in Linux
Files found in Linux is a very important skill, an OPS engineer to do what they want in the system to find their own files.
The file lookup methods that we often use in Linux are find and locate. ①find command. Many many parameters, I will simply write a few, if you do not understand the man manual can be viewed.

Find/file path-name "*.iso" Lookup by file name

Find/file path-iname "*.iso" lookup is case insensitive

Find/file path-inum "num" finds hard-linked files through Inodenum

Find/file path-size +4g look for files larger than 4G

Find/file path-perm 777 look for a file with permission 777

② through locate to find files, locate-b + Direct file name, find out is with the file path together check.

Here I say the difference between find and locate: The Find file principle is to scan the disk, locate find the file is the principle of finding their own database, so find the speed is slow, but the file search accuracy, locate faster, but the update is slow. Locate will perform periodic tasks every day to update its own database, if you create a new file now, through the locate is not found, perhaps tomorrow morning you can find out.

[[Email protected]~]# How to unzip a file in Linux
The concept of packaging and compression in Linux is a completely different concept, so don't mix it up by putting a few files together, and compression is the same concept as compression in Windows.
Windows and Linux file sharing, both systems recognize the file format is zip, so the zip file transfer is the best, zip A.zip,unzip a.zip.

The compressed file format commonly used in Linux is GZ and dz2, and I say they create a compressed file-specific process: Create a tar Package---compress the TAR package--and unpack the tar package--and unpack the tar package, but in practice we don't have to step through it, just two steps in the end.

①gz format: Tar czvf a.tar.gz b/tar xvf a.tar.gz, respectively, in GZ format compression and decompression.

②DZ2 format: Tar cjvf a.tar.dz2 b/tar xvf a.tar.dz2, respectively, compression and decompression in DZ2 format.

In fact, you can see that the decompression is the same, because when the decompression will automatically determine the format of the compressed package. When extracting, we can use the parameter-C to determine the path of decompression.

We can look at the contents of the compressed package without pressure, tar tf a.tar.gz, can also extract one of the files out, tar xvf a.tar.gz b/a.txt.

[[Email protected]~]# knowledge points about I/O redirection
In Linux, we have three standard input and output, standard output stdout, standard error output stderr, standard input stdin, their file descriptors are 1,2,0 respectively. An example is shown below:
Example said: A.txt exists, B.txt does not exist, when using LS, B.txt is stdout,a.txt is stdout, so all redirect &> to Io.txt, will show an error, a normal.

Here is the keyboard input, the pipe input is the standard input. A here document and here String that you need to know about Linux.

Here document:cat>file<<eof, we enter from the keyboard and then become a file content.

Here string:bc<<<12+23, which means that the calculator reads the data from the string for calculation.

[[Email protected]~]# remote SCP Mate pipeline
We generally use SCP to remotely copy files, the General command is: SCP [email protected] Address:/path/path.
Said SCP, have to talk about SSH, in many cases, we need to SSH to the remote server, repair maintenance and so on.
In many cases, we can use SSH by default without logging on for remote monitoring:
For example: SSH [email protected] "uptime" to see how long the system has been running, uptime can also be replaced by various commands. Look, my server has been running for 182 days.
Of course, we can also use SSH for remote file compression copy transfer:
SSH [email protected] Address "CD/&& tar-c Directory | Gzip-f "|tar-xzf-
This means that a tar package is created remotely, compressed using gzip, and then transferred to the local by pipeline redirection. Compressed file transfer, a lot of traffic left.

Summarize:

[[Email protected]~]# It guy from Love family love wife
Today's focus is the process and document search, as well as redirect, I hope everyone to study hard, day up! Favorite friends can order a subscription, thank you very much for your support!
Blog Park: Love family love wife's it male QQ Group: Public Number: program ape Wild Banana "get the tool that appears in the article"

< training | 11th day > Learn about processes in Linux, file lookups, file compression and IO redirection

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.