TOP Command monitors system tasks and mask umask functions, topumask

Source: Internet
Author: User

TOP Command monitors system tasks and mask umask functions, topumask
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 indicates the interval between two refreshes. For example,-d 5 indicates that the interval between two refreshes is 5 seconds;
  • -I. Do Not Display idle or zombie processes;
  • -N NUM: displays the number of updates and then exits. For example,-n 5 indicates that the top node will exit after 5 data updates;
  • -P PID only monitors the ID of the specified process; PID is a value;
  • -Q: refresh without any delay;
  • -S runs in safe mode, and some mutual effect commands are disabled;
  • -S cumulative mode: outputs the total CPU time of each process, including dead sub-processes;
Interactive command key:

  • Space is updated immediately;
  • C switch to the command name display, or display the entire command (including parameters );
  • F and F add or delete display fields;
  • H ,? Displays help information about the security mode and cumulative mode;
  • K indicates the ID of the process to be killed, which is used to kill the process (the message number is 15)
  • I. Prohibit idle and zombie processes;
  • L average load switching to the display mode and normal running time;
  • M switches to the memory information and sorts it by memory usage;
  • N indicates the number of processes displayed. For example, if you enter 3, three processes are displayed on the screen;
  • O and O change the field display order;
  • R applies renice to a process and prompts you to enter the PID and renice values;
  • S changes the interval between two refreshes, in seconds;
  • T switch to display process and CPU status information;
  • A is sorted by process lifecycle, and the latest process is displayed 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, from large to small
  • S switches to the cumulative time mode;
  • T sort tasks by time/accumulation time;
  • W write the current configuration ~ /. Toprc;
The top monitoring tool displays the processes whose CPU usage is the first few, and provides 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: set the number of screen refresh times. After the refresh is completed, the system exits.
  • -Q: If you are authorized by nice, using-q can make top running faster.
  • -U replace username with the Display User ID to speed up command running
  • -H when the system is composed of multiple CPUs, the status information of individual CPUs is hidden and only the average status value is displayed.
  • -N number: set the number of processes displayed on each screen. If the number value exceeds the maximum number of processes, the setting is invalid.
  • -F filename: redirects the output to the specified file name. The default value is 16 process information.



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

Keyboard Command:
 
  • If not displayed on the final screen, press the j key to switch to the next screen.
  • If k is not displayed on the initial screen, press k to switch to the previous screen.
  • T press the k key to switch to the initial Screen
  • Q exits the execution of the top command. 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, as long as the number of active processes per CPU is not greater than 3, the system performance is good. If the number of active processes per 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 number of processes in the run, sleep, idle, and zomb statuses respectively.
  • + CPU state: the percentage of the user's time in use, the percentage of CPU time used by the system, the percentage of CPU time used by tasks whose priority is changed by nice commands, 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 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_c
  • Swap: 8289500 k av, 119824 k used, 8169676 k free 3517880 k cached
  • Memory: Memory usage statistics, including the actual (real) Memory activity value/total value, virtual Memory usage value/total value, and 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 a multi-processor system is used)
  • TTY: terminal name
  • PID: process ID
  • USERNAME: User Name
  • PRI: task priority
  • NICE: The nice value of the task. A process with a lower value has 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 is higher.
  • SIZE: the SIZE of the task code plus data plus the SIZE of the stack space.
  • RES: Total number of physical memory used by the task.
  • STATE: the status of the task.
  • TIME: The total cpu time used since the start of the task, in seconds, for example, 153: 43, corresponding to 153 seconds and 43 milliseconds
  • % WCPU: Percentage of CPU utilization weights of processes
  • % CPU: Percentage of the original CPU usage of the process. The CPU usage of the task since the last screen refresh
  • COMMAND: the name of the COMMAND that starts the process. 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.