cancel
Showing results for 
Search instead for 
Did you mean: 
Chetan_Tiwary_
Community Manager
Community Manager
  • 473 Views

Red Hat Linux Interview Series 19

Q.) What is the difference between cache and buffer ? What does it signify here ?

 

         total        used        free    shared  buff/cache   available
Mem:       3936        1087       252       130      2596         2427
Swap:       0           0           0

 

 

Q.) How can you load a kernel module ?

 

Q.) What is the difference between public IP and private IP ? 

 

Bonus Q.) How can you know that what is your public IP ?

 

 

Level - L2 and above.

 

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.

7 Replies
Scott
Starfighter Starfighter
Starfighter
  • 442 Views

Let me start with the second question: What does it signify here?

The buff/cache entry from the free command shows you how much of your system memory (RAM) is being used for storing data in buffers and caches.  The default unit is in KiB.  If you use free -h, you'll see the value reflected in MiB.  In this example, the machine is using 2596 KiB (about 2.5MiB) of system memory for storing buffers and caches.

Now to the other: What is the difference between buffer and cache?

Generically, a buffer is something used to collect fragmented or partial data until you have all the data you need.  A great more tangible example of this is in video streaming.  The video player will download data until it has enough of the video to start playing.  If, for some reason, it is unable to continue to fill that buffer with video data, it will stop and many video players will have a spinning wheel or some other thing to tell you that it is 'buffering' meaning it's collecting more data so that the player can resume.

In Linux, buffers take the form of things like memory for network connections on the machine where we are collecting data from network interfaces and once the packets have been recieved, can pass that data to applications that service or use the data.  It also allows for activities like if data packets are received out of order, they can be re-ordered, or if packets are missing, they can be requested for resend.  So it's an area where we can store and organize data prior to passing it to some requesting application or user.

We also buffer things like disk I/O already engaged in the I/O subsystem through the assigned disk elevator (if applicable).  Another example would be how sound is handled, being buffered, then sent to the sound card to ensure a consistent playing.

A cache is a collection of data we might find useful later, so we save it.  There are lots of different caches which are reflected in the cache/buffers entry.  swap cache - things we've sent to swap space, but don't need to expunge from memory yet, directory entry (dentry) cache - files and inode information from directories that have been recently accessed on the system, file cache - read file data or data intended to be written to disk which has not yet been sent to the disk I/O subsystem, page cache - things that have been deallocated or no longer needed by applications, but also who's memory has not been reused by the system or new applications/allocations.

Generally the buffers/cache space can be reclaimed by the kernel and re-used by applications naturally as free memory becomes more scarce.  But there's also a kernel tunable under /proc, /proc/sys/vm/drop_caches where you can force the kernel to flush unused cache and buffer memory.

Chetan_Tiwary_
Community Manager
Community Manager
  • 436 Views

@Scott this is gold for learners !! Thanks a lot!

0 Kudos
Trevor
Starfighter Starfighter
Starfighter
  • 438 Views

What is the difference between cache and buffer ? What does it signify here ?

Cache
-  stores frequently accessed data
-  can exist in RAM or on hard disk
-  data stored here is accessed frequently
-  can exist on a computer chip
-  stores a copy of the original data
-  made of static RAM

Buffer
-  refers to temporary storage in RAM
-  are used for input and output processes
exists only in the RAM
-  stores the original data
-  made of dynamic RAM


The output, in the question, appears to be from the "free" command, and that 2596
value in the buff/cache column refers to a sum of the buffers and cache memory.

 

 

Trevor "Red Hat Evangelist" Chandler
Trevor
Starfighter Starfighter
Starfighter
  • 437 Views

What is the difference between public IP and private IP ? 

 

The primary/major difference is that a Public IP can be routed across the
Internet - a Private IP cannot!!!

Public IP addresses cost money!!!!  Each public IP address can only be used
by one customer!!!

Private IP addresses are freebies!!!  Each private IP addresses can be used a
million (or billion) times!!!

 

 

Trevor "Red Hat Evangelist" Chandler
Trevor
Starfighter Starfighter
Starfighter
  • 436 Views

Bonus Question:
How can you know that what is your public IP ?

 

What I routinely do is to execute the following command:

   #  curl ifconfig.me


It's never failed me!!!!

Trevor "Red Hat Evangelist" Chandler
Chetan_Tiwary_
Community Manager
Community Manager
  • 435 Views

@Trevor Spot on!

Trevor
Starfighter Starfighter
Starfighter
  • 427 Views

How can you load a kernel module ?


To do so with a Linux command, use the tried-and-true modprobe command.
Have a look at the manpage, MODPROBE(8), for some delightful reading!!!

 

 

 

Trevor "Red Hat Evangelist" Chandler
Join the discussion
You must log in to join this conversation.