Linux Learning Chapter Fourth

Source: Internet
Author: User

5-1-1 Viewing system load commands

Command W or command uptime

Load average:a (average load of the system within 1 minutes), B (within 5 minutes), C (within 15 minutes)

A: How many processes are using the CPU in a minute

The value of the processor displayed by the Cat/proc/cpuinfo is the number of CPU cores

A> high load of the core


5-1-2vmstat detailed

Command Vmstat 1 5 1 seconds Display 5 times

R indicates the average number of processes using the CPU in a second

B Blocked Tasks

SWPD swap memory does not change memory stability

Free remaining memory

Buff remaining buff

Cache remaining Cache

Si:swap in memory not changing memory stability

So:swap out read from memory without changing memory stability

Bi enters memory read disk longer than 1000 problem

Bo reads from memory to write disk

In 1 seconds interrupt count

CS within 1 seconds context switch

US user-state process consumes percent of CPU

SY kernel state process consumes CPU percentage

ID Idle process consumes CPU percentage

WA waits for a process that consumes CPU percent

The percentage of St stolen is generally 0

Focus on R b si so bi bo us


5-1-3top Dynamic View Load

Command Top

Cpu (s): US sy

PR, NI value smaller priority higher virt virtual memory usage res physical memory usage shr shared memory%cpu%men (memory) Time use Cpu

Q (Exit)

TOP-BN1 Static Display

Top-d1-c One second refresh


5-1-4sar command

Sar-n DEV 1 101 seconds Display 10 times view network card traffic

RXBYT/S Inlet traffic txbyt/s out the network port traffic byt bytes

1byt=8bit

Bandwidth =byt x8

Calculate the peak x 8 for txbyt using bandwidth = view

Installing the SAR

Yum Install-y Sysstat

The SA file in the Ls/var/log/sa directory is the generated history NIC traffic

Sar-n-dev-f/var/log/sa/sa20 View network card traffic for the day of SA20

Sar-q Viewing historical load

Sar-b Viewing disks

SAR View CPU


5-1-5free Viewing memory

Free in units of K

Free-m in megabytes-G as a unit

Buffers buffer speed slower than disk faster than CPU

Cached Cache Space Size


5-1-6ps Viewing processes

PS aus

Ps-elf

vsz Virtual Memory Usage RSS physical memory where does the TTY start? is the COMMAND process name in the background

STAT indicates process state s sleep S main process < priority comparison High N priority low + foreground running process R running L locked L multithreading process Z Zombie process x dead process T paused process D cannot interrupt process

PS aux |grep php view php process no boot


5-1-7netstat Viewing network ports

NETSTAT-LNP Viewing the Listening window

Netstat-an View Status

|grep Filtration

|grep-ic Filter and Statistic quantity


5-1-8 Grab Bag tool tcpdump and Tshark

Installing tcpdump

Yum Install tcpdump

Grab bag tcpdump-nn-c 100 grab 100 packs

Tcpdump-nn-i eth1 catch eth1 network card, not add-I default catch eth0

Tcpdump-nn Port 22 catches 22 ports of communication

Plus TCP, IP, and so on are both connected with and.

-W 1.cap put the contents of the captured package into file 1.cap

Tcpdump View IP is a flow direction-W is the content of the package

Tcpdump-nn-s0 Catch the full package

Installing Tshark

Yum Install-y Wireshark

Complex command complexity for Tshark functions


5-1-9selinux Introduction

Firewall (interested to deepen research)

Cat/etc/selinux/config configuration file

SELinux has no impact on Linux security, there may be a variety of error on the Open

Enforcing fully open

Permissive Open but do not block error

Disabled off

Getenforce View Status

If SELinux is enforcing status, use Setenforce 0 to close

Setenforce 1 Open


5-2-0iptables Detailed-1

NetFilter Firewall Tool iptables Table Filter, Nat, mangle chain chain

Iptables-t FILTER-NVL View the chain, rules under the filter table

-I write rules such as iptables-t filter-i input-p TCP--dport 80-s 114.245.31.22-j reject into INPUT chain prohibit 80 port source IP to 114 ... Address of the access, deny this package

-d Delete Rule

-A and-I similar-I precedence effect

Iptables no-t defaults into the filter table

Three methods of treatment-J reject, accept, drop


5-2-1 Iptables Detailed-2

Iptables-z the data of the rules in the table 0 pkts and bytes

Iptables-f emptying the rules in the table

Service Iptables Save Save rule is not lost after reboot

Iptables-save >1.ipt specified to be saved in a 1.ipt file

Iptables-restore < 1.ipt Recovery


5-2-2iptable Detailed-3

Table Filter Nat Mangle

NAT network address translation similar to routers

Mangle the packet and then operates the package according to the tag


5-2-3iptables Detailed-4

Chain mainly with input

-I insert, rule top, highest priority

-a increases, rules down, and lowest priority

-D Delete

The master switch of the policy chain

-P modify policy such as-P INPUT ACCEPT


5-2-4cron Scheduled Tasks

Crontab-l Viewing task Schedules

Crontab-u user-l Viewing the task schedule for user users

Crontab-e into writing plans

Time, Pace, command

* * * * * *:min hour day Mon week

*/5 * * * * * Every 5 minutes every day

30 1,12,18 * * * daily 1:30, 12:30, 18:30 execution

Crontab file location/var/spool/cron/user name


5-2-5 System Services

Yum Install-y Ntsysv

NTSYSV Tuning Service Program startup

Space Select whether

tab switch to OK or cancel bar

Chkconfig--list View all program status after adding program name, only see individual program status

Chkconfig program name on all levels open

Chkconfig program name off all levels off

Chkconfig--level 345 User name on open 3, 4, 5 level

Write your own startup steps join the system's service list

Service List/etc/init.d/

Chkconfig--add Program name Add service program--del Delete


5-2-6linux Log

Core Log/var/log/messages

Cat/etc/logrotate.conf log-cut configuration file

Weekly Weekly cut

Rotate 4 reserved 4

Create creates a new

Dateext Named by date

Compress, if it's turned on, it compresses the log.

ls/etc/logrotate.d/

Cat/etc/logrotate.d/syslog log-cut configuration file

Postrotate the operation after cutting is complete

Kill-9 PID mandatory kill process PID

Ls/var/log/wtmp View log of user login history

Last to view

/log/btmp Invalid login history log

Lastb to view

/log/maillog about mail logs

/log/secure about validation related

/LOG/DMESG about Hardware

DMESG is also a command to view hardware information


5-2-7xarg and exec detailed

have similar functions

Pipeline

find/var/log/-type f-mtime +10-exec cp {}{}.bak\; Locate and copy files in the log directory for more than 10 days in BAK format original file retention

-exec change to |xargs-i cp{} {}.bak result

|xarg-i and-exec Take the result of the previous instruction and execute the next instruction.


5-2-8screen command

Nohup indicates that the command does not break the information system that generates the Nohup.out file collection process keeps the process running in the background

Nohup + Instruction

Screen is similar to Nohup

Yum install-y Screen

Screen enter creates a virtual terminal

Top Enter to execute top command

CTRL A+d temporarily quits, running in the background

Screen-ls to see the screens and screen ID numbers running in the background.

CTRL d or ESC disconnects the screen process

Screen-r +id enters the specified screen process

Screen can be created consecutively

Screen-s A enter the created screen named a


5-2-9curl command

Access to external access websites download files similar to the wget directive

Curl-i www.aminglinux.com omitting source code access page

http/1.1 200 is the status Code common status code 200,301,302,502 and so on

Curl-x Agent

Curl-o + address Download-O a renamed to a

CURL-IV + page details to give access to the steps and information

Curl-u Username:password + URL to access a Web page that requires a password


5-3-0rsync format

Synchronous data copy data supports remote copy of network communication

Remote IP A local IP B

Rsync-av a:/tmp/1.txt/tmp/Copy the remote 1.txt to the native TMP

Rsync-av/tmp/1.txt a:/tmp/Copy the local 1.txt to the TMP directory of the remote address A

: Transmission via SSHD protocol

:: Or://monitor a port via Daemon boot service to allow client to connect to local

Rsync-av A:: module name/tmp/1.txt/tmp/usage with energy: consistent


5-3-1rsync Common Options

5-3-2rsync Options Detailed

Rsync-av 111//tmp/322/Synchronize all files in the local 111 directory to the 322 directory remember to add/

-avl Synchronizing source files

command diff Compare file differences

-AVL--delete Ensure two address synchronization is identical

-avlu not synchronized after modification

-avlu--exclude= "A" except for a file is not synchronized

-avlup display a lot of synchronization information

-avlupz compression and copying speed, low bandwidth


5-3-3rsync Synchronous SSH tunnel mode

Native to remote

SSH default go 22 port

-avpz-e "Ssh-p 10022" Specify Go 10022 port sync

Telnet +ip + port number to see if the port is turned on press CTRL + "quit


5-3-4rsync Backstage Service Mode-1

Background service mode

Write configuration file is placed in etc under the start of listening to a port client and server can communicate

Vim/etc/rsyncd.conf

port=8730 (default 873)

Log File=/var/log/rsync.log

PID File=/var/run/rsync.pid

[Aming] Module name

Path=/tmp/rsync

Use Chroot=yes

Max Connections=4

Read Only=yes

List=yse

Uid=root

Gid=root

Auth users=aming

Secrets file=/etc/rs.passwd

Host allow=192.168.11.190 which client connections are allowed

You can also continue to add modules ...

To write a password after exiting

vim/etc/rs.passwd

Aming:123aaa left user name right password

chmod 400/etc/rs.passwd Password Change permission is not writable and readable only

rsync--daemon Boot

PS aux |grep rsync

NETSTART-LNP View Port

Cat/var/log/rsync.log Viewing logs

Verifying data copies

RSYNC-AVZP [email protected]::aming/1.txt./Sync 16 module 1.txt to current directory, default port 873, specify port-aczp--port 8730

Enter Password 123aaa

Complete remote Copy


5-3-5 Backstage Service Mode-2

RSYNC-AVZP--port 8730/tmp/111/[Email protected]::aming/directory Port 8730 under aming module for local 111 directory transfer to remote 16 address

Enter Password 123aaa

Note Read only modifies the read only in the configuration file.

Command ln-s a B to set a soft link to a B source file is a

-AVZPL only transfer source files

Change the configuration file use Chroot to no without restricting the transmission of the soft connection

Whether the list is allowed to view the module name

Can be set up without a password to connect the network transmission



Linux Learning Chapter Fourth

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.