UNIX Commands Interview Questions

In this Post, We will discuss most frequently asked UNIX Commands Interview Questions.

Common Commands:

  • Pwd – Present working directory.
  • clear – clear the screen.
  • ls – listing of the files.
  • ls -l – Listing of the files with numbers.


Folder Commands:

  • mkdir dirName – To create the directory
  • mkdir -v dirName – To create the directory with verbose message.
  • ./.. —  two folder back.
  • mv oldDirName newDirName —- Rename the file
  • rmdir -v DirName – removing file.


Working with directory:

mkdir Hello{1..10} – it will create 10 folder Hello1, Hello2……Hello10

rmdir Hello* — Remove folder which start from Hello name.


Create File using Commands:

touch filename – Create a blank file

cat > filename [Press Enter] —– Enter data inside the file.

data…. [Enter]

 Press Ctrl+C


Check the details: – ls -l


Display files in folder: – Use of ls command)

  1. ls -l
  2. ls -la – also show hidden file.
  3. ls -lat – Files showing in sorted order of creation. [l for listing order, a for all and t for sorted in time.]
  4. ls -t – Display in sorted order of time.
  5. ls -latr – display in reverse order of time.


UNIX Commands Interview Questions of CAT command: –

  1. cat Filename – Display content of the file.
  2. cat -n filename – display content of file with line number.
  3. cat old filename > new Filename – where u want to copy content of old file. [This will delete the previous data of new file in which u want to copy content]
  4. cat oldfilename >> new file name – copy data in append
  5. cat file1 file2 > file3 – merge multiple file data into new a file.
  6. tac filename – show reverse order of content in file.


View Content of File: –

  1. Display few lines from the top of the file (default 10) – head file name
  2. Control lines what you line want to print – head  20 fileName
  3. Display bottom lines – tail filename

Search Data in File – Grep (Global regular expression parser) Command

grep “Content” filename

Search data in more than one file: –           

Grep “Content” fileName1 fileName2

Search data in all files: –

Grep “Content” *.*

Search data by ignoring case:

grep -I Content *


Use of Cat Commands:

Creating the new file

Display content of the file

Concatenating more than one file

Appending data to the existing file


Use of cp Command:

Copy contents from a file to another file(source to destination)


Use of mv Command:

Renaming a file(changing name of the file)

Renaming a directory

Moves files from one directory to another directory


Use of rm Command :

Delete/remove a file or directory (only if directory is empty).

More UNIX Interview Questions


Must Read:

QA Interview Questions List

WebServices Interview Questions



Leave a Comment