Linux command df file fsck fuser

Source: Internet
Author: User
Tags disk usage

There are very many people who say. There is a lot of knowledge on the Internet, why do you have to repeat these things in your blog?

What I want to say is that what other people write is something that others understand. At the same time is the summary of the learning process for others, for themselves. Write their own blog The most basic purpose is to record their own learning process, the same time on their own learning things to summarize, when after a period of time to look back. I have experienced before. This is also a kind of learning, but also a life attitude.


Here's to the bottom: continue to introduce several commands for 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 shows the use of the I node and disk blocks by all file systems.

Number of references:

-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: The appropriate device file path for the file system (that is, the disk partition)

K-blocks: Number of data blocks (1024 bytes) included in the partition

Used: Data block used

Available: Data block not used

use%: Percentage of normal User space usage

Mounted on: Mounted folder

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 < filename] [-m < magic digital file; ...] [File or folder]

Number of references:

-B lists the identification results. Do not display file names

-C Specific display of instructions to run the process, easy to debug or analyze the operation of the program situation

-F < name file > Specify a name file with one or more file names to allow file to identify the files sequentially. The format is one file name per column

-L directly displays the type of file that the symbolic connection is running on

-m < magical digital files > Specifying magic Digital files

-V Displays version number 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.

Four modernizations occurs when file system errors occur. The fsck command can be used to try to fix it.

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

Number of references:

-a self-proactively repair file system without asking questions no matter what
-A follows the contents of the/etc/fstab configuration file. Check all file systems listed in the file.
-N does not run the instruction, only the actions that are performed by the actual run are listed.


-P matches the "-a" parameter and checks the entire file system at the same time.
-R uses interactive mode to ask questions when running a fix, allowing the user to confirm and decide how to handle it.
-R when used with the "-A" parameter, the file system will skip/folder is not checked
-S runs the check job sequentially instead of at the same time.
-t specifies the type of file system to check
-T when you run the fsck command. Do not display header information
-V Show instruction run process

Eg: Check the Msdos file system/dev/hda5 is normal, assuming that there is an exception to their own initiative to repair

Fsck-t msdos-a/dev/hda5

What is the use of the file generated after the fsck command is executed?

When you run the fsck command. The fsck command assumes that there are orphaned files or folders. These orphaned files or folders are inaccessible to system administrators or users because they are not associated with their parent folder. Suppose the user agrees that fsck will retrieve them again. The fsck command places these orphaned files or folders under the/lost+found folder of the file system. Use their I-node number to name them so they can find the files they need.

Lost+found folder through its English meaning we can all know that it is a lost and found place.

So when a user discovers that he or she has lost a file and is able to go down to the/lost+found folder after running fsck, the file name is not able to recognize the function, only the file type can be determined with a command such as files, which is assumed to be a data file. Can be viewed with the more or VI command, if it is a binary file, can be debugged with the DBX command or try to run it (note that it may be a destructive program), know the role of a file or folder can be renamed.


Fuser command

Function: Identifies the process in which a file or port is being interviewed.

At the same time lsof can also identify the process that is being interviewed for the specified file. The difference is that fuser can kill the process that is visiting the specified file at once.

The fuser command lists the process number of the local process. Which local processes use the file or remote file specified by the file parameter.

For plugging special equipment. This command lists the processes that use whatever files are on the device.

Each process number listed is followed by 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 folder of the process

>e indicates that the file is a running file for the process (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 folder of the process

>m indicates that the process uses this file for memory mapping. Or 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

Number of references:

-l list all known signal names

-a displays all files specified on the command line

-K kills access to the entire process of the specified file

-I need user confirmation before killing process

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

-N Select a different namespace

-U displays the owning username after each process

-V Displays specific processing information when executing

-C Display file system including file on no matter what open files

-D implies that the-C and-X flags are used to display open files that are not linked to the file system (deleted from the parent folder) 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 objects that can be run and loadable except for the 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 folder

$ 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



Linux command df file fsck fuser

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.