William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

LAMP interview

   1. Give an example of set of shell commands that will give you the number of files in a directory
   ls -l | grep ^- | wc -l
   
   2. How do you tell what process has a TCP port open in Linux
   netstat -a | grep tcp
   
   3. On a Red Hat Linux Variant how do you control whether a service starts when the system boots
   /etc/init.d, /etc/rc[0-6].d/K, S
   
   4. How do you tell the amount of free disk space left on a volume
   df -kh
   
   5. Give an example of a set of shell commands to tell how many times “bob” has logged on to the system this month
   
   6. Give an example of a recursively copying a directory from one location to another.
   cp -r abc/* ../bak/

   7. How do you modify the IP and Net mask of a system running a Red Hat Variant of Linux
		/sbin/ifconfig
		
   8. Give an example of a set of shell commands that will give you the number of “httpd” processes running on a Linux box.
   ps -ef | grep httpd | grep -v grep | wc -l


	   1. How do you list the files in an UNIX directory while also showing hidden files?
	   ls -a
	   
   2. How do you execute a UNIX command in the background?
   	command &
   	
   3. What UNIX command will control the default file permissions when files are created?
   chmod
   
   4. Explain the read, write, and execute permissions on a UNIX directory.
   drwxrwxr-x
   
   5. What is the difference between a soft link and a hard link?
   default ln (hard link); ln -s
   
   6. Give the command to display space usage on the UNIX file system.
   df -k
   
   7. Explain iostat, vmstat and netstat.
   	vmstat: virtual memory statistics
   	netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
   	
   8. How would you change all occurrences of a value using VI?
   :1,$s/value/str/g
   
   9. Give two UNIX kernel parameters that effect an Oracle install
   
   
  10. Briefly, how do you install Oracle software on UNIX.
	

-------------- Linux application programming questions ------------------------------

   1. Explain the difference between a static library and a dynamic library? 
   - Static library is linked into the executable, while a dynamic library (or shared object) is loaded while the executable has started.
   
   2. How do you create a static library? 
   - If you have a collection of object (.o) files, you can do it by running ar command. Generally a static library has a .a extension, 
    you can link it into an executable by providing -l libraryname to gcc.
   
   3. Where should the developed libraries be installed on the system? 
   - GNU recommends /usr/local/bin for binaries and /usr/local/lib for libraries.
   
   4. What’s LD_LIBRARY_PATH? 
   - It’s an environment variable that lists all the directories which should be searches for libraries before the standard directories are searched.
   
   5. How do you create a shared library? 
   - Create the object file with -fPIC for position-independent code, then run gcc with -shared option.
   
   6. How do you install a shared library? 
   - Run ldconfig in the standard directory that it’s installed in.
   
   7. What does ldd do? 
   - It shows a list of installed shared libraries.
   
   8. How do you dynamically load a library in your app? 
   - Use dlopen()
   
   9. What does nm command do? 
   - It reports the list of symbols in a given library.


----------------------- MySQL management interview questions --------------------------------

   1. How do you show the currently running queries? 
   - SHOW FULL PROCESSLIST;
   
   2. How do you kill a MySQL query? 
   - See the ID of it from the question above, then KILL id. You can separate multiple IDs by space.
   
   3. I need to find out how many client connections were aborted by MySQL server. 
   - It’s displayed in SHOW STATUS query, alternatively accessible via mysqladmin extended-status.
   
   4. What does SET SQL_AUTO_IS_NULL = 1 do? 
   - you can find the last inserted row for a table that contains an AUTO_INCREMENT column by issuing WHERE auto_increment_column IS NULL



------------------------ Apache ---------------------------
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


----------------------------------------------------------------------------------------------------------------------------------------
   
   9. On CentOS or Fedora based system using the package management application, how do you tell what package provided the file “libnss_ldap.so”
   
  10. What is the difference between VTP client, server, and transparent
  
  11. What is the maximum length of CAT6
  
  12. How does one set up a layer two link to share VLANs
  
  13. How does one implement redundant links at Layer 2
  Use Port Channel
  
  14. What is the difference between a hub, switch, and a router? What are the security advantages of switch vs. hub?
  hub = bigger collision and broadcast domain
	switch = collisions are now limited to the switched port, and broadcasts are limited generally to the same device and vlan.
	router = Terminates the 2 above layer 2 issues because it's handling layer 3 (In most cases).

		a. What are the security advantages of switch vs. hub
			Switches that are capable of Vlans can host several networks independent of each other if properly configured.

  15. Show an example of using telnet to learn the headers of an http server.
  telnet agencyhomeport.com 80
    
  16. In what OSI layer does PPP exist
  2/3
  
  17. What’s the difference between TCP and UDP
  UDP: broadcase, TCP: p2p
  
  18. Given a DNS server that has just started (with an empty cache) and host contacting this DNS server (using it’s OS setting) 
  to learn an address for google.com, list the steps the DNS server will take to learn it with IP addresses (each step will have 
  multiple possible IP addresses – you need choose only one per step).
  
  19. Why are layer 2 loops bad, and what protocol was designed to prevent them
  
  20. Given a radius server at 10.0.0.2 and a shared key of ‘abc123′ show the IOS commands necessary to authenticate switch users 
  against the radius server, while still allowing the use of local username / password pairs

----------------------------------
. An until loop ends with done (until – do – done)
. A while loop ends with done (while – do – done)
. The –f option is used to see if a file exists and is a regular file.
. The declare command is used to proclaim what type of variable it is so it can be handled accordingly.

. The variable $* can be used to see the arguments given when the shell script was invoked. 不是 $#.
. The value of $# can be checked to see how many positional parameters were used to call a script.

39. Which of the following should be used to test if the value of two integers is the same?
A. integer1 = integer2
B. integer1 –eq integer2
C. integer1 –a integer2
D. integer1 –o integer2 
A test can be done to see if the values of two integers are the same using the –eq parameter. Answer: B.

To test and see if two string values are the same, the equal sign (=) is used.
正好和perl相反.

17. You want to perform a test on a string to make sure that the length of it is not zero before using it. 
Which test should be done to accomplish this?

A. [[ string ]]
B. [[ -z string ]]
C. [[ -n string ]]
D. [[ -a string ]] 
. The syntax [[ -n string ]] is used to see if the string has a length greater than zero
. The test [[ -z string ]] will verify that the length of the string is zero.

. The expression [[:space:]] can be used to find any white space, including spaces and tabs. 

.Which of the following should be used to find "Sam" and "Samantha" in a file?
A. Sam(antha)*
B. Sam[antaha]
C. Sam|antha
D. Sam\(antha\)\? 
Using the expression Sam\(antha\)\? will always match "Sam" and it can be followed by zero or one (?) 
occurrences of "antha" . Answer: D.


To check the current runlevel: who -r 



What file contains the list of drives that are mounted at boot?
/etc/fstab - Linux / Other UNIX version
/etc/vfstab - Solaris UNIX

Explain the usage of the fourth field in /etc/fstab?
It is formatted as a comma separated list of options. Read mount command man page for all the option.

What is /etc/inittab file? In what file is the default run level defined?
System V init examines the '/etc/inittab' file for an 'initdefault' entry, which tells init whether there is a default runlevel. 
init is the program on Unix that spawns all other processes. It runs as a daemon and typically has PID 1.

. What command is used to list the top 10 files / directories size wise?
for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done
Advertisements

One response to “LAMP interview

  1. Gregg L 02/02/2013 at 2:10 pm

    Isn’t the answer to the second number 3 umask, and not chmod? Also I would do httpd -k stop or use the init script before I would use kill on httpd, but that’s just my preference.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: