Linux Admin Sitemap  

Linux Admin Interview Questions

  1. How do you take a single line of input from the user in a shell script?
  2. Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.
    Answer: Here is a Python script that converts all DOS style backslashes to UNIX style slashes in a list of files:
    import os
    
    files = ['/path/to/file1', '/path/to/file2', '/path/to/file3']
    
    for file in files:
        new_file = file.replace('\\', '/')
        os.rename(file, new_file)
    

    This script uses the os.rename function to rename each file in the files list by replacing all instances of '\\' with '/' in the file path.
    Please note that it will only work for file in your local machine, if the files are on a network drive the os.rename will fail. In that case you can use the following code to replace the backslashes with forward slashes
    import os
    
    files = ['/path/to/file1', '/path/to/file2', '/path/to/file3']
    
    for file in files:
        with open(file, "r") as f:
            contents = f.read()
            contents = contents.replace("\\", "/")
        with open(file, "w") as f:
            f.write(contents)
    

    This will read the contents of the file, replace all the backslashes with forward slashes, and then write the modified contents back to the file.
  3. Write a regular expression (or sed script) to replace all occurrences of the letter ‘f’, followed by any number of characters, followed by the letter ‘a’, followed by one or more numeric characters, followed by the letter ‘n’, and replace what’s found with the string “UNIX”.

  4. Write a script to list all the differences between two directories.

  5. Write a program in any language you choose, to reverse a file.

  6. What are the fields of the password file?

  7. What does a plus at the beginning of a line in the password file signify?

  8. Using the man pages, find the correct ioctl to send console output to an arbitrary pty.

  9. What is an MX record?

  10. What is the prom command on a Sun that shows the SCSI devices?

  11. What is the factory default SCSI target for /dev/sd0?

  12. Where is that value controlled?

  13. What happens to a child process that dies and has no parent process to wait for it and what’s bad about this?

  14. What’s wrong with sendmail? What would you fix?

  15. What command do you run to check file system consistency?

  16. What’s wrong with running shutdown on a network?

  17. What can be wrong with setuid scripts?

  18. What value does spawn return?

  19. Write a script to send mail from three other machines on the network to root at the machine you’re on. Use a ‘here doc’, but include in the mail message the name of the machine the mail is sent from and the disk utilization statistics on each machine?

  20. Why can’t root just cd to someone’s home directory and run a program called a.out sitting there by typing “a.out”, and why is this good?

  21. What is the difference between UDP and TCP?

  22. What is DNS?

  23. What does nslookup do?

  24. How do you create a swapfile?

  25. How would you check the route table on a workstation/server?

  26. How do you find which ypmaster you are bound to?

  27. How do you fix a problem where a printer will cutoff anything over 1MB?

  28. What is the largest file system size in solaris? SunOS?

  29. What are the different RAID levels?