Common CentOS O & M management commands
Sort out common Linux O & M and common linux management commands by yourself. Of course they are not very detailed and rich, but they are basically enough. Please leave a message to add more common Linux O & M and common linux management commands. Constantly improving ....
Command for backing up mysql Data:
/Usr/local/mysql/bin/mysqlhotcopy-u root-p 'Password' -- addtodest wehefei/data1
W # check who is online.
Last # view logon logs.
Lastlog # logon logs for all accounts.
Sudo passwd username # Change Password:
Shutdown-h now # shutdown
Shutdown-r now # restart now
Reboot # Switch off the power and restart (root permission is required). We recommend that you do not use this function.
Logout # logout command
Netstat # view network status
Sudo iptables-a input-s 117.64.88.239-j DROP # IP Address
Sudo iptables-L # view rules
Iptables-d input 1 # Delete rule 1.
Sync server time
Cp/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
Ntpdate us.pool.ntp.org
Modification time:
Date-s
Modified by string
You can modify only the date without changing the time. Enter: date-s
Modify the time only. Enter date-s 14:15:00.
Modify the date and time at the same time. Note that double quotation marks are required. There is a space between the date and time. Enter date-s "14:15:00"
After modification, enter clock-w.
Write System Time to CMOS
Install and delete the Deb package file:
Sudo apt-get autoremove name of the software package to be removed
Sudo apt-get install name of the software package to be installed
To install the. deb package
Sudo dpkg-I package_file.deb
To reinstall the. deb package
Sudo dpkg-r package_name
Static binding of the gateway MAC and IP addresses in linux:
Arp-s 61.191.xxx.x 00: 0f: e2: 50: 9e: 06
I. File directory
1. Create a directory: mkdir directory name
2. Delete the empty directory: rmdir directory name
3. Delete the subdirectory unconditionally: rm-rf directory name
4. Change the current directory: cd directory name (go to the user's home directory: cd ~; Go to the upper-level Directory: cd -)
5. view your own directory: pwd
6. view the current directory size: du
7. display the directory file list: ls-l (-a: add an implicit directory)
Blue: Directory; Green: executable file; Red: compressed file; light blue: linked file; Gray: other files; Red: Wrong link file
8. Browse File: more file name. txt; less file name. txt
9. copy the file: the target file of the cp source file (-r: Contains directory)
10. find the file: (1) find (2) locate command name
11. Link: (1) create a hard link: ln to link the source file (-d: create a directory link); (2) create a symbolic link: ln-s to link the source file
Search file: find/path-name keyword
Find uploadfile/-name '*. php'
Move: mv/path target path
Copy: cp/path target path
Decompress: tar zxvf file .tar.gz
Delete file: rm-rf/path
Query size: du-sh/path
View service: chkconfig -- list
View memory: free-m
View resources: top
Set User Group: chgrp [-R] [user group] [path]
Set User: chown [-R] [user name] [path]
Set permissions: chmod [-R] 775 [path]
User Management:
Userdel (delete)
-R is deleted along with the user's HOME directory.
For example, userdel-r test will delete the test user and delete the test directory under the/home directory.
View system account problems
Cat/etc/passwd
Cat/etc/shadow
Network problems:
View the pid that occupies the Port:
Fuser-n tcp 80
Check whether the system is under DDOS attack?
Netstat-ntu | awk '{print $5}' | cut-d:-f1 | sort | uniq-c | sort-n
Find more SYN connections:
Netstat-an | grep SYN | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-nr | more
Netstat-tln # command is used to view linux port usage
Netstat-tlnap: view the port and corresponding program.
Sudo netstat-ap # view all service ports and display the corresponding service program name
Process related:
Ps # command to get the list of current processes
Ps-e # list all processes currently running in the system
Ps aux $ provides a more detailed list
Lsof (list open files) is a tool used to list open files in the current system.
Lsof filename displays all processes that open the specified file
Lsof-a indicates that the result is displayed only when both parameters are met.
Lsof-c string displays all open files of the process whose COMMAND column contains the specified characters.
Lsof-u username: displays the files opened by the user process
Lsof-g gid: displays the processes that belong to the gid.
Lsof + d/DIR/displays files opened by processes in the directory
Lsof + D/DIR/is the same as above, but all directories under the directory will be searched for a relatively long time
Lsof-d FD displays the process of the specified file descriptor
Lsof-n does not convert the IP address to the hostname. The-n parameter is not added by default.
Lsof-I is used to display qualified Processes
Lsof-I [46] [protocol] [@ hostname | hostaddr] [: service | port]
The common form of the kill command is: the PID of the kill option.
Kill-9 PID # force process Shutdown
Kill-1 PID # suspend and clear all related processes
Disk related:
Df-h # Shows hard disk usage in common units (G, K.
Du-sh directory # Count the directory size in Linux
Du-s directory statistics directory size, display byte book
System related:
Cat/proc/cpuinfo # view CPU Information
Cat/proc/meminfo # view memory information:
Uname-a # view the system architecture:
Other commands:
Cat/etc/issue can view the version number of the currently running Ubuntu
View the current MAC address:
Ifconfig-
Packaging command:
$ Tar-zcvf/tmp/etc.tar.gz/etc
Package all the files in the/etc directory into the/tmp/etc.tar Example 1: create a full file named usr.tar in the/home directory.
$ Tar cvf usr.tar/home
Example 2: complete the sub-directories in the/home directory and compress them with the name usr.tar.gz.
$ Tar czvf usr.tar.gz/home
Example 3: Restore and decompress the backup file usr.tar.gz.
$ Tar xzvf usr.tar.gz
Example 4: The contents of the usr.tar backup file are displayed on the display in split screen mode.
$ Tar tvf usr.tar | more
To back up a file to a specific device, you only need to use the device name as the backup file name.
Compression and decompression:
Zip-r filename.zip filesdir-r recursive File
Zip-r myfile.zip./* The current directory is compressed.
Unzip file. Zip
File Editing:
Exit Vi
In the last line mode
: W
: Q
Other common commands:
1. lsof-n | grep tcmalloc query tcmalloc Installation
Change the directory owner:
Chown-R www: www data/
Chown-R www: www *
Configure DNS in ubuntu
Vi/etc/resolvconf/resolv. conf. d/tail
Nameserver 202.102.192.68
NOTE: If/etc/resolv. conf is modified, it will be overwritten at startup and must be reconfigured again.
1. Copy Data-v to display the progress.-r directory:
Cp-r-v wehefeiask.wehefei.com/home/wwwroot/
Cp 1.txt 2.txt
2. mount a mobile hard drive on ubuntu
Mkdir/media/disk
Mount-t ntfs/dev/sdb1/media/disk
If you do not need to uninstall the SDK, run the following command:
Umount/media/disk unmount
If the disk is busy
A. process of investigation and possession
# Fuser-m-v/media/disk/
/Media/disk/: 3539c
B. kill the process
# Kill-9 3539