Basic Unix Interview Questions

Unix Interview questions for Software developers and testers

Q.Unix, How to create multiple files with a single command?

We can use touch command for creating multiple empty files as below.
 touch 1 2 3 4 5

Q.Unix, How to search for a file throughout the system?

We can use find command, which works in all flavors of Unix.

Ex: find / -type f -name x

As we have given / hence it will search for all folders throughout the system and list all.Type f is for file.

Q.How to install or update packages in Linux systems.

Difference Linux distribution has different package managers as below.

  • apt - For Ubuntu and Debian
  • yum - For Redhat,  CentOS, Fedora
  • emerge - For Gentoo
  • Pacman - for Arch
  • zipper - for OpenSuse

Q.How to see the process in Linux and which process is using which port?

There are many commands, below are some example.

  • netstat -  netstat - lntp 
  •  lsof -i -P -n | grep LISTEN
  • ps -ef
  • top Show top n processes 

Q. Unix Find the latest modified file in a directory?

Below is the command to find the last 5 modified files only in one directory.
ls -Art /u01 | tail -n 1

Q.How to replace in Unix?

We use sed filter for replacing in bash script. Below are some examples of the same.

Suppose I want to replace all old with new in a file.

//This will change only 1st occurence.
sed 's/old/new/' developer.txt
//To change the  2nd occurrence below command is used.

sed 's/old/new/2' developer.txt

// To change all occurrence below is the command
sed 's/old/new/g' developer.txt

Previous
Next Post »

Pages