Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Simple Linux file system - df, du, ln     - CentOS of NFS (Server)

- Depth Java Singleton (Programming)

- High-performance open-source http accelerator Varnish introduce (Server)

- CentOS 7 hard disk expansion toss record (Linux)

- Linux configuration startup mount: fstab file (Linux)

- Installation and operation GAMIT software under Linux operating system (Linux)

- HomeKit User Interface Guidelines (Linux)

- C data types is how it is supported by most computer systems (Programming)

- 2016, the new Node project Precautions (Programming)

- PostgreSQL log classification and management (Database)

- Java Learning: elegant string (Programming)

- Linux Oracle environment variable is invalid Problem Solving (Database)

- Oracle physical storage structure outline (Database)

- Linux system find command Detailed (Linux)

- ORA-00020: No more process state objects available (Database)

- To install Xen in Ubuntu 12.04 (Linux)

- Why you should choose Python Programming (Programming)

- Python system default encoding (Programming)

- How ONLYOFFICE collaborative editing document on Linux (Linux)

- VMware virtual machines to install virt-manager unable to connect to libvirt's approach (Linux)

 
         
  Simple Linux file system - df, du, ln
     
  Add Date : 2016-08-28      
         
         
         
  Now we know that the whole data disk is in the superblock block, but the capacity of each individual file in the inode were described. The text underneath the interface, how to call out these data? Let us talk about under these two commands:

df: Lists overall disk usage of the file system;

du: assess disk usage of the file system (commonly used in reckoning catalog occupied capacity)

df: Lists overall disk usage of the file system;

du: assess disk usage of the file system (commonly used in reckoning catalog occupied capacity)

df

[Root @ www ~] # df [-ahikHTm] [directory or file name]

Options and parameters:

-a: List all file systems, including the system-specific / proc file system, etc;

-k: KBytes capacity to display all file system;

-m: MBytes capacity to display all file system;

-h: It is easier to read GBytes, MBytes, KBytes own display formats;

-H: M = 1000K to replace M = 1024K carry manner;

-T: Together with the partition of the filesystem name (such as ext3) are also listed;

-i: without hard drive capacity, and to the inode number to display

Example 1: all the filesystem listed in the system!

[Root @ www ~] # df

Filesystem 1K-blocks Used Available Use% Mounted on

/ Dev / hdc2 9920624 3823112 5585444 41% /

/ Dev / hdc3 4956316 141376 4559108 4% / home

/ Dev / hdc1 101086 11126 84741 12% / boot

tmpfs 371332 0 371332 0% / dev / shm

# Under Linux if df did not add any options, then the system will default within all

# (Excluding special file system and swap memory inside) are in 1 Kbytes capacity to be listed!

# As for the / dev / shm mount is related to memory, the first not to him!

Example 2: The capacity of the results are displayed in an easy-capacity format

[Root @ www ~] # df -h

Filesystem Size Used Avail Use% Mounted on

/ Dev / hdc2 9.5G 3.7G 5.4G 41% /

/ Dev / hdc3 4.8G 139M 4.4G 4% / home

/ Dev / hdc1 99M 11M 83M 12% / boot

tmpfs 363M 0 363M 0% / dev / shm

# Unlike Example 1, it will be displayed here in G / M and other volume format, easier Kanla!

Example 3: all special file formats and names are listed in the system

[Root @ www ~] # df -aT

Filesystem Type 1K-blocks Used Available Use% Mounted on

/ Dev / hdc2 ext3 9920624 3823112 5585444 41% /

proc proc 0 0 0 - / proc

sysfs sysfs 0 0 0 - / sys

devpts devpts 0 0 0 - / dev / pts

/ Dev / hdc3 ext3 4956316 141376 4559108 4% / home

/ Dev / hdc1 ext3 101086 11126 84741 12% / boot

tmpfs tmpfs 371332 0 371332 0% / dev / shm

none binfmt_misc 0 0 0 - / proc / sys / fs / binfmt_misc

sunrpc rpc_pipefs 0 0 0 - / var / lib / nfs / rpc_pipefs

# There are many special system which file systems exist. Those special file system is almost

# Memory which are, for example, / proc the mount point. Therefore, these special file system

# Will not occupy hard disk space Oh! ^ _ ^

Example 4: the available disk capacity / etc under the display to readable volume format

[Root @ www ~] # df -h / etc

Filesystem Size Used Avail Use% Mounted on

/ Dev / hdc2 9.5G 3.7G 5.4G 41% /

# This example a little more interesting to you, behind df add directory or file, df

# Automatically analyzes partition the directory or file is located, and the partition capacity is displayed,

# So, you can know how much a directory under capacity can be used! ^ _ ^

Example five: the inode number of each partition is currently listed among the available

[Root @ www ~] # df -ih

Filesystem Inodes IUsed IFree IUse% Mounted on

/ Dev / hdc2 2.5M 147K 2.3M 6% /

/ Dev / hdc3 1.3M 46 1.3M 1% / home

/ Dev / hdc1 26K 34 26K 1% / boot

tmpfs 91K 1 91K 1% / dev / shm

# This example is mainly lists the available inode remaining amount of the total capacity. Analyze the relationship between one paradigm,

# You can clearly found to usually inode number of the remaining even more than block it

Let's explain the example of an output result information is:

Filesystem: The file system is representative of what partition, so the device name listed;

1k-blocks: the number of units is described under the 1KB Yo! -h -m Can be used to change or capacity;

Used: As the name suggests, is the use of hard disk space it out!

Available: that is, the remaining disk space;

Use%: is the disk usage of it! If the utilization rate up to 90%, preferably need to look at the lack of capacity to avoid causing system problems Oh! (For example, most likely to be Guanbao the / var / spool / mail messages to place this disk)

Mounted on: is the mounted disk directory where it! (Mount point it!)

Since almost all of the data for an entire file system, the read range is mainly the information in Superblock main df read, so this command displays the results of the speed is very fast! The result that appears you need to pay special attention to the remaining capacity of the root directory! Because all of our data is derived from the root of it, so when the remaining capacity of the root of the remaining 0:00, then your Linux may be a big problem.

du

[Root @ www ~] # du [-ahskm] file or directory name

Options and parameters:

-a: lists all files and directories capacity because only the amount of the default file directory under the statistics only.

-h: It is easier to read the volume format (G / M) display;

-s: Lists the total amount of it, rather than listing each respective directory occupancy capacity;

-S: Total does not include subdirectories, and -s bit different.

-k: listed in KBytes capacity display;

-m: In MBytes listed capacity display;

Example 1: List all the file size of the current directory

[Root @ www ~] # du

8 ./test4

8 ./test2

.... Snip ....

12 ./.gconfd

220.

# Direct input du did not add any options, then du analyzes the "current directory."

# Files and directories occupied hard disk space. However, the actual display, will only display the directory capacity (excluding file)

# Therefore, there is a lot of catalog file is not listed, it does not equal the sum of all directories. Capacity Oh!

# In addition, the output value data for the size of the capacity of 1K units.

Example 2: with a paradigm, but also the capacity of the file listed

[Root @ www ~] # du -a

12 ./install.log.syslog

8 ./.bash_logout

8 ./test4

8 ./test2

.... Snip ....

12 ./.gconfd

220.

Example 3: Check the root directory under each occupied capacity

[Root @ www ~] # du -sm / *

7 / bin

6 / boot

..... Snip ....

0 / proc

..... Snip ....

1 / tmp

3859 / usr

77 / var

# This is a very commonly used functions - use the wildcard * to represent each directory,

# If you want to check a directory, sub-directory which occupied the largest capacity, you can use this method to find out

# It is noteworthy that, if just installed Linux, then the whole system is the largest capacity to / usr

# The / proc Although listed capacity, but the capacity is in memory, does not occupy hard disk space.

And df is not the same, du This command will actually go directly to search all of the data files within the file system, so the operation of the above third example command will run for a short time! Further, in the case of default, the output capacity is KB to design, if you want to know how many directories accounted MB, then use this parameter -m to Hello! And, if you just want to know how much capacity is accounted directory, use the -s can be friends!

As part of this option -S due du will default size of all files are listed, it is assumed that you are in / etc underneath when using du, size of all files, including / etc sub-directory under the capacity will be counted only once. Then the final volume (/ etc) will be added to the total time, so many of my friends will misunderstand du analysis results not quite right. Hello So, if you wanted to list all the data in a directory, you may also be used with the -S option to reduce the increase in the total secondary directory Oh!

Hard Link (physical link, hard link or destination)

[Root @ www ~] # ln / etc / crontab.

[Root @ www ~] # ll -i / etc / crontab / root / crontab

1912701 -rw-r - r-- 2 root root 255 Jan 6 2007 / etc / crontab

1912701 -rw-r - r-- 2 root root 255 Jan 6 2007 / root / crontab

You can find two file names are linked to the inode number 1912701, so you look, whether the file permissions / attributes exactly the same? Because these two "filename" is actually exactly the same as "File" it! And you will find the second field from the original into a 2 1! The field is called "Link", the significance of this field is: "How many filename links to the inode number" means.

You can specify through a catalog of 1 or 2 inode block to find two different file name, regardless of which file name may refer to both the inode to read the real data to the final! That so what good is it? The greatest advantage is "safe"! As the figure above, if any of you will "filename" delete, in fact, inode and block are still there! At this point you can through other "file name" to read the data to the correct file Oh! In addition, no matter what you use "file name" to edit the final result will be written to the same inode and block, so data can be modified mile!

hard link is limited:

Not cross Filesystem;

You can not link directories.

Symbolic Link (symbolic links, that is, a shortcut)

With respect to hard link, Symbolic link may like to understand more, basically, Symbolic link is created in a separate file, and read the file data will point to the file name link that his file! Since only the use of the file to point to the action to do so, when the source file is deleted, symbolic link files are "not open", will always say, "Can not open a file! . " In fact I could not find the original "filename" just friends!

For example, we first create a symbolic link file is linked to / etc / crontab to see:

[Root @ www ~] # ln -s / etc / crontab crontab2

[Root @ www ~] # ll -i / etc / crontab / root / crontab2

1912701 -rw-r - r-- 2 root root 255 Jan 6 2007 / etc / crontab

654687 lrwxrwxrwx 1 root root 12 Oct 22 13:58 / root / crontab2 -> / etc / crontab

The results of the above table we can see that the two files point to a different inode numbers, of course, it is the existence of two separate files! And an important part of the link is that he file will be written on the target file "File name", you can see why the size of the table is 12 bytes file link it? Because the arrow (->) to the right of the file name "/ etc / crontab" A total of 12 English and each occupies an English byes, so the file size is 12bytes!

No. 1 inode to be read by the content of the linked file only file name, go get inode target file based on the file name link to the correct directory, and ultimately will be able to read the data correctly. You can see that if the target file (/ etc / crontab) has been deleted, then the whole chain will not continue to go on, so the problem can not be read through the file link will be happening!

Here still have to pay particular attention to this shortcut Symbolic Link and Windows may equate to him, by the Symbolic link files created as a separate new file, it will take out the inode and block Oh!

[Root @ www ~] # ln [-sf] source file target file

Options and parameters:

-s: If you do not add any parameters to be linked, it is hard link, as for -s is symbolic link

-f: If the destination file exists, the initiative will be removed and then create the target file directly!

Example 1: Copy the / etc / passwd to / tmp under, and observe the inode and block

[Root @ www ~] # cd / tmp

[Root @ www tmp] # cp -a / etc / passwd.

[Root @ www tmp] # du -sb; df -i.

18340.

Filesystem Inodes IUsed IFree IUse% Mounted on

/ Dev / hdc2 2560864 149738 2411126 6% /

# Use du and df to check the current parameter ~ du -sb

# Evaluate the entire / tmp under the number of bytes of capacity it!

Example 2: The / tmp / passwd make hard link become passwd-hd file, and observe and document capacity

[Root @ www tmp] # ln passwd passwd-hd

[Root @ www tmp] # du -sb; df -i.

18340.

Filesystem Inodes IUsed IFree IUse% Mounted on

/ Dev / hdc2 2560864 149738 2411126 6% /

# Look carefully, even if more than one file in / tmp under, the whole block and inode capacity has not changed!

[Root @ www tmp] # ls -il passwd *

586361 -rw-r - r-- 2 root root 1945 Sep 29 02:21 passwd

586361 -rw-r - r-- 2 root root 1945 Sep 29 02:21 passwd-hd

# Turned out to be a point to the same inode ah! This is the key ah! In addition, the number of links that will add a second column!

Example 3: The / tmp / passwd to create a symbolic link

[Root @ www tmp] # ln -s passwd passwd-so

[Root @ www tmp] # ls -li passwd *

586361 -rw-r - r-- 2 root root 1945 Sep 29 02:21 passwd

586361 -rw-r - r-- 2 root root 1945 Sep 29 02:21 passwd-hd

586401 lrwxrwxrwx 1 root root 6 Oct 22 14:18 passwd-so -> passwd

# Passwd-so points to inode number is different! This is the content of a new file - This file is pointing

# Passwd's. Size passwd-so is 6bytes, because it passwd total of six characters

[Root @ www tmp] # du -sb; df -i.

18346.

Filesystem Inodes IUsed IFree IUse% Mounted on

/ Dev / hdc2 2560864 149739 2411125 6% /

# Whistling! Use the entire capacity and inode number changed Hello ~ true ah!

Example 4: delete the source file passwd, the file is able to open the other two?

[Root @ www tmp] # rm passwd

[Root @ www tmp] # cat passwd-hd

...... Display properly completed!

[Root @ www tmp] # cat passwd-so

cat: passwd-so: No such file or directory

[Root @ www tmp] # ll passwd *

-rw-r - r-- 1 root root 1945 Sep 29 02:21 passwd-hd

lrwxrwxrwx 1 root root 6 Oct 22 14:18 passwd-so -> passwd

# Pale Ba! Sure enough, a symbolic link can not be opened! In addition, if the symbolic link target file does not exist,

# In fact, part of the file name will be displayed with special color Oh!

About directory link Quantity:

Perhaps you have found, that is, when we were hard link to "File links" can be found in the second field of the ls -l displays will add a fishes, then ask, if you create a directory, he the default number of link would it be? Let's think about what there will be at least a "empty directory" inside? Ha ha! It is that there is. .. And these two directories ah! Then, when we create a new directory name for / tmp / testing, basically there will be three things, that is:

/ Tmp / testing

/ Tmp / testing /.

/ Tmp / testing / ..

And where / tmp / testing and / tmp / testing /. Is the same! Ah ~ represents the directory and / tmp / testing / .. represents the / tmp directory, so that when we create a new directory, "the new directory link is 2, and on a directory link number 1 is added. "
     
         
         
         
  More:      
 
- JIRA 3.6.2 Upgrade from older version to the new version 6.0.8 (Linux)
- The easiest 11g Active DataGuard (ADG) to establish the configuration process (Database)
- CentOS7 installation performance monitoring system (Server)
- Oracle Listener can not start (TNS-12555, TNS-12560, TNS-00525) (Database)
- C # function (Programming)
- Remote installation of Net-SNMP whole process (Linux)
- Unix system security configuration (Linux)
- Limit the use of the request being Nginx Flood attack (Linux)
- Ubuntu 14.04.02 LTS startup items erroneous writing / dev / sda1 (win 7 loader) Repair (Linux)
- About Python default character set (Linux)
- Oracle 11gr2 new APPEND_VALUES tips (Database)
- Setting the RedHat9 Intrusion Detection System (Linux)
- Neo4j map data processing tab (Database)
- Ubuntu apt-mirror established local private sources (Linux)
- installation of Piwik under Ubuntu (Programming)
- Linux 10 useful examples of command-line completion (Linux)
- Gentoo: startx problem appears Failed to load module (Linux)
- After you change the GRUB boot disk partition repair (Linux)
- How to use the on-screen keyboard in Linux (Linux)
- Zabbix monitors the status of TCP connections (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.