Linux Interview Questions For Software Testers Software Testing - Questions and Answers - Linux / Unix
Linux Interview Questions For Software Testers Software Testing - Questions and Answers - Linux / Unix
2. Q. How do you list all files in a directory, including the hidden files?
3. Q. How do you find out all processes that are currently running?
4. Q. How do you find out the processes that are currently running or a particular user?
most useful is command: tail file_name - you can see the end of the log file.
8. Q. What would you use to view contents of a large error log file?
A. Using telnet server_name or ssh -l (ssh - OpenSSH SSH client (remote login program))
1
11. Q. How do you list contents of a directory including all of its subdirectories, providing full
details and sorted by modification time?
12. Q. How do you create a symbolic link to a file (give some reasons of doing so)?
A. ln /.../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of the files.
That is, a link is a way of providing another name to the same file.
There are two types of links to a file:Hard link, Symbolic (or soft) link;
A. By storingand manipulatefiles.
15. Q. How do you check the sizes of all users� home directories (one command)?
all subdirectories and shows disk usage by each subdirectory with a final total at the end.
Q. in current directory
A. bg %4 (job 4)
18 Q. What utility would you use to replace a string '2001' for '2002' in a text file?
19. Q. What utility would you use to cut off the first column in a text file?
A. awk, kde
2
20. Q. How to copy file into directory?
A. rm -rf directory_name
commands are stored on the hard disk among the other utility programs.
A. The three main parts are the command, options and arguments.
24Q. What is the difference between an argument and an option (or switch)?
filename,
additional
information over and above the basic information each command supplies.
Command, the syntax, the options, the arguments with descriptive information.
A. Two forms of security are Passwords and File Security with permissions specified.
27. Q. What command do you type to find help about the command who?
A. $ man who
28. Q. What is the difference between home directory and working directory?
A. Home directory is the directory you begin at when you log into
The System. Working directory can be anywhere on the system and it is where you are currently
working.
3
29. Q. Which directory is closer to the top of the file system tree, parent directory or current
directory?
$ /business/acctg/payable/supplier/april
A. a) $ payable/supplier/april
b) $ /business/acctg/payable/supplier/april
c) What is the command to list all "help" files with one character extension?
A. a) ls *2 b) ls aid.* c) ls help.?
32. Q. What are two subtle differences in using the more and the pg commands?
A. With the more command you display another screenful by pressing the spacebar, with pg you
press the return key.
The more command returns you automatically to the UNIX shell when completed, while pg waits
until you press return.
33. Q. When is it better to use the more command rather than cat command?
A. It is sometimes better to use the more command when you are viewing a file that will display
over one screen.
34. Q. What are two functions the move mv command can carry out?
A. The mv command moves files and can also be used to rename a file or directory.
4
35. Q. Name two methods you could use to rename a file. A. Two methods that could be used:
b. copy the file and give it a new name and then remove the original
36. The soccer league consists of boy and girl teams. The boy file
names begin with B, the girl teams begin with G. All of these files are in one
b) erase the file Gteam. win after you have viewed the contents of the file
c) make a directory for the boy team files called "boys", and one for
A.
g) There are several ways to do this. Remember that we are currently in the directory
/soccer/girls.
cp../boys/Bteam.OO2 Gteam.OO5
or cd../boys
cp Bteam.OO2 ../girls/Gteam.OO5
5
37. Q. Draw a picture of the final directory structure for the "soccer" directory, showing all the
files and directories.
A.
1. 1.1 double-dot or ..
1.2 asterisk or *
1.3 question or ?
39. Q. List all the files beginning with A. To list all the files beginning with A command: ls A*
40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special
meaning? A. The double quote (") allows the dollar sign ($) to retain its
special meaning.
Both the backslash (\) and single quote (') would remove the special
mv fileO.txt newdir
mv filel.txt newdir
mv file2.txt newdir
mv file3.txt newdir
6
42. Q. List two ways to create a new file:
A.
A. The operator > either overwrites the existing file (WITHOUT WARNING) or creates a new
fileThe operator >> either adds the new contents to the end of an existing file or creates a new
file.
44.2 Add the file efg.txt to the end of the file abc.txt.
44.3 The file test data feeds information into the file called program
44.4 Observe the contents of the file called xyz.txt using MORE.
A.
A. Use du command (Summarize disk usage of each FILE, recursively for directories.)
Good to use arguments du –hs (-h, --human-readable print sizes in human readable format
(e.g., 1K 234M 2G)
A. mount -l
7
47. Q. How can you find a path to the file in the system? A. locate file_name (locate - list files in
databases that match a pattern) 48. Q. What LinuxHotKeys do you know? A. Ctrl-Alt-F1 Exit to
command prompt Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt Crtl-
Alt-Backspace Restart XWindows Ctrl-Alt-D Show desktop 49. Q. What can you tell about the
tar Command?
A. The tar program is an immensely useful archiving utility. It can combine an entire directory
tree into one large file suitable for transferring
or
compression.
Normal files, Directories, Hard links ,Symbolic links, Sockets, Named pipes
8
we have two files, 6 directories and one link to client-2.9.5 directory.
There is number of files in every directory, size and data of last change.
53. Q. If you would like to run two commands in sequence what operators you can use?
if you separate commands with && second command will be run only in the case
A. Use tar command (The GNU version of the tar archiving utility): tar -zxvf file_name.tar.gz 55.
Q. How do you execute a program or script, my_script in your current directoty?
A. ./my_script
A. grep time my_new.cfg Grepsearches the named input files (or standard input if no files are
named, or the file name - is given) for lines containing a match to the given pattern.
A. Top provides an ongoing look at processor activity in real time. It displays a listing of the
most CPU-intensive tasks on the system, and can provide an interactive inter face for
manipulating processes. (q is to quit)
A. by using /sin/ifconfig
9
59.Q. How to find difference in two configuration files on the same server?
diff -u /usr/home/my_project1/etc/ABC.conf
/usr/home/my_project2/etc/ABC.conf
60.Q. What is the best way to see the end of a logfile.log file?
A. Use tail command - output the last part of files tail -n file_name ( the last N lines, instead of
the last 10 as default)
61.Q. Please write a loop for removing all files in the current directory that contains a word 'log'
A. for i in *log*; do rm $i; done
Answer: cd –
A. Three modes -Command mode: letters or sequence of letters interactively command vi.
Command line mode: enter this mode by typing ":"and entry command
3. Q. How can you copy lines into the buffer in command mode?
3yy - copy 3 lines. Current line and two lines below it.
10