Sunday 30 December 2012

TOP 100 LINUX TIPS AND TRICKS - 1


Tip 1: Which distribution is good for you
They are all good. But that's not a real tip. What you should be looking for is which distribution you feel the
most comfortable with. RedHat has the reputation of being very easy to install. They provide special tools to
make the configuration easier. Debian also has some tools, but will usually require you to go on the command
line more often to configure the system. If you want to be on your own, and really learn how to edit
configuration files then Slackware is for you. The Web site http://www.linux.org lists all the available
distributions.

Tip 2: How to find a Linux CD-ROM at low cost
The Linux market started from a few distributions available only from FTP servers, to full feature
commercial distributions available in stores and online including a printed manual and phone support.
Here are the main choices you have when looking for a Linux distribution:
·  You can download any Linux distribution from its FTP server. To take a few examples,
RedHat can be downloaded from ftp://ftp.redhat.com, Slackware from ftp://ftp.cdrom.com and
Debian from ftp://ftp.debian.org. That method is free, but requires you to have a fast Internet
connection. Downloading a full Linux distribution over a 56Kbps modem will take you quite a
few hours.
·  An other way is to buy a full distribution. RedHat, for example, can be bought online for about
$50. This will include a box, a CD-ROM, a boot diskette, a manual and support from RedHat.
·  The last way is to buy only the CD-ROM. There are a few places selling CD-ROMs of various
distributions for $2. One of them is http://www.cheapbytes.com. You will only get the
CD-ROM, but this is all you need to install Linux if you are comfortable with the fact that you
don't get a printed manual or free support. You can find the manual and other documentation
on the CD-ROM.

Tip 3: Multiple operating systems
A computer only needs one operating system to work. But what if you just want to try out a new system? Do
you need to forget about the old one and erase your hard drive? No, you can have as many operating systems
on your computer as you wish.
Linux requires 2 partitions to work. Partitions are sections of the hard drive. When you install Linux, it will
provide a program called fdisk or disk druid allowing you to create the needed partitions. The main problems
people have is that they don't have empty partitions to use for Linux, and they don't want to erase the current
Windows or DOS partition. The trick is to resize your current partition to create empty space. Then you will
be able to make the partitions needed by Linux to install properly.
Fdisk doesn't allow you to resize a partition. You will need to use another program to do the job, before using
fdisk to create the Linux partitions. A very popular commercial product to do this is Partition Magic from
http://www.powerquest.com.
Let's see step by step what is needed to resize an existing partition to allow the creation of a new one for
Linux:
·  Buy Partition Magic, or get any other tool that can safely resize partitions.
·  Make sure you have at least 150 megs free on your main partition, the required amount for
Linux.
·  Resize the partitions so you have at least 150 megs free, outside of any current partition.
·  Reboot and launch the Linux installation.
·  Run fdisk or any partitioning program that comes with the Linux distribution, and follow the
installation instructions to make the required Linux partitions.

Tip 4: Installing with no CD-ROM drive or modem
Most Linux distributions come on a CD-ROM. You can also download them from an FTP site, but that
requires an Internet connection. What if you have a system with no CD-ROM drive or Internet connection,
like an old 486 laptop? The trick here is to have another desktop system with a CD-ROM drive, and a
null-modem serial cable.
I will show you how to do it with Slackware. It is also possible with most other Linux distributions. Insert the
Linux CD-ROM in the drive on the desktop and copy the A (base) and N (networking) packages on diskettes.
You need at least those in order to use a serial cable to transfer the rest of the packages.
Now you need to enable NFS networking on the desktop, and allow the laptop to connect. You can give a
temporary IP address to the laptop, like 192.168.1.11 that you need to add to your /etc/exports file on your
desktop.
To link the two systems together, this is what you need to type on the laptop:
/usr/sbin/pppd -detach crtscts lock 192.168.1.11:192.168.1.10 /dev/ttyS1 115200
And this on the PC:
/usr/sbin/pppd -detach crtscts lock 192.168.1.10:192.168.1.11 /dev/ttyS1 115200
This is assuming the cable is linked to ttyS1 (COM2) on both systems.
With NFS, you can mount the CD-ROM drive remotely and tell the installation program to use a specific
path to install the remaining packages. Mount the CD-ROM with a command like this:
mount -tnfs 192.168.1.10:/cdrom /mnt
Then run the installation program:
setup
and enter the new path for the packages files.

Tip 5: Swap and memory
One important setting in any protected mode operating system like Linux is the swap space. In the
installation, you will need to create a swap partition. A common question is what size should the partition be?
The proper size depends on 2 things: The size of your hard drive and the size of your RAM memory. The less
RAM you have, the more swap you will need. Usually you will want to set your swap space size to be twice
the RAM size, with a maximum of 128 megs. This of course requires you to have a hard drive with enough
free space to create such a partition.
If you have 16 megs of RAM, making the swap space 32 megs or even 64 megs is very important. You will
need it. If you have 128 megs of RAM on the other hand, you won't need much swap because the system will
already have 128 megs to fill before using swap space. So a swap partition of 128 megs or even 32 megs
could be enough.
If you don't select enough swap, you may add more later.

Tip 6: More swap with a swap file
You installed a new Linux system, but forgot to set enough swap space for your needs. Do you need to
repartition and reinstall? No, the swap utilities on Linux allow you to make a real file and use it as swap
space.
The trick is to make a file and then tell the swapon program to use it. Here's how to create, for example, a 64
megs swap file on your root partition (of course make sure you have at least 64 megs free):
dd if=/dev/zero of=/swapfile bs=1024 count=65536
This will make a 64 megs (about 67 millions bytes) file on your hard drive. You now need to initialize it:
mkswap /swapfile 65536
sync
And you can then add it to your swap pool:
swapon /swapfile
With that you have 64 megs of swap added. Don't forget to add the swapon command to your startup files so the command will be repeated at each reboot.

Tip 7: Kernel size and modules
To configure Linux to detect a new hardware part, especially on a new kernel, you may need to recompile the kernel. If you add too many devices in the kernel configuration, you may get an error message telling you that
the kernel is too big. The trick is to enable modules.
The kernel itself must be a certain size because it needs to be loaded in a fixed memory size. This is one
reason why modules can be very handy. If you enable modules, you will need to make them:
make modules
and install them:
make modules_install
Then using the modprobe utility you can load selected modules on bootup. This way the kernel will be
smaller and will compile with no error.

Tip 8: The boot prompt
The Linux system uses a program called LILO to boot itself. This is the LInux LOader, and will load a kernel
and can pass various parameters. This is what the "boot:" prompt is for.
At the "boot:" prompt, you can enter a lot of parameters. You can send parameters to drivers like the ethernet
driver, telling it at which IRQ the ethernet card is located, or you can pass parameters to the kernel, like
memory size or what to do in a panic. Reading the LILO manual will tell you all of the nice things LILO can
be used for.
Note that for device drivers compiled as modules, you need to pass values when you load these drivers, and
not on the "boot:" prompt.

Tip 9: Wrong memory size found
The Linux kernel will detect various settings from your computer configuration. This includes the size of
memory you have. In some cases, it will find the wrong size. For example, it could find only 64 megs of
memory when in fact you have 128 megs.
The trick here is to specify the amount of RAM memory you have with the "mem=" parameter. Here is what
you would type when your system boots if you have 128 megs of memory:
LILO boot: linux mem=128M
This will tell LILO to load the linux kernel with 128 megs of memory.

Tip 10: Master boot record and LILO
What is the master boot record (MBR) and why does LILO erase the old boot loader? Every hard drive has a top space called the MBR where the BIOS will try to load an operating system. Every system has its own
loader. DOS has DOS-MBR, Windows NT has the NTLDR and Linux has LILO.
When you install LILO, you can install it in the MBR or in a boot record for the Linux partition. If you want
to keep your current boot loader, you can select the Linux partition, and make sure it is the active partition in
fdisk. This way you will be able to boot to LILO, and then boot the old loader from the MBR.
If you plan on only using Linux on your system, you can tell LILO to boot right into Linux and not display a
"boot:" prompt, and you can install it in the MBR.

No comments:

Post a Comment