Well, not really, the damaged "superblock" can be restored from a backup. There are several backups stored on the harddisk. But let me first have a go at explaining what a "superblock"is.

A superblock is located at position 0 of every partition, contains vital information about the filesystem and is needed at a fielsystem check.

The information stored in the superblock are about what sort of fiesystem is used, the I-Node counts, block counts, free blocks and I-Nodes, the numer of times the filesystem was mounted, date of the last filesystem check and the first I-Node where / is located.

Thus, a damaged superblock means that the filesystem check will fail

Our luck is that there are backups of the superblock located on several positions and we can restore them with a simple command.

The usual ( and only ) positions are: 8193, 32768, 98304, 163840, 229376 and 294912. ( 8193 in many cases only on older systems, 32768 is the most current position for the first backup)

You can check this out and have a lot more info about a particular partition you have on your HD by:

$ dumpe2fs /dev/hda5

( go on, try it right now ! )

You will see that the primary superblock is located at position 0, and the first backup on position 32768.

O.K. let's get serious now, suppose you get a "Damaged Superblock" error message at filesystem check ( after a power failure ) and you get a root-prompt in a recovery console, then you give the command:

# e2fsck -b 32768 /dev/hda5

( don't try this at home . . uh, I mean: don't try this on a mounted filesystem )

It will then check the filesystem with the information stored in that backup superblock and if the check was successful it will restore the backup to position 0.Now imagine the backup at position 32768 was damaged too . . . then you just try again with the backup stored at position 98304, and 163840, and 229376 etc. etc. until you find an undamaged backup ( there are five backups so if at least one of those five is okay it's bingo ! )

So next time don't panic . . just get the paper where you printed out this Tip and give the magic command

here are times that an install just will not go the way it's supposed to. Sometimes it hangs half way installing the packages or during the hardware detection. In those cases a "cheatcode" or an alternative kernel version can help.

The default is that you press F1 ( or F2 ) at the first screen as you boot from the CD, then you will get a screen with some info about boot options and a prompt where you can type a code.

In most cases the CD has a few different kernels you can use, ( Mandrake has: "linux", "alt0" and "alt1" ) we take as example the default one "linux", you start with typing the kernel version and then add the option:

Whatis is a funny command that might come in handy as you learn Linux. Let's give an example, we want to know what the command "cp" does:NOTE: On some systems you have to build the database first by running "/usr/sbin/makewhatis" as root ( Thanks Owyn )

$ whatis cp
cp (1) - copy files and directories

Or the command ifconfig:

$ whatis ifconfig
ifconfig (8) - configure a network interface

Now we can do a lot more with whatis, imagine you want to have the information on all the commands stored in, let's say, /usr/bin. We will have to move to that directory first:

$ cd /usr/bin

And then we give the next command:

$ ls | xargs whatis | less

( the "|" are pipe signs, the "shfit \" key )

This is a part of the list you will get ( scoll page with the spacebar, and close with Q ):

This has been in The Tips before, but got lost at the end part of another tip: "searching" . . Just because it's such a handy feature of the commandline and because many members are struggling to get the commands typed correctly . . . here it is again:

The Tab key autocompletes on the commandline, you type a few characters and press the Tab key and the command or the name of the file will be completed:
Try this, < cd /u > and press tab now add an "s" and press tab, give an "h" and press tab, now we have got < cd /usr/share/ > OK lets go on, type a "f" "o" "n" tab "t" tab "d" tab. < Enter > Now we are in /usr/share/fonts/ttf/decoratives. < ls > will give you a list of all the fancy ttf fonts on your system.

Split is a command we use for splitting large files into smaller ones without corrupting the integrity of the file. We can later merge the files again to the original size.
Why would we want to do that ? Well, an example would be if your laptop only has a floppy drive and you want to copy a large file from your PC to your laptop.

This is how it works:

# split -b1m lastweek.mp3 lastweek.mp3.

( The first "lastweek.mp3" is the original file, while the second "lastweek.mp3." is the name of the new files, the last dot has to be there for the double extension, or else it won't work. The -b stands for bytes, the "1m" means in portions of 1 MB . You can use -l instead of -b, then it will be the number of lines, the default is 1,000 lines )

If the original file was 5.6 MB you will get 6 files named: , lastweek.mp3.aa, lastweek.mp3.ab, lastweek.mp3.ac, lastweek.mp3.ad, lastweek.mp3.ae and lastweek.mp3.af ( the last one only 0.6MB )

Merging them together on the laptop is quite simple too:

$ cat lastweek.mp3.* >lastweek.mp3

( don't forget the * )

That's all, so now you've got a spotless lastweek.mp3 of 5.6 MB on the laptop.

Bruno

Yarg mailed us, "I found the windows command that would successfully combine the files":

If the GUI-tool for making a boot-floppy fails, there is a simple ( command line ) way to make one, the tools are a bit different depending on the distro you use:
( no need to wipe/format the floppy before you start, it will simply be overwritten anyway)

RedHat:
The same as Mandrake ( only another kernel version ) but you have to add /sbin:

# /sbin/mkbootdisk --device /dev/fd0 <kernel version>

Slackware:

$ su
< password >
# makebootdisk

And a dialog will pop up and make the floppy.

VectorLinux:Same as Slackware

Debian:( Also Knoppix HD installed )

# mkboot -r dev/hda? <kernel-version>

( hda? Is the root partition, replace the "?" )

NOTE: Always test your boot-floppy after you made it

So, next time you feel like doing some serious work on your system, and things go wrong, you will have a good way to boot even if the MBR gets overwritten. Simply boot from the floppy and restore Lilo or Grub to the MBR:

$ su[/size]
< password >
# /sbin/lilo

or

# grub-install /dev/hda

Have fun tweaking your Linux box ! ( you can even do a re-install of windows without having to worry about the boot-loader )

ATTENTION: These instructions are for the HD install of version 1.0 and before ( some parts even before 0.4.8 ).Versions beyond 1.0 are so easy to install that they do not need any intructions, just find the menu entrie for the installer and follow the wizard.

DSL HD install . . . . really simple, just boot it as Live CD but don't download firebird yet, and as it is booted up, just open a console ( "rxvt" as it is called in DSmall ) and type:
sudo dsl-hdinstall

When asked, just type the partition you want to use ( partitioning is already done so you can skip that part. )

Also installing Lilo is not what you want.

When finished, reboot into Mandrake to adapt Lilo.

See Tip about Multiboot Lilo for moving the vmlinuz-2.4.20-xfs to a DSmall directory you will make in /boot from Mandrake.

Installing Sun´s Java can pose a bit of a problem. Sun does have it´s own view on packaging software, not only for Star Office but even worse for Java, that is why I collected some bits and pieces that can help.Download it here: www.java.com/en/download . . . get the 'jre-6u11-linux-i586.bin' ( not the rpm ) the package that ends on ".bin"

CD to the directory you downloaded jre-6u11-linux-i586.bin ( your version might have different numbers )

first:

# chmod a+x jre-6u11-linux-i586.bin

and run the file:

# ./jre-6u11-linux-i586.bin

( don't forget the dot at the beginning, no space after the /)

You will get a license agreement before it will start and install the package.

After the install you will have to make a link from the java plugin to the /usr/lib/mozilla/plugins directory ( check the path, for example in SUSE 10.1 it is /usr/lib/browser-plugins ) .The java plugin ( libjavaplugin_oji.so ) will most likely be located in /usr/lib/jvm/java-1.6.0-sun-1.6.0.11/jre/plugin/i386/ns7/libjavaplugin_oji.so ( Also in this case: check the path ).

Other browsers will look for their plugins in /usr/lib/mozilla/plugins too !( Exception: Depending on the version of Firefox you additionally need to put a link to the libjavaplugin_oji.so in your /firefox/plugins directory too )

Now restart your browser, type 'about:plugins' in the address bar and see if java is listed.

There has been a Tip a while ago about the vi-editor and emacs, but because of popular demand here is a more elaborate version of the vi Tip, but first a quote from previous Tip:

Quote

All configuration files in Linux are written in plain English, easy to read and to adapt. We use a text-editor to write or make changes to those files.
The two most popular, powerful and "difficult" editors that you will find in every distro are Vi and Emacs. They both have "syntax-highlighting" to make writing and editing code easy.

NOTE: Vi and Emacs fans fight bitter religious wars over which is better

The vi-editor . . the exercise
( Vim is an iMproved version of Vi )

Because many people have problems with the vi-editor I will try to set up a lesson-exercise-detailed explanation about the bare basics.

To be able to change most config files that your system depends on, the vi-editor is your best tool, not really simple to learn, but very effective and safe.

Sure other editors like "kedit" are easier to manage, but there are situations where you will have no GUI and Vi is the only one that works without the GUI in text-mode, so you will have to learn how to handle it. ( Yes you could use emacs too, but I prefer Vi )

The biggest problems for novice users are:

1). The difference between "insert-mode" and "command-mode"With the vi-editor you can do two things, edit text and give commands . . . . to switch between the two modes two keys are important: The "i" key to put vi in "insert mode" ( modern vi versions will then show the text "INSERT' on the bottom line ) and the Esc key to put the editor back in "command-mode" ( to save the file ). As soon as you hit the Esc key the text "INSERT" on the bottom line will be gone.

2). Correctly saving a file:If you make a mistake when saving a file, or close vi before the file is saved, you will end up with a swap-file ( mostly marked with the .~ extension ) and the original file. The original one will not have the changes you made and the swap file is useless. Trying to reopen the original one will result in an error message. The best/easiest way to resolve this is to manually delete the .swap ( or .~ ) file. After that you can open the original file again and the error message will be gone.

Resuming:After opening a file in vi you press the i key, and only then you can start writing/editing. When you are finished writing, you press the Esc key to put vi back in command mode and give the command ZZ to save the file. ( Also the command :wq <Enter> will do the same job, take what you prefer as long as it works. )

EXERCISE

Now we will do an exercise to be sure you can handle vi as easy as eating French Fries ( please follow all instructions to the end )

To make a new file called "tessst" you type in a console after the prompt:

$ vi tessst

You will get an empty consoles screen as vi starts with an empty file. Vi always starts in "command-mode" so to put it in "insert-mode" we have to give the command:

" i "

In most modern versions of vi you will see the text "INSERT" on the bottom line of the console. ( if you're not sure just hit the i-key again ) Now type:

The quick brown fox etc. etc.

After typing the text you go back to the "command-mode" by pressing the Esc-key. "Esc"

And you will see the text "INSERT" disappear. ( again if you're not sure just hit Esc again ) Now hold down the Shift key ( !! not the Ctrl !! ) and give the command ZZ

ZZ ( or :wq < Enter > )

Now vi should close and you should get your prompt back in the console. We will check if the text we wrote was correctly saved:

$ cat tessst

( cat is for reading only )

This should show: "The quick brown fox" line.

Now we will open the same file again:

$ vi tessst

You see it does not make a new file this time but it opens the existing one ( use a new name, it will open a new file; use an existing name, it will open the existing file )

We put vi in "insert-mode" again: " i "

and are able to add another line of text:

The stupid dog did not notice the clever fox

Now we save the file again:< Esc > < ZZ >

And again we have a look to see if the changes were saved:

$ cat tessst

Again we open the file to add a 3rd line:

$ vi tessst

< i >

I think I've got the idea now . .

< Esc > < ZZ >

And check the file again:

$ cat tessst

Now to finish off we are going to have a look ( GUI ) in your home directory . . . there should only be ONE file called "tessst" . . . if there are more of them and even with the extension tessst.swap or tessst.~ you know you made mistakes and will have to do the exercise again ! Delete all the tessst files and start reading again at the top of this post . . . If you made No mistakes, you passed the test and deserve a pat on the back !

Disclaimer: for those who know their way around vi, I know there is an "Ex-mode" too and 10 pages to fill with additional commands . . . . but I did try to keep things ultra simple for the ones doing their first steps in our all time favorite vi-editor.

A simplified overview of the file system, with only the most important subdirectories and an absolute minimal description:

/bin ( most programs for the user with normal user permissions )

/boot ( where you can add extra kernels for multi booting )

/dev ( Contains all the special files (nodes) used to access hardware and other device drivers )

/etc ( most of the config files )

/home /home/lost and found ( where things end up after a "scandisk" due to an improper shutdown ) /home/bruno ( here opens "home" icon, konqueror and the console )/home/bruno/tmp ( where I download/store my ISO's )/home/bruno/downloads ( other downloads, directory made by user )/home/bruno/documents ( documents )

/initrd ( nearly empty )

/lib ( all the libraries needed for the programs to run )

/lost and found ( where things end up after a "scandisk" due to an improper shutdown )

There have been questions , what is the difference between "su" and "root" . . well, the difference is minimal but still very important.

As you login as "root" right from booting the system, all the privileges are set to root, what makes your system more vulnerable to your own mistakes and those wishing to enter your system.
As you login as normal user, the privileges are limited, thus it's safer. To be able to do administrative tasks you can temporally login as root using "su" in a console/terminal, that way the root privileges are limited to the actions you do in the console ( and the applications you start from the console ). So the rest of the system is still in "normal user" mode, and this makes it safer.We do use the same password for "su" and "root", but typing "root" and the root-password at the console/terminal does not get you in "su" ( SuperUser ) mode.

Rmind me that next time we should have a talk about the "sudo" file . . .

Members that use D Small Linux or VectorLinux know there is a prefix to a command called "sudo" to perform commands as root without having to log in as root, or using "su" and <password>. Pretty convenient, not 100% bullet proof, but still . . . . if you're the only user and behind a decent firewall . . . .

Alright here is the trick, imagine you want to do "mount /dev/hda7 /mnt/loop" and you know this command has to be given as root, you don't have to "su" but:

$ sudo mount /dev/hda7 /mnt/loop

You simply add sudo before the command, and only for that specific command you are "temporary root", now that is simple, isn't it ?
Well that part indeed is simple, but "sudo" does not work out of the box like that on most distros, you first have to change the "sudoers" file. Editing the sudoers file does NOT work with:

# vi /etc/sudoers

No you have to give it a special command:

$ su
< password >
# visudo

And you will get this:

Quote

# sudoers file.#
# This file MUST be edited with the 'visudo' command as root.## See the sudoers man page for the details on how to write a sudoers file.## Host alias specification# User alias specification# Cmnd alias specification# Defaults specification# User privilege specificationroot ALL=(ALL) ALL# Uncomment to allow people in group wheel to run all commands# %wheel ALL=(ALL) ALL# Same thing without a password# %wheel ALL=(ALL) NOPASSWD: ALL# Samples# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom# %users localhost=/sbin/shutdown -h now

So to be able to use the "sudo" prefix on the most used commands, just delete the two # marks ( this action is called un-commenting the line ) on these two:

If you want a more drastic approach, in most cases, in most distros ( not in Slackware by default ) you are part of the "wheel" group, so "un-commenting" the next two lines will give you passwordless access to all commands:

# %wheel ALL=(ALL) ALL
# %wheel ALL=(ALL) NOPASSWD: ALL

You save the sudoers file the same as you do the vi-editor:EscZZ

If you want to know more about sudo and the sudoers file:

$ man sudo

An extract of the man page on security:

Quote

sudo tries to be safe when executing external commands. Variables that control how dynamic loading and binding is done can be used to subvert the program that sudo runs. To combat this the LD_*, _RLD_*, SHLIB_PATH (HP-UX only), and LIBPATH (AIX only) environment variables are removed from the environment passed on to all commands executed. sudo will also remove the IFS, ENV, BASH_ENV, KRB_CONF, KRBCONFDIR, KRBTKFILE, KRB5_CONFIG, LOCALDOMAIN, RES_OPTIONS, HOSTALIASES, NLSPATH, PATH_LOCALE, TERMINFO, TERMINFO_DIRS and TERMPATH variables as they too can pose a threat. If the TERMCAP variable is set and is a pathname, it too is ignored. Additionally, if the LC_* or LANGUAGE variables contain the / or % characters, they are ignored. If sudo has been com- piled with SecurID support, the VAR_ACE, USR_ACE and DLC_ACE variables are cleared as well. The list of environment variables that sudo clears is contained in the output of sudo -V when run as root.

To prevent command spoofing, sudo checks "." and "" (both denoting cur- rent directory) last when searching for a command in the user's PATH (if one or both are in the PATH). Note, however, that the actual PATH environment variable is not modified and is passed unchanged to the program that sudo executes.

For security reasons, if your OS supports shared libraries and does not disable user-defined library search paths for setuid programs (most do), you should either use a linker option that disables this behavior or link sudo statically.

sudo will check the ownership of its timestamp directory (/var/run/sudo by default) and ignore the directory's contents if it is not owned by root and only writable by root. On systems that allow non-root users to give away files via chown(2), if the timestamp directory is located in a directory writable by anyone (e.g.: /tmp), it is possible for a user to create the timestamp directory before sudo is run. However, because sudo checks the ownership and mode of the directory and its contents, the only damage that can be done is to "hide" files by putting them in the timestamp dir. This is unlikely to happen since once the timestamp dir is owned by root and inaccessible by any other user the user placing files there would be unable to get them back out. To get around this issue you can use a directory that is not world- writable for the timestamps (/var/adm/sudo for instance) or create /var/run/sudo with the appropriate owner (root) and permissions (0700) in the system startup files.

sudo will not honor timestamps set far in the future. Timestamps with a date greater than current_time + 2 * TIMEOUT will be ignored and sudo will log and complain. This is done to keep a user from creating his/her own timestamp with a bogus date on systems that allow users to give away files.

Please note that sudo will only log the command it explicitly runs. If a user runs a command such as sudo su or sudo sh, subsequent commands run from that shell will not be logged, nor will sudo's access control affect them. The same is true for commands that offer shell escapes (including most editors). Because of this, care must be taken when giving users access to commands via sudo to verify that the command

You might not be aware of it, but these days lots of hardware is supported in Linux. The general rule is: don't be the first on your block to get the latest hardware, as it takes a few months for programmers to make Linux-compatible drivers, because often the manufacturers are only focused on Windows drivers.

To help you with your research on the compatibility of your hardware, here is a list of links to hardware databases.

Because some new computers don't have a floppy-drive anymore, new versions of "mkrescue" have the option to make a bootable rescue.iso you can burn to CD and use instead of a boot floppy.

I tested this in a few distros and up to now only Slackware 9.1 and Mandrake 9.2 have a version of "mkrescue" ( 2.3 ) that has the --iso option. Mandrake 9.1, Redhat 9 and SuSE 8.2 still have an older version of mkrescue that did not include the --iso option, but I'm sure the future versions will have it too.

Making a boot-CD is mainly important for the new Mandrake 9.2 that needs a 1722kB floppy to make a boot-floppy, and rumors are spreading that over-sized floppies are not very stable.

NOTE: "mkrescue" only works if you use Lilo as bootloader because it reads the info from /etc/lilo.conf

Here is how to make a boot CD for your Mandrake 9.2 ( default kernel ):

After a system crash or an unclean shutdown, you see in the boot messages: "Press Y within 5 seconds to force the File system check" . . . it seems now that this is only meant for Ext2 filesystems and NOT for Ext3 !

( So you should not press Y if you have Ext3 )

Eric, on Cooker Oct 2003, said:

In case of a hard-reset, init messages indicate the computer was not shut down cleanly, and a message appear: "Press Y within 5 seconds to force the file system check " Actually this is very misleading : if you do it with ext3, it does NOT use the journal and then you will experience system losses. Lots of new users have reported that problem. Now that would be nice to change this message so that people leave the journalisation do the good work. --Eric

I do hope that the messages on the screen will be less confusing in next versions.

NOTE: Mandrake users can get it in the MCC if they have all the sources configured

Simply ./configure, make and make install ( as root ) and the job is done in Slackware. In Mandrake, after compiling, make a link to the application in "/home/bruno/.kde/autostart" that points to "/usr/local/kde/bin/oooqs" and then the quickstarter will be started at every boot.

Once in the autostart directory, rightclick on an empty space and select "make new" > "link to application" . . . call it oooqs and on tab 3 give it the command "/usr/local/kde/bin/oooqs". That's it!

To start it right now, without rebooting, just click on the link you just made . . . this will put an icon on the taskbar . . . . rightclick the icon and you will see the quickstart menu . .

Owyn wrote and tested the procedure to make an update CD for Mandrake 9.2 ( NOTE: I updated it recently to 10.1 ):

Owyn, on Nov 20 2003, said:

This procedure describes HowTo- Create a Mandrake 10.1 update CD

The procedures have been tested on Mandrake 10.1 (create CD) and Mandrake 10.1 (original ISO).Any updates will be applied to this initial post. Questions anyone?

Note: Last updated 2005-12-14 ( adapted to Mandriva 2006 )

To create the CD# Create the CD - This procedure uses a new temporary directory to download the update files[/color]
# and create the ISO for burning. The recommended ftp site for the files is ftp.nluug.nl.[/size][/color]
#
# Create and change to new directory
mkdir updatetmp
cd updatetmp
# Retrieve the update files using wget. This will create a Mandrake directory tree.
wget -nH --cut-dirs=5 -r ftp://ftp.nluug.nl/pub/os/Linux/distr/Mandrakelinux/official/updates/2006.0/main_updates/[/size]# wget finished - should have about 378MB of downloaded files.

And you should get a list of the updates for your system . . just reply with Y to the question if you want to install them and that is all there is to it.

After that you can re-check the sources you had unchecked before you started. And if not yet present configure the regular update source for the additional updates that were posted after the CD was made.

Bruno

Thanks Owyn, now the ones who adopted a dial-up user can make and send them the updates too !

There are packages in many different formats and I thought you would like to know all the different options for unpacking them:

.tar.gz

$ tar -xvzf package_name.tar.gz

( x= extract v=verbose z=(un)compress f=file )

.tgz

$ tar -xvzf package_name.tgz

.tar.z

$ tar -xvzf package_name.tar.z

.tar.bz2

$ tar -jxvf package_name.tar.bz2

( j=bzip2 )

.gz

$ gunzip package_name.gz

.bz2

$ bunzip2 package_name.bz2

So, now if you get a package, no need to right click it and select unpack . . . but choose the more speedy method of the commandline !
( Just for your info, to wrap a package up: "tar -cvzf package.tar.gz file1 file2 file3" where "package" is the name you want the wrap to have, and file1 etc. the files that will be in the package )