Linux command df file fsck fuser

Source: Internet
Author: User
Tags parent directory disk usage

Many people say that there is a lot of knowledge on the Internet, why do you want to repeat these things in your blog?

What I want to say is that other people write things that others understand, but also the summary of others learning process, for their own, write their own blog The main purpose is to record their own learning process, at the same time on their own study of things to summarize, when after a period of time can look back, I have experienced, This is also a kind of learning, but also a life attitude.


The following: Continue to introduce several commands of Linux

DF Disk Management Command

function: Check the disk space consumption of the file system. Gets the remaining space and the space used for disk space.

Syntax: DF [Options]

The DF command displays the use of all file systems for I nodes and disk blocks.

Parameters:

-a displays disk usage for all file systems, including 0 blocks of file systems, such as the/proc file system

-k is displayed in bytes

-I displays information about the I node, not the disk block's

-T displays disk space usage for each file system of the specified type

-x lists disk space usage that is not a specified type of file system (as opposed to the T option)

-t display file system type

$ dffilesystem 1 k-blocks used Available use% mounted on/dev/hda2      1361587 1246406 44823   
output List of the DF command:

Filesystem: Represents the file system corresponding to the device file path (that is, the disk partition)

K-blocks: The number of data blocks (1024 bytes) that the partition contains

Used: Data block used

Available: Data block not used

use%: Percentage of normal User space usage

Mounted on: Mounted Directory

Note: The sum of the number of blocks in the third to fourth column is not equal to the total number of blocks in the second column, because each of the default partitions leaves a small amount of space for the system administrator to use, even if the normal user space is full, the administrator can still log in and leave the workspace required to resolve the problem.

Eg: List the usage of the file system I node

$ df-ia  Filesystem inodes iused IFree iused% mounted on  /dev/hda2 352256 75043 277213 21%/  None 0 0 0 0%/P  Roc  localhost: (pid221) 0 0 0 0%/net  eg: List file system types $ df-t  Filesystem type 1k-blocks used Available use% mounted On  

File Command

Function: Identify file types

Syntax: file [-BELVZ] [-F < document name] [-m < magic digital file; ...] [File or directory]

Parameters:

-B The file name is not displayed when the identification results are listed

-c Verbose Display instruction execution process, easy to debug or analyze the program execution situation

-F < name file > Specify a name file with the contents of one or more file names, let file identify these files sequentially, in the format of one file name per column

-L Displays the type of file that the symbolic connection executes directly

-m < magical digital files > Specifying magic Digital files

-V Display version information

-Z try to interpret the contents of the compressed file


fsck command

Function: Used to check and attempt to repair errors in the file system. When the file system error four modernizations, the fsck command can be used to try to repair.

Syntax: fsck [-AANPRRSTV][-T] [File system ...]

Parameters:

-A automatically fix file system without asking any questions
-A according to the contents of the/etc/fstab configuration file, check all the file systems listed in the file.
-N does not execute instructions, only the actions performed by the actual execution are listed.
-P is used when matching "-A" parameters, and all file systems are checked at the same time.
-R uses interactive mode to ask questions when performing a fix, allowing the user to confirm and decide how to handle it.
-R when used with "-A" parameter, the file system will skip/directory is not checked
-S executes the check job sequentially instead of concurrently.
-t specifies the type of file system to check
-T displays header information when the fsck command is executed
-V Show Instruction execution process

Eg: check whether the/dev/hda5 of the Msdos file system is normal and automatically fix if there is an abnormality

Fsck-t msdos-a/dev/hda5

What is the use of files generated after running the fsck command?

When the fsck command is executed, the fsck command, if found to have orphaned files or directories, cannot access the orphaned files or directories to the system administrator or user because it is associated with its parent directory, and if the user allows fsck to retrieve them again, The fsck command places these orphaned files or directories in the file system's/lost+found directory and names them with their i-node number, so that users can find the files they need. Lost+found catalogue through its English meaning we can all know that it is a lost and found place. Therefore, when a user discovers that he or she has lost a file, it can go to the/lost+found directory after the execution of fsck, and then the file cannot be identified by the filename, only the type of the file is determined by a command such as files, if it is a data file, Can be viewed with the more or VI command, if it is a binary file, you can use the DBX command to debug or try to execute it (note that it may be a destructive program), know the role of a file or directory, you can rename it.


Fuser command

Function: Identifies the process that is being accessed on a file or port. At the same time lsof can also identify the process that is being accessed for the specified file. The difference is that fuser can kill the process that is accessing the specified file at once.

The fuser command lists the process number of the local process and which local processes use the file or remote file specified by the file parameter. For blocking special devices, this command lists the processes that use any file on the device.

Each of the process numbers listed follows a letter that indicates how the process uses the file

eg

$ fuser-v-N TCP                      USER        PID ACCESS COMMAND 80/tcp:              root       3067 F .... (root) httpd                      apache     3096 F .... (Apache) httpd                      Apache     3097 F .... (Apache) httpd

>C indicates the working directory of the process

>e indicates that the file is a process executable file (that is, the process is pulled from the file)

>f indicates that the file is open by the process and the F character is not displayed by default

>f indicates that the file is written by the process open and the F character is not displayed by default

>r indicates that the file is the root directory of the process

>m indicates that the process uses this file for memory mapping, or that the file is a shared library file that is mapped into memory by the process

Syntax: fuser[-c|-d|-f][-k][-u][-x][-v] File

Parameters:

-l list all known signal names

-a displays all files specified on the command line

-K kills all processes that access the specified file

-I require user confirmation before killing process

-m specifies a loaded file system or a loaded block device

-N Select a different namespace

-U Displays the user name to which it belongs after each process

-V Run-time display verbose processing information

-C Displays the file system containing the file about any open files

-D implies that the-C and-X flags are used to display any open files that are not linked to the file system (deleted from the parent directory) and that the node number and size of the deleted file are reported when used with-V.

-X is used with-C and-F to display executable and non-loaded objects other than standard fuser output

-F Show only open instances of files

eg

Mount the USB device and display the owning user

$ fuser-m-u/mnt/usb1/mnt/usb1:   1347c (Root)  1348c (Guido)  1349c (Guido)

List all known signals

$ fuser-lhup INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE alrm termstkflt chld CONT STOP tstp ttin Ttou UR G xcpu xfsz vtalrm PROF WINCH IO PWR sysunused

Kill all processes associated with the root directory

$ fuser-k/root/root:4552c 4630c 4661c 4664c 4666c 4669c 4671c 4732c 4733c 4735c 4736c 4740c 4741c 4743c 4744c 4750c 475 1c 4767C 11065C 30632C 31755c



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.