Linux Interview Questions For software testers

<p>Linux Interview Questions For software testers <br/>Linux面试题专栏, 软件测试面试题专栏 <br/><br/>Software testing ? Questions and Answers ? Linix / Unix<br/><br/>1. Q. How do you list files in a directory?<br/>A. ls ? list directory contents<br/>ls ?l (-l use a long listing format)<br/><br/>2. Q. How do you list all files in a directory, including the hidden files?<br/>A. ls -a (-a, do not hide entries starting with .)<br/><br/>3. Q. How do you find out all processes that are currently running?<br/>A. ps -f (-f does full-format listing.)<br/><br/>4. Q. How do you find out the processes that are currently running or a particular user?<br/>A. ps -au Myname (-u by effective user ID (supports names)) (a ? all users)<br/><br/>5. Q. How do you kill a process?<br/>A. kill -9 8 (process_id 8) or kill -9 %7 (job number 7)<br/>kill -9 -1 (Kill all processes you can kill.)<br/>killall ? kill processes by name most (useful ? killall java)<br/><br/>6. Q. What would you use to view contents of the file?<br/>A. less filename<br/>cat filename<br/>pg filename<br/>pr filename<br/>more filename<br/>most useful is command: tail file_name ? you can see the end of the log file.<br/><br/>7. Q. What would you use to edit contents of the file?<br/>A. vi screen editor or jedit, nedit or ex line editor<br/><br/>8. Q. What would you use to view contents of a large error log file?<br/>A. tail -10 file_name ( last 10 rows)<br/><br/>9. Q. How do you log in to a remote Unix box?<br/>A. Using telnet server_name or ssh -l ( ssh ? OpenSSH SSH client (remote login program))<br/><br/>10.Q. How do you get help on a UNIX terminal?<br/>A. man command_name<br/>info command_name (more information)<br/><br/>11.Q. How do you list contents of a directory including all of its<br/>subdirectories, providing full details and sorted by modification time?<br/>A. ls -lac<br/>-a all entries<br/>-c by time<br/><br/>12.Q. How do you create a symbolic link to a file (give some reasons of doing so)?<br/>A. ln /../file1 Link_name<br/>Links create pointers to the actual files, without duplicating the contents of<br/>the files. That is, a link is a way of providing another name to the same file.<br/>There are two types of links to a file:Hard link, Symbolic (or soft) link;<br/><br/>13.Q. What is a filesystem?<br/>A. Sum of all directories called file system.<br/>A file system is the primary means of file storage in UNIX.<br/>File systems are made of inodes and superblocks.<br/><br/>14.Q. How do you get its usage (a filesystem)?<br/>A. By storing and manipulate files.<br/><br/>15.Q. How do you check the sizes of all users? home directories (one command)?<br/>A. du -s<br/>df<br/><br/>The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end.<br/><br/>Q. in current directory<br/>A. ls -ps (p- directory; s ? size)<br/><br/>16.Q. How do you check for processes started by user ‘pat’?<br/><br/>A. ps -fu pat (-f -full_format u -user_name )<br/><br/>17.Q. How do you start a job on background?<br/><br/>A. bg %4 (job 4)<br/><br/>18 Q. What utility would you use to replace a string ‘2001′ for ‘2002′ in a text file?<br/><br/>A. Grep, Kde( works on Linux and Unix)<br/><br/>19. Q. What utility would you use to cut off the first column in a text file?<br/>A. awk, kde<br/><br/>20. Q. How to copy file into directory?<br/>A. cp /tmp/file_name . (dot mean in the current directory)<br/><br/>21. Q. How to remove directory with files?<br/>A. rm -rf directory_name<br/><br/>22. Q. What is the difference between internal and external commands?<br/>A. Internal commands are stored in the; same level as the operating system while external<br/>commands are stored on the hard disk among the other utility programs.<br/><br/>23. Q. List the three main parts of an operating system command:<br/>A. The three main parts are the command, options and arguments.<br/><br/>24 Q. What is the difference between an argument and an option (or switch)?<br/>A. An argument is what the command should act on: it could be a filename,<br/>directory or name. An option is specified when you want to request additional<br/>information over and above the basic information each command supplies.<br/><br/>25. Q. What is the purpose of online help?<br/>A. Online help provides information on each operating system command, the<br/>syntax, the options, the arguments with descriptive information.<br/>26. Q. Name two forms of security.<br/>A. Two forms of security are Passwords and File Security with permissions specified.<br/><br/>27. Q. What command do you type to find help about the command who?<br/>A. $ man who<br/><br/>28. Q. What is the difference between home directory and working directory?<br/>A. Home directory is the directory you begin at when you log into the<br/>system. Working directory can be anywhere on the system and it is where you are currently<br/>working.<br/><br/>29. Q. Which directory is closer to the top of the file system tree, parent directory or current directory?<br/>A. The parent directory is above the current directory, so it is closer to<br/>the root or top of the<br/>file system.<br/><br/>30. Q. Given the following pathname:<br/>$ /business/acctg/payable/supplier/april<br/>a) If you were in the directory called acctg, what would be the relative<br/>pathname name for the file called april?<br/>b) What would be the absolute pathname for april?<br/>A.<br/>a) $ payable/supplier/april<br/>b) $ /business/acctg/payable/supplier/april<br/><br/>31. Q. Suppose your directory had the following files:<br/>help. 1 help.2 help.3 help.4 help.O1 help.O2<br/>aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3<br/>a) What is the command to list all files ending in 2?<br/>b) What is the command to list all files starting in aid?<br/>c) What is the command to list all “help” files with one character extension?<br/>A.<br/>a) ls *2<br/>b) ls aid.*<br/>c) ls help.?<br/><br/>32. Q. What are two subtle differences in using the more and the pg commands?<br/>A. With the more command you display another screenful by pressing<br/>the spacebar, with pg you press the return key.<br/>The more command returns you automatically to the UNIX<br/>shell when completed, while pg waits until you press return.<br/><br/>33. Q. When is it better to use the more command rather than cat command?<br/>A. It is sometimes better to use the more command when you are viewing<br/>a file that will display over one screen.<br/><br/>34. Q. What are two functions the move mv command can carry out?<br/>A. The mv command moves files and can also be used to rename a file or directory.<br/><br/>35. Q. Name two methods you could use to rename a file.<br/>A. Two methods that could be used:<br/>a. use the mv command<br/>b. copy the file and give it a new name and then remove the original file if no longer needed.<br/><br/>36. The soccer league consists of boy and girl teams. The boy file names begin<br/>with B, the girl teams begin with G. All of these files are in one directory<br/>called “soccer”, which is your current directory:<br/>Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4<br/>Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3<br/>Write the commands to do the following:<br/>a) rename the file Bteam.abc to Bteam.OO3.<br/>b) erase the file Gteam. win after you have viewed the contents of the file<br/>c) make a directory for the boy team files called “boys”, and one for the girl team files<br/>called” girls”<br/>d) move all the boy teams into the “boys” directory<br/>e) move all the girl teams into the “girls” directory<br/>f) make a new file called Gteam.OO4 that is identical to Gteam.OOl<br/>g) make a new file called Gteam.OO5 that is identical to Bteam.OO2<br/>A.<br/>a) mv Bteam.abc Bteam.OO3.<br/>b) cat Gteam.win -or- more Gteam.win<br/>rm Gteam. win<br/>c) mkdir boys<br/>mkdir girls<br/>d) mv Bteam* boys<br/>e) mv Gteam* girls<br/>f) cd girls<br/>cp Gteam.OO1 Gteam.OO4<br/>g) There are several ways to do this. Remember that we are currently in the directory<br/>/soccer/girls.<br/>cp ../boys/Bteam.OO2 Gteam.OO5<br/>or<br/>cd ../boys<br/>cp Bteam.OO2 ../girls/Gteam.OO5<br/><br/>37. Q. Draw a picture of the final directory structure for the “soccer”<br/>directory, showing all the files and directories.<br/><br/>38. Q. What metacharacter is used to do the following:<br/>1.1 Move up one level higher in the directory tree structure<br/>1.2 Specify all the files ending in .txt<br/>1.3 Specify one character<br/>1.4 Redirect input from a file<br/>1.5 Redirect the output and append it to a file<br/>A.<br/>1. 1.1 double-dot or ..<br/>1.2 asterisk or *<br/>1.3 question or ?<br/>1.4 double greater than sign: &gt;&gt;<br/>1.5 the less than sign or &lt;<br/><br/>39. Q. List all the files beginning with A<br/>A. To list all the files beginning with A command: ls A*<br/><br/>40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special meaning?<br/>A. The double quote (”) allows the dollar sign ($) to retain its special meaning.<br/>Both the backslash () and single quote (’) would remove the special meaning of the dollar sign.<br/><br/>41. Q. What is a faster way to do the same command?<br/>mv fileO.txt newdir<br/>mv filel.txt newdir<br/>mv file2.txt newdir<br/>mv file3.txt newdir<br/>A. A shortcut method would be: mv file?.txt newdir<br/><br/>42. Q. List two ways to create a new file:<br/>A.<br/>a. Copy a file to make a new file.<br/>b. Use the output operator e.g. ls -l &gt; newfile.txt<br/><br/>43. Q. What is the difference between &gt; and &gt;&gt; operators?<br/>A. The operator &gt; either overwrites the existing file (WITHOUT WARNING) or creates a new file.<br/>The operator &gt;&gt; either adds the new contents to the end of an existing file or creates a new file.<br/><br/>44. Write the command to do the following:<br/>44.1 Redirect the output from the directory listing to a printer.<br/>44.2 Add the file efg.txt to the end of the file abc.txt.<br/>44.3 The file testdata feeds information into the file called program<br/>44.4 Observe the contents of the file called xyz.txt using MORE.<br/>44.5 Observe a directory listing that is four screens long.<br/>A.<br/>44.1 ls &gt; lpr<br/>44.2 cat efg.txt &gt;&gt; abc.txt<br/>44.3 program &lt; testdata<br/>44.4 more &lt; xyz.txt<br/>44.5 ls &gt; dirsave | more<br/><br/>45. Q. How do you estimate file space usage<br/>A. Use du command (Summarize disk usage of each FILE, recursively for<br/>directories.) Good to use arguments du -hs<br/>(-h, ?human-readable print sizes in human readable format (e.g., 1K 234M 2G)<br/>(-s, ?summarize display only a total for each argument)<br/><br/>46. Q. How can you see all mounted drives?<br/>A. mount -l<br/><br/>47. Q. How can you find a path to the file in the system?<br/>A. locate file_name (locate ? list files in databases that match a pattern)<br/><br/>48. Q. What Linux HotKeys do you know?<br/>A. Ctrl-Alt-F1 Exit to command prompt<br/>Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt<br/>Crtl-Alt-Backspace Restart XWindows<br/>Ctrl-Alt-D Show desktop<br/><br/>49. Q. What can you tell about the tar Command?<br/>A. The tar program is an immensely useful archiving utility. It can combine<br/>an entire directory tree into one large file suitable for transferring or<br/>compression.<br/><br/>50. Q. What types of files you know?<br/>A. Files come in eight flavors:<br/>Normal files<br/>Directories<br/>Hard links<br/>Symbolic links<br/>Sockets<br/>Named pipes<br/>Character devices<br/>Block devices<br/><br/>51. Q. How to copy files from on PC to another on the same network<br/>A. Use the following command:scp yur_file you_login@your_IP<br/>example: copy .conf file from your PC to alex computer-<br/>scp /etc/X11/xorg.conf alex@10.0.10.169:<br/><br/>52. Q. Please describe information below:<br/><br/>-rw-rw-r? 1 dotpc dotpc 102 Jul 18 2003 file.buf<br/>drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin<br/>lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -&gt; client-2.9.5<br/>drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9<br/>drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data<br/>drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs<br/>drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc<br/>drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5<br/>-rw-r?r? 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz<br/><br/>A. This is a result of command $ls -l<br/>we have two files, 6 directories and one link to client-2.9.5 directory.<br/>There is number of files in every directory, size and data of last change.<br/><br/>53. Q. If you would like to run two commands in sequence what operators you can use?<br/><br/>A. ; or &amp;&amp; the difference is:<br/>if you separate commands with ; second command will be run automatically.<br/>if you separate commands with &amp;&amp; second command will be run only in the case<br/>the first was run successfully.<br/><br/>54. Q. How you will uncompress the file?<br/>A. Use tar command (The GNU version of the tar archiving utility):<br/>tar -zxvf file_name.tar.gz<br/><br/>55. Q.How do you execute a program or script, my_script in your current directoty?<br/>A. ./my_script<br/><br/>56. Q.How to find current time configuration in the file my_new.cfg<br/>A. grep time my_new.cfg<br/>Grep searches the named input files (or standard input if<br/>no files are named, or the file name ? is given) for lines<br/>containing a match to the given pattern.<br/><br/>Q. What does grep() stand for?<br/>A. General Regular Expression Parser.<br/><br/>57. Q. What does the top command display?<br/>A. Top provides an ongoing look at processor activity in real<br/>time. It displays a listing of the most CPU-intensive<br/>tasks on the system, and can provide an interactive inter-<br/>face for manipulating processes. (q is to quit)<br/><br/>58. Q. How can you find configuration on linux?<br/>A. by using /sin/ifconfig<br/>If no arguments are given, ifconfig displays the status of the cur-<br/>rently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argu-<br/>ment is given, it displays the status of all interfaces, even those<br/>that are down. Otherwise, it configures an interface.<br/><br/>59. Q. How to find difference in two configuration files on the same server?<br/>A. Use diff command that is compare files line by line<br/>diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf<br/><br/>60. Q. What is the best way to see the end of a logfile.log file?<br/>A. Use tail command ? output the last part of files<br/>tail -n file_name ( the last N lines, instead of the last 10 as default)<br/><br/>61. Q. Please write a loop for removing all files in the current directory that contains a word ‘log’<br/>A. for i in *log*; do rm $i; done<br/><br/>62. Question: How to switch to a previously used directory?<br/>Answer: cd -<br/></p>
RangeTime:0.007194s
RangeMem:219.61 KB
返回顶部 留言