Functions of Unix/Linux Unlink and differences between the command du and DF.

Source: Internet
Author: User

First, create a file larger than the limit and use the DD command.
Dd If =/dev/Zero of =/home/Leon/tmpfile BS = 1024 COUNT = 1048576
In this case, a 1 GB file is created.
TheProgram:

# Include <unistd. h> # include <stdlib. h> # include <stdio. h> # include <fcntl. h> int main (INT argc, char ** argv) {If (open ("tempfile", o_rdwr) <0) {fprintf (stderr, "Open error "); exit (-1);} If (unlink ("tempfile") <0) {fprintf (stderr, "unlink error"); exit (-1 );} printf ("file unlinked \ n"); sleep (15); printf ("done \ n"); exit (0 );}

During program sleep, run the DF command to check the hard drive space;
At the end of the program, run the DF command again to check the hard drive space, and the system will find that the hard drive space resource is 1 GB more.
However, when you run the "du" command, there will be no difference.
The reason is:
The unlink function is to delete a file without being accessed by any other file and without any progress.

Difference between du and DF:
The Du-s command accumulates the total number of directories, symbolic links, and blocks used by the specified file system;
The DF command displays the disk block distribution graph of the file system to obtain the total number of blocks and the remaining number.
Du is a user-level program and does not consider meta data (some disk blocks allocated by the system)

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.