Linux File System:
The Linux file system architecture is an interesting example of abstracting complexity. Using a common set of API functions, a large variety of file systems can be supported on a large variety of storage devices. Take, for example, the read function call, which allows some number of bytes to be read from a given file descriptor. The read function is unaware of file system types, such as ext3 or NFS. It is also unaware of the particular storage medium upon which the file system is mounted, such as AT Attachment Packet Interface (ATAPI) disk, Serial-Attached SCSI (SAS) disk, or Serial Advanced Technology Attachment (SATA) disk. Yet, when the read function is called for an open file, the data is returned as expected. This article explores how this is done and investigates the major structures of the Linux file system layer.

Virtual file system layer:
The VFS acts as the root level of the file-system interface. The VFS keeps track of the currently-supported file systems, as well as those file systems that are currently mounted.

What is a block device?
A block device is one in which the data that moves to and from it occurs in blocks (such as disk sectors) and supports attributes such as buffering and random access behavior (is not required to read blocks sequentially, but can access any block at any time). Block devices include hard drives, CD-ROMs, and RAM disks. This is in contrast to character devices, which differ in that they do not have a physically-addressable media. Character devices include serial ports and tape devices, in which data is streamed character by character.

$su : Setting root user with existing environment
$su – : Setting root access for a single command
$sudo : Setting root access for a single command
$exit or ctrol+d -> Exit from Super User

Linux File formats
ELF stands for Executable and Linking Format. This format is used for object files on most UNIX platforms including Linux. There are basically three types of object files:
- A relocatable file holds code and data suitable to be linked with other object fields to create an executable or shared object file, or another relocatable object.
- An executable file holds a program that is ready to execute.
- A shared object file holds code and data suitable to be linked to other shared objects or relocatable files. (The object file format is shown in the figure below.)

Every file has an ELF header that resides at the beginning of the file and acts like a roadmap to the rest of the file. Sections represent the smallest unit that can be processed in a file and hold the bulk of the information required for linking. A section header table contains information about the sections in the file. A program header table, if present, tells how to create a process image, which is used if the object file is an executable. The exec program uses the program header table to fork a process. Note that the position of the ELF header is constant in the file, although other parts may appear at different places than shown in the figure.

The ELF header is used by the file program, (see Utility programs and tools later in this article) to print out information about the file. (The libelf library package provides a programming interface to access information in the ELF headers.)

How to write dynamically loadable libraries

Compiler –c
Linker – ld (Static Linking and Dynamic Linking)

$gcc –o hello hello.c
$gcc –c hello.c
$ld –lc –o hello hello.c

Listing 1: Libprint.h Code; Header file
/* file libprint.h – for example use! */
void printstring(char* str);

Listing 2: libprint.c Code
Creating Library:
/* file libprint.c */
#include “stdio.h”
void printstring(char* str)
printf(“String: %s\n”, str);

Listing 3: Code for _init() and _fini()
void _init()
printf(“Inside _init()\n”);
void _fini()
printf(“Inside _fini()\n”);

$ gcc -fPIC -c libprint.c (PIC – Position Independent Code)
$ ld -shared -soname -o -lc libprint.o

Installing and using shared libraries
Now that we’ve built our library, let’s install it and make a small client program that uses it. A special program called ldconfig is used for installing shared libraries.
- Generally, shared libraries are installed in either /usr/lib, lib or /usr/local/lib. ‘
- Once the library is made, it should be copied in one of these directories.
- Then we just run the ldconfig program.
$ldconfig -v -n .
…: => ./

Now we’ve created a symbolic link named to The next step in installing is creating another link for the linker name, like this:
Link for the linker name
$ ln -sf

Check the IP Address in Linux:


Linux OS Info:

uname -arv / uname -s

Check the current logged user name:

Change Password for the root user:

#sudo passwd root

Moving Files:

$mv -f source-folder-or-file target-folder/-or-/filename

File size and disk utilization in Linux:

  • $du    ==> used to estimate file space usage—space used under a particular directory or files on a file system
    • $du /folder_or_file_name  <- For all directories
    • $du -H /folder_or_file_name <- For directories and total
    • $du -a /folder_or_file_name   <- Size for for each file
  • $df     ==> display the amount of available disk space for filesystems on which the invoking user has appropriate read access
  • du-cmd

Setting Git in Mac:

  • Install Git (from site and by default the git will be installed at /usr/local/git location. there is no UI or application to show the progress)
  • Setup path (Open /etc/paths and then add a new line as /usr/local/git/bin, use $sudo root vi /etc/paths )
  • Once path is set git can run now, $git or $git help or $git config –list
    • AVKASHs-MacBook-Pro:~ avkashchauhan$ git config –list
      AVKASHs-MacBook-Pro:~ avkashchauhan$ git config –global “Avkash Chauhan”
      AVKASHs-MacBook-Pro:~ avkashchauhan$ git config –global “my email address .com”
      AVKASHs-MacBook-Pro:~ avkashchauhan$ git config –list
      credential.helper=osxkeychain Chauhan email address .com
  • Now git is ready in your mac

VMWare Image Clone Problem: eth0 Renamed As eth1


How to Run Linux without the GUI (level 3) ?

  • Open /etc/inittab file and you will see this line
    • id:5:initdefault
  • change the value 5 to 3 .when you will change it line will look like this
    • id:3:initdefault:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 36 other followers

%d bloggers like this: