Linux operating system

  
                  

For Linux systems, whether it is a central processor, memory, disk drive, keyboard, mouse, or user, etc., the Linux system management commands are the core of its normal operation. After familiarizing yourself with the common file processing commands for Linux, this session introduces commands for managing systems and users.

◆df

1. Function

The df command is used to check the disk space usage of the file system. The usage rights are all users.

2.Format

df [options]

3. Main parameters

-s: Give only the occupied data blocks for each Names parameter total.
-a: Recursively displays the number of data blocks occupied by each file in each directory and subdirectory in the specified directory. If neither -s nor -a is specified, only the number of disk blocks occupied by each directory in Names and its subdirectories is displayed.
-k: Lists disk space usage in units of 1024 bytes.
-x: Skip directories on different file systems are not counted.
-l: Calculate all file sizes, and calculate the hard link file multiple times.
-i: Display inode information instead of block usage.
-h: Prints the file system size in an easy-to-understand format, such as 136KB, 254MB, 21GB.
-P: Use the POSIX output format.
-T: Displays the file system type.

4. Description

The df command is widely used to generate usage statistics for file systems. It displays information about all file systems in the system, including total capacity and available free space. , current installation points, etc.

Super-privileged users will find this when using the df command: the capacity of a partition exceeds 100%. This is because the Linux system reserves 10% of the space for the superuser, which is dominated by it. In other words, for the super user, the hard disk capacity he sees will be 110%. This arrangement is good for system management, and the system administrator can still work when the capacity of the hard disk is close to 100%.

5. Application Examples

Linux supports a large number of file systems, including JFS, ReiserFS, ext, ext2, ext3, ISO9660, XFS, Minx, vfat, MSDOS, and so on. You can also get the file system information when you use the df -T command to view the disk space:

#df -T
File system type capacity is available. Used % Mount point
/Dev/hda7reiserfs5.2G 1.6G 3.7G 30% /
/dev/hda1vfat2.4G 1.6G 827M 66% /windows/C
/dev/hda5vfat3.0G 1.7G 1.3G 57% /windows/D< BR>/dev/hda9vfat3.0G 2.4G 566M 82% /windows/E
/dev/hda10NTFS 3.2G 573M 2.6G 18% /windows/F
/dev/hda11vfat1.6G 1.5G 23M 99% /Windows/G

In addition to the capacity and usage of the disk space, the file system type and mount point of the partition are also available.

◆top


1. Function

The top command is used to display the program process in execution. The usage rights are all users.

2.Format

top [-] [d delay] [q] [c] [S] [s] [i] [n]

3. Main Parameters

d: Specifies the interval for the update, in seconds.
q: There are no delayed updates. If the user has a superuser, the top command will be executed with the highest priority.
c: Display the complete path and name of the process.
S: Accumulation mode, which accumulates the CPU time of the sub-strokes that have been completed or disappeared.
s: Safe mode.
i: Does not display any idle (Idle) or useless (Zombie) itinerary.
n: Displays the number of updates, and will exit top when completed.

4. Description

The top command is a major command for Linux system management, through which you can get a lot of information. Here we describe the information it gives in conjunction with Figure 1.

498)this.style.width=498;">Figure 1: display of the top command

In Figure 1, the first line represents the current time, system startup time The current number of system login users, average load. The second line shows all started processes, currently running, Sleeping, and useless (Zombie) processes. The third line shows the current CPU usage. , including the proportion of system occupancy, user usage ratio, idle (Idle) ratio. The fourth line shows the use of physical memory, including the total available memory, used memory, free memory, memory occupied by the buffer. Shows swap partition usage, including total swap partition, used, free, and size for cache. The sixth line shows the most items, and the detailed explanation is listed below.

PID(Process ID ): Process identification number.

USER: User name of the process owner.
PR: Priority of the process.
NI: Priority value of the process.
VIRT: Process occupied Virtual memory value.
RES: physical memory value occupied by the process
SHR: The shared memory value used by the process.
S: The state of the process, where S means sleep, R means running, Z means zombie state, N means the process priority value is negative.
%CPU : CPU usage occupied by the process.
%MEM: The percentage of physical memory and total memory occupied by the process.
TIME+: Total CPU time taken after the process starts.
Command: Process start The name of the startup command. If this line is not displayed, the process will have a complete command line.

During the use of the top command, you can also use some interactive commands to complete the functions of other parameters. These commands are passed. The shortcut key is activated.

<Space>: Refresh immediately.
P: Sort according to the CPU usage size.
T: Sort according to time and accumulated time.
q: Exit Top command.
m: Switch display memory information.
t: Switch display process and CPU status information.
c:Switch display command name and complete command line.
M:According to memory usage size Sort.
W: Write the current settings to the ~/.toprc file. This is The recommended method of the top configuration file.

As you can see, the top command is a very powerful monitoring system tool, especially important for system administrators. However, its disadvantage is that it consumes a lot of system resources.

5.Application example

Use the top command to monitor the specified user. The default is to monitor the progress of all users. If you want to view the specified user, press "U" in the terminal. Key, then enter the username, the system will switch to the process running interface of the specified user, as shown in Figure 2. 498)this.style.width=498;">Figure 2 Use the top command to monitor the specified user


Copyright © Windows knowledge All Rights Reserved