Monday 31 December 2012

TOP 100 LINUX TIPS AND TRICKS - 3


Tip 21: Default boot mode
When a Linux system boots, it loads the kernel, all its drivers, and the networking servers, then the system
will display a text login prompt. There, users can enter their user names and their passwords. But it doesn't
have to boot this way.
There are 3 modes defined in most Linux distributions that can be used for booting. They are defined in
/etc/inittab and have specific numbers. The first mode, also called runlevel 1, is single user mode. That mode
will only boot the system for 1 user, with no networking. Runlevel 3 is the default mode. It will load the
networking servers and display a text login prompt. Runlevel 5 is the graphical mode. If you have X Window
installed and configured, you can use it to display a graphical login prompt.
The way to change this is to edit /etc/inittab and change the initdefault line:
id:3:initdefault:
Changing a 3 to a 5 will make the system display a xdm graphical screen on bootup.

Tip 22: More information from usenet
There are newsgroups about everything. Newsgroups on the latest TV show, on gardening, and more. There
also are newsgroups on Linux. In fact, the best help can be obtained from newsgroups. But which ones?
Here is a list of a few newsgroups dedicated to Linux, and what they are used for:
·  comp.os.linux.advocacy: This newsgroup is used for advocacy. People stating their opinions
about Linux or Linux applications, and about Linux competitors. Some post facts, some will
flame other people.
·  comp.os.linux.setup: This is a general purpose setup help group. Users will post questions and
get answers there.
·  linux.*: There now is a linux section on usenet. Currently there are more than 150 groups in
linux.* and they are all about Linux!
Make sure you read the FAQ and rules of every newsgroup you want to post to.

Tip 23: Bytes per inodes
When you format a partition using Linux's primary file system, ext2, you have the choice of how many bytes
per inode you want. From the man page:
-i bytes-per-inode
Specify the bytes/inode ratio. mke2fs creates an
inode for every bytes-per-inode bytes of space on
the disk. This value defaults to 4096 bytes.
bytes-per-inode must be at least 1024.
This means that by using a smaller size, you will save disk space but may slow down the system. It is a
space/speed trade off.
This is similar to one of FAT16/FAT32' major differences.

Tip 24: LILO and boot problems
When a computer starts, the number of beeps the BIOS outputs tells you the state of the computer. On some
computers, one beep means all is ok, but 2 beeps mean there is an error. LILO uses the same kind of codes.
The number of letters you see from the word LILO on the screen says what is wrong. The whole word means
everything is fine, only LI means only the first part of LILO could be loaded. A full description of this is
available from the Bootdisk HOWTO.
When LILO can't load, it's a major problem. This often means that the boot code was corrupted. The only
way to boot is from a floppy disk. In RedHat, you can use the rescue disk, in Slackware, you can use the boot
disk with the "mount" image.
When LILO is fine, it's often easier to figure a boot problem. If the kernel panics when it tries to boot, it is
usualy due to a configuration error. You can tell LILO to mount another kernel you may have, like a "safe" or
"old" image you kept for these cases. If the problem is in initialization scripts, you can tell LILO to boot
directly into a shell with the following boot command line:
LILO boot: linux init=/bin/sh
Where "linux" would be your kernel image.

Tip 25: Making CD-ROM images
With other operating systems, such as Microsoft Windows or IBM OS/2, you are not allowed in the license to
make your own CD-ROM with the OS on it and then distribute it.
Linux, being Open Source and free, can be copied. You can download a distribution or buy it from an online
store and burn your own copy, and then install it on many computers, or give it to your friends. Usually, you
will find instructions on how to do that on the FTP server for your favorite distribution. You will need the
main directory on the CD-ROM. The sources are not needed since they are available from the FTP site.
Some distributions also come with ISO images of their CD-ROM. This is a single file that can be put onto a
CD-ROM, and will create a full file system with files on it.
One thing you have to be careful is not to copy commercial programs. The basic CD-ROM where the Linux
distribution is located is composed of free software. But some distributions may come with other commercial
programs, and you should read the license first.

Tip 26: FTP access restrictions
When you first install Linux, it comes with a lot of Internet services running, including mail, telnet, finger
and FTP. You really should disable all those that you don't need from /etc/inetd.conf and your startup scripts.
FTP may be very useful, but must be configured correctly. It can allow people to log into their accounts, it
can allow anonymous users to login to a public software directory, and it can display nice messages to them.
The files that you will probably want to modify are /etc/ftpusers and /etc/ftpaccess.
The file /etc/ftpusers is very simple. It lists the people that will not be allowed to use FTP to your system. The
root account, and other system accounts should be in that file.
The file /etc/ftpaccess is a bit more complex and controls the behaviour of the FTP server. It tells it what to
use as README file to display on a directory listing, what kind of logs to create and what messages to
display.
Note that if you create an anonymous FTP area, you will need to read the FTP man page and do exactly what
it tells you to avoid possible security risks.

Tip 27: Detecting 2 ethernet cards
To configure an ethernet card in Linux, you need to enable it in the kernel. Then the kernel will detect your
ethernet card if it is at a common IO port. But it will stop there, and will never check if you have 2 ethernet
cards.
The trick is to tell the ethernet driver that there are 2 cards in the system. The following line will tell the
kernel that there is an ethernet card at IRQ 10 and IO 0x300, and another one at IRQ 9 and IO 0x340:
ether=10,0x300,eth0 ether=9,0x340,eth1
You can add that line on bootup at the "boot:" prompt, or in the /etc/lilo.conf file. Don't forget to run:
lilo
That will reload the lilo.conf file and enable changes.

Tip 28: Everything on sound cards
A sound card can be easy or hard to detect. It depends on who made it. Many Sound Blaster Compatible
cards in fact are not compatible with the Linux Sound Blaster driver. Other cards will be compatible with a
driver you would never have thought of.
There are multiple drivers for Linux. Currently the kernel comes with its own set of sound drivers, plus the
OSS/Free drivers. These will support most generic cards. In the installation program, or when compiling your
kernel, you can pick the sound card that matches yours, or the one that matches the chipset on your sound
card (for example, the Sound Blaster PCI64 card uses the AudioPCI chipset).
If your sound card is not supported by the kernel, you will need to get another driver. 2 popular ones are
ALSA available from http://alsa.jcu.cz and OSS/Linux available from http://www.opensound.com
OSS/Linux is a commercial product that supports a lot of cards not available in other drivers because of card
specification restrictions. You will need to see the list of supported cards in each driver and pick the driver
you need.

Tip 29: Non-PostScript printers
Unfortunately, most printers are non-PostScript compatible. This means that your LPR program won't like it.
You will probably notice that when you first use 'lpr' to print, the output looks weird on your printer. This is
because these models do not support PostScript. You will need a converting program for it.
Note that newer versions of RedHat already have those programs or similar filters so it may not apply to all
Linux systems.
First, you need to go read the Printing HOWTO to find out how to use lpr and related printing programs.
Then, you'll need to get 2 programs from http://metalab.unc.edu:
·  bjf
·  aps
These are the filters to convert text and PostScript to your printer's format.
First, install bjf which will be used to print text. Installation is very simple. type:
make
cp bjf /bin/bjf
Then, make a simple shell script to print text files and call it print.sh:
#!/bin/sh
/bin/bjf <$1> /dev/lp0
Where /dev/lp0 is your printer.
Now, install aps by running the SETUP script in its package. It's really easy to setup, but you do need to have
the GhostScript program installed prior to installation. You are now ready to print PostScript files from, for
example, Netscape or XV.

Tip 30: Use Windows special keys in Linux
Why are all the new keyboards sold with Win95 keys on them? How about making them do real keyboard
functions while in X Window? Here is how.
First you need to find out which key mapping you are using. Usually it will be US, it might also be en_US, ca
or else. Locate the file, usually in /usr/X11/lib/X11/xkb and edit it with your favorite editor. For me the file is
called /usr/X11/lib/X11/xkb/symbols/ca.
The file lists all the key codes and what they do. The key codes for the Win95 special keys are LWIN, RWIN
and MENU. All you need to do is add them to the list, with the functions for them. I decided to map the left
WIN key to "@" and the right WIN key and MENU keys to "{" and "}". Here are the lines I added:
key <RWIN> { [ braceleft ] };
key <LWIN> { [ at ] };
key <MENU> { [ braceright ] };
By browsing the file you can find all the other symbols and what they do. You can also add multiple
functions to a key, by using ALT and SHIFT.
The changes will take effect when you restart X Window. With the XKB extension (you do need to have it
enabled in /etc/XF86Config btw) it's easy to change the mapping of any key.

No comments:

Post a Comment