Linux Interview Questions and Answers – Part 3

1. What is meaning of “ls”
ls command
(List directory contents)
The ls command will list the files and directories within the current working directory (the directory you are currently in).
There are a few options you can use with ls, and the format, or syntax of the command is….

ls [options] [file]

>ls -l /home/rich/www
Lets break that down….

ls is the command
-l is the option which will give you a long listing format (which shows more info than just the file names – the owner, size, date last modified etc)
/home/rich/www is the directory we want to see a listing of (if you omit this part, ls will print the contents of the directory you are in).
Some useful options are -l, -a, -s, -h and -R

-l will give you a long listing (as explained above)
-a will show you ALL the files in the directory, including hidden files
-R will the subdirectories recursively, which means it will show all the directories and files within the specified directory.
-s will also show you the size of the files (in blocks, not bytes)
-h will show the size in “human readable format” (ie: 4K, 16M, 1G etc). Of course you must use this option in conjunction with the -s option to see the latest modification file’s, under one directory?
Using Find Command
find /home/you -iname “*.txt” -mtime -60 –print

3. How to see the size of the file in human readable status using “ls” command
ls –lh

4.what is “ls -i “ ?
-i –inode
print the index number of each file

5. what is inode ?
An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :

  • Size of file
  • Device ID
  • User ID of the file
  • Group ID of the file
  • The file mode information and access privileges for owner, group and others
  • File protection flags
  • The timestamps for file creation, modification etc
  • link counter to determine the number of hard links
  • Pointers to the blocks storing file’s contents

When a file is created inside a directory then the file-name and Inode number are assigned to file. These two entries are associated with every file in a directory. The user might think that the directory contains the complete file and all the extra information related to it but this might not be the case always. So we see that a directory associates a file name with its Inode number.
When a user tries to access the file or any information related to the file then he/she uses the file name to do so but internally the file-name is first mapped with its Inode number stored in a table. Then through that Inode number the corresponding Inode is accessed. There is a table (Inode table) where this mapping of Inode numbers with the respective Inodes is provided.

6. What is ls -la ? What it will show , (i need full information)?
This is very common option of ls command. By default ls displays only name of a file or directory. -l , alias long listing format, will instruct ls command to display more information for any given output.
-a, –all
Display also hidden files. In shell hidden files contain a “.” in front of its name. -a option will ensure that these files are not omitted from ls output.

7. how to see the inode information?
To see the inode information on linux using this command
Ls –i
Df –i
Stat a

8. check this permission and give the explanation (drwxr-xr–) ?
d – for directory
Rwx – for root user to read,write and execute the directory
r-x – for normal user only to read and execute the directory
r– – other user only read the directory

9. Check this permission and give the answer (lrwxrwxrwx)?
L  –  indicates the symbolic link of files
Root user , Normal user , Other User to access the full permission of the file.

10.How to check the your current working terminal (pts ? And tty )
tty command using to check the your current working terminal
pts – pseudo terminal master and slave

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 1 = seven

Popup Dialog Box Powered By :
  • RSS
  • Facebook
  • Google+
  • Twitter