Function of TOP command to monitor system tasks and mask umask

Source: Internet
Author: User

Function of TOP command to monitor system tasks and mask umask
Top command usage and parameters;
Top selection parameters
Parameters:
-B runs in batch mode, but cannot accept command line input.-c displays the command line, not just the command name.-d N shows the interval between two refresh times, for example,-d 5 indicates that the interval between two refreshes is 5 seconds.-I indicates that idle or zombie processes are prohibited.-n indicates that NUM indicates the number of updates and then exits. For example,-n 5 indicates that the top five data updates will exit;-p PID only monitors the ID of the specified process; PID is a value;-q will be refreshed without any delay; run in-s safe mode, disable some valid mutual commands, and output the total CPU time of each process in-S cumulative mode, including dead sub-processes, and interactive command key bit:

Space is updated immediately; c is switched to the command name display, or the entire command (including parameters) is displayed; f, F is added to the display field, or the display field is deleted; h ,? Displays help information about the security mode and accumulation mode. k indicates the ID of the process to be killed, which is used to kill the process (the message number is 15). I disable idle and zombie processes; l average load and normal running time for switching to the display mode; m is switched to the memory information and sorted by memory usage; n is the number of processes displayed, for example, input 3, three processes are displayed on the screen; o and O change the order of the display fields; r applies renice to a process, prompting you to enter the PID and renice values; s changes the interval between two refreshes, in seconds; t switches to display the process and CPU status information; A is sorted by the process life size, and the latest process is shown at the beginning; M is sorted by memory usage, from large to small; N is sorted by process ID size, from large to small; P is sorted by CPU usage, and switched from large to small to the cumulative time mode; T sorts tasks by time/accumulation time; W writes the current configuration ~ /. Toprc; top monitoring tool can display the processes whose CPU usage is the first few, and provide real-time CPU Activity

Syntax and parameter description

Usage: top-hvbcisqS-d delay-p pid-n iterations

-S time sets the screen refresh latency, in seconds. The default value is 5 seconds.-d count sets the number of screen refresh times. After the refresh is completed, the system exits.-If the refresh request is nice, -q can be used to make top running faster-u can replace username with the displayed User ID to improve command Running Speed-h when the system has multiple CPUs, the status information of an individual CPU is hidden. Only the average status value is displayed.-n number indicates the number of processes displayed on each screen. The number value exceeds the maximum number of processes, invalid-f filename is set to redirect the output to the specified file name. The default value is 16 processes.

Screen Control Command: when multiple screen content is displayed, you can use the following command

Keyboard Command:

If not, press the j key to switch to the next screen. If not, press the k key to switch to the previous screen t press the k key to switch to the original screen q exit top Command Execution, you can enter the q key at any time
System Information:
14:50:01 up 83 days, 10 min, 0 users, load average: 0.75, 0.86, 0.86
164 processes: 160 sleeping, 4 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
Total 38.3% 0.0% 19.4% 0.0% 0.0% 0.7% 41.5%
Cpu00 70.8% 0.0% 26.2% 0.0% 0.0% 0.0%
Cpu01 51.4% 0.0% 33.0% 0.0% 0.0% 0.9%
Cpu02 25.2% 0.0% 17.4% 0.0% 0.0% 0.0% 57.2%
Cpu03 5.8% 0.0% 0.9% 0.0% 0.0% 1.9%
The first line shows the system information, including:

+ System: system name and current date. + Load averages: average Load for 1 minute, 5 minutes, and 15 minutes. Generally, the system performance is good as long as the number of active processes per CPU is not greater than 3, if the number of tasks of each CPU is greater than 5, it indicates that the performance of this machine has a serious problem + the total number of processes in the last update, and the run (run) are listed separately) number of processes in sleep, idle, and zomb States + CPU state: the percentage of time consumed by the user, the percentage of CPU time used by the system, the percentage of CPU time used by the task whose priority is changed by nice command, and the percentage of CPU idle time. (Tasks whose priorities are changed by nice commands only refer to those tasks whose nice values are negative ). The time spent on tasks whose priorities are changed by nice commands will also be calculated in the system and user time. Therefore, the total time may exceed + avg: average value of active processes (listed only when a multi-processor system is used ). memory information Mem: 4115792 k av, 4056080 k used, 59712 k free, 0 k shrd, 7072 k buff 2950040 k actv, 263064 k in_d, 82612 k in_cSwap: 8289500 k av, 119824 k used, 8169676 k free 3517880 k cachedMemory: memory usage statistics, including the actual (real) memory activity value/total value, virtual) memory usage/total value, remaining memory. Process Information
Pid user pri ni size rss share stat % CPU % MEM TIME CPU COMMAND
26359 oracle 16 0 687 M 686 M 685 m s 0.5 17.0 0 oracle
25427 oracle 16 0 504 M 503 M 502 m s 0.5 12.5 3 oracle
1605 oracle 24 0 10516 9.9 M 8848 S 0.1 0: 00 3 oracle
1607 oracle 24 0 10500 9.8 M 8832 S 0.1 0: 00 1 oracle
1 root 15 0 492 460 S 436 0.0 1 init
2 root RT 0 0 0 SW 0.0 0.0 0: 00 0 migration/0
3 root RT 0 0 0 SW 0.0 0.0 0: 00 1 migration/1
4 root RT 0 0 0 SW 0.0 0.0 2 migration/2
5 root RT 0 0 0 SW 0.0 0.0 0: 00 3 migration/3
6 root 15 0 0 0 SW 0.0 0.0 0: 00 1 keventd
7 root 34 19 0 0 0 SWN 0.0 0: 00 0 ksoftirqd/0
8 root 34 19 0 0 0 SWN 0.0 0: 00 1 ksoftirqd/1

Lists the information of each processor in the system. When the information cannot be displayed on one screen, it is divided into multiple screens for display. You can refer to the preceding commands for viewing the information of l, k, and t.

 

CPU: processor number (listed only when the multi-processor system is used) TTY: terminal name PID: Process number USERNAME: User Name PRI: task priority NICE: Task nice value, A process with a lower value will have priority on the system. You can increase the speed of some processes by changing the nice value, but this is actually a transaction, because the processes whose nice value is elevated will run slowly at this time. NI is a Nice value, PR is a priority, and Nice value is an attribute of the process. PR is sorted by NICE. The rule is that the smaller the NICE value, the smaller the PR value (the smaller the value, the higher the priority ), if NICE is the same, the priority of the Process gid or uid is root. larger SIZE: the task code plus data plus the SIZE of the stack space. RES: Total number of physical memory used by the task. STATE: Task status TIME: total cpu time used since the start of the task, in seconds, for example, 153: 43, corresponding to 153 seconds 43 ms % WCPU: CPU usage weight % CPU: Percentage of the original CPU usage of the process, the CPU usage of the task since the last screen refresh COMMAND: The COMMAND name of the process to start. If the name is too long

 





Linux permission mask umask

A permission mask umask
Umask is supported by chmod. It has a total of four bits (gid/uid, owner, group permission, and permissions of other users), but the last three are usually used, for example, if you use chmod 755 file (the permission for this file is Master read (4) + write (2) + execute (1), the same group and other users have read and write permissions)

 

Role of binary umask
By default, the umask value is 022 (which can be viewed using the umask command). The default permission for the created file is 644 (6---2 ), the default permission for the Created directory is 755 (7---2). You can use ls-l to verify it. Now you should know the usage of umask, it is used to control the default permissions. Do not assign full permissions to the default files and directories.

 

3. How to calculate the umask value

The umask command allows you to set the default mode when creating a file. Each type of user (file owner, users in the same group, and other users) has a number in the corresponding umask value. For files, the maximum value of this number is 6. The system does not allow you to grant the execution permission when creating a text file. You must use the chmod command to add this permission after the creation. Directory allows you to set the execution permission. For the directory, the maximum number of umask numbers is 7.

Calculation of u m a s k value: we only need to remember that u m a s k is to "take away" the corresponding bit from the permission.

Umask value and permission table

 

A user in Umask

File

Directory

0

6

7

1

6

6

2

4

5

3

4

4

4

2

3

5

2

2

6

0

1

7

0

0

 

If umask is set to 023, No permissions are granted to the file owner. By default, no execution permission is granted to the newly created file, so rw-(6) is assigned to the file owner ); for the group owner, the write permission is granted. If the group owner has no execution permission, the permission is r -- (4). For other users, the write and execution permissions are granted. The group owner has no execution permission, so it is r -- (4 );

If umask is set to 023, the execution permission is not restricted because no new directory is created. If the directory owner does not have any permissions, the permission for the directory owner is rwx (7). For the group owner, the permission for writing is r-x (5 ); for other users, the write and execution permissions are granted, so r -- (4 );

 

Four Common u m a s K values and corresponding file and directory permissions

 

Umask

Directory

File

0 2 2

7 5

6 4 4

0 2 7

7 5 0

6 4 0

0 0 2

7 7 5

6 6 4

0 0 6

7 7 1

6 6 0

0 0 7

7 7 0

6 6 0

 

 

5. Modify umask values
After you understand the role of umask, you can modify the umask value. For example, umask 024 sets the default permissions for files and directories created later to 642 and 753.

 

6. Save the umask value to the Environment File
To change the umask value for a long time, you can write it into/etc/profile or ~ /. Profile or ~ /. Bash_profile.


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.