Common CentOS commands and common centos commands
System Command yum command
Yum makecache yum generation Cache
Yum list installed mysql * check whether the * package has been installed
Rpm-qa | grep mysql * check whether the mysql * package has been installed
Yum list mysql * check whether there is an installation package
Yum search mysql * search package
Restart
Reboot-h now
Shutdown
Shutdown-h now
-H to avoid MySql corruption
View CPU
More/proc/cpuinfo | grep "model name" # view CPU
Grep "CPU"/proc/cpuinfo # view CPU
Grep "model name"/proc/cpuinfo | cut-f2-d:
Getconf LONG_BIT # Number of CPU digits
CentOS kernel version
Uname-r
Uname-
View Processes
Ps-A: view all processes
Ps-au View Details
Ps f displays the process tree relationship
View port
Lsof-I tcp: 80 view port
Netstat-ntlp: list all ports
View memory
Grep MemTotal/proc/meminfo
Grep MemTotal/proc/meminfo | cut-f2-d:
Free-m | grep "Mem" | awk '{print $2 }'
View System Resources
Vmstat 1-S m
View hard disks and partitions
Df-h
Fdisk-l
View the software packages installed during system installation
Cat-n/root/install. log
More/root/install. log | wc-l
Check the software packages that have been installed.
Rpm-qa
Rpm-qa | wc-l
Yum list instal
View package installation path
Rpm-ql package name
Firewall
Systemctl start firewalld. service # start firewall
Systemctl stop firewalld. service # stop firewall
Systemctl disable firewalld. service # disable firewall startup
Service iptables status query Firewall status
Service iptables stop
Service iptables start
Service iptables restart
Chkconfig iptables off permanently disabled
Chkconfig iptables on enabled after permanent shutdown
Enable Port
Method 1:
/Sbin/iptables-I INPUT-p tcp-dport 80-j ACCEPT write Modification
/Etc/init. d/iptables save changes
Service iptables restart firewall, modification takes effect
Method 2:
Vi/etc/sysconfig/iptables open the configuration file and add the following statement:
-A input-p tcp-m state-state NEW-m tcp-dport 80-j ACCEPT restart firewall, Modification complete
Close the port
Method 1:
/Sbin/iptables-I INPUT-p tcp-dport 80-j DROP write Modification
/Etc/init. d/iptables save changes
Service iptables restart firewall, modification takes effect
Method 2:
Vi/etc/sysconfig/iptables open the configuration file and add the following statement:
-A input-p tcp-m state-state NEW-m tcp-dport 80-j DROP restart firewall, Modification complete
View port status
/Etc/init. d/iptables status
View Host Name
Hostname
Cat/etc/sysconfig/network
View the file content and display the row number
Cat-n test.txt
Shutdown-r now restart the system to make the settings take effect
Shutdown-h now shutdown
Reboot restart
Power off
Apache
Rpm-qa | grep httpd: Check whether apache is installed in the system.
Start and Stop apache
Service httpd start # start
Service httpd stop # disable
Service httpd restart # restart
/Etc/init. d/httpd restart is also restarted
#/Sbin/chkconfig httpd on [set the startup of the httpd service on the apache server]
#/Sbin/service httpd start [start the httpd service, which has nothing to do with startup]
MySql
Service mysqld start
Service mysqld stop
Mysql-version # view the version
Rpm name command
Rpm-q php # Whether to install PHP
Rpm-q mysql # Whether to install mysql
Rpm-q httpd # Whether to install apache
Whereis mysql # mysql installation location
Set temporary IP settings:
Ifconfig eth0 192.168.1.122
Permanent settings:
Vi/etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO = static
BROADCAST = 192.168.0.255
IPADDR = 12.168.0.33 # If you set the method for obtaining the IP address from the network adapter to static, this field specifies the IP address of the network adapter.
NETMASK = 255.255.255.0 # network mask corresponding to the network adapter
NETWORK = 192.168.0.0 # NETWORK address of the NIC
Vi/etc/sysconfig/network
NETWORKING = yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
HOSTNAME = centos (set the Host Name of the local machine. The host name set here must correspond to the host name set in/etc/hosts)
GATEWAY = 192.168.0.1 (set the IP address of the GATEWAY connected to the local machine .)
Vi/etc/resolv. conf
Nameserver is the IP address of the DNS server. The first is the first choice, and the second is the backup.
Restart the network:
Service network restart or/etc/init. d/network restart
Zip command
ZIP compression:
Cd/wwwroot
Zip-r wwwroot.zip wwwroot
ZIP:
Cd/home
Unzip wwwroot.zip