File authorization

TXT Current file accessible to all: chmod 777 file. TXT All files and subdirectories in the current directory accessible to all: chmod -r a+r /filesCopy the code

Compression related

Tar: tar XVF filename.tar: tar CVF filename.tar dirname/. Zip: unzip filename.zip: Zip filename.zip dirname/.rar Rar a filename.zip rar e filename.zip. Gz or gunzip filename.gz Compression: gzip filename/Copy the code

Soft links

ln -s /www/test hash
Copy the code

Number of lines in. TXT files

Wc-lcw 2018-02-22.txt 2018-02-22.txt -c Indicates the number of bytes. -l Indicates the number of rows. -w Indicates the number of words counted. Example analysis: 1. The demo directory, js file number: the find demo / -name "*. Js" | wc - 2 l. Statistics all the demo directory js file lines of code: find the demo / -name "*. Js" | | xargs cat wc - l or wc -l ` find. / -name "*. Js" ` | tail - n1. 3. Statistics all the demo directory js file lines of code, filtering the empty line: find/demo - name "*. Js" | xargs cat | grep -v ^ $| wc -lCopy the code

Statistical operations

Statistical file number: the ls - lR | grep "^ -" | wc -lCopy the code

Filtering operation

Output of the process ID: ps - ef | grep 'app. Py 5000 | grep -v grep | awk' {print $2} 'Copy the code

The use of the Crontab

Syntax: crontab(option)(parameter) Parameters: -e: edit the timer Settings for the user -l: list the timer Settings for the user -r: delete the timer Settings for the user -u< user name > : Specify the user name for which the timer is to be set Timing configuration: Minute hour day Month Week Command Order: Minute Day Month week eg: Every minute */1 * * * *Copy the code

Check the system

Run the cat /etc/issue or head -n 1 /etc/issue command to view the detailed version number: lsb_release -a Command to view the kernel/OS /CPU information: uname -r Command to view all information (-a) View the CPU information: Cat /proc/cpuinfo Displays the computer name: hostname Lists all PCI devices: lSPCI-TV Lists all USB devices: lSUSb-TV Lists loaded kernel modules: lsmod Displays environment variables: env Displays the machine model: sudo dmidecode | grep "Product Name"Copy the code

See the resources

Df -h du -h --max-depth=1 / WWW # Go through the file size free -m # Check the memory usage and swap usage du -sh/WWW # Check the size of the specified directory grep MemTotal /proc/meminfo # Check the total memory capacity. Grep MemFree /proc/meminfo # Check the free memory capacity. Uptime # Check the system running time, number of users, and loadCopy the code

Check the disk

Mount /dev/sdb1/data1 mount 172.18.34.20:/data1 /data1 #Copy the code

Check the network

Iptables -l # Query firewall Settings route -n # Query routing table netstat -lntp # Query all listening ports netstat -antp # Query all established connections Netstat -s # Check network statisticsCopy the code

Check the process

Ps - ef top # # to see all process real-time display process status htop # real-time display process status pstree -p < PID > | wc - l # to check the process related threadsCopy the code

To view the user

Cut -d: -f1 /etc/passwd: cut -d: -f1 /etc/passwd -f1 /etc/group # check all groups crontab -l # check the scheduled task of the current user Sudo passwd <username> or sudo /usr/bin/passwd <username> Password: current Password Enter new UNIX Password: New password Retype new UNIX password: confirm the new passwordCopy the code

Check the service

Curl -v 'url' curl -v 'url' curl curl 'url'Copy the code

View Linux log errors

Out of Memory error: sudo grep "Out of Memory "/var/log/syslog Login log: /var/log/auto-. log Timing log: /var/log/cron information log: /var/log/messages System logs: /var/log/syslogCopy the code

Development environment Operations

To set the environment variable: export HOST='XXX' To remove the environment variable: unset HOSTCopy the code

Viewing CPU Information (Model)

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel Xeon (R) (R) E5410 @ 2.33 GHz CPU (see eight logical CPU, Also know the CPU type) cat/proc/cpuinfo | grep physical | uniq -c 4 physical id: 0 4 physical id: Getconf LONG_BIT 32 getConf LONG_BIT 32 getConf LONG_BIT 32 But do not represent the CPU does not support 64 - bit) cat/proc/cpuinfo | grep flags | grep 'lm' | wc -l 8 (results greater than zero, support 64 - bit computing. Lm refers to the long mode, support lm is a 64 - bit)Copy the code