Linux interview questions and answers - 2

15. What is the difference between 'more' and 'less' command?

Both more and less commands are used for viewing large files page wise.

The main difference between more and less is that less command is faster because it does not load the entire file at once and allows navigation though file using page up/down keys.

16. What does the shred command do?

Normally, when you delete a file, a third party can recover the data that you thought you had deleted using special software.

Shred utility overwrites your files in a way that makes them very difficult to recover. This command is used to delete data permanently which you don't want anyone to be able to recover.

17. What is the difference between find and locate command?

Both find and locate commands are used for searching files on Linux.

The 'find' command works in real time mode and searches all the directories to find the particular file specified and it examine each file one-by-one. Therefore, it requires a lot of I/O calls and thus takes longer time to return the search result.

The 'locate' works in an offline mode. It is much faster as it searches files in a database called updatedb which takes a snapshot of the system files once a day. It is a quicker method but this efficiency comes at a cost. The result of locate isn't as fresh as the result reported by the find command.