Linux Cloud Server OPS (Operations and commands)

Source: Internet
Author: User
Tags system log cpu usage disk usage server memory

1. What is Linux server load average?

Load is used to measure the size of the server workload, that is, the length of the computer's CPU task execution queue, and the larger the value, the greater the number of processes that include running and waiting to run.

2. How do I view Linux server load?

Can be viewed through the w,top,uptime,procinfo command or through the/proc/loadavg file.
ProcInfo Tool Installation Please refer to installing the software under the Linux environment.

4. How do I check server memory usage?

Can be free,top (after execution can be sorted by shitf+m memory), vmstat,procinfo commands, or/proc/meminfo files can be viewed.

5. How can I see how much memory a single process consumes?

You can use the Top-p pid,pmap-x pid,ps aux|grep pid command, or you can view/proc/files by _id $process/status (PID of the process), such as/proc/7159/status files.

6. How do I see which services and ports are being used?

You can use the Netstat-tunlp,netstat-antup,lsof-i:port command to view.

7. How do I view server process information?

Can be viewed using the PS auxww|grep pid,ps-ef,lsof-p pid,top-p PID command.

8. How do I kill a process?

You can use the kill-9 PID (process number) to killall the program name (such as Killall cron) to kill the process.
If you want to kill a zombie process, you need to kill the process of the parent process is effective, the command is: kill-9 ppid (Ppid is the parent process ID number, can be found through Ps-o ppid PID, such as Ps-o ppid 32535).

9. How do I find a zombie process?

You can use the top command to see the total number of zombie processes (zombie), using Ps-ef | grep defunct | Grep-v grep to find information about the specific zombie process.

11. What are the common Linux server Performance view commands?
command name Description
Top Process monitoring commands to monitor the overall performance of the system.

can display system load, process, CPU, memory, paging and other information, commonly used shift+m and shift+p to sort processes by memory and CPU usage.

Vmstat System monitoring commands that focus on virtual memory, or monitor CPU, process, memory paging, and IO status information.

For example, Vmstat 3 10, outputs the result every 3 seconds, and executes 10 times.

Iostat A tool for outputting CPU status and IO status, which provides detailed information about the system's IO.

For example, IOSTAT-DXMT 10, output IO details every 10 seconds in MB format.

Df Used to check the disk space usage of the system.

For example: df-m, showing disk usage in megabytes.

Lsof Lists the files that are open in the system, and because Linux is based on a file system, this command is helpful in system administration.

For example:
lsof-i:36000, displaying a process using port 36000
Lsof-u root, showing the program running as root
Lsof-c php-fpm, displaying files opened by the PHP-FPM process
Lsof php.ini, which shows the process of opening php.ini.

Ps A process view command that can be used to display the details of a process.

The common command parameter combination, ps-ef,ps aux, is recommended to use PS-A-o to customize the output field.
For example:
Ps-a-o pid,stat,uname,%cpu,%mem,rss,args,lstart,etime |sort-k6,6-rn, output by column field and sorted in sixth field
Ps-a-O comm |sort-k1 |uniq-c|sort-k1-rn|head, which lists the processes that run the most instances.

Other commonly used commands and files, Free-m,du,uptime,w,/proc/stat,/proc/cpuinfo,/proc/meminfo.

What if the cron does not take effect?

The troubleshooting steps are as follows:
1) Confirm that the crontab is operating properly.
You can run the command crontab-e add the following test entry */1 * * * */bin/date >>/tmp/crontest 2>&1 & and then observe the/tmp/crontest file.
If there is a problem, it is recommended to use PS Aux|grep cron to find the cron pid,kill-9 PID end cron process and then restart Cron by/etc/init.d/cron start.

2) Confirm that the script path in the cron entry is the absolute path.

3) Check that the user account running Cron is correct, and see if the account is included in the/etc/cron.deny.

4) Check script execution permissions, script directory, and log file permissions.

5) It is recommended to run the script in the background, add "&" after the script entry, for example, */1 * * * */bin/date >>/tmp/crontest 2>&1 &

14. Why is the server hard disk read-only?

The common causes of hard disk read-only are as follows:
1) Full disk space
You can view disk usage through the DF-M command, and then delete the extra files to free up disk space (non-third-party files are not recommended for deletion, if necessary, please confirm);
2) The disk Inode resource is exhausted
Can be viewed through the df-i command to confirm the relevant process;
3) Hardware failure

15. How do I view Linux system logs?

The system-level log file storage path is/var/log.
The common system log is/var/log/messages.

6. How do I find large file system files?

The use of disk partitioning can be viewed first through the DF command, such as Df-m;
Then use the DU command to see the size of the specific folder, such as Du-sh./*,du-h--max-depth=1|head-10;
Use the LS command to list files and sizes, such as ls-lsh;
Alternatively, you can view the file size in a specific directory directly through the Find command, such as Find/-type f-size +10m-exec ls-lrt {};

17. How do I view the server OS version?

You can view the system version with the following commands:
Uname-a,cat/proc/version,cat/etc/issue

20. Why delete files on the Linux server, hard disk space is not released?

Sometimes, after logging on to the Linux server to execute the RM command to delete files, use the DF command to view hard disk space and find that the available hard disk space is not increased after deleting files. The reason is that when the file is deleted through the RM command, if there are other processes accessing the file through the DF command, the deleted file occupies space that is not immediately released.

Workaround:
Use root privileges to execute lsof |grep deleted, to view the PID of the process using the deleted file, and to kill the corresponding process through the command kill-9 PID.

Linux Cloud Server OPS (Operations and commands)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.