日期:2014-05-16  浏览次数:20731 次

收集的一些简单的UNIX/Linux面试题
1. Q. How do you find out the processes that are currently running or a particular user?
   A. ps -au Myname   (-u by effective user ID (supports names)) (a - all users)

2. Q. How do you kill a process?
   A. kill -9  8 (process_id or kill -9  %7  (job number 7)
      kill -9 -1  (Kill all processes you can kill.)
      killall - kill processes by name most (useful - killall java)


3. Q. What would you use to view contents of a large error log file?
   A. tail  -10 file_name   ( last 10 rows)


4.Q. How do you list contents of a directory including all of its
  subdirectories, providing full details and sorted by modification time?
   A. ls -lac
      -a all entries
      -c by time


5.Q. How do you create a symbolic link to a file (give some reasons of doing so)?
   A. ln /../file1 Link_name
Hard Link, soft Link?

6.Q. How do you check the sizes of all users锟?home directories (one command)?
   A. du -s
      df

7.Q. How do you check for processes started by user 'pat'?

   A. ps -fu pat   (-f -full_format u -user_name )

8.Q. How do you start a job on background?

   A. bg  %4  (job 4)

9. Q. How to remove directory with files?
    A. rm -rf directory_name

10. Q. How can you see all mounted drives?
    A. mount -l

11. 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)

12. Q. What Linux  HotKeys 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

13. Q. If you would like to run two commands in sequence what operators you can use?

     A. ; or && the difference is:
if you separate commands with ; second command will be run automatically.
if you separate commands with && second command will be run only in the case
the first was run successfully.

14.  Question: How to switch to a previously used directory?
     Answer:  cd -