Linux system information view command collection

Linux system information viewing commands

【system】

uname -a
#View kernel/OS/CPU information

head -n 1 /etc/issue
#Check the operating system version

cat /proc/cpuinfo
#View CPU information

hostname
#View computer name

lspci -tv
#List all PCI devices

lsusb -tv
#List all USB devices

lsmod
#List loaded kernel modules

env
#View environment variables

【resource】

* Documentation: https://help.ubuntu.com/

root@ubuntu-512mb-sfo1-01:~# free -m
total used free shared buffers cached
Mem: 494 227 266 0 10 185
-/+ buffers/cache: 31 462
Swap: 0 Ask 0 0

root@ubuntu-512mb-sfo1-01:~# grep MemFree /proc/meminfo
MemFree: 272820 kB

 

free -m
#View memory usage and swap usage

df -h
#View the usage of each partition

du -sh <目录名>
#View the size of the specified directory

find . -type f -size +100M
#Find files over 100M

find . -type f -print |wc -l
#Count the number of files in the current directory

grep MemTotal /proc/meminfo
#View the total amount of memory

grep MemFree /proc/meminfo
#Check the amount of free memory

uptime
#View system running time, number of users, load

cat /proc/loadavg
#View system load

【Disks and Partitions】

mount | column -t
#View the attached partition status

code>fdisk -l

#View all partitions

swapon -s
#View all swap partitions

hdparm -i /dev/hda
#View disk parameters (only for IDE devices)

dmesg | grep IDE
#View IDE device detection status at startup

【The internet】

ifconfig
#View the properties of all network interfaces

iptables -L
#View firewall settings

route -n
#View routing table

netstat -lntp
#View all listening ports

netstat -antp
#View all established connections

netstat -s
#View network statistics

【process】

cat /proc/sys/kernel/threads-max
View the maximum number of threads allowed by the system

cat /proc/sys/kernel/pid_max
View the maximum number of processes allowed by the system

ps -ef
# view all processes

top
#Display process status in real time

ll /proc/PID/fd/
#If the process occupies too much CPU, be sure to use the command ll /proc/PID/fd/ to find it, if you can't find it, find it several times

【user】

w
#View active users

id <用户名>
#View the specified user information

last
#View user login log

cut -d: -f1 /etc/passwd
#View all users of the system

cut -d: -f1 /etc/group
#View all groups in the system

crontab -l
#View the current user's scheduled tasks

【service】

chkconfig --list
#List all system services

chkconfig --list | grep on
#List all started system services

##【CentOS Service version query]
CentOS service version query command:

1. Check the Linux Kernel version
uname -r

2. Check the CentOS version
cat /etc/redhat-release

3. Check the PHP version
php -v

4. View MySQL version
mysql -v

5. Check the Apache version
rpm -qa httpd

6. View current CPU information
cat /proc/cpuinfo

7. Check the current cpu frequency
cat /proc/cpuinfo | grep MHz

【program】

rpm -qa
# view all installedsoftwarepackage

#Restart command for common services
service memcached restart

service monit restart
service mysqld restart
service mysql restart
service httpd restart

monit start all

service nginx restart

#restart CWP
service cwpsrv restart

#restartMemcached
service memcached restart
service memcached start
service memcached stop

#boot start memcached
chkconfig memcached on

Restart httpd to make the code take effect command:
service httpd restart
service httpd start
service httpd stop

chkconfig httpd on

reload httpd command:
service httpd force-reload
service httpd reload

Nginx restart command:
/etc/init.d/nginxd restart

service nginxd force-reload
service nginxd reload
service nginxd restart

php-fpm restart command:
/etc/init.d/php-fpm restart
service php-fpm restart
service php-fpm start

Reinstall php-fpm:
sudo yum reinstall php-fpm

service mysql restart
service mysqld restart

service mysql stop
service mysqld stop

service mysql start
service mysqld start

Use the following command to see the memory usage and process memory usage ranking:
free -m
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less

mysql_upgrade executes the following commands to check and repair tables and upgrade system tables:
mysqlcheck --all-databases --check-upgrade --auto-repair

Close MySQL command:
killall mysqld

View the mysql process:
ps -ef|grep mysqld
watch -n 1 "ps -ef | grep mysql"

pid-file=/var/lib/mysql/centos-cwl.pid

The PID file path of MYSQL, KLOXO-MR can be viewed through the control panel "process":
pid-file=/var/lib/mysql/centos-512mb-sfo1-01.pid
pid-file=/var/lib/mysql/xxxx.pid

or SSH command "ps -ef" to see all processes:
check process apache with pidfile /usr/local/apache/logs/httpd.pid
check process mysql with pidfile /var/run/mysqld/mysqld.pid

You can add this line to /etc/crontab to start the command every minute to check mysql status:
* * * * * /sbin/service mysql status || service mysql start

【Monit command】

monit standard start, stop, restart commands:
/etc/init.d/monit start
/etc/init.d/monit stop
/etc/init.d/monit restart

monitnotice
Since monit is set as a daemon process, and the settings that start with the system are added to inittab, if the monit process stops, the init process will restart it, and monit monitors other services, which means that the monit monitors The service cannot be stopped using the normal method, because once stopped, monit will start it again.

To stop a service monitored by monit, a command like monit stop name should be used, for example to stop tomcat:
monit stop tomcat

To stop all services monitored by monit use:
monit stop all

To start a service you can use the command monit stop name,

To start all is:
monit start all

Set monit to start with the system and add it at the end of the /etc/inittab file
# Run monit in standard run-levels
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc

Uninstall monit:
yum remove monit

【Download and decompress】

download wordpress The latest version
wget http://zh.wordpress.org/latest-zh_CN.tar.gz

unzip
tar zxvf latest-zh_CN.tar.gz

Move the files in the wordpress folder (absolute path) to the current directory location
mv wordpress/* .

Move the /cgi-bin directory to the current directory
$mv wwwroot/cgi-bin .

Copy all files in the current directory to the previous directory
cp -rpf -f * ../

How to stop/restart/startredisServe?
If you installed redis with apt-get or yum install, you can stop/start/restart redis directly with the following commands
/etc/init.d/redis-server stop
/etc/init.d/redis-server start
/etc/init.d/redis-server restart
/etc/init.d/redis restart

If you installed redis from source code, you can restart redis through the shutdown command of redis client program redis-cli:
redis-cli -h 127.0.0.1 -p 6379 shutdown

If none of the above methods succeed in stopping redis, you can use the ultimate weapon:
kill -9

[View file location command]

See where the PHP configuration file is placed:
Use phpinfo to see that if the function is prohibited, execute it under the shell
php -v / -name php.ini
或者
find / -name php.ini

 

Generally, when linux is minimally installed, wget will not be installed by default.
yum install
yum -y install wget

System auto-upgrade is running and yum is locked.
You can force the yum process to shut down:
rm -f /var/run/yum.pid

 

Checking for perl...Perl was not found on your system: Please install perl and try again
Obviously, perl needs to be installed. The perl installation command is as follows:
yum -y install perl perl*

 

[SSH commands for Kloxo-MR control panel]

When installing a theme or plugin, it fails with "Unable to create directory"
Solution: re-change the permissions of the wp theme plugin and upload folder
For server security, 777 permissions cannot be given all, so as long as these directories are given 755 permissions, only the owner has permission to write.

If you run the following command:
sh /script/fix-chownchmod

Kloxo-MR will attempt revision ownership and permissions on files and directories in the site's document root

Kloxo-MR Control Panel: Go to "admin>Server>(localhost)>IP Address>Reread IP".

Server update
Update the server to the latest version
yum -y update

The above method has been tried many times, but there is still a problem, please enter the following repair command:
yum clean all; yum update -y; sh /script/cleanup

(The program is updating. I went to eat and came back to check later. Refreshing the ufo.org.in and img.ufo.org.in pages restored the normal functionality.)

yum clean all; yum update -y; sh /script/cleanup
service httpd restart

To ensure that the included dns records "statistics", after updating yum clean all; yum update -y; sh /script/cleanup, be sure to run:
sh /script/fixdnsaddstatsrecord

Upgrade Kloxo-MR:
yum clean all; yum update kloxomr7 -y; yum update -y

Reinstall Kloxo-MR:
If no errors are found, try the following command:
sh /script/upcp -y

Comment

Your email address will not be published. Required fields are marked with * .

Scroll to Top