Javascript Menu by Deluxe-Menu.com

US & Canada: 1-888-354-6128

Local & International: 1-206-438-5887

1-703-564-9887/1-604-638-2525

Web Site Hosting, Dedicated Hosting, Cheap Hosting  Web Hosting Sales Assistance

Support > Linux Documentation
 
Introduction

Linux Operating System
The Kernel
The Shell

Logging in
SSH
Root Login

Navigation
cd (change directory)
ls (list)
pwd (print working directory)

File Management
mkdir (make directory)
cp (copy)
ln (link)
mv (move, rename)
rm (remove), rmdir (remove directory)
cat (concatenate)
less 
head
tail

File Editing
emacs
pico
vim
Linux File Permission
Access Rights on Files
Access Rights on Directories
Changing Access Rights

Processes and Jobs
ps (process status)
top
w (who)
Running Processes in the Background
Backgrounding a Forground process
List Running Processes
kill

Rebooting Your Server

reboot
shutdown

Managing Users
passwd file
shadow file
group file
Adding Users
Modifying Users
Deleting Users

Disk Quota
Ensuring Disk Partitions Support Quota
quotacheck
quotaon, quotaoff
edquota
Viewing a User's quota
Generating Quota Report

Linux Networking
Network Configuration Tools
Analysis Tools
Adding Additional IPs to Your Server

Apache Web (httpd) Server
Starting and Stopping
Configuration File
Global Section
Main (Default Server) Section
Virtual Servers Section
IP Based Virtual Hosts

Introduction

Thank you for choosing Superb as your dedicated hosting partner.  We hope this document helps you on your way to administering your Linux server.  The possible range of topics to cover is nearly limitless so it is not possible to cover everything.  We've tried to cover the most important and relevant to you.  The topics covered in this document will also be covered in books and other sources of information widely available on the net which you can use to further your understanding.  As well, we will include relevant links throughout this document so that you can get more in depth information.

 
Linux Operating System 

The LINUX operating system is made up of three parts; the kernel, the shell and the programs.

The kernel

The kernel of Linux is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.

As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file "myfile"). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the Linux prompt % to the user, indicating that it is waiting for further commands.

The shell

The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems).

Filename Completion - By typing part of the name of a command, filename or directory and pressing the [Tab] key, the bash shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed, it will beep, prompting you to type a few more letters before pressing the tab key again.

History - The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands.

Back to Top

Logging in

SSH The Acronym SSH stands for Secure Shell. There are a couple of ways that you can access most Linux/Unix systems. The most common way is to use a telnet program such as the one called telnet. Accessing a shell account in this fashion though poses a danger in that everything that you do over that telnet session is visible in plain text to anyone who "snoops" in.  For this security reason, we do not enable telnet on your server by default.

SSH was created to encrypt the data being sent over the network as well as provide an option that prevents passwords from being ever passed over the network. We recommend connection to your server via SSH.  To connect to your server via SSH, you need to have a ssh client installed.  We recommend one of the following:

For more information, please refer to The SSH FAQ

Root Login

For security reason, please do not  SSH to your server directly as root.  Always connect using your own login first and then use the command su (switch user) to root.  Root is used for administrative purposes. The root login is much like the administrative login on Windows or many other servers. You will have full access to all areas of the server. Therefore, only use root when you absolutely need to perform administrative tasks.  All other times, log in as yourself.

Back to Top


Navigation

Navigating around the files and directories of your hard drive could be a dreaded task for you, but it is necessary knowledge. In this section, we will cover some basic commands to help you navigate through your system.

cd (change directory)
As you might already have guessed, the cd command means "change the current working directory to 'directory'. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree.  To change to the directory my_directory, type

% cd my_directory

there are two special directories called "." and ".."

In Linux, "." means the current directory, so typing

% cd . (NOTE: there is a space between cd and the dot)

means stay where you are (the my_directory directory).
This may not seem very useful at first, but using "." as the name of the current directory will save a lot of typing, as you will see later.

".." means the parent of the current directory, so typing

% cd ..

will take you one directory up the hierarchy (back to your home directory). Try it now.

Note: typing cd with no argument always returns you to your home directory. This is very useful if you are lost in the file system.

ls (list)
The ls letters stand for list.  Typing ls will give you a listing of all the files in the current directory. If you're new to Linux, chances are that the directories you are commonly in will be empty, and after the ls command is run, you are not given any information and will just be returned to the command prompt (the shell).

There are "hidden" files in Linux, too. Their file names start with a dot, and doing a normal ls will not show them in a directory. Many configuration files start with a dot on their file names because they would only get in the way of users who would like to see more commonly used items. To view hidden

% ls -a

To view more information about the files in a directory, use the -l flag with ls. It will show the file permissions as well as the file size, which are probably what are the most useful things to know about files.

You can put flags together, so to view all the files in a directory, show their permissions/size, and view all the files that way through the subdirectories, you could type:

% ls -laR

 

pwd (print working directory)
This command enables you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, type cd to get back to your home-directory and then type:

% pwd

The full pathname will look something like this:

/home/joe

which means that joe (your home directory) is inside the /home directory.

~ (your home directory)
Home directories can also be referred to by the tilde ~ character. It can be used to specify paths starting at your home directory. So typing

% ls ~/html will list the contents of your html directory, no matter where you currently are in the file system.Typing

% ls ~ would list the contents of your home directory;

And typing% ls ~/.. would list the parent directory - that is one directory above your current one.

Back to Top

File Management

Most of the file management in Linux is done through the command line, so once you learn some basic commands and utilities, you will find it surprisingly easy and efficient.

mkdir (Make Directory)
This command is used to create a new directory if one does not exists.  The basic command is: % mkdir my_directory

cp (copy)
The cp command is used for copying files and directories. The basic command line is :

% cp file1 file2

There are other extensions to the cp command. You can use the -f parameter to force it. You can use the -a (arvhive) parameter to preserve all attributes of the original files or directories.

Using the cp command, you can copy an entire directory to its new destination. Suppose you want to  copy a directory (and all of its contents) from /home/template/html/index.html to your current directory, you would type:

% cp -rpf /home/template/html/index.html .

(Note: Don't forget the dot "." at the end. Remember, in Linux, the dot means the current directory.)

ln (link)
A feature of linking files is available in Linux. It works by "redirecting" a file to the actual file. It is analogous to creating a shortcut to the real file. There are two ways to link files:  hard linking or a symbolic linking.

We will only cover symbolic linking here since it is the most commonly used and it serves most purposes. The basic command line is:

% ln -s actual_file link_file This means that any read and write action you take on the link_file, you are actually accessing the actual file. Making symbolic links to directories also follow the same principle.
To remove a symbolic link, simply type rm link_file. This action will NOT remove the file that it is pointing to.

mv (move)
% mv file1 file2 moves (or renames) file1 to file2


To move a file from one place to another, use the mv command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two.It can also be used to rename a file, by "moving" the file to the same directory, but giving it a different name.

 rm (remove), rmdir (remove directory)
The rm command is used for removing files and directories. Suppose you want to remove a file called foobar in your current directory. To do that, simply type rm foobar. Note that in a Linux environment, removing is permanent.  You cannot un-delete it.  So please exercise caution when using this command.  It is advisable to always use the parameter -i with the rm command so that the system prompts you to make sure you really want to remove something.  Example:

% rm -i my_file

To delete something in some other directory, use the full path as the file name. For example, if you want to delete a file called "foobar" that's in the directory /usr/local/src/, you would type:

% rm -i /usr/local/src/foobar

To remove an entire directory and all of its contents, type rm -rf /directory where "/directory" is the path to the directory that you want to delete. The "r" and "f" paramters stand for "recursive" and "force" respectively. We cannot stress how potentially harmful this rm command (used in conjunction with -rf) to your system's health. Do be careful.

You can use the rmdir command to remove a directory (make sure it is empty first).
 
cat (concatenate)
This command can be used to display the contents of a file on the screen. Type:

% cat index.html

As you can see, the file is longer than than the size of the window, so it scrolls past making it unreadable.
 

less
This command writes the contents of a file onto the screen a page at a time. Type % less index.html

Press the space-bar if you want to see another page, type q if you want to quit reading. As you can see, less is used in preference to cat for long files.
 
head
This command writes the first ten lines of a file to the screen. Type : % head index.html
  • Then type:

    % head -5 index.html

    This time, it should only displays the first 5 lines.
     
    tail
    Conversely, this command writes the last ten lines of a file to the screen. Try the command: % tail index.html

    Simimlarly, if you type: % tail -50 index.html

    You will get the last 50 lines of the index.html file.
  • Back to Top

    File Editing

    A common way to edit files is to download them to your local computer, edit them using your favourite text editor, and uploading them when you are done.  However, if you wish to edit your files on the server itself, you have a variety of text editor tools at your disposal.  The basic syntax to invoke these text editors is the same. Type the name of the editor followed by the file you want to edit, separated by a space in between. Non-existent files will be blank and will be created when you save.

    emacs

    Emacs is text editor that probably has more features than any other in the Unix/Linux world.  In order to take advantage of its power, you will need to learn its commands.  To start of it, there are  two important commands you need to know:

    While you're editing a certain file with emacs, you can save it with the [Ctrl]-x [Ctrl]-s keystrokes. Then to exit, type [Ctrl]-x [Ctrl]-c.

    pico

    The instructions for using pico are located on the screen. You save the file by using the [Ctrl]-o keystroke (for write-out) and exit with [Ctrl]-x.

    Although pico is a very simple text editor to use, as a permanent solution, we do not recommend it.  It tends to introduce line breaks (even with the use of -w parameter) and it lacks real power.

    vim
    Most Linux distributions now include vim, derived from the infamously arcane Unix editor, vi. (It stands for vi Improved). It is the most popular and arguably the most difficult text editor to learn for Linux/Unix systems.  However, once you learn vi's commands, you will find it very efficient and perhaps even enjoy it.  Many Linux/Unix system administrators have sworn by it.

    Using vim is different in that there are several modes in which you use it. To do actual editing of the files, press [ESC] i (both separately). Then to save it, press [ESC] : w. Escape, the colon, and "w" should be keyed in one after the other. Finally, to quit, type [ESC] : q. The same rules apply as in previous vim commands.

    You can use "w" and "q" at the same time to enable yourself to write to the file and then quit right afterwards. Just press [ESC] : w q.

    If you don't have vim installed, try vi instead.
    Back to Top

    Linux File Permission (Access Rights)

    In your home directory, type

    % ls -l (l for long listing!) 1)------------------------------------------------ Each file (and directory) has associated access rights, which may be found by typing ls -l. Also, ls -lg gives additional information as to which group owns the file (beng95 in the following example):-rwxrw-r-- 1 ee51ab beng95 2450 Sept29 11:52 file1In the left-hand column is a 10 symbol string w, x, -, and, occasionally, s or S. If d is present, it will be at the left hand end of the string, and indicates a directory: otherwise - string.The 9 remaining symbols indicate the permissions, or access rights, and are taken as three groups of 3.
    • The left group of 3 gives the file permissions for the user that owns the file (or directory) (ee51ab in the above example);
    • the middle group gives the permissions for the group of people to whom the file (or directory) belongs (eebeng95 in the above example);
    • the rightmost group gives the permissions for all others.
    The symbols r, w, etc., have slightly different meanings depending on whether they refer to a simple file or to a directory.

    Access rights on files
    • r indicates read permission (or otherwise - for no read permission), that is, the permission to read and copy the file
    • w indicates write permission (or otherwise - for no write permission), that is, the permission to change or delete a file
    • x , indicates execution permission (or otherwise - for no executable permission), that is, the permission to execute a file, where appropriate
    Access rights on directories
    • r allows users to list files in the directory
    • w means that users may delete files from the directory or move files into it
    • x means the right to access files in the directory. This implies that you may read files in the directory provided you have read permission on the individual files.
    So, in order to read a file, you must have execute permission on the directory containing that file, and hence on any directory containing that directory as a subdirectory, and so on, up the tree.Some examples
    • -rwxrwxrwx a file that everyone can read, write and execute (and delete)
    • -rw------- a file that only the owner can read and write - no-one else
      can read or write and no-one has execution rights (e.g. your mailbox file).
    Changing access rights
    chmod (changing a file mode) Only the owner of a file can use chmod to change the permissions of a file. The options of chmod are as follows
    Symbol
    Meaning
    u user
    g group
    o other
    a all
    r read
    w write (and delete)
    x execute (and access directory)
    + add permission
    - take away permission
     

    For example, to remove read write and execute permissions on the file biglist for the group and others, type % chmod go-rwx biglist This will leave the other permissions unaffected.To give read and write permissions on the file biglist to all, % chmod a+rw biglist
    Back to Top

    Processes and Jobs

    ps (process status)

    A process is an executing program identified by a unique PID (process identifier). To see information about your processes, with their associated PID and status, type

    % ps

    A process may be in the foreground, in the background, or be suspended. In general the shell does not return the UNIX prompt until the current process has finished executing.

    Some processes take a long time to run and hold up the terminal. Backgrounding a long process has the effect that the UNIX prompt is returned immediately, and other tasks can be carried out while the original process continues executing.

    top
    This program shows a lot of stuff that goes on with your system. In the program, you can type:
    1. M for memory usage information
    2. P for CPU information
    3. q to quit
    Once you try it, you can see that top shows you the memory usage, uptime, load average, CPU states, and processes.

    w (who)

    Typing w will tell you who is logged in. This can be helpful if you're the only one who uses your computer and you see someone logged in that's not supposed to be.Another alternative is who.

    Running background processes
    To background a process, type an & at the end of the command line. For example, the command sleep waits a given number of seconds before continuing. Type: % sleep 10

    This will wait 10 seconds before returning the command prompt %. Until the command prompt is returned, you can do nothing except wait.

    To run sleep in the background, type:

    % sleep 10 &
    [1] 6259
    The & runs the job in the background and returns the prompt straight away, allowing you do run other programs while waiting for that one to finish.

    The first line in the above example is typed in by the user; the next line, indicating job number and PID, is returned by the machine. The user is be notified of a job number (numbered from 1) enclosed in square brackets, together with a PID and is notified when a background process is finished. Backgrounding is useful for jobs which will take a long time to complete.

    Backgrounding a current foreground process
    At the prompt, type:

    % sleep 100

    You can suspend the process running in the foreground by holding down the [control] key and typing z (written as ^Z) Then to put it in the background, type

    % bg

    Note: do not background programs that require user interaction such as pine

    Listing suspended and background processes
    When a process is running, backgrounded or suspended, it will be entered onto a list along with a job number. To examine this list, type

    % jobs

    An example of a job list could be

    [1] Suspended sleep 100
    [2] Running backup.pl
    [3] Running gzip


     To restart (foreground) a suspended processes, type

    % fg %jobnumber

    For example, to restart sleep 100, type

    % fg %1

    Typing fg with no job number foregrounds the last suspended process.

    Kill (terminate or signal a process)
    It is sometimes necessary to kill a process (for example, when an executing program is in an infinite loop)

    To kill a job running in the foreground, type ^C (control c). For example, run sleep 100 then kill it with ^C

    To kill a suspended or background process, type

    % kill %jobnumber

    For example, run sleep 100 & then type jobs to see its job number. If it is job number 4, type:

    % kill %4

    To check whether this has worked, examine the job list again to see if the process has been removed.  Alternatively, processes can be killed by finding their process numbers (PIDs) with the ps command and using kill PID_number.

    Run sleep 100 & again, then type:

    % ps

    PID TT S TIME COMMAND
    20077 pts/5 S 0:05 sleep 100
    21563 pts/5 T 0:00 netscape
    21873 pts/5 S 0:25 nedit
    To kill off the process sleep 100, type: % kill 20077
    and then type ps again to see if it has been removed from the list.

    If a process refuses to be killed, uses the -9 option, i.e. type

    % kill -9 20077

    Note: Only user root is allowed to kill off other users
    Back to Top
    Rebooting Your Server

    Shutting down and restarting properly will prevent your filesystem from being damaged. Filesystem damage is the most obvious of the consequences, but there are probably other things such as database corruptions etc. that may occur if proper shut down procedure is not followed.  When you or as per your request, our technician issue a shutdown command, the system goes through a series of steps that properly terminate all processes that are running at that time.

    reboot

    To do a reboot, you can either type reboot or shutdown -r now.  The -r parameter instructs the server to start up again right after the system finishes the shutdown cycle. The now parameter instructs the system to do it without delay.  Instead of now, you can use 12:00 which means perform the shutdown command at exactly at 12 o'clock.  Alternatively you can type shutdown -r +5 which instructs the system to shutdown in 5 minutes.

    shutdown

    To shut down your system completely and not start it up again, such as when you require your system to be serviced by our technicians, type shutdown -h now, which instructs  the shutdown program to begin system halt immediately.

    There are rare cases in which your server may lock up entirely, and prevent you from being able to access a command prompt to perform these shutdown or reboot procedures. Only then will your last resort be to contact our online technicians to do a forced reboot (pressing the restart button on the server).

    Back to Top
    Managing Users

    Whether or not you have many users on your system, it's important to understand the aspects of user management under Linux. Even if you're the only user, you should presumably have a separate account for yourself (an account other than root to do most of your work).

    Each person using the system should have his or her own account. It is seldom a good idea to have several people share the same account. Not only is security an issue, but accounts are used to uniquely identify users to the system. You need to be able to keep track of who is doing what.

    The system keeps track of a number of pieces of information about each user. They are summarized below.
     

    • username The username is the unique identifier given to every user on the system. Examples of usernames are larry, karl, and mdw. Letters and digits may be used, as well as the characters ``_'' (underscore) and ``.'' (period). Usernames are usually limited to 8 characters in length.
       
    • user ID
      The user ID, or UID, is a unique number given to every user on the system. The system usually keeps track of information by UID, not username.

    • group ID
      The group ID, or GID, is the ID of the user's default group. Each user belongs to one or more groups defined by the system administrator. More about this below.

    • password
      The system also stores the user's encrypted password. The passwd command is used to set and change user passwords.
       
    • full name
      The user's "real name" or "full name" is stored along with the username. For example, the user schmoj may have the name ``Joe Schmo'' in real life.

    • home directory
      The home directory is the directory in which the user is initially placed at login time. Every user should have his or her own home directory, usually found under /home.

    • login shell
      The user's login shell is the shell which is started for the user at login time. Examples are /bin/bash and /bin/tcsh.
     

    passwd file

    The file /etc/passwd contains this information about users. Each line in the file contains information about a single user; the format of each line is

    username:x:UID:GID:full name:home directory:login shell

    An example might be:

    gshrub:x:102:100:George W. Shrub:/home/gshrub:/bin/bash

    As we can see, the first field, "gshrub", is the username.

    The next field, "x'', is no longer used.  In the older system, it used to be the encrypted password. For security reasons, passwords are no longer stored in the /etc/password file which is world readable.  Previously, any user with malicious intention can take the password and perform exhaustive dictionary password cracking algorithm to it and extract simple passwords.  Nowaday, encrypted passwords  are relegated to the file /etc/shadow which provide some degrees of extra security because it is not world readable. Shadow password provides some other features such as password expiration and so on; we will go over that briefly below.

    The third field, "102", is the UID. This must be unique for each user. The fourth field, "100", is the GID. This user belongs to the group numbered 100. Group information, like user information, is stored in the file /etc/group.

    The fifth field is the user's full name, "George W. Shrub". The last two fields are the user's home directory (/home/gshrub) and login shell (/bin/bash), respectively. It is not required that the user's home directory be given the same name as the username. It does help identify the directory, however.

    shadow file
    In the /etc/shadow file, you will see a corresponding line for user "gshrub":

    gshrub:Igljf78DS:543:14:180:10:60:557:

    It follows the scheme:

    gshrub 
    username
    Igljf78DS 
    encrypted password
    543 
    last change of password (number of days since Jan 1, 1970)
    14
    minimum days that the password should exist without changing
    180
    maximum days of the password's existence
    10
    number of days until the user gets a message that his password will expire
    60
    number days after password expires that account is considered inactive and disabled
    557
    days since Jan 1, 1970 when account will be disabled


    group file
    The file /etc/group contains information about the group of the system. It's lines are like the one below:

    bush:x:14:gshrub,grass

    following the scheme:

    bush 
    username
    encrypted group password. x stands for empty
    14 
    GID the numerical group ID
    gshrub
    group member's user name
    grass
    group member's user name

    Back to Top

    Adding Users

    Linux provides you with a number of useful administrative tools for adding users to your system, so that you not need to manually modify the /etc/password and /etc/shadow files. These tools automate the steps for adding users. The command useradd adds the user in /etc/passwd, sets up /etc/group, creates a home directory and copies the files that reside in the directory /etc/skel to the user's home directory. The directory /etc/skel contains some ready-to-use configuration files, that are necessary for every user of your system.

    As an example of how to use this command:
    % useradd -d /home/joe -k /etc/skel -s /bin/bash username

    -d /home3/joe parameter pair gives the instruction to create a new directory /home/joe if that directory does not already exists.  Furthermore, the directory will be owned by user joe and group joe (group joe is default since we did not specify the group using -g parameter).

    -k /etc/skel gives the instruction to use /etc/skel as the template directory when creating /home/joe. Therefore, if you wish to customize what files your users will get by default, modify /etc/skel or create another template directory and use that one with the -k parameter.

    -s /bin/bash allows the new user to have /bin/bash as this user's shell.
    username is the login name of the user.

    What the useradd command actually is doing is the following steps:

    • Add information about the user in /etc/passwd
    • Set the group that the user belongs to in /etc/group
    • Create a home directory for the user
    • Set the default user's configuration file in his home directory

    Before the user can log into the server, you have to set the password for this user.  So for user joe that you have just added, type:

    % passwd joe

    Please avoid using any simple, dictionary passwords or passwords based on publicly available information such as your phone number.  Clever password cracking programs can solve them.  Use a password that is at least 8 characters long, containing letters, numbers as well as other characters and in mixed cases.


    Back to Top

    Modifying Users

    Sometimes you may wish to change one or more attributes of a user.  For example, suppose you decide to change the login from joe to johny, you can do this:

    % usermod -l johny joe

    Suppose you have also renamed the directory /home/joe to /home/johny, you would also need to change the information in the /etc/passwd file.  You can do this by:

    % usermod -d /home/johny johny (since the user name is now johny)

    Deleting Users

    When you want to delete a user from your system, use the command userdel to do that.  For example:

    % userdel johny

    Basically the userdel command performs these two steps:

    • Remove the user's information from the files /etc/passwd and /etc/shadow
    • Remove the user's information from /etc/group
       
    However, it does not delete the user's home directory.  You will have to use the rm command to do that when you wish to remove the user's home directory and everything else inside it.
    Back to Top


    Disk Quota

    The main purpose of quota is to limit the disk space or the number of inodes used by a user or group. Disk space is referred to the ammount of space allocated to the user whereas the inodes refer to the number of files that a user can access at a time. On every server where disk space is shared among users there is a need to restrict them to a certain amount of disk space. This is done to prevent some users hogging up the entire disk space.  Inodes limitation is rarely used so we will not discuss it here.

    Ensuring disk partitions support quotas

    Disk quotas are implemented per user (or per group) per disk partition. During the boot time each partition is checked to see if quota has been implemented on it or not. To implement user or group quotas for a given partition we specify usrquota or grpquota options in the fourth field of /etc/fstab file.

    /dev/sda2 / ext3 defaults,usrquota,grpquota 1 1 This indicates that you would like to implement both user and group quota on the partition "/".  Once you have changed the /etc/fstab file, it is necessary to reboot the system so that the partitions that have been changed will be mounted correctly with quota capability.  Then in the root directory of that partition we create files `aquota.user' and `aquota.group' respectively using the touch command. Example:

    % touch /aquota.user /aquota.group

    quotacheck

    The contents of the above files are not in human readable form. The most important thing is in order for quota to work on a partition, you have to initialize this file.  To do that you have to run quota check for both group and user. If you use the default -avu option it only checks the user quotas and uitilizes the aquota.user file only. Example:

    % quotacheck -avu (for user quota only - initialize aquota.user file) % quotacheck -avg (for group quota only - initialize aquota.group file) % quotacheck -avug (for both user and group quota - initialize both files)

    quotaon, quotaoff

    Once you have initialize the aquota.user or the aquota.group or both files, you can finally turn on quota.  Use this command:

    % quotaon -v / (turn on quota for "/" partition) % quotaon -av (turn on all quota)

    Conversely, if you wish to turn off quota, use this command:

    % quotaoff -v / (turn on quota for "/" partition) % quotaoff -av (turn on all quota)

    Now that quota to your desired partitions have been turned on, you can go ahead and allocate quota to your users.  To accomplish this, you use the edquota (edit quota) command. The edquota command puts you into a "vi" editing mode so knowledge of the "vi" editor is necessary. Another editor may be specified with the EDITOR environment variable. You are NOT editing the aquota.user file directly. The /partition/aquota.user or aquota.group file is a binary file which you do not edit directly. The command edquota gives you an ascii interface with the text is prepared for you. When you ":wq" to save the file from the vi session, it is converted to binary by the edquota command and stored in the aquota.user or aquota.group file. edquota

    To allocate 100MB of disk space for user joe in the "/" partition, you type:

    % edquota joe You will be brought to a text editor screen with content similar to:

    Quotas for user joe:
               /dev/sdb6: blocks in use: 56, limits (soft = 0, hard = 0)
                       inodes in use: 50, limits (soft = 0, hard = 0)

    You need to change this text so it will look like (remember that we are only interested in limiting the space consumption and not the number of files:

    Quotas for user joe:
               /dev/sdb6: blocks in use: 56, limits (soft = 100000, hard = 105000)
                       inodes in use: 50, limits (soft = 0, hard = 0)

    Explanation of terms:

    /dev/sdb6 the actual hard disk partition mounted as "/"
    blocks in use the total number of blocks (in kilobytes) a user has consumed
    Soft Limit Indicates maximum amount of disk usage a user has on a partition.  When combined with grace period, it acts as the border line, which a user is issued warnings about his impending quota violation when passed
    Hard Limit Works only when grace period is set.  I specifies the absolute limit on the disk usage, which a user cannot go beyond
    inodes in use The total numbers of files a user currently has on a partition


    Grace Period
    Grace period is a time limit before the soft limit is enforced for a file system with quota enabled. Also when it is enabled, the user absolutely cannot go beyond the hard limit if set.  Time units of sec(onds), min(utes), hour(s), day(s), week(s), and month(s) can be used. To set a grace period for user joe, you type: % edquota -t joe Time units may be: days, hours, minutes, or seconds Grace period before enforcing soft limits for users: /dev/hda2: block grace period: 0 days, file grace period: 0 days

    0 days indicate that grace period has NOT been enabled.  Change the 0 days part to any length of time you feel reasonable. A good choice might be 7 days (or 1 week).

    Viewing a user's quota
    To view joe's current quota and  usage information, type:

    % quota -v joe

    Generating quota report

    To display a summary report of all users' quota and usage information on your server, type:

    % repquota -a

    Back to Top
    Linux Networking

    This topic is vast in its scope and it is not the intention of this document to cover it in any significant detail.  If you wish to find out more, please refer to many available books and other resources on this topic.  We will just point out the tools available to you and especially help you set up  multiple IPs on your server.

    Network Configuration Tools
    netconfig A program that provides step by step interface for network configuration
    ifconfig A text based program to configure the network interface. Type "man ifconfig" for info.


    These programs will modify values in the following files:

    • /etc/sysconfig/network - Defines your network and some of its characteristics.
    • /etc/HOSTNAME - Shows the host name of this host. IF your server's name is "myhost" then that is exactly the text this file will contain.
    • /etc/resolv.conf - Specifies the domain to be searched for host names to connect to, the nameserver address, and the search order for the nameservers.
    • /etc/host.conf - Specifies the order nameservice looks to resolve names.
    • /etc/hosts - Shows addresses and names of local hosts.
    • /etc/networks - Provides a database of network names with network addresses similar to the /etc/hosts file. This file is not required for operation.
    • /etc/sysconfig/network-scripts/ifcfg-eth* - There is a file for each network interface. This file contains the IP address of the interface and many other network variables.
    Analysis Tools
    • netstat - Displays information about the systems network connections, including port connections, routing tables, and more. The command "netstar -r" will display the routing table.
    • traceroute - This command can be used to determine the network route from your computer to some other computer on your network or the internet. To use it you can type "route IPaddress" of the computer you want to see the route to.
    • nslookup - Used to query DNS servers for information about hosts.
    • arp - This program lets the user read or modify their arp cache.
    • tcpdump - This program allows the user to see TCP traffic on their network.
    • dig(1) - Send domain name query packets to name servers for debugging or testing.

     For any of the above command, if you wish to know more detail, please type man <command>.

    Adding IPs to Your Server

    Although there are configuration utilities you can use to help you perform this task,  we will show you a simple manual procedure to do this.  The rationale is that if something goes wrong with the configuration, at least you know what has been done and you can reverse it.  What you are trying to accomplish is what many people refer to as IP address aliasing.  That is, enabling multiple IP addresses on one ethernet card. Assuming that your server currently has the IP address: 192.168.100.4 and you wish to set up the additional 192.168.100.50 IP to it.  The following is a step by step instructions on how to manually and permanently add that IP to your server:

    1. % cd /etc/sysconfig/network-scripts 
    2. % cp ifcfg-eth0 ifcfg-eth:0 (assuming that you this is the first additional IP, otherwise change 0 to 1 for second additional IP and 0 to 2 for third additional IP and so on)
    3. % vi ifcfg-eth:0  (or instead of vi use your favourite text editor)
      Initially, the file will look similar to this:

      DEVICE=eth0
      ONBOOT=yes
      BOOTPROTO=static
      IPADDR="192.168.100.4"
      NETMASK="255.255.255.0"
      GATEWAY="192.168.100.1"

      You will need to change it to:

      DEVICE=eth0:0
      ONBOOT=yes
      BOOTPROTO=static
      IPADDR="192.168.100.50"
      NETMASK="255.255.255.0"
      GATEWAY="192.168.100.1"

    Please note that if the new IP given to you does not belong to the same C-block as the IP of your server, the NETMASK and GATEWAY parameters will necessarily be different for this file.  Please consult us for the the exact values of those.  

    To set up additional IPs, repeat the above procedure using different filename, such as ifcfg-eth:1, device=eth0:1, and change IPADDR as appropriate.

    In order for your changes to take effect, you must restart your server's network functions.  To do that, type:

    % /etc/rc.d/init.d/network restart
    Back to Top
    Apache Web server configuration

    At the time of this writing, Apache still dominates the internet as the most deployed web server.  When we install your Linux server, we configure it with Apache web server.  In this section, we will go over some Apache basics so that you can hopefully understand how it works and configure it to host your site(s).

    Stopping and Starting your Apache Server

    % /etc/rc.d/init.d/httpd stop

    % /etc/rc.d/init.d/httpd start
    % /etc/rc.d/init.d/httpd restart 

    Apache was set up on your server to serve its web pages from the directory /home/httpd/html/. The default home page for the default configuration is index.html.

    If you intend to only serve one web site, then all you need to do is upload all your web content to this /home/httpd/html directory.  However, Apache may be configured to host multiple domains each serving files from a different directory. This is referred to as virtual hosting, and it consists of two types:

    • Name based virtual hosts: One IP address but multiple domains
    • IP based virtual hosts: One IP address for each domain

    Before we get into how to configure apache for virtual hosting, we need to focus on the all important /etc/httpd/conf/httpd.conf file.

    Configuration File (httpd.conf)
    The apache's config file is broken up into three sections, the Global Section, the Main (or default server) section, and the Virtual Hosts section:

    Global Section
    This section controls behaviour that is global to all instances of apache running on your system. The example configuration file contains excellent documentation for each of the options. Below is a table containing some general guidance for use when modifying the options.
     
    Global Section Directives
    Directive Description
    ServerRoot If you configured sysconfdir to be /etc/httpd/conf then
    make this "/etc/httpd"
    LockFile This file is used by apache to decide if it's running or not.
    If the path does not start with a leading /, apache will assume the path is relative to the ServerRoot defined above.
    (RedHat /var/lock/httpd.lock)
    pidfile This file is where apache stores the process id of the server.
    If the path does not start with a leading "/" apache will assume the path is relative to the ServerRoot defined above.
    (Redhat /var/run/httpd.pid)
    ScoreBoardFile This file stores internal server information, but is not needed on most Linux configurations. Just to be safe, create a place for it.
    (RedHat /var/run/httpd.scoreboard)
    TimeOut This is the number of seconds before net traffic times out. The default on this is 300, which is 5 minutes. It can be set much
    lower, but values below 30 tend to cause problems.
    KeepAlive Allows persistant connections. Unless you have a good reasons to not want them, set this to "on".
    MaxKeepAliveRequests This determines the maximum number of Requests allowed on a persistant channel before it closes. 100 is a reasonable number
    KeepAliveTimeout Determines how long a KeepAlive channel will remain open if idle. 15 is a good number.
    MinSpareServers Sets the desired number of servers that are idle, awaiting requests. If there are ever less than this many of idle child processes, apache will start spawning more until this number is reached. Too many wastes resources. Too few and spikes in server hits could degrade performance. 2 is a good number for home or SOHO, 3 - 5 for a business or small university.
    MaxSpareServers Sets the maximum desired number of idle servers. If there are more idle servers than desired, apache will begin to kill off children, reclaiming their resources. 10 is the default, while for the hobbyist or SOHO user, a value of 5 can be used to save resources.
    StartServers The number of children to spawn at startup. The default is 5. Busy sites should set this higher, but not too high or you'll spend your first minute and a half spawning children and not serving requests. Apache will dynamically adjust the number of processes later, so setting this value very high is almost never useful.
    MaxClients This sets a ceiling on the number of child processes that can be spawned. It can be set up to 256 without modifying source code.
    MaxRequestsPerChild This sets the maximum number of requests that a child process will handle before dying. It is mainly useful on IRIX and SunOS where there are noticeable memory leaks in the libraries. A vaule of 0 will allow unlimited requests per child, and is claimed to be safe on Linux. I recommend a value of 1000, or 10000 for heavily loaded sites.
    Listen Determines the address and port number that apache will bind. This can be used to limit apache to a specific address. For instance, you can use Listen 127.0.0.1:80 to cause apache to respond only to requests from the localhost. The usual value is 80, which tells apache to listen on the HTTP port of all interfaces. Multiple Listen directives can be used.
    BindAddress Detemines which IP addresses apache will respond to. This is used on machines with multiple IP addresses (either through multiplexing or using multiple interfaces). The normal value is *, which causes apache to listen on all addresses.
    ExtendedStatus This is only useful if you have loaded mod_status, and tells apache to keep track of extended information on a per request basis. It cannot be used on a virtualhost by virtualhost basis. Set this value to "on" if you've decided to compile mod_status as a built-in module (recommended).
    ClearModuleList Apache has a list of modules that should be active. This directive clears that list. It is assumed that you will then turn on what you want using the AddModule directive.
    AddModule Modules are sort of complicated. When you compile apache, it gets a list of included modules, not all of which are "turned on". This directive is used to activate a built-in module. It can be used even if you haven't used the ClearModuleList directive.
    LoadModule This directive is used to load a dynamically loaded module (as oppossed to a built-in module. Order of execution can be important, so pay close attention to the example configuration and the documentation for any alternative modules you load.
    <IfDefine></IfDefine> This is used to conditionally execute directives based on whether or not a specific value is defined, usually by means of a command line switch (-D foo). One use for this is for a startup script to check for the existance of a module, and load/configure it if it exists (RedHat's startup script does this, for example).
    Back to Top
    Main (Default Server) Section

    This section of the configuration file deals with the default server. The default server (or main server) is the one that will handle any requests not captured by a <VirtualHost> stanza in your configuration. Directives and instructions that you set in this section are, in general, inherited by virtualhosts as well, so you can set some good default behaviours here rather than duplicating a lot of effort. Settings inside <VirtualHost> stanzas will override these options for that particular virtualhost only.

     
    Main (Default) Section Directives
    Directive Notes
    Port Here for historical reasons, and for setting the SERVER_PORT environment variable for CGI and SSI. Set this to whatever your HTTP port will be (usually 80). Note: This does NOT apply to virtualhosts.
    User Sets the user that apache will handle requests as. For security reasons, apache changes its effective UID before handling requests, so all of your documents must be accessible to this user. For this reason, it is useful to create a user called www or apache to use with your webserver. Running as the user nobody or as UID -1 does not work on all systems or with all libraries.
    Group Just as apache changes its UID, it also changes its GID. This is the group to change to. Once again, nobody can cause you some difficult to track-down problems, so it's probably a good idea to create a group.
    ServerAdmin Set this to the e-mail address that should receive all error notifications.
    ServerName Set this to the fully qualified domain name of the server. Also used when setting up name-based virtual hosts. If you don't set this, you will likely encounter problems on startup.
    DocumentRoot Set this to the directory to search for the main index file for this server. Apache will search for a file that matches your DirectoryIndex in this directory to display when no other page is requested (as when you request http://www.example.com)
    UserDir When using the mod_userdir module, this allows you to map requests to user's home directories instead of to the document root tree. Set this to "public_html" to map requests for http://example.org/~foo to ~foo/public_html on the example.org server, for example. For security reasons, if you use this, also use UserDir Disabled root.
    DirectoryIndex Used with mod_dir, this option sets the search order for files when a user requests a directory listing by specifying a "/" at the end of a directory name or for the document root. Normally this will just return "index.html", but you could specify
    DirectoryIndex index.html index.php index.pl index.cgi
    to have apache search for each of these files, returning the first one it found.
    HostNameLookups Gener