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

Example Analysis of maintenance commands commonly used in Linux Operation and maintenance

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

Share

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

This article mainly shows you the "sample analysis of maintenance commands commonly used in Linux operation and maintenance", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn the article "sample analysis of maintenance commands commonly used in Linux operation and maintenance".

(1) keep the program running after the user exits

1 ctrl+z pause program

2 bg lets the program run in the background

3 you can log in by logging out of the user

(2) use the Find command to find the specified file and perform the Rm operation

[root@tiejiang ~] # find. /-name "*"-exec rm-f {}\

(3) Recursive search for the file directory containing a keyword.

[root@tiejiang] # grep-iHR "*". / *

-I ignore the case of the characters to be searched

-H also prints the file name including the search string

-R recursive search, when the specified search path is a directory, the search with-R will perform a recursive search

(4) Linux hardware time to check Hkclock-Show

Hardware time modification:

[root@tiejiang] # hwclock-- set-- date='10/11/2016 17pur07pur00'

System time is synchronized with hardware time:

[root@tiejiang] # hwclock-- hctosys

(5) Scp copy files, Key method

[root@tiejiang] # / usr/bin/ssh-x-oForwardAgent no-oPermitLocalCommand no-oClearAllForwardings yes-i/root/.ssh/iptvcp 10.0.51.198 scp-r-d-t / letv/...

(6) check the situation of multicast

[root@tiejiang ~] # netstat-ng

(7) Smarttools can obtain important parameters of hard disk.

(8) Grep exact search

[root@tiejiang ~] # grep-w 'north' install.log

(9) Expr pattern matching

Expr also has pattern matching capabilities. You can use expr to calculate the number of characters in a string by specifying the colon option. . * means that any character is repeated 0 or more times. Expr $a:'[a-zA-Z] *'

(10) Vim lines are aligned to the left

: 1 dint $left

(11) string in reverse order, string content in file in reverse order

[root@tiejiang ~] # rev + file name

(12) Sed replaces "/ File/File1" with "\ / File\ / File1"

[root@tiejiang ~] # sed-e's /\ / /\\ / / g'

[root@tiejiang ~] # sed-E-e "s:\ /:\ /: G" (written to shell file)

(13) Modprobe-V-R module name

Remove module

(14) Modprobe-V module name

Load module

(15) Lsmod | Grep module name

View the modules of related dependencies

(16) Modinfo view the information of the module and the relevant configuration parameters

Modinfo module name

(17) Ssh login is slow

Removal of dns reverse parsing

[root@tiejiang ~] # UseDNS no

(18) detailed output of Ssh connection boot

[root@tiejiang] # ssh-v

(19) how to use Pkill command

Pkill plus command name can kill command

(20) Ntpdate synchronous Server address

128.138.140.44

(21) Date command setting time

[root@tiejiang ~] # date-s 20161115

[root@tiejiang ~] # date-s 08:45:00

(22) Linux Ntpd configuration

Ntpstat checks the connection status between its own server and the server at a higher level

If appears: synchronised to local net at stratum

You need to check # server 127.127.1.0 # local clock

[root@tiejiang ~] # fudge 127.127.1.0 stratum 10 has been commented

(23) number of available memory

[root@tiejiang ~] # total-free-cache-buffer

(24) Ps-Auxww sorted by relevant usage

Because the output of ps is displayed in the order of a PID number, to sort by a certain amount of usage, you need to put an item first.

[root@tiejiang ~] # ps-auxww | awk'{print $5 and sort-r | more (sorted by memory usage)

Sort by memory from large to small

Sort processes by virtual memory from largest to smallest:

[root@tiejiang ~] # ps-eo "% C%p%z%a" | sort-K3-nr

Sort by percentage of memory actually used

[root@tiejiang ~] # ps-eo user,pid,size,pmem,vsize,command | sort-K4-nr | more

View the top 10 bits of concurrent access users

[root@tiejiang ~] # netstat-anp | grep 80 | grep ESTAB | awk'{print $5}'| awk-F':'{print $1}'| sort | uniq-c | sort-rn | head-n 10

Sort processes with high cpu traffic

[root@tiejiang ~] # ps-eo user,pid,size,pmem,vsize,command,%cpu | sort-K7-nr | more

(25) 1080p hard disk (2t capacity) will report an error when it is mounted on 115.182.51.25 (Centos system). It is initially estimated that it is due to the Linux system's limitation on the capacity of the mobile hard drive, but this did not happen when mounting my own mobile hard disk.

Error condition: "the partition table is corrupt (partition is smaller than NTFS)"

Mount ntfs on linux system

Ntfs-3f fuse needs to be installed

(26) View the files opened by the process:

[root@tiejiang] # lsof-p PID

(27) kill a process, kill a Nginx process (kill a process)

[root@tiejiang ~] # ps-ef | grep-v grep | grep nginx | awk'{print $2}'or

[root@tiejiang ~] # for i in ps aux | grep nginx | grep-v grep | awk {'print $2'}; do kill $I; done

(28) clear Linux Buffer Cache

[root@tiejiang] # sync & & echo 3 > / proc/sys/vm/drop_caches

(29) Linux tests the read and write speed of the hard disk

Time has a timing function, and dd is used to copy, read from if, and write to of. If=/dev/zero does not produce IO, so it can be used to test pure write speed. In the same way, of=/dev/null does not produce IO and can be used to test pure read speed. Bs is the size of each read or write, that is, the size of a block, and count is the number of read and write blocks.

1. Test the pure write speed of the disk on which the directory is located:

[root@tiejiang /] # time dd if=/dev/zero bs=1024 count=1000000 of=/1Gb.file

two。 Test the read-only speed of the disk on which the directory is located:

Dd if=/kvm/ftp/other/1Gb.file bs=64k | dd of=/dev/null

3. Measure the speed of reading and writing (what is this):

[root@tiejiang ~] # dd if=/vat/test of=/oradata/test1 bs=64k

In theory, the greater the number of copies, the more accurate the test.

(30) what commands are used in Crontab to define the priority of a program's execution

Nice/renice: process execution priority

Concept:

Process priority: the system allocates CPU time according to the priority of the process, and the process with high priority will get more CPU usage time to improve the speed and shorten the total execution time.

Process priority range:-20 to 19

Highest level:-20

Minimum level: 19

The system administrator has the right to set the process priority to-1 to-20, while the average user can only set 0 to 19.

The default level for a process to run is 0.

The default level of a process executed with nice is 10 (that is, nice, when no level is specified).

Format:

Nice

Nice-

Such as: (adding & after the command means to run in the background)

Vi & priority 0, the default level.

Nice vi & priority 10, the default level when executing programs using nice.

Nice-50 vi & the priority level 19-sign indicates the option, level 50 exceeds the lowest level 19, so the system executes at level 19.

Nice-18 vi & priority 18.

Nice-- 50 vi & priority-20, option value is-50, exceeding the highest level-20, so the system executes at level-20.

Nice-18 vi & priority-18.

You can view the execution of the above commands through ps-l (note that the Ni values of each vi process are different).

Reprioritize the processes that are being executed:

Adjust the level of the specified PID process

Renice

Note: it is a parameter, not an option, without a prefix-sign.

Adjust the level of all processes for the specified user

Renice...

Adjust the level of all processes for all users of the specified group

Renice-g

(31) Xargs is a common command for Unix and Unix-like operating systems. Its function is to convert the parameter list into small blocks and pass it to other commands to avoid the problem that the parameter list is too long

[root@tiejiang] # find. -name "* .foo"-print0 | xargs-0-I mv {} / tmp/trash

Use the-I parameter to replace the contents of {} with the contents of the list

(32) add a system user to an existing directory

[root@tiejiang] # useradd-d / bak_important-s / sbin/nologin tiejiang-p tiejiang

(33) Linux memory calculation

A formula: physical memory + occupied swap = free physical memory + Memory buffer + Disk Cache + used resident memory 4G + 53MB = 17MB + 46MB + 3.2GB +?

So the resident memory used is almost 700-800MB and then accumulate the amount of resident memory of those processes that you top out, which should be close to ten percent. From the performance data of your operating system, the physical memory is still very free, most of the physical memory is used by the operating system as disk cache, maybe your system IO is still a little frequent. Swap also takes up a little bit, indicating that the operating system has experienced a temporary shortage of memory, and some idle processes have been replaced with swap, but these idle processes have never been used again, so they have stayed in swap all the time.

(34) Strace

Track system calls and received signals when the program is running. The usual usage is that strace executes until the end of commande. And output the name, parameters and return values of the called system call to standard output or to the file specified by-o. Strace is a powerful debugging, analysis and diagnosis tool. You will find that he is an excellent helper when you want to debug a source code that cannot be seen or cannot be compiled.

[root@tiejiang ~] # man strace

(35) Ldd + process name View the library used by the command process

(36) Watch executes a command from time to time-N interval

[root@tiejiang ~] # watch-N1 "ps-auxww"

(37) Vncserver Xstartup Gnome start

[root@tiejiang] # vi ~ / .vnc/xstartup

[root@tiejiang ~] # gnome-session &

(38) Nmap-V-SP 192.168.0.0 Universe 24 scanned network segment survival machine.

(39) Gpt can mount more than 2T of storage space

(40) the maximum file system limit of Ext3 is 8T, so you can mount it using Ext4.

Break through the limitations of the file system

One of the obvious differences between ext4 is that it supports larger file systems, files, and subdirectories. The maximum file system supported by ext4 is 1 EB (1000 PB). Although the file system is huge by today's standards, the consumption of storage space will continue to grow, so ext4 must take into account the future development. Ext4 supports files up to 16 TB (assuming it is made up of blocks of 4KB), which is eight times the capacity of ext3.

Finally, ext4 also expands the capacity of subdirectories from 32KB to infinity. This is an extreme case, and we also need to consider the hierarchy of the file system, which has a maximum storage capacity of 1 EB. In addition, the catalog index is optimized to be similar to the hash B-tree structure, so ext4 supports faster lookups, although it is more restrictive.

The above is all the contents of the article "sample Analysis of maintenance commands commonly used in Linux Operation and maintenance". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to 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.

Share To

Servers

Wechat

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

12
Report