Tuesday, August 17, 2010

LAMP Web Server with out SSL


This document will walk you through the installation of what is known as a “LAMP” system: Linux,ApacheMySQL and PHP. Depending on who you talk to, the P also stands for Perl or Python, but in general, it is assumed to be PHP. I run CentOS on my servers; these directions were written for CentOS/Red Hat/Fedora. I have had requests for SuSE (another RPM-based distribution) as well as Debian-based systems, so I will work on variants of these directions for those distributions in the future (donations might help speed that process up!). The main difference between the distributions is in the paths to the startup scripts. Red Hat systems used /etc/rc.d/init.d and SuSE uses /etc/init.d.
Initial Steps
PLEASE BE AWARE THAT A SOURCE-BASED INSTALLATION LIKE THIS ONE IS NOT NEEDED FOR A BASIC LAMP SERVER! You should only be doing a source-based installation if you need to alter settings in one or more components of the LAMP stack (e.g., you need a feature in PHP that isn’t in the default RPM). If you are just getting started with LAMP, use the binaries provided by your distribution – it is much simpler, and a lot easier to upgrade later.
Most out-of-the-box Red Hat Linux installations will have one or more of the LAMP components installed via RPM files. I personally believe in installing things like this from source, so I get the most control over what’s compiled in, what’s left out, etc. But source code installs can wreak havoc if overlaid on top of RPM installs, as the two most likely won’t share the same directories, etc.
If you have not yet installed your Linux OS, or just for future reference, do not choose to install Apache, PHP, or MySQL during the system installation. Then you can immediately proceed with the source-based install listed here.
Note: to install applications from source code, you will need a C++ compiler (gcc++) installed. This is generally taken care of, but I’ve had enough queries about it that I’ve added this note to avoid getting more! You can use your distribution’s install CDs to get the proper version of the compiler. Or, if you are using an RPM based distro, you can use a site like http://www.rpmfind.net/ to locate the correct RPM version for your system. (You will obviously not be able to use/rebuild a source RPM to get the compiler installed, as you need the compiler to build the final binary RPM!) On a Fedora system, you can do this command:
su – root
yum install gcc gcc-c++
Log in as root
Because we will be installing software to directories that “regular” users don’t have write access to, and also possibly uninstalling RPM versions of some applications, we’ll log in as root. The only steps that need root access are the actual installation steps, but by doing the configure and makesteps as root, the source code will also be inaccessible to “regular” users.
If you do not have direct access (via keyboard) to the server, PLEASE use Secure Shell (SSH) to access the server and not telnet!! Whenever you use telnet (or plain FTP for that matter), you are transmitting your username, password, and all session information in “plain text”. This means that anyone who can access a machine someplace between your PC and your server can snoop your session and get your info. Use encryption wherever possible!
su – root
Remove RPM Versions of the Applications
Before we start with our source code install, we need to remove all the existing RPM files for these products. To find out what RPMs are already installed, use the RPM query command:
rpm -qa
in conjunction with grep to filter your results:
rpm -qa | grep -i apache
rpm -qa | grep -i httpd
rpm -qa | grep -i php
rpm -qa | grep -i mysql
The ‘httpd’ search is in case you have Apache2 installed via RPM.
To remove the RPMs generated by these commands, do
rpm -e filename
for each RPM you found in the query. If you have any content in your MySQL database already, the RPM removal step should not delete the database files. When you reinstall MySQL, you should be able to move all those files to your new MySQL data directory and have access to them all again.
Get the Source Code for all Applications
We want to put all our source code someplace central, so it’s not getting mixed up in someone’s home directory, etc.
cd /usr/local/src
One way application source code is distributed is in what are known as “tarballs.” The tarcommand is usually associated with making tape backups – tar stands for Tape ARchive. It’s also a handy way to pack up multiple files for easy distribution. Use the man tar command to learn more about how to use this very flexible tool.
At the time of updating this, the current versions of all the components we’ll use are:
MySQL – 4.1.22
Apache – 1.3.37
PHP – 4.4.6
Please note: these are the only versions of these that I have set up myself, and verified these steps against. If you use another version of any component, especially a newer version, this HOWTO may not be accurate, and I won’t be able to provide free support under those circumstances. Paid support and assistance is always available however.
wget http://www.php.net/distributions/php-4.4.6.tar.gz
wget http://apache.oregonstate.edu/httpd/apache_1.3.37.tar.gz
There may be an Apache mirror closer to you – check their mirror page for other sources. Then insert the URL you get in place of the above for the wget command.
For MySQL, go to http://www.mysql.com/ and choose an appropriate mirror to get the newest MySQL version (v4.1.22).
Unpack the Source Code
tar zxf php-4.4.6.tar.gz
tar zxf apache_1.3.37.tar.gz
tar zxf mysql-4.1.22.tar.gz
This should leave you with the following directories:
/usr/local/src/php-4.4.6
/usr/local/src/apache_1.3.37
/usr/local/src/mysql-4.1.22
Build and Install MySQL
First, we create the group and user that “owns” MySQL. For security purposes, we don’t want MySQL running as root on the system. To be able to easily identify MySQL processes in top or a pslist, we’ll make a user and group named mysql:
groupadd mysql
useradd -g mysql -c “MySQL Server” mysql
If you get any messages about the group or user already existing, that’s fine. The goal is just to make sure we have them on the system.
What the useradd command is doing is creating a user mysql in the group mysql with the “name” of MySQL Server. This way when it’s showed in various user and process watching apps, you’ll be able to tell what it is right away.
root is started (via the safe_mysqld script). Then child processes, owned by mysql are spawned from it. The parent controlling process watches the child processes and restarts them automatically if they get killed off, etc.
–>Now we’ll change to the “working” directory where the source code is, change the file ‘ownership’ for the source tree (this prevents build issues in reported in some cases where the packager’s username was included on the source and you aren’t using the exact same name to compile with!) and start building.
The configure command has many options you can specify. I have listed some fairly common ones; if you’d like to see others, do:
./configure –help | less
to see them all.
cd /usr/local/src/mysql-4.1.22
chown -R root.root *
make clean
./configure \
–prefix=/usr/local/mysql \
–localstatedir=/usr/local/mysql/data \
–disable-maintainer-mode \
–with-mysqld-user=mysql \
–with-unix-socket-path=/tmp/mysql.sock \
–without-comment \
–without-debug \
–without-bench
18-Jul-2005: If you are installing MySQL 4.0.x on Fedora Core 4, there is a problem with LinuxThreads that prevents MySQL from compiling properly. Installing on Fedora Core 3 works fine though. Thanks to Kevin Spencer for bringing this to my attention. There is a workaround listed athttp://bugs.mysql.com/bug.php?id=9497. Thanks to Collin Campbell for that link. Another solution can be found at http://bugs.mysql.com/bug.php?id=2173. Thanks to Kaloyan Raev for that one.
Now comes the long part, where the source code is actually compiled and then installed. Plan to get some coffee or take a break while this step runs. It could be 10-15 minutes or more, depending on your system’s free memory, load average, etc.
make && make install
Configure MySQL
MySQL is “installed” but we have a few more steps until it’s actually “done” and ready to start. First run the script which actually sets up MySQL’s internal database (named, oddly enough, mysql).
./scripts/mysql_install_db
Then we want to set the proper ownership for the MySQL directories and data files, so that only MySQL (and root) can do anything with them.
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
Copy the default configuration file for the expected size of the database (small, medium, large, huge)
cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf
If you get an error message about the data directory not existing, etc., something went wrong in the mysql_install_db step above. Go back and review that; make sure you didn’t get some sort of error message when you ran it, etc.
Now we have to tell the system where to find some of the dynamic libraries that MySQL will need to run. We use dynamic libraries instead of static to keep the memory usage of the MySQL program itself to a minimum.
echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
ldconfig
Now create a startup script, which enables MySQL auto-start each time your server is restarted.
cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig –level 3 mysql on
Then set up symlinks for all the MySQL binaries, so they can be run from anyplace without having to include/specify long paths, etc.
cd /usr/local/mysql/bin
for file in *; do ln -s /usr/local/mysql/bin/$file /usr/bin/$file; done
MySQL Security Issues
First, we will assume that only applications on the same server will be allowed to access the database (i.e., not a program running on a physically separate server). So we’ll tell MySQL not to even listen on port 3306 for TCP connections like it does by default.
Edit /etc/my.cnf and uncomment the
skip-networking
line (delete the leading #).
Start MySQL
First, test the linked copy of the startup script in the normal server runlevel start directory, to make sure the symlink was properly set up:
cd ~
/etc/rc.d/rc3.d/S90mysql start
If you ever want to manually start or stop the MySQL server, use these commands:
/etc/rc.d/init.d/mysql start
/etc/rc.d/init.d/mysql stop
Let’s “test” the install to see what version of MySQL we’re running now:
mysqladmin version
It should answer back with the version we’ve just installed…
Now we’ll set a password for the MySQL root user (note that the MySQL root user is not the same as the system root user, and definitely should not have the same password as the system rootuser!).
mysqladmin -u root password new-password
(obviously, insert your own password in the above command instead of the “new-password” string!)
You’re done! MySQL is now installed and running on your server. It is highly recommended that you read about MySQL security and lock down your server as much as possible. The MySQL site has info at http://www.mysql.com/doc/en/Privilege_system.html.
Test MySQL
To run a quick test, use the command line program mysql:
mysql -u root -p
and enter your new root user password when prompted. You will then see the MySQL prompt:
mysql>
First, while we’re in here, we’ll take care of another security issue and delete the sample databasetest and all default accounts except for the MySQL root user. Enter each of these lines at themysql> prompt:
drop database test;
use mysql;
delete from db;
delete from user where not (host=”localhost” and user=”root”);
flush privileges;
As another security measure, I like to change the MySQL administrator account name from root to something harder to guess. This will make it that much harder for someone who gains shell access to your server to take control of MySQL.
MAKE SURE YOU REMEMBER THIS NEW NAME, AND USE IT WHEREVER
YOU SEE “root” IN OTHER DIRECTIONS, WEBSITES, ETC.
ONCE YOU DO THIS STEP, THE USERNAME “root” WILL CEASE TO
EXIST IN YOUR MYSQL CONFIGURATION!
update user set user=”sqladmin” where user=”root”;
flush privileges;
Now, on with the “standard” testing… First, create a new database:
create database foo;
You should see the result:
Query OK, 1 row affected (0.04 sec)
mysql>
Delete the database:
drop database foo;
You should see the result:
Query OK, 0 rows affected (0.06 sec)
mysql>
To exit from mysql enter \q:
\q
Build and Install Apache (with DSO support)
The advantage to building Apache with support for dynamically loaded modules is that in the future, you can add functionality to your webserver by just compiling and installing modules, and restarting the webserver. If the features were compiled into Apache, you would need to rebuild Apache from scratch every time you wanted to add or update a module (like PHP). Your Apache binary is also smaller, which means more efficient memory usage.
The downside to dynamic modules is a slight performance hit compared to having the modules compiled in.
cd /usr/local/src/apache_1.3.37
make clean
./configure \
–prefix=/usr/local/apache \
–enable-shared=max \
–enable-module=rewrite \
–enable-module=so
make && make install
Build and Install PHP
This section has only been tested with PHP v4.x. If you are trying to build PHP 5.x, I do not have experience with this yet, and do not provide free support for you to get it working. Please note that there are many options which can be selected when compiling PHP. Some will have library dependencies, meaning certain software may need to be already installed on your server before you start building PHP. You can use the command
./configure –help | less
once you change into the PHP source directory. This will show you a list of all possible configuration switches.
cd /usr/local/src/php-4.4.6
./configure \
–with-apxs=/usr/local/apache/bin/apxs \
–disable-debug \
–enable-ftp \
–enable-inline-optimization \
–enable-magic-quotes \
–enable-mbstring \
–enable-mm=shared \
–enable-safe-mode \
–enable-track-vars \
–enable-trans-sid \
–enable-wddx=shared \
–enable-xml \
–with-dom \
–with-gd \
–with-gettext \
–with-mysql=/usr/local/mysql \
–with-regex=system \
–with-xml \
–with-zlib-dir=/usr/lib
make && make install
cp php.ini-dist /usr/local/lib/php.ini
I like to keep my config files all together in /etc. I set up a symbolic link like this:
ln -s /usr/local/lib/php.ini /etc/php.ini
Then I can just open /etc/php.ini in my editor to make changes.
Recommended reading on securing your PHP installation
Edit the Apache Configuration File (httpd.conf)
I like to keep all my configuration files together in /etc, so I set up a symbolic link from the actual location to /etc:
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
Now open /etc/httpd.conf in your favorite text editor, and set all the basic Apache options in accordance with the official Apache instructions (beyond the scope of this HOWTO).
To ensure your PHP files are properly interpreted, and not just downloaded as text files, remove the # at the beginning of the lines which read:
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps
If the AddType lines above don’t exist, manually enter them (without the leading # of course) after the line
AddType application/x-tar .tgz
or anyplace within the  section of httpd.conf.
If you wish to use other/additional extensions/filetypes for your PHP scripts instead of just .php, add them to the AddType directive:
AddType application/x-httpd-php .php .foo
AddType application/x-httpd-php-source .phps .phtmls
An example: if you wanted every single HTML page to be parsed and processed like a PHP script, just add .htm and .html:
AddType application/x-httpd-php .php .htm .html
There will be a bit of a performance loss if every single HTML page is being checked for PHP code even if it doesn’t contain any. But if you want to use PHP but be “stealthy” about it, you can use this trick.
Add index.php to the list of valid Directory Index files so that your “default page” in a directory can be named index.php.

DirectoryIndex index.php index.htm index.html
You can add anything else you want here too. If you want foobar.baz to be a valid directory index page, just add the .baz filetype to the AddType line, and add foobar.baz to the DirectoryIndex line.
Start Apache
We want to set Apache up with a normal start/stop script in /etc/rc.d/init.d so it can be auto-started and controlled like other system daemons. Set up a symbolic link for the apachectl utility (installed automatically as part of Apache):
ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache
Then set up auto-start for runlevel 3 (where the server will go by default):
ln -s /etc/rc.d/init.d/apache /etc/rc.d/rc3.d/S90apache
Then start the daemon:
/etc/rc.d/init.d/apache start
You can check that it’s running properly by doing:
ps -ef
and look for the httpd processes.

How To Run Multiple Operating Systems @ Same Time


I have been dual booting Windows + Linux for a long time but that has been a pain. Since Windows is my primary environment, I am unable to work on my Windows apps every-time I boot into Linux. I require both Windows and Linux to be available to me side-by-side so that I can conveniently experiment with Linux whenever I want to. In this article, we will find out how to easily run multiple Operating Systems at the same time, in a single machine.

What We Need: 


  • A decent computer with at least 1GB RAM (more recommended)

  • VMware Player software

  • Your favorite Unix/Linux CD or iso file; for me, I will use Ubuntu version 9.10 but this article works for any OS, any version

Let’s Get Started: 


More RAM:
Why do we need more memory?
Computer memory is like our sleeping bed in real life. When we are single, we can sleep on single bed but when we get married, we need King bed ;)
The more applications you run, the more RAM you need.

VMware Player: What is this and why do we need it?
In order to boot up an Operating System inside another Operating System, we need a technology called virtualization. VMware is one of the companies who makes virtualization products. VMware Player is the free virtualization product created by VMware allowing us to use multiple OS at the same time. There are many other virtualization products available but VMware Player is very good and best of all, it is free.

How to download VMware Player: 


  1. Click on Download
  2. At the time of this article, the latest version of VMware Player is 3.0 => click onVMware Player 3.0 at the very bottom of that page to continue. If you happen to see a newer version, simply download the new version.

  3. Locate “VMware Player for 32-bit and 64-bit Windows” then click on Download.

  4. VMware would then prompt you to signup “Register for your FREE Download” on the top right. You need to register for an account in order to download. VMware will send you an email with an activation link. Note: it may take several hours for VMware to send out the email. For my case, it took around 20 hours :)

  5. Once you have your VMware Player downloaded, simply double click on it and install.
How to download Unix/Linux:

In this article, I will use Ubuntu 9.10. Ubuntu is a very popular, stable, secure and very easy to use Linux Operating System. It is based on Debian and is ranked the top OS of all Unix/Linux OSs. 

  1. To download, visit ubuntu.com and click on Download Ubuntu

  2. Under Download location, select your location (country) then click on the big greenBegin Download button to begin your download. 

Now time to install our cool Unix/Linux Operating System: 

  1. Start VMware Player: Start => All Programs => VMware => VMware Player
  2. Click on Create A New Virtual Machine

  3. Selecting your media: If you have your Unix OS in a CD => select Installer Disk
    If you have your Unix OS in an iso file => select 
    Installer disk image file iso
    For this article, I will use Ubuntu 9.10 ISO file.

  4. Click Next then enter your login information. This is the login you will use to login to your Linux OS.
  5. Click Next then enter your Virtual Machine name. I recommend entering it as “Ubuntu 9.10″ or the name of your Linux OS so that you can easily recognize the OS at a later time.
  6. Click Next then enter your Disk Capacity. This is the maximum hard drive capacity limit you set for Ubuntu. I recommend 10Gig of disk space or more.
  7. Press Next then press Finish to begin the Ubuntu installation. Once the installation is finished, to start Ubuntu, simply double click on Ubuntu 9.10 under Home

Good Collection Of Questions

 Differentiate RAID & JBOD?
RAID: “Redundant Array of Inexpensive Disks”
Fault-tolerant grouping of disks that server sees as a single disk volume
Combination of parity-checking, mirroring, striping
Self-contained, manageable unit of storage
 

JBOD: “Just a Bunch of Disks”
Drives independently attached to the I/O channel
Scalable, but requires server to manage multiple volumes
Do not provide protection in case of drive failure


        What is the difference between RAID 0+1 and RAID 1+0
RAID 0+1 (Mirrored Stripped)
In this RAID level all the data is saved on stripped volumes which are in turn mirrored, so any disk failure saves the data loss but it makes whole stripe unavailable. The key difference from RAID 1+0 is that RAID 0+1 creates a second striped set to mirror a primary striped set. The array continues to operate with one or more drives failed in the same mirror set, but if drives fail on both sides of the mirror the data on the RAID system is lost. In this RAID level if one disk is failed full mirror is marked as inactive and data is saved only one stripped volume.
RAID 1+0 (Stripped Mirrored)
In this RAID level all the data is saved on mirrored volumes which are in turn stripped, so any disk failure saves data loss. The key difference from RAID 0+1 is that RAID 1+0 creates a striped set from a series of mirrored drives. In a failed disk situation RAID 1+0 performs better because all the remaining disks continue to be used. The array can sustain multiple drive losses so long as no mirror loses both its drives.
This RAID level is most preferred for high performance and high data protection because rebuilding of RAID 1+0 is less time consuming in comparison to RAID 0+1.


Define RAID? Which one you feel is good choice?
RAID (Redundant array of Independent Disks) is a technology to achieve redundancy with faster I/O. There are Many Levels of RAID to meet different needs of the customer which are: R0, R1, R3, R4, R5, R10, R6.
Generally customer chooses R5 to achieve better redundancy and speed and it is cost effective.


R0 – Striped set without parity/[Non-Redundant Array].
Provides improved performance and additional storage but no fault tolerance. Any disk failure destroys the array, which becomes more likely with more disks in the array. A single disk failure destroys the entire array because when data is written to a RAID 0 drive, the data is broken into fragments. The number of fragments is dictated by the number of disks in the drive. The fragments are written to their respective disks simultaneously on the same sector. This allows smaller sections of the entire chunk of data to be read off the drive in parallel, giving this type of arrangement huge bandwidth. RAID 0 does not implement error checking so any error is unrecoverable. More disks in the array means higher bandwidth, but greater risk of data loss
R1 - Mirrored set without parity.
Provides fault tolerance from disk errors and failure of all but one of the drives. Increased read performance occurs when using a multi-threaded operating system that supports split seeks, very small performance reduction when writing. Array continues to operate so long as at least one drive is functioning. Using RAID 1 with a separate controller for each disk is sometimes called duplexing.
R3 - Striped set with dedicated parity/Bit interleaved parity.
This mechanism provides an improved performance and fault tolerance similar to RAID 5, but with a dedicated parity disk rather than rotated parity stripes. The single parity disk is a bottle-neck for writing since every write requires updating the parity data. One minor benefit is the dedicated parity disk allows the parity drive to fail and operation will continue without parity or performance penalty.
R4 - Block level parity.
Identical to RAID 3, but does block-level striping instead of byte-level striping. In this setup, files can be distributed between multiple disks. Each disk operates independently which allows I/O requests to be performed in parallel, though data transfer speeds can suffer due to the type of parity. The error detection is achieved through dedicated parity and is stored in a separate, single disk unit.
R5 - Striped set with distributed parity.
Distributed parity requires all drives but one to be present to operate; drive failure requires replacement, but the array is not destroyed by a single drive failure. Upon drive failure, any subsequent reads can be calculated from the distributed parity such that the drive failure is masked from the end user. The array will have data loss in the event of a second drive failure and is vulnerable until the data that was on the failed drive is rebuilt onto a replacement drive.
R6 - Striped set with dual distributed Parity.
Provides fault tolerance from two drive failures; array continues to operate with up to two failed drives. This makes larger RAID groups more practical, especially for high availability systems. This becomes increasingly important because large-capacity drives lengthen the time needed to recover from the failure of a single drive. Single parity RAID levels are vulnerable to data loss until the failed drive is rebuilt: the larger the drive, the longer the rebuild will take. Dual parity gives time to rebuild the array without the data being at risk if one drive, but no more, fails before the rebuild is complete.


What are the advantages of RAID? 
“Redundant Array of Inexpensive Disks”
Depending on how we configure the array, we can have the
- data mirrored [RAID 0] (duplicate copies on separate drives)
- striped [RAID 1] (interleaved across several drives), or
- parity protected [RAID 5](extra data written to identify errors).
These can be used in combination to deliver the balance of performance and reliability that the user requires.


What is a Firewall?
Firewall is a protective boundary for a network and it prevents the unauthorized access to a network. Most of the Windows operating system such as Windows XP Professional has built-in firewall utilities. There are the large number of the third party firewall software and the basic purpose of all the firewall software and hardware is same i.e. to block the unauthorized user access to a network.

What is DNS and how it works? -Network admin interview
DNS stands for Domain name system and it translates (converts) the host name into the IP address and IP address into to the host name. Every domain and the computer on the internet is assigned a unique IP address. The communication on the internet and in the network is based on the IP addresses. IP addresses are in this format 10.1.1.100, 220.12.1.22.3, 1.1.1.1 etc. IP addresses can’t be remembered but the host names are easy to remember instead of their IP addresses.

What is DHCP? --Network admin interview questions
DHCP stands for Dynamic Host Configuration Technology. The basic purpose of the DHCP is to assign the IP addresses and the other network configuration such as DNS, Gateway and other network settings to the client computers. DHCP reduces the administrative task of manually assigning the IP addresses to the large number of the computers in a network.

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. 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.
9. What is mod_vhost_alias? - It allows hosting multiple sites on the same server via simpler configurations.
10. What does htpasswd do? - It creates a new user in a specified group, and asks to specify a password for that user.
11. If you specify both deny from all and allow from all, what will bethe default action of Apache? - In case of ambiguity deny always takes 

Linux interview Questions,Faqs 
What text filter can you use to display a binary
How can you find configuration on Linux?

What utility can you use to automate rotation of logs?
What file should you examine to determine the
Where standard output is usually directed?
Which distro you prefer?
What is the minimum number of partitions you need
Explain about TAR Command?
What is LILO?
What are RPM’s?
Which Linux distros do you have experience with?
How can you see all mounted drives?
What command can you use to review boot messages?
What does ‘route’ command do?
What is the difference between TCP and UDP
What is the complete name of the default configuration
How you will uncompress the file?
What are the Advantages and disadvantages of

What utility should use to create a compressed
What is the most graceful way to get to run level
What is the difference between home directory
Set the Display automatically for the current new user?

What does the top command display?
Why have you chosen such a combination of products?
How does the boot process [init levels] work on Linux?
Display the Disk Usage of file sizes under each
What is the difference between an argument and an option/switch?
What is the name and path of the main system log?

Shell Scripting Interview Questions
What is Path variable?
What is MUTEX?
What are special characters?
How do you schedule a command to run at 4:00
What is the use of Path variable?
What is the need of including script interpreter
What does $# stand for?
What are environment variables?
What is the syntax of "grep" command?
How to create environment variables?
Explain how does text varies by the usage of single quotes

What is egrep?
How would you replace the n character in a file with some xyz?
What are the different shells available?
What are the additional egrep symbols?
What is the difference between a variable and value?
What is the use of "exec" command?
What is "umask"?
What is the use of "shift" command in passing parameters?
What is the difference between a 'thread' and a 'process'?
How will you list only the empty lines in a file?
What is the use of "test" command?
What is use of "cut" command?
How do you read arguments in a shell program - $1, $2 ..?
How to change our default shell?
How to print some text on to the screen?
What does it denotes in shell scripting if text
Write a shell script to identify the given string
How to customize the other shell?
What are the different methods available to
How to group the commands in shell scripting?

What is the difference between writing code
What is the difference between a shell variable
How to customize the existing shell?
What are the conditions for creating variables?
How to take input values from the user?
What is the syntax of "expr" command?
What are the three main forms of enabling
What is INODE?
What are the different kinds of loops available
What are the advantages of bash over all other shells?

When we login into our account which files are
How to include comments in your shell scripts?
What is the use of script interpreter in shell scripting?
What is the basic difference you find between

What are the Different types of shells?
When you login to a c shell, which script would
How to make user defined variables to available
How to modify the PATH variable and make it executable?
How to declare functions in UNIX shell script?

Unix interview Questions,Unix interview faqs
What is pid ?
What does a process mean ?
Explain UNIX System Kernel ?
What is a zombie ?

Explain ‘UNIX is a portable os' ?
What is the difference between a soft link and
WHAT is kernel ?
What happens when you execute a command ?
WHAT is the use of "fg" command ?
What is iostat ?
What is IPC ?
What is the procedure of "at" and crontab" commands ?
What are threads ?
What does the “route” command do ?
What is Fork swap ?
How do you remove a crontab file ?
How to recover a system whose root password has lost ?
What is a FIFO ?
How do you execute one program from within another ?
How to create hardlinks and softlinks on files ?
What is the difference between physical addresses
What is an inode ?
What is the significance of "su" command ?
How to list only the directories inside a directory ?
WHAT is the very first process created by kernel ?
What are Profilers ?
What is the command to edit contents of the file ?
What are the main families of threads ?
What is tar command ?
Which command is used to stop a running process in UNIX ?
How to view the hidden files in /etc directory ?
What is egrep ?

What is the command that will make the file "run.sh" executable ?
What is the use of uniq command ?
WHAT is the use of wild cards ?
What are default permissions for others in a file ?
What is netstat ?
Explain fork () system call ?
What is a Map ?
What do you understand by 'building block primitive' ?
What is 'inode' ?
What is a Daemon ?
What are the UNIX system calls for I/O ?
What are processor execution levels and priorities ?
How do you execute UNIX commands in VI editor ?
How to connect oracle database from UNIX
How do you find out all processes that are currently
What is Scheduling ?
What is the use of command 'wc' ?
How to get the operating system's information in UNIX ?
How to remove weird filenames ?
What are the files in /etc directory ?
What does inetd do ?
How to copy multiple files and directories into
What command will bring user back to their home
What are filters ?
What is a level 0 backup ?
How do you install Oracle software on UNIX ?
What is a Region ?
What is the difference between interrupts and exceptions ?
What is the use of pipes ?
Explain the Write permission on a UNIX directory ?
What is telnet ?
WHAT is the functionality of kernel in UNIX architecture ?
What is the syntax of grep command and What is its use ?
What is a file system ?
What are wild cards ?
What are the different commands used to view

What is a pipe ?
WHAT is the condition required for dead lock in UNIX system ?
What are the events done by the Kernel ?
What are the different kinds of threads ?
How do you log in to a remote UNIX box ?
WHAT are the uses of filters ?
How will you add a user account from command line ?
What is the use of "test" command in UNIX ?
What Command will remove a Directory in UNIX ?
Explain the execute permission on a UNIX directory ?
What is the command to kill a process ?
What scripting languages do you know ?
What is the difference between commands cmp and diff ?
WHAT is the use of nice command ?
How to rename files and folders ?
What is an incremental backup ?
What is vmstat ?
How do you create special files like named pipes
What is the difference between Swapping and Paging ?
What is Expansion swap ?
What is the difference between multi-tasking,
What command is used to replace the existing
What is the command to display space usage on
What is the difference between internal and
What is Critical section ?
How to identify whether a file is normal file or directory ?
What is RAID 1+0 ?
What UNIX command will control the default file
What about the initial process sequence while
What do you mean by nice value ?
Which command will you use to change the
How does a user get the current date, time in UNIX ?
What steps are required to perform a bare-metal recovery ?
Explain about fork() ?
What are the processes that are not bothered by the swapper ?
What is virtual machine ?
How do you move a process Which is running background to foreground ?
What is the basic difference between UNIX and
How does the user view the contents of a text file in UNIX ?
What is the command to list files in a directory in UNIX ?
What is the difference between > and >> operators ?
What is the function of grep command ?
How to redirect standard error to a file ?
WHAT is shell ?
What are the read or write or execute bits on a
How can you get or set an environment variable
What are the various schemes available in IPC ?
How do you know about running processes of a
What is the Command that will move a single file called "UNIX.txt"
How would you change all occurrences of a value using VI ?
What is Context switch ?
Which command is used to change group ?
WHAT are the different commands used to create files ?
How to put a job in background & bring it to foreground ?
What are the mount and unmount system calls ?
How to setup display for a remote system ?
How do you copy a directory with many files and
What is the command to remove directory with files ?
What does init do ?
What is the difference between relative path and
What is the difference between "cron" commands
How to delete a directory containing files and folders ?
What is the difference between grep & find ?
How would you change all occurrences of a value using VI ?
What is an advantage of executing a process in background ?
What is the advantage of each user having its
Write a command to find all of the files Which have
What Command is used to make a directory ?
What is the command to get help on a UNIX terminal ?
What are the different types of tar commands ?
WHAT is the use of "grep" command ?
How do you change your account's password ?
What does iostat do ?
How can a parent and child process communicate ?
What are various IDs associated with a process ?
How do you find path of a directory ?
What command a user use to view a long text file
What is the command to list all files in a directory,
What is setuid/setgid in relation to file permissions ?
What is the use of ‘tee’ command ?
WHICH command is used to identify the type of the file ?
What are the main differences between Apache 1.x and 2.x ?
What is the command to view contents of a large
What is the command to find out the difference
What does the second field denotes in UNIX file permissions ?
What are the differences between CUI and
WHAT is a profile ?
WHAT is the process id for kernel process ?
How does the inode map to data block of a file ?
What is the system calls used for process management ?
What is the main advantage of creating links to a
What command is used to execute system calls from exe ?
How do you execute a UNIX command in the background ?
What does mknod do ?
How to convert a hidden file to normal visible file ?
WHAT are the different operating systems available ?
WHAT happens when we create a file system ?
How do you list the files in an UNIX directory while
How are devices represented in UNIX ?
What do you mean by user area or user block ?
What is the difference between user mode and kernel mode ?
How to get a particular string as your prompt ?
What are raw sockets ?
What command would users use to see What file
How to copy file into directory in UNIX ?
What is the command to find out Which shell you are running ?

Explain the read permission on a UNIX directory ?
What are the process states in UNIX ?
What is the difference between paging and swapping ?
Explain about term 'de-mountable volumes' ?

Unix/Linux system admin 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.

What is LILO? -Linux admin interview question
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 a router? What is a gateway?
Routers are machines that direct a packet through the maze of networks that stand between its source and destination. Normally a router is used for internal networks while a gateway acts a door for the packet to reach the ‘outside’ of the internal network

Linux Administrator Interview questions
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?