Linux System Administration

Introduction

How often do you need to install your favorite Linux distribution in a single year either virtually or using real hardware? How frequently it happens that you just want to test new release of certain Linux distribution so you install it on different partition or simply virtually using your current system as a host. How often do you need to deploy a server which is a complete clone of the one you configured yesterday. The installation part of any Linux system today is a very straightforward process. Nonetheless, the hardest and the most tedious part comes with a fine tuning, customization and configuration of your system's services as well as your own user environment. You can simply copy your custom system configuration files from one system to another but engaging in this concept this task can become quite disorganized, time consuming and most importantly error-prone.

In this article, we are going to take a different approach which involves a creation of a Debian package archive containing all required custom user and configuration files. First part of this article describes a rather simple way on how to create a Debian package archive containing all custom files followed by its installation. In the second part, we will look at the way on how to create our own very basic Debian Repository and use it to deploy a simple website including Apache webserver installation and configuration on a freshly installed Linux system.

Part1

In this section, we create and install simple Debian package. The package will accommodate some sample user data to serve as an example.

Creating a Debian Package

It took you a while to configure your desktop to have it the way it best suits your needs and convenience. In your custom environment, you may for example include some bash scripts, create several aliases using .bashrc file or changed default behavior of a vim text editor by altering .vimrc file. Furthermore, you may also have customized numerous system configuration files such as /etc/network/interfaces and so on. All this hard work can be saved within a Debian package and installed and removed from any system with a single dpkg command. As a first step we need to create a bare minimum skeleton for a Debian package. This is a fairly simple task as it only involves a single DEBIAN/control file. So let us start by creating a directory named "myenv". This directory will hold all data for our own version 1.0 Debian package.

$ mkdir myenv

In the next step, we need to create a control file:

$ cd myenv
$ mkdir DEBIAN
$ vi DEBIAN/control

Read more...

There are many backup tools around and many ways how to use them. For example, it is possible to use gzip and ftp to make a local copy of your web site. This approach have couple drawbacks such us: data are transferred over the internet unencrypted and we are most likely transferring data which we had copied over the day before.

To solve an unencrypted transfer problem we can instead of ftp use scp. However, this time the transfer time will be even longer as scp will create an extra overhead of creating encrypted tunnel for our backup internet connection. To stop transferring a duplicate data we can use rsync. If we combine rsync with ssh, compression, bash and cron we can end up with a ultimate backup tool.

Let's create simple but powerful backup solution using rsync, ssh, compression and cron scheduler:

Passwordless ssh

At this point we need to create passwordless ssh login. By doing this we can avoid the need of entering password when doing our backup. This way we can make the whole backup process completely automatic. Please follow this tutorial to make ssh login to your server without password.

rsync installation

If you have not done so yet install rsync tool as a root user:
For Ubuntu, Debian enter as:

# apt-get install rsync

And Fedora, RHEL and CentOS:

# yum install rsync

Making a database backup

In case that your website is using database such as mysql we first need to make a database backup. Therefore. our backup bash script starts with following lines:

#!/bin/bash 
 
# create database backup 
/usr/bin/ssh This email address is being protected from spambots. You need JavaScript enabled to view it. '( mysqldump --password='pass' \  
mydatabase > ~/public_html/mywebsite/mydatabase.sql )'
Read more...

Are you unable to create uppercase directory name on your storage device mounted as vfat file system. The reason for this behavior is that vfat filesystem is by default mounted by mount command with shortname option set to lower. Therefore, you nay force your system to mount your disk to show directory names as they are with winnt:

mount -o shortname=winnt /dev/sdb1 /media/temp

Here are couple more options to be complete:

lower  Force  the  short  name to lower case upon display; store a long
                     name when the short name is not all upper case.

              win95  Force the short name to upper case upon display;  store  a  long
                     name when the short name is not all upper case.

              winnt  Display  the  shortname  as is; store a long name when the short
                     name is not all lower case or all upper case.

              mixed  Display the short name as is; store a long name when  the  short
                     name is not all upper case.

Another solution to this problem is to use pmount. pmount command syntax is little different from the ordinary mount command. Instead of specifying a mount directory as an argument a user needs to specify lable. The lable will be eventually a name of the directory under /media:

# pmount /dev/sdb1 MY_DISK
# cd /media/MY_DISK/
/media/MY_DISK# ls
MEMSTICK.IND  MP_ROOT  MSTK_PRO.IND  MUSIC  PICTURE  PSP  TEST  VIDEO

Page 69 of 73



Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top