System Command Yum command
Yum Makecache Yum Generate cache
Yum List installed mysql* see if there are any installed * packages
Rpm-qa | grep mysql* See if mysql* package is installed
Yum List mysql* See if there are any installation packages
Yum Search mysql* Find Package
Restart
Reboot-h now
For off-machine
Shutdown-h now
-H Avoid damaging MySQL
View CPU
More/proc/cpuinfo | grep "model name" #查看CPU
grep "CPU"/proc/cpuinfo #查看CPU
grep "model Name"/proc/cpuinfo | Cut-f2-d:
getconf Long_bit #CPU位数
CentOS kernel version
Uname-r
Uname-a
View process
Ps-a View All Processes
Ps-au View more information
PS F shows the process tree-like relationship
View ports
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 $} '
View system resources
Vmstat 1-s m
View hard disks and partitions
Df-h
Fdisk-l
To view the packages installed on the system
Cat-n/root/install.log
More/root/install.log | Wc-l
See which packages are now installed
Rpm-qa
Rpm-qa | Wc-l
Yum list instal
View Package Installation Path
RPM-QL Package Name
Firewall
Systemctl Start Firewalld.service #启动firewall
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动
Service iptables status Query firewall state
Service Iptables Stop Stop
Service Iptables Start
Service Iptables Restart Restart
Chkconfig iptables off permanently closed
Chkconfig iptables on permanently closed after enable
Open port
Method One:
/sbin/iptables-i input-p tcp–dport 80-j ACCEPT Write modification
/etc/init.d/iptables Save Changes
Service iptables Restart Restart Firewall, modification takes effect
Method Two:
Vi/etc/sysconfig/iptables Open the configuration file by adding the following statement:
-A input-p tcp-m state–state new-m tcp–dport 80-j ACCEPT reboot firewall, modify complete
Close port
Method One:
/sbin/iptables-i input-p tcp–dport 80-j DROP Write modification
/etc/init.d/iptables Save Changes
Service iptables Restart Restart Firewall, modification takes effect
Method Two:
Vi/etc/sysconfig/iptables Open the configuration file by adding the following statement:
-A input-p tcp-m state–state new-m tcp–dport 80-j DROP reboot firewall, modify complete
View port Status
/etc/init.d/iptables status
View Host Name
Hostname
Cat/etc/sysconfig/network
View file contents, display line numbers
Cat-n Test.txt
Shutdown-r now reboot the system for the settings to take effect
Shutdown-h now shutdown
Reboot restart
Poweroff shut down the machine
Apache
Rpm-qa |grep httpd to see if Apache is installed in the system
Apache Start stop
Service httpd Start #启动
Service httpd Stop #关闭
Service httpd Restart #重新启动
/ETC/INIT.D/HTTPD Restart is also restarted
#/sbin/chkconfig httpd on [setting Apache server httpd service boot]
#/sbin/service httpd start [Start httpd Service, independent of boot start]
Mysql
Service mysqld Start
Service Mysqld Stop
Mysql–version #查看版本
RPM Name Command
Rpm-q PHP #是否安装PHP
Rpm-q MySQL #是否安装mysql
RPM-Q httpd #是否安装 Apache
Whereis MySQL #mysql安装位置
Set the IP temp 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 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the NIC
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.0.0 #网卡对应的网络地址
Vi/etc/sysconfig/network
Networking=yes (Indicates whether the system uses a network and is generally set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (Set the hostname of this machine, the host name set here should correspond to the hostname set in/etc/hosts)
gateway=192.168.0.1 (Sets the IP address of the gateway for the native connection. )
Vi/etc/resolv.conf
NameServer is the DNS server IP address, the first is the preferred one, the second is the standby.
To restart the network:
Service network restart or/etc/init.d/network restart
Zip command
Zip compression:
Cd/wwwroot
Zip-r Wwwroot.zip Wwwroot
Zip Decompression:
Cd/home
Unzip Wwwroot.zip
Common CentOS Commands