cancel
Showing results for 
Search instead for 
Did you mean: 
Chetan_Tiwary_
Community Manager
Community Manager
  • 1,189 Views

Red Hat Linux Interview Series 2

Q.)  Explain the discrepancy between these 2 outputs:

df -h /tmp/
Filesystem     Size    Used   Avail   Capacity    Mounted on
/dev/sda1      496M     39M    417M     9%        /tmp
du -d 0 -h /tmp/
22M    /tmp/

 

Q.) Explain what could be the reason that student user is not able to delete the file :

Chetan_Tiwary__0-1726158661686.png

Q.) What could be the reason that "newdir" cannot be created in this case ? How can we solve this ?

#pwd 
/root 
#mkdir newdir 
mkdir: cannot create directory `newdir': No space left on device 
#df -h 
Filesystem  Size    Used     Avail    Use%      Mounted on 
/dev/sda1   41G     4.1G      35G      11%       / 
/dev/sda3   91G     36G       51G      42%       /home 
/dev/sda2   99G     3.4G      91G       4%       /usr

 

 

I'll be posting a series of Linux-related questions covering various skill levels. Feel free to share your insights and expertise. Your contributions will benefit learners at all stages, from those in current roles to those preparing for Linux interviews.

4 Replies
Trevor
Starfighter Starfighter
Starfighter
  • 1,115 Views

These interview questions are tempting me to update my CV, so that I can 
begin pursuing some interviews     

Okay, let me take a swing at that first question:

Explain the discrepancy between these 2 outputs:

    -  See the output in the initial post - 

The discrepancy has to do with the 39M (df command) and 22M (du command)
values.

Let's see, the df command displays disk usage information for an entire filesystem
(i.e. partition); the du command displays disk usage information a directory and its
subdirectories.

The 22M value that appears in the output of that du command represents the data
stored in files - the amount of space (blocks) used to store the data. 

The 39M value that appears in the output of that df command represents the data
stored in files, along with the metadata information for the files.  Metadata?  Yes,
metadata!!

Let me expound just a little bit about this metadata thing. 

Again, the df command displays information related to the entire file system - not
just directories, and any subdirectories on that file system.  File system data includes
not only the data in the files, but also metadata (e.g. creation date, last access date,
last modification date, etc.) for each file. The disk usage shown by the du command 
DOES NOT include this metadata information. The size information provided by the du command represents only the actual sectors/blocks allocated for the file's data - not metadata.  Okay, that's all I'll say about that!  How data is stored on a file system, and
what data is stored, is a completely separate tutorial!!!

In summary, the difference/discrepancy in the values, in the output of the 2 commands,
is due to what's being reported:  df (file data + metadata)      du (file data ONLY)

The digestion of my explanation would be aided considerably by your having a healthy
understanding of what goes on under the hood, as it relates to a file being stored on
a file system.

Thanks for reading!!!!

Trevor "Red Hat Evangelist" Chandler
TM
Flight Engineer Flight Engineer
Flight Engineer
  • 1,063 Views

Hi,

I will try to give my views on the questions 2 and 3.

For question 2, I think what is missing are the permissions of student on the directory /shared/. Indeed you need write permission on the directory in order to be able to remove a file from it.
In addition, the file /shared/secret.txt has the sticky bit enable. On file that forces a file to only be deletqble by its sole owner, even if the other user hqs write permission on the parent directory.

For question 3, the reason I foresee for the "newdir" creation failure is rhe exhaustion of inodes. Indeed, a part from required spare space, it is also required that spare inodes be available as well for a new file to be created.
The inodes usage (and availability) can be seen by executing the command "dh -i".

Regards,

Tshimanga

Ad_astra
Flight Engineer Flight Engineer
Flight Engineer
  • 1,041 Views

Hello

Did you mean "df -i" instead of "dh -i"? 

I have no "dh" command on my versions of RHEL, but the "df" command does have a -i option:

-i, --inodes
list inode information instead of block usage

Hope this is correct!

TM
Flight Engineer Flight Engineer
Flight Engineer
  • 1,023 Views

Yes,
df -i

Join the discussion
You must log in to join this conversation.