Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Showing posts with label Unix/Linux. Show all posts
Showing posts with label Unix/Linux. Show all posts

Thursday, 19 June 2008

Basic C++ and UNIX OS programming

Q1: Could you tell something about the Unix System Kernel? (from ITCO )

A1: The kernel is the heart of the UNIX openrating system, it’s reponsible for controlling the computer’s resouces and scheduling user jobs so that each one gets its fair share of resources.

Q2: What are each of the standard files and what are they normally associated with? (from ITCO )

A2: They are the standard input file, the standard output file and the standard error file. The first is usually associated with the keyboard, the second and third are usually associated with the terminal screen.

Q3: Detemine the code below, tell me exectly how many times is the operation sum++ performed ? (from ITCO )

for ( i = 0; i < j =" 100;"> 100 - i; j–)
sum++;
A3: (99 * 100)/2 = 4950
The sum++ is performed 4950 times.

Q4: Give 4 examples which belongs application layer in TCP/IP architecture? (from CISCO )

A4: FTP, TELNET, HTTP and TFTP

Q5: What’s the meaning of ARP in TCP/IP? (from CISCO )

A5: The "ARP" stands for Address Resolution Protocol. The ARP standard defines two basic message types: a request and a response. a request message contains an IP address and requests the corresponding hardware address; a replay contains both the IP address, sent in the request, and the hardware address.

Unix/Linux programming interview questions

Question 1: What is the major advantage of a hash table? (Asked by Silicon Magic Corp. people)

Answer: The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.

Question 2: What are the techniques that you use to handle the collisions in hash tables?(Asked by Silicon Magic Corp. people)

Answer: We can use two major techniques to handle the collisions. They are open addressing and separate chaining. In open addressing, data items that hash to a full array cell are placed in another cell in the array. In separate chaining, each array element consist of a linked list. All data items hashing to a given array index are inserted in that list.

Question 3: In Unix OS, what is the file server? (Asked by Silicon Magic Corp. people)

Answer: The file server is a machine that shares its disk storage and files with other machines on the network.

Question 4: What is NFS? What is its job?(Asked by Silicon Magic Corp. people)

Answer: NFS stands for Network File System. NFS enables filesystems physically residing on one computer system to be used by other computers in the network, appearing to users on the remote host as just another local disk.

Question 5: What is CVS? List some useful CVS commands.(Asked by Silicon Magic Corp.people)

Anser: CVS is Concurrent Version System. It is the front end to the RCS revision control system which extends the notion of revision control from a collection of files in a single directory to a hierarchical collection of directories consisting of revision controlled files. These directories and files can be combined together to form a software release.
There are some useful commands that are being used very often. They are

cvs checkout
cvs update
cvs add
cvs remove
cvs commit

Unix/Linux administration interview questions

What is LILO?

LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.

What is the main advantage of creating links to a file instead of copies of the file?

A: The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.

Write a command to find all of the files which have been accessed within the last 30 days.

find / -type f -atime -30 > December.files

This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call December.files.

What is the most graceful way to get to run level single user mode?

A: The most graceful way is to use the command init s.
If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s.

What does the following command line produce? Explain each aspect of this line.

$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log

A: First let’s dissect the line: The date gives the date and time as the first command of the line, this is followed by the a list of all running processes in long form with UIDs listed first, this is the ps -ef. These are fed into the awk which filters out all but the UIDs; these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort - uniq only works on sorted data - if the list is A, B, A, then A, B, A will be the output of uniq, but if it’s A, A, B then A, B is the output) which produces only one copy of each UID.

These UIDs are fed into wc -l which counts the lines - in this case the number of distinct UIDs running processes on the system. Finally the results of these two commands, the date and the wc -l, are appended to the file "Activity.log". Now to answer the question as to what this command line produces. This writes the date and time into the file Activity.log together with the number of distinct users who have processes running on the system at that time. If the file already exists, then these items are appended to the file, otherwise the file is created.

Unix sysadmin interview questions

Q: How would you make the following SQL statement run faster? SELECT * FROM TABLEA WHERE COL1=’A’ AND COL2=’B';
A: Make sure that COL1 and COL2 have indexes.
Find out which condition will return less values and use that as the first conditonal.

Q: What is Data Mining
A: Data Minig is the process of sifting through extremeley large amounts of Data to find trends or relevent information.

Q: Name the Seven layers in the OSI Model.
A: Appication, Presentation, Session, Transport, Network, Data Link, Phyiscal

Q: What is one way to view a unix network share on a Windows computer, within explorer
A: NFS, The Unix computer can be running a NFS Server Daemon.

Q: How would you find all the processes running on your computer.
A: Unix, is ps -ef or ps -aux depending on version.

Q: What is DHCP
A: DHCP is a way to dynamically assign IP address to computers. Dyanmic Host Configuration Protocol

Q: What is HTTP Tunneling
A: HTTP Tunneling is a security method that encryptes packets traveling throught the internet. Only the intended reciepent should be able to decrypt the packets. Can be used to Create Virtual Private Networks. (VPN)

Q: Scenario: You have 9 identical looking balls, however one ball is heavier than the others. You have two chances to use a balance. How do you find out which ball is the heaviest?
A: Split into groups of three, randomly choose two groups and use balance on them. If one group is heavier, then discard the other 6 balls. If the two groups are the same weight. The heavier ball must be in the group that was not on the scale. Now randomly choose two balls and test on balance. If they are the same weight, the heaviest ball is on one that was not tested. Else the heaviest ball is already known from the balance.

Linux admin interview questions

  1. How do you list the files in an UNIX directory while also showing hidden files? ls -ltra
  2. How do you execute a UNIX command in the background? Use the “&”.
  3. What UNIX command will control the default file permissions when files are created? umask
  4. Explain the read, write, and execute permissions on a UNIX directory. Read allows you to see and list the directory contents. Write allows you to create, edit and delete files and subdirectories in the directory. Execute gives you the permissions to run programs or shells from the directory.
  5. What is the difference between a soft link and a hard link? A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.
  6. Give the command to display space usage on the UNIX file system. df -lk
  7. Explain iostat, vmstat and netstat. iostat reports on terminal, disk and tape I/O activity. vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity. netstat reports on the contents of network data structures.
  8. How would you change all occurrences of a value using VI? %s/(old value)/(new value)/g
  9. Give two UNIX kernel parameters that effect an Oracle install. SHMMAX & SHMMNI
  10. Briefly, how do you install Oracle software on UNIX? Basically, set up disks, kernel parameters, and run orainst.

Interview questions for Linux admin

  1. Advantages/disadvantages of script vs compiled program.
  2. Name a replacement for PHP/Perl/MySQL/Linux/Apache and show main differences.
  3. Why have you choosen such a combination of products?
  4. Differences between two last MySQL versions. Which one would you choose and when/why?
  5. Main differences between Apache 1.x and 2.x. Why is 2.x not so popular? Which one would you choose and when/why?
  6. Which Linux distros do you have experience with?
  7. Which distro you prefer? Why?
  8. Which tool would you use to update Debian / Slackware / RedHat / Mandrake / SuSE ?
  9. You’re asked to write an Apache module. What would you do?
  10. Which tool do you prefer for Apache log reports?
  11. Your portfolio. (even a PHP guest book may work well)
  12. What does ‘route’ command do?
  13. Differences between ipchains and iptables.
  14. What’s eth0, ppp0, wlan0, ttyS0, etc.
  15. What are different directories in / for?
  16. Partitioning scheme for new webserver. Why?

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.
  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?

Solaris interview questions

  1. List the files in current directory sorted by size ? - ls -l | grep ^- | sort -nr
  2. List the hidden files in current directory ? - ls -a1 | grep "^\."
  3. Delete blank lines in a file ? - cat sample.txt | grep -v ‘^$’ > new_sample.txt
  4. Search for a sample string in particular files ? - grep “Debug” *.confHere grep uses the string “Debug” to search in all files with extension“.conf” under current directory.
  5. Display the last newly appending lines of a file during appendingdata to the same file by some processes ? - tail –f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.
  6. Display the Disk Usage of file sizes under each directory in currentDirectory ? - du -k * | sort –nr (or) du –k . | sort -nr
  7. Change to a directory, which is having very long name ? - cd CDMA_3X_GEN*Here original directory name is – “CDMA_3X_GENERATION_DATA”.
  8. Display the all files recursively with path under current directory ? - find . -depth -print
  9. Set the Display automatically for the current new user ? - export DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
  10. Display the processes, which are running under yourusername ? - ps –aef | grep MaheshvjHere, Maheshvj is the username.
  11. List some Hot Keys for bash shell ? - Ctrl+l – Clears the Screen. Ctrl+r – Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a – Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently running process into background.
  12. Display the files in the directory by file size ? - ls –ltr | sort –nr –k 5
  13. How to save man pages to a file ? - man | col –b > Example : man top | col –b > top_help.txt
  14. How to know the date & time for – when script is executed ? - Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, “timeinfo.inf” contains date & time details ie., when script is executed and history related to execution.
  15. How do you find out drive statistics ? - iostat -E
  16. Display disk usage in Kilobytes ? - du -k
  17. Display top ten largest files/directories ? - du -sk * | sort -nr | head
  18. How much space is used for users in kilobytes ? - quot -af
  19. How to create null file ? - cat /dev/null > filename1
  20. Access common commands quicker ? - ps -ef | grep -i $@
  21. Display the page size of memory ? - pagesize -a
  22. Display Ethernet Address arp table ? - arp -a
  23. Display the no.of active established connections to localhost ? - netstat -a | grep EST
  24. Display the state of interfaces used for TCP/IP traffice ? - netstat -i
  25. Display the parent/child tree of a process ? - ptree Example: ptree 1267
  26. Show the working directory of a process ? - pwdx Example: pwdx 1267
  27. Display the processes current open files ? - pfiles Example: pfiles 1267
  28. Display the inter-process communication facility status ? - ipcs
  29. Display the top most process utilizing most CPU ? - top –b 1
  30. Alternative for top command ? - prstat -a

Interview questions for Web developer position

  1. What’s the difference between primary key and unique key?
  2. The Perl script on the site is working slow. What’s your plan of attack?
  3. Name several reasons why a Web site would not work entirely.
  4. Write an SQL statement that would select only the customers who made multiple orders within a single week.
  5. What version control systems do you use?
  6. How do you configure the maximum number of processes in Apache?
  7. How much memory do you need for Web server app? Describe your logic of calculating this number.
  8. What are response codes 302 and 303?
  9. How do you delete all files with file extension temp recursively on a Linux box?
  10. What Perl tools do you use for coding, testing, debugging?
  11. Do you use DHTML and JavaScript? Describe the projects you’ve used them in.

General UNIX interview questions

  1. What are the main differences between Apache 1.x and 2.x?
  2. What does the “route” command do?
  3. What are the read/write/execute bits on a directory mean?
  4. What does iostat do?
  5. what does vmstat do?
  6. What does netstat do?
  7. What is the most graceful way to bring a system into single user mode?
  8. How do you determine disk usage?
  9. What is AWK?
  10. What is SED?
  11. What is the difference between binaries in /bin, and /usr/bin?
  12. What is a dynamically linked file?
  13. What is a statically linked file?

Network administrator interview questions

  1. What is the difference between layer 2 and layer 3 in the OSI model?
  2. What is the difference between a hub, switch, and router?
  3. What is a VLAN?
  4. What is the difference between TCP and UDP?
  5. How do you distinguish a DNS problem from a network problem?
  6. What is a runt, Giant, and collision?
  7. What is a broadcast storm?
  8. What is the purpose of VRRP?
  9. What is a VPN?
  10. What information about a peer would I need to establish a VPN?
  11. What is a full-class C in CIDR notation?
  12. What is a default route?
  13. What is a metric?
  14. What is a MAC address?
  15. What is ARP/RARP?
  16. Describe a TCP connection sequence
  17. What is MTU?
  18. What other TCP setting can you modify besides MTU to shorten packets?

Sysadmin interview questions

  1. What is a level 0 backup?
  2. What is an incremental backup?
  3. What steps are required to perform a bare-metal recovery?
  4. Name key files or directories on a UNIX system that should always be backed up.
  5. Name key files or directories on a Windows system that should always be backed up.
  6. What is RAID 0?
  7. What is RAID 0+1? Why is it better than 0?
  8. What is RAID-5?
  9. Why would you NOT want to encapsulate a root directory with Veritas?
  10. What is concatenation?
  11. What is striping?
  12. What is a spindle?

Network developer interview questions

  1. What ports does FTP traffic travel over?
  2. What ports does mail traffic utilize?
  3. What ports do HTTP and HTTPS use?
  4. Why is NTP required in an NFS network?
  5. Name some common mal software on the server side
  6. What is CPAN? How do you access it?
  7. What is PEAR?
  8. What advantages does mod_perl have over a perl CGI?
  9. What is required to do SSL in Apache 1.x?
  10. What is Tcl?
  11. What is a servlet engine/container?
  12. What is BIND?
  13. Name the steps to setup a slave zone in BIND
  14. Name the steps to setup a primary zone in BIND
  15. What commands would you use under Solaris or Linux to modify/view an LDAP tree?

OS interview questions

  1. What is MUTEX ?
  2. What isthe difference between a ‘thread’ and a ‘process’?
  3. What is INODE?
  4. Explain the working of Virtual Memory.
  5. How does Windows NT supports Multitasking?
  6. Explain the Unix Kernel.
  7. What is Concurrency? Expain with example Deadlock and Starvation.
  8. What are your solution strategies for “Dining Philosophers Problem” ?
  9. Explain Memory Partitioning, Paging, Segmentation.
  10. Explain Scheduling.
  11. Operating System Security.
  12. What is Semaphore?
  13. Explain the following file systems : NTFS, Macintosh(HPFS), FAT .
  14. What are the different process states?
  15. What is Marshalling?
  16. Define and explain COM?
  17. What is Marshalling?
  18. Difference - Loading and Linking ?

Oracle on Linux/Unix questions

  1. How many memory layers are in the shared pool?
  2. How do you find out from the RMAN catalog if a particular archive log has been backed-up?
  3. How can you tell how much space is left on a given file system and how much space each of the file system’s subdirectories take-up?
  4. Define the SGA and how you would configure SGA for a mid-sized OLTP environment? What is involved in tuning the SGA?
  5. What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?
  6. Other than making use of the statspack utility, what would you check when you are monitoring or running a health check on an Oracle 8i or 9i database?
  7. How do you tell what your machine name is and what is its IP address?
  8. How would you go about verifying the network name that the local_listener is currently using?
  9. You have 4 instances running on the same UNIX box. How can you determine which shared memory and semaphores are associated with which instance?
  10. What view(s) do you use to associate a user’s SQLPLUS session with his o/s process?
  11. What is the recommended interval at which to run statspack snapshots, and why?
  12. What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given statement use an index, even if the index scan may appear to be calculated as more costly?
  13. Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at 2AM.
  14. How would you edit your CRONTAB to schedule the running of /test/test.sh to run every other day at 2PM?
  15. What do the 9i dbms_standard.sql_txt() and dbms_standard.sql_text() procedures do?
  16. In which dictionary table or view would you look to determine at which time a snapshot or MVIEW last successfully refreshed?
  17. How would you best determine why your MVIEW couldn’t FAST REFRESH?
  18. How does propagation differ between Advanced Replication and Snapshot Replication (read-only)?
  19. Which dictionary view(s) would you first look at to understand or get a high-level idea of a given Advanced Replication environment?
  20. How would you begin to troubleshoot an ORA-3113 error?
  21. Which dictionary tables and/or views would you look at to diagnose a locking issue?
  22. An automatic job running via DBMS_JOB has failed. Knowing only that “it’s failed”, how do you approach troubleshooting this issue?
  23. How would you extract DDL of a table without using a GUI tool?
  24. You’re getting high “busy buffer waits” - how can you find what’s causing it?
  25. What query tells you how much space a tablespace named “test” is taking up, and how much space is remaining?
  26. Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.
  27. Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracle’s. What database recovery options are available? Database is in archive log mode.
  28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).
  29. How do you increase the OS limitation for open files (LINUX and/or Solaris)?
  30. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.
  31. Explain how you would restore a database using RMAN to Point in Time?
  32. How does Oracle guarantee data integrity of data changes?
  33. Which environment variables are absolutely critical in order to run the OUI?
  34. What SQL query from v$session can you run to show how many sessions are logged in as a particular user account?
  35. Why does Oracle not permit the use of PCTUSED with indexes?
  36. What would you use to improve performance on an insert statement that places millions of rows into that table?
  37. What would you do with an “in-doubt” distributed transaction?
  38. What are the commands you’d issue to show the explain plan for “select * from dual”?
  39. In what script is “snap$” created? In what script is the “scott/tiger” schema created?
  40. If you’re unsure in which script a sys or system-owned object is created, but you know it’s in a script from a specific directory, what UNIX command from that directory structure can you run to find your answer?
  41. How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?
  42. You create a private database link and upon connection, fails with: ORA-2085: connects to . What is the problem? How would you go about resolving this error?
  43. I have my backup RMAN script called “backup_rman.sh”. I am on the target database. My catalog username/password is rman/rman. My catalog db is called rman. How would you run this shell script from the O/S such that it would run as a background process?
  44. Explain the concept of the DUAL table.
  45. What are the ways tablespaces can be managed and how do they differ?
  46. From the database level, how can you tell under which time zone a database is operating?
  47. What’s the benefit of “dbms_stats” over “analyze”?
  48. Typically, where is the conventional directory structure chosen for Oracle binaries to reside?
  49. You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?
  50. How do you recover a datafile that has not been physically been backed up since its creation and has been deleted. Provide syntax example.

Topics for a Unix sysadmin interview

1. Job Scheduling; mainly crontab, at, batch command
2. Backup stetegy; incremental, full system back up; diff between tar & ufsdump
3. diff between hard link & softlink
4. How to list only the directories inside a directory (Ans. ls -l|grep "^d")
5. RAID levels; pros & cons of diffrent levels; what is RAID 1+0

6. How to recover a system whose root password has lost?
7. What is a daemon?
8. How to put a job in background & bring it to foreground?
9. What is default permissions for others in a file?
10. Questions on shell initialization scripts?
11. Questions on restricted shell
12. What is diff betwn grep & find?
13. What is egrep?
14. Questions on shell programming
15. What is a pipe?
16. Questions on Solaris patch management like pkgadd etc
17. Questions on file system creation; actually what happens when we create a file system?
18. Questions on RBAC? what is a role accound & what is a profile?
19. From command line how will you add a user account? the full command will all arguments.
20. Fs it advisable to put a swap partion in RAID1 (mirroring?) pros & cons?

Apache interview questions

  1. On a fresh install, why does Apache have three config files - srm.conf, access.conf and httpd.conf? - The first two are remnants from the NCSA times, and generally you should be ok if you delete the first two, and stick with httpd.conf.
  2. What’s the command to stop Apache? - kill the specific process that httpd is running under, or killall httpd. If you have apachectl installed, use apachectl stop.
  3. What does apachectl graceful do? - It sends a SIGUSR1 for a restart, and starts the apache server if it’s not running.
  4. How do you check for the httpd.conf consistency and any errors in it? - apachectl configtest
  5. When I do ps -aux, why do I have one copy of httpd running as root and the rest as nouser? - You need to be a root to attach yourself to any Unix port below 1024, and we need 80.
  6. But I thought that running apache as a root is a security risk? - That one root process opens port 80, but never listens to it, so no user will actually enter the site with root rights. If you kill the root process, you will see the other kids disappear as well.
  7. Why do I get the message "… no listening sockets available, shutting down"? - In Apache 2 you need to have a listen directive. Just put Listen 80 in httpd.conf.
  8. How do you set up a virtual host in Apache?

    ServerAdmin admin@techinterviews.com
    DocumentRoot /home/apache/share/htdocs/hostedsites
    ServerName www.interviewdoor.com
    ErrorLog /home/apache/logs/error/hostedsites/error_log
    TransferLog /home/apache/logs/access/hostedsites/access_log
  9. What is ServerType directive? - It defines whether Apache should spawn itself as a child process (standalone) or keep everything in a single process (inetd). Keeping it inetd conserves resources. This is deprecated, however.
  10. What is mod_vhost_alias? - It allows hosting multiple sites on the same server via simpler configurations.
  11. What does htpasswd do? - It creates a new user in a specified group, and asks to specify a password for that user.
  12. If you specify both deny from all and allow from all, what will be the default action of Apache? - In case of ambiguity deny always takes precedence over allow.

Simple FreeBSD questions

Test the basic knowledge of FreeBSD.

  1. What’s in the file /etc/ttys? - Configuration for virtual consoles for the startup. By default FreeBSD has 8 virtual consoles.
  2. You’re told that the permissions of a file are 645. Quick, how do you calculate what it means? - The permissions value are always 4 for read, 2 for write, 1 for execute. The three numbers are always for owner, group, and everybody on the system. Therefore 645 means: owner - read and write, group - read only, everybody - read and execute. You’ll rarely see such a permission set, but for interview question it might just work.
  3. Explain what each column means in the top command:
    48630 techinterviews         2   0 29816K  9148K select   3:18  0.00%  0.00% navigator-linu
    175 root 2 0 924K 252K select 1:41 0.00% 0.00% syslogd
    7059 techinterviews 2 0 7260K 4644K poll 1:38 0.00% 0.00% mutt

    The first column is the process id, followed by the username, followed by priority…

  4. Explain the difference between SIGTERM and SIGKILL. SIGTERM asks the application to terminate in a polite way, it warns about the pending closure and asks the app to finish whatever it is doing. SIGKILL will kill the process no matter what. This is telling the application that it will be shut down no matter what.
  5. Explain the difference between SIGHUP, SIGUSR1 and SIGUSR2. Those are application specific and therefore are not defined on the OS level.
  6. How do you change your shell to bash?
    % chsh -s /usr/local/bin/bash

Interview questions for a sysadmin

1. Difference between layer 2 and layer 3 devices?
2. What is VLAN?
3. What is the subnet for a class C network?
4. Are you familiar with automounter?
5. Have you configured an NIS server/client?
6. Have your configured a NFS server?
7. Windows and Linux interoperability how to?
8. What is RAID 1?

Basic shell scripting questions

  1. How do you find out what’s your shell? - echo $SHELL
  2. What’s the command to find out today’s date? - date
  3. What’s the command to find out users on the system? - who
  4. How do you find out the current directory you’re in? - pwd
  5. How do you remove a file? - rm
  6. How do you remove a - rm -rf
  7. How do you find out your own username? - whoami
  8. How do you send a mail message to somebody? - mail somebody@techinterviews.com -s ‘Your subject’ -c ‘cc@techinterviews.com‘
  9. How do you count words, lines and characters in a file? - wc
  10. How do you search for a string inside a given file? - grep string filename
  11. How do you search for a string inside a directory? - grep string *
  12. How do you search for a string in a directory with the subdirectories recursed? - grep -r string *
  13. What are PIDs? - They are process IDs given to processes. A PID can vary from 0 to 65535.
  14. How do you list currently running process? - ps
  15. How do you stop a process? - kill pid
  16. How do you find out about all running processes? - ps -ag
  17. How do you stop all the processes, except the shell window? - kill 0
  18. How do you fire a process in the background? - ./process-name &
  19. How do you refer to the arguments passed to a shell script? - $1, $2 and so on. $0 is your script name.
  20. What’s the conditional statement in shell scripting? - if {condition} then … fi
  21. How do you do number comparison in shell scripts? - -eq, -ne, -lt, -le, -gt, -ge
  22. How do you test for file properties in shell scripts? - -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability
  23. How do you do Boolean logic operators in shell scripting? - ! tests for logical not, -a tests for logical and, and -o tests for logical or.
  24. How do you find out the number of arguments passed to the shell script? - $#
  25. What’s a way to do multilevel if-else’s in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi
  26. How do you write a for loop in shell? - for {variable name} in {list} do {statement} done
  27. How do you write a while loop in shell? - while {condition} do {statement} done
  28. How does a case statement look in shell scripts? - case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac
  29. How do you read keyboard input in shell scripts? - read {variable-name}
  30. How do you define a function in a shell script? - function-name() { #some code here return }
  31. How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.