Sunday 30 December 2012

TOP 100 LINUX TIPS AND TRICKS - 2


Tip 11: LILO can't find a kernel on a big drive
On some big hard drives, LILO can have problems loading your kernel. The problem is because the hard
drive has more then 1024 cylinders.
The trick is to make sure your kernel is in the first 1024 cylinders so LILO can find it. The way to do this is
to make a small /boot partition at the begining of the drive, and make sure the kernel is in the /boot directory.
You can set the partitions in fdisk, and select the right path for the kernel in /etc/lilo.conf so LILO knows
where it is. When you compile your kernel, simply move the new kernel in that directory so LILO can load it.

Tip 12: X Window configuration options
Each Linux distribution has its own X Window configuration program. XFree86 also has a text-based
configuration program which is complex to use. But what if both the distribution program and xf86config, the
text-based configuration for XFree86, do not seem to do what you need? XFree86 also comes with a
graphical configuration tool.
The name of the graphical program is XF86Setup. This will launch a graphical window and allow you to
configure the X Window Server.

Tip 13: Allowing users to mount drives
By default, Linux will not allow users to mount drives. Only root can do it, and making the mount binary suid
root is not a good idea. With a special command in the /etc/fstab file, you can change that.
This is a typical line for the fd0 (A:) drive in /etc/fstab:
/dev/fd0 /mnt auto noauto,user 1 1
The keywords here are noauto and user. Noauto tells mount not the try to mount a diskette on boot, and user allows any user to mount the drive into /mnt. The auto keyword is also interesting. It tells mount to try to find out which file system is on the diskette. You could also use msdos or ext2.

Tip 14: Allowing users to run root programs
When a user starts a command, it runs with the permissions of that user. What if you want to allow them to
run some commands with root permissions? You can, and that's called suid.
You can set a command to be suid root with the chmod command. This will make it run as root even if a user
starts it. Here is how to set mybin suid root:
chmod +s mybin
Note that you must be very careful with this option. If the command has any security hole, or allows the user
to access other files or programs, the user could take over the root account and the whole system.

Tip 15: Linux and NT booting
Some people choose to have both Windows NT and Linux on the same system. Windows NT has its own
boot loader called NTLDR and Linux has LILO. Which should go on the MBR?
The safest way is to install Windows NT first, and give it the MBR. Then, when you install Linux, tell LILO
to install on the Linux partition. Also set the Linux partition as the active partition. When the system boots,
LILO will be loaded, and if you want to boot Windows NT, then LILO can load the MBR with NTLDR in it.


Tip 16: Annoying boot messages
When recompiling your kernel, you might end up seeing strange messages on bootup like:
modprobe: cannot find net-pf-5
modprobe: cannot find char-major-14
These are messages from the modules loader telling you that he can't find specific modules. This usualy
happens when you compile modules, but modprobe tries to load modules that were not compiled and it can't
find them. The way to remove those messages is to set the modules to off. In the file /etc/conf.modules you
may want to add:
alias net-pf-5 off
alias char-major-14 off
This will stop modprobe from trying to load them. Of course you could also try to resove the problem by compiling the modules and make sure modprobe knows where they are.

Tip 17: Programs on CD-ROM
http://metalab.unc.edu, ftp://ftp.cdrom.com and more are sites with a lot of programs available freely for Linux. But you may not want to download gigabytes of data over a slow Internet link.
Several places offer a bunch of free programs on CD-ROM. http://www.cheapbytes.com and http://www.linuxmall.com are 2 places that can sell multiple CD-ROMs with all those programs for a very low price

Tip 18: International console
Most Linux distributions are configured to use a US english keyboard. If you need to write on a french or any
other kind of keyboard, you will want to change the locale so special keys like accents appear in the console.
The way to do this is to change the system locale with a program called loadkeys. For example, to enable a canadian-french locale, you need to add this line in your startup files:
loadkeys cf
Here cf means the canadian-french keyboard. Other locales are us, fr and more.

Tip 19: Multiple kernels choices
When you compile a new kernel, you will often change your configuration. This means you may forget to
include an important driver, like the IDE driver, or otherwise make your system unbootable. The solution is
to always keep your old kernel.
When you compile your kernel, the compilation procedure will often copy your old kernel into vmlinuz.old.
If it does not, you can do it manually. What you should do is add an entry to /etc/lilo.conf allowing you to
boot your old kernel. You should view the lilo man page for the complete syntax. You could also add entries
for different kernels, for example if you want to have an older stable version of the kernel and the newest
development version on your system.
Note that some distributions name their kernel with the version they represent. For example, your current
kernel may be /boot/vmlinuz-2.0.36-0.7

Tip 20: Default file permissions
When you create a file, the system gives it default permissions. On most systems the permissions are 755
(read, write and execute for the owner, and read and execute for others).
This default is setup with the umask command. To use the command, you need to find the right octal number
to give it. The permissions in the umask are turned off from 666. This means that a umask of 022 will give
you the default of 755. To change your default permissions from 755 to 700, you would use this command:
umask 077

No comments:

Post a Comment