Linux process and task management commands detailed

Source: Internet
Author: User
Tags cpu usage

Everything that runs on a Linux system can be called a process. Each user task, each system Management daemon, can be called a process. Linux uses time-sharing management to make all tasks share system resources. The following are some common commands for viewing and controlling processes.

1. PS

The PS command is the most basic and very powerful process view command. Use this command to see which processes are running and running, whether the process is over, if the process is zombie, which processes are consuming too much resources, and so on.

The basic usage of this command is as follows

PS [Options]

Among the common options are:

-E Show All processes

-F Full format

-L Long format

Example:

1, in the console input PS command, get similar to the following output:

PID TTY Time CMD

12039 pts/0 00:00:00 Bash

18710 pts/0 00:00:00 PS

This command displays the execution process for the currently logged-on user. The items displayed are divided into four items, followed by the PID (process ID), TTY (terminal name), time (Process execution), and CMD (the process's command-line input).

2. Enter the following command on the console:

Ps–ef

UID PID PPID C stime TTY time CMD

Root 1 0 0 Jan14? 00:00:05 Init

Root 2 1 0 Jan14? 00:00:00 [Keventd]

Root 3 1 0 Jan14? 00:00:00 [KAPMD]

.......................

This command displays information about all the execution processes. The items displayed are in turn the UID (the user ID of the executing process) PID (process id), PPID (parent process ID), TTY (terminal name), stime (process start time), time (Process execution times), CMD (the process's command-line input).

This command has more output and can be used for more than the grep command for easy viewing, such as:

Ps–ef|grep Oracle

Displays only the output lines that contain Oracle, and you can query all processes that the user of the executing process is Oracle.

2, Top

The basic function of the top command and the PS command is the same, showing the current process and other conditions of the system. But top is a dynamic display process in which the current state can be refreshed continuously by user interaction. The command parameters for top are not important, so simply enter the command to view the running state of the system.

You can use interactive commands during the top command execution. From a usage point of view, mastering these commands is more important than mastering the options. These commands are all single letter, commonly used commands are:

< space > Immediate refresh Display

H or? Show help screen give some short command summary instructions

M Toggle Display Memory Information

T toggle display process and CPU state information

C Toggle Display command name and full command line

M sort based on the size of the resident memory

P sort based on percentage size of CPU usage

Q exit

3. Kill

The KILL command can be used to terminate a background process. The KILL command ends a process by sending a specified signal to the process. The KILL command has a simple syntax format, which is roughly in the following two ways:

(1) Kill [s signal] process number

The signals emitted can be either a signal name or a corresponding number.

such as: kill-9 1234 command, will terminate the PID (process number) of the process of 1234.

(2), kill-l

This command displays a list of signals

4. Cron

Cron commands are used to accomplish timed tasks, such as tasks that are performed daily (processes). Cron commands should not be started manually. In general, cron commands are started automatically by a shell script when the system is started. After startup, the cron command searches the/var/spool/cron directory for the crontab file named after the user name in the/etc/passwd file, and the found file is loaded into memory. For example, a user named users of the user it corresponds to the crontab file should be/var/spool/cron/user. In other words, the crontab file named by the user is stored under the/var/spool/cron directory. The cron command will also search for the/etc/crontab file, which is written in a different format. After Cron starts it will first check if a user has set up the crontab, Release system resources If the file is not in hibernation it wakes up every minute to see if there are any commands you want to run at this time.

You can use the Crontab–l command to view current cron tasks that already exist.

Disk and file System management commands
Management file system is actually quite complex work, this article will only describe the day-to-day maintenance needs of some management commands, the main contents are: Mount and uninstall hard disk partitions.

1. DF

The DF command displays the disk space remaining on the current disk, and the commonly used parameter is-K, such as:

Df–k

This statement displays disk space usage for each partition.

2. Mount and Umount

The mount command has many parameters, most of which are not used in daily work. The most common uses of the Mount command are as follows:

mount [options] Device directory

One of the most common options is

-A to mount the file systems listed in the/etc/fstab file.

The command to mount the floppy drive and the CD drive is simpler, and you can enter the following command directly:

Mount/mnt/cdrom

Mount/mnt/floppy

The Umount command is used to uninstall a file system with the following format:

Umount [F] Directory

Where directory is the name of the catalog to be uninstalled.

The Umount command has one disadvantage: If the file system is in use (that is, someone opened the file on that partition), you cannot uninstall the file system. You can use the and-F parameters to force the uninstall operation, of course, this operation may cause loss of user data, such as:

Umount-f/mnt/cdrom

This command will force uninstall of the file system that is mounted in the/mnt/cdrom directory

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.