1) How do you find a  running Java process on UNIX? 
You can use the combination of ‘ps’ and ‘grep’ command to find any process running on UNIX machine. Suppose your Java process has a name or any text which you can use to match against just use following command.

ps -ef | grep "myJavaApp"
  • ps -e will list every process i.e. process from all user not just you
  • ps -f will give you full details including PID,which will be required if you want to investigate more or would like to kill this process using kill command.

2) How do you find large files in UNIX  e.g. more than 1GB? 

This command will list all files which are more than 1GB. You can tweak the size easily e.g. to find all files with more than 100 MB just use +100M.

find . - type f -size +1G -print

3) Find files which have been modified less than one day

  • find -mtime is used to search files based upon modification time
  • find -atime which denotes the last accessed time of the file
  • find –ctime denotes last changed time.
  • find . -mtime 1  (find all the files modified exact 1 day)
  • find . -mtime -1 (find all the files modified less than 1 day)
  • find . -mtime +1 (find all the files modified more than 1 day)

4) What is “chmod” command? What do you understand by this line “r– -w- –x?

  • chmod command is used to change permission of a file or directory in UNIX.
  • The line you see shows the permission for three different set of people : user, group and others
  • Each group has three permissions rwx stands for read, write and execute.
  • So in above line, user has only read permission, group members has write permissions and other people has only execute permission.
  • If it is a directory then you need execute permission to go inside that directory.

5) Find all the files and directories which hold the 777 permission

find –perm option is used to find files based upon permissions
find –perm 777 
find –perm 444 to get all files which allow read permission to the owner, group, and others.
find . –perm 444  //Here “.” or period denotes the current directory
To understand these numbers 444 , 777 etc , you need to understand file permissions in Linux.

6) How to do case insensitive search using find command

By default , the find searches are case sensitive.
So Use option “-i” with name.

find . –iname “error” –print ( -i is for ignore )
Note:   find –print and find is same as –print is a default option of the find command.

7) How to delete files for eg: log files, using find command

(Details about xargs is at the bottom of this page)

cd /usr/folder1
rm -rf “*.log”

find . -name “*.log”| xargs rm –f

Use of xargs along with find gives ability to perform any operation on each search result.

8) How to find all text file which contains word Exception

find . –name “*.txt”| xargs grep “Exception”

9) Count the number of times a particular word say “hello” is appearing in a file

grep -c "hello" filename

10) Find files only in the current directory not searching on subdirectories

find . -maxdepth 1 -type f -newer first_file

  • find –type option to specify the search for the only file, link or directory
  • find . The “.” says starts from current directory and include all subdirectory
  • maxdepth option specifies how deep find command has to search

11) Find files based on size

find . -size +1000c -exec ls -l {} \
find . -size +10000c -size -50000c

(+ means greater than, minus means less than..so here greater than 10k bytes but less than 50k bytes. Put c after the number, and specify the size in bytes)

12) Find files which are more than 10 days old and size greater than 50K.

find .mtime +10size +50000c -exec ls -l {} \;


13) Find and AWK

use awk in a combination of find to print a formatted output

find . -type l  | xargs ls -ld | awk ‘{print $10}’
  • “.” says starts from current directory and include all subdirectory
  • -type l” says list all links.

14) How do you find how many cpu are in your system and there details

By looking into file /etc/cpuinfo for example you can use below command:

cat /proc/cpuinfo

15) What is difference between ps -ef and ps -auxwww?
  • ps -ef will omit process with very long command line
  • ps -auxwww will list those process as well.
  • Show processes of the current user:   ps
  • Show full information about processes:   ps -f 
  • Show all the processes in the system: ps -ef | more

16) Display task status & system status?

To observing the current state of your Unix system, by default presenting you the list of top users of your system’s resources – CPU shares and memory, use the command “top

17) How do you find which processes are using a particular file?

By using lsof command in UNIX.

It wills list down PID of all the process which is using a particular file.

18) How do you find which remote hosts are connecting to your host on a particular port say “8080”?

By using netstat command

execute netstat -a | grep “port” and it will list the entire host which is connected to this host on port 8080.

19) What is nohup in UNIX?
nohup is a special command which is used to run process in background, but it is slightly different and is normally used for putting a process in background.

eg: nohup java -jar myapp.jar , and you can close the terminal without terminating the process.

An UNIX process started with nohup will not stop even if the user who has started log off from system.

20) How to kill a running process?

kill -9 PID

21) There is a file file1.txt which contains words “hello”, how will you replace all “hello” to “bye”?

sed s/hello/bye/g fileName

22) Your application home directory is full? How will you find which directory is taking how much space?

By using disk usage (DU) command in Unix for example du –sh . | grep G  will list down all the directory which has GIGS in Size.

23) How do you find for how many days your Server is up?

By using uptime command in UNIX


24) You have a tab separated file which contains name, email , phoneNumber. List down all  phoneNumber alone without their name and email?

You can either use  AWK or CUT command here.
CUT use tab as default separator so you can use

cut -f3 filename

25) Find ipaddress from hostname?

  • ping hostname
  • nslookup hostname
  • ifconfig -a | grep hostname

26) What does xargs do? Why do you use it along with find and grep?


One use case of the xargs command is to remove a list of files using the rm command. Under the Linux kernel before version 2.6.23, and under many other Unix-like systems, arbitrarily long lists of parameters cannot be passed to a command,  so the command may fail with an error message of “Argument list too long” (meaning that the exec system call’s limit on the length of a command line was exceeded):

rm /path/*


rm $(find /path -type f)

This can be rewritten using the xargs command to break the list of arguments into sublists small enough to be acceptable:

find /path -type f -print | xargs rm

In the above example, the find utility feeds the input of xargs with a long list of file names. xargs then splits this list into sublists and calls rm once for every sublist.