DAY07 Linux disk partition, Ps,kill,df,top command uses

Source: Internet
Author: User
Tags cpu usage pkill

Day07
Access to single-user mode delete password does not enter system problem:

Selinux=disabled


Operating system Linux boot process
Power-up
Bios
Find Boot Media
First sector (MBR) Read first
Grup
Find kernel loaded into memory
Execute a program init

Top
The top command is used to display the program process in progress, and the permissions are all users.
D: Specifies the interval of the update, in seconds.
C: Displays the full path and name of the process.
I: Do not display any idle (idle) or useless (Zombie) travel.
N: Displays the number of updates and exits top when finished.


The first line represents the command time, the current time, the system run time, the current number of system logon users, the 1/5/10 minute system average load (generally, this load value should not be more than 1, unless your system is busy. If it lasts above 5, then ..... Take a closer look at how the program is affecting the overall system! )。

The second line shows all processes started, currently running, suspended (sleeping), and useless (Zombie). (The comparison needs to be noted is the last zombie that value, if not 0, hey!) Take a good look at the end of the process and become a corpse, right? (Stop mode: The sleep process should be different, sleep will actively abandon the CPU, and stop is passively discard the CPU, example of single-step tracking, Stop (pause) process is unable to return to the running state)

The third line shows the current CPU usage, including the US user space consumption CPU percentage, the SY core space consumption cpu percentage, the NI user process space has changed the priority of the process occupied CPU percentage (interrupt processing Occupation), the ID idle CPU percentage, WA Waiting for the input and output of the CPU time percentage, hi,si,st the meaning of the directory is unclear:)

Row four shows the use of physical memory, including total available memory, used memory, free memory, and memory consumed by the buffer.

The five rows show the swap partition usage, including the total swap partition, used, idle, and the size used for the cache.

Line six shows the most items, and the detailed explanations are listed below.

PID (Process ID): Process identification Number (ID per process)

User: The username of the process owner (the consumer of which this process belongs)

PR: The priority level of the process (shorthand for priority, the order of precedence of the program, the smaller the sooner executed)

NI: The priority value of the process (the shorthand for Nice, which is related to the precedence, is also smaller and is executed sooner)

VIRT: The virtual memory value that the process occupies.

RES: The physical memory value that the process occupies.

SHR: Shared memory value used by the process.

S: The state of the process, where s indicates hibernation, R is running, Z represents a zombie state, and N indicates that the process precedence value is negative.

%CPU: The CPU usage that the process consumes.

%MEM: The percentage of physical memory and total memory that the process occupies.

Time+: Total CPU time taken up after the process is started (cumulative CPU usage time)

Command: The start command name of the process startup, and if this line does not appear, the process will have a full command line.

While the top command is in use, you can also use some interactive commands to complete the functionality of other parameters. These commands are started by using shortcut keys.

Space: Refresh now.

P: Sort According to CPU usage size.

T: Sort by time, cumulative time.

Q: Exit the top command.

M: Toggles display memory information.

T: Toggles display of process and CPU status information.

C: Toggle display command name and full command line.

M: Sorts according to the size of the memory used.

W: Writes the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.

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

5. Application examples

You can use the top command to monitor a specified user, and the default is to monitor processes for all users. If you want to see the situation of the specified user, press the "U" key in the terminal, and then enter the user name, the system will switch to the specified user's process run interface, as shown in Figure 2.

A. Role

The free command is used to display memory usage, and the use of permissions is for all users.

B. Format

free [-b|-k|-m] [-O] [-s delay] [-t] [-v]

C. Main parameters

-b-k-M: Displays memory usage in bytes (KB, MB), respectively.

-S delay: Displays the number of seconds per second to show memory usage.

-T: Displays the memory sum column.

-O: Do not display buffer throttling columns.

D. Application examples

The free command is the primary command used to view memory usage. Compared to the top command, it has the advantage of being simple to use and consuming very little system resources. With the-s parameter, you can use the free command to continuously monitor how much memory is in use, which can be used as a handy real-time monitor.

#free-b-S5

With this command, the terminal continuously reports memory usage (in bytes), updated every 5 seconds.

Note: Echo 3 >/proc/sys/vm/drop_caches Release memory

===========================================================================================================

Use CentOS common commands to see the hard disk and partition df-hfdisk-l can also view the partition Du-sh can see all the space occupied du/etc-sh can see the size of this directory

Simple test HDD io speed
DD If=/dev/zero of=/a.txt bs=1g count=2
if = input file//abbreviation translation
of = output file//abbreviation translation
Bs=block size//abbreviation translation

PS command

Used to report the process status of the current system. You can break and delete unnecessary programs with the KILL command at any time. The PS command is the most basic and very powerful process for viewing commands.

Kill: End Process

Kill-9 PID

Pkill-9 Process Name

Fdisk-l/DEC/SDA//view partition information for the first disk

===========================

Partition

Partition Type
After the hard disk partition, there are 3 forms of partition State, i.e. primary partition, extended partition and non-DOS partition.

1 Non-DOS partitions
The non-DOS partition on the hard disk (Non-dos Partition) is a special partitioning form that divides a piece of the hard disk into a separate control system for use by another, and is a partitioned storage space for the primary partition's operating system. Only operating systems that are not DOS partitioned can manage and use this storage area.
2 Primary Partition
The primary partition is a relatively simple partition, usually located in the first area of the hard disk, constituting a logical C disk. The main bootstrapper is part of it, this program is mainly used to detect the hard disk partition correctness, and determine the active partition, is responsible for the transfer of the boot to the active partition DOS or other operating system. This program is corrupted and will not boot from the hard drive, but can read and write to the hard drive after booting from the floppy drive or optical drive.
3 Extended Partitions
Extended partition strictly speaking it is not a meaningful partition, it is just a pointer to the next partition, this pointer structure will form a one-way list. So in the main boot sector in addition to the primary partition, only need to store a partition called extended partition data, through this extended partition of the data can find the next partition (in fact, the next logical disk) starting position, so that the starting position and so on to find all the partitions. Regardless of the number of logical disks established in the system, each logical disk can be found individually in the main boot sector through an extended partition parameter. The extended partition is not used directly, and is used in logical partitioning, so the extended partition can be divided into logical partitions. Their relationship is a contained relationship, and all logical partitions are part of the extended partition.

Partitioning method

1) Add a 15G SCSI hard disk before opening the Linux system

2) Turn on the system, right click on the desktop, open the terminal

3) for the newly added hard disk partition, a primary partition size of 5G, the remaining space to the extended partition, on the extended partition divided 1 logical partitions, the size of 5G

input w save

4) format primary partition as ext3 system

4) set logical partition to swap partition

MKSWAP/DEV/SDB5 set to swap partition

6) enable the Swap partition for the previous step

Swapon/dev/sdb5

7) View the status of the swap partition

Swapon-s

DD command to test hard drive speed

DD If=/dev/zero of=/a.txt bs=200m count=2
Test the speed of the hard drive, write the/dev/zero file to/a.txt, in M, the number of times is 2

find a process named SSH and force it to kill

============================================================================================================

Use CentOS common commands to view the current version of Linux More/etc/redhat-releasecat/etc/redhat-release
Class notes


Fdisk-l/DEV/SDA View the partition status of the first hard drive
Fdisk/dev/sdb Start partition

W Save partition information

Ls/dev/sdb (tab) to view the partitioning situation
MAFS.XFS/DEV/SDB1 to SDB1 file system.


MOUNT/DEV/SDB1 (partition Name)/part1 (folder)

Free//view memory
echo $[1+3] Simple integer operation
echo 3 >/proc/sys/vm/drop_caches Empty Cached cache

Cat/etc/redhat_release Viewing the system version
Uname-r View kernel version,-R only look at the kernel,-a See all

Free-w the buff and the cache separately.

Free-m in m units, not very precise

Df
Df-h with units view
Df-i to see how many files the hard drive can save, it's full.
DF-T contains file types


Mount Detailed view hard drive information

Log system: Write the file, first write to the log in the temporary storage, and then to the hard disk (if the log disk speed, can speed up the hard disk, should be written to the SSD, it is believed to have written to the hard disk)

DD If=/dev/zero of=/a.txt bs=200m count=2
Test the speed of the hard drive, write the/dev/zero file to/a.txt, in M, the number of times is 2

PS aux viewing process
PS aux | Head-3 View top three articles
PS aux | grep top view data containing the top row

Kill process
Kill-9 Process ID//force End Process

PKILL-9 Process name//force End Process

Pstree 1//view process Tree

Ps-elf//Increase view ID of parent process

DAY07 Linux disk partition, Ps,kill,df,top command uses

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.