Tuesday, March 19, 2019


File Comparison: -
Q) What are File Comparison Operators ?
Ans – There are 3 file comparison operators. Such as –
1.       cmp (Compare)
2.       comm (Common)
3.       diff (difference)
Q) There are two files f1 and f2. How you confirm that these two files are equal or not ?
Ans - $ diff f1 f2<Enter – Key>
In above command, if you will get no result in output, then these files are same otherwise not same.
Q) There are two files f1 and f2. How you will get 1st non matching character of both files ?
Ans - $ cmp f1 f2<Enter – Key>
The result will be the 1st non matching character of both the files if both files are unequal.
Q) How you will get both common and un common rows of both files f1 and f2 ?
Ans - $ comm f1 f2<Enter – Key>
The result will be in three columns.
1st Column will give unique lines of first file f1
2nd Column will give unique lines of second file f2
3rd Column will give common lines of both file f1 and f2

Link (ln): -
Q) What is link and what are they ?
Ans – link is a pointer to an original file. It is of two types.
1.       Soft Link (Symbolic Link)
2.       Hard Link
Q) What is soft link ?
Ans – It has below characteristics.
1.       It creates copy of original file.
2.       Both link file and original file have different inode number.
3.       Once original file is deleted, its corresponding soft link file is unusable.
4.       We can create soft link throughout the file system for the original file.
5.       You can create soft link to a directory.
Syntax: -
$ ln –s <Original File Name> <Soft Link File Name><Enter – Key>
Example –
$ ln –s Sample.txt Sample.link<Enter – Key>
Q) What is Hard Link ?
Ans - It has below characteristics.
1.       It points to the inode number of the original file.
2.       Both link file and original file have same inode number.
3.       We can access the content of the link file as same as original file, once original file is deleted i.e. it is the backup of the original file.
4.       We can create hard link only within the file system, where original file is present.
5.       You cannot create hard link to a directory.
Syntax: -
$ ln <Original File Name> <Hard Link File Name><Enter – Key>
Example –
$ ln Sample.txt Sample.link<Enter – Key>
Q) How to get inode number of a file ?
Ans - $ ls –i <File Name><Enter – Key>
-i -> inode number
Example –
$ ls –i f1

No comments:

Post a Comment

Interview Questions: - (UNIX - 0) UNIX: -   Q) How to get inode number of a file/directory? Ans – $ ls –i <File/Directory_Name...