Jump to content

Tips for Linux Explorers

  • This topic is locked This topic is locked
375 replies to this topic

#201 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 12 August 2003 - 04:19 PM


If a filesystem check fails and returns the error message "Damaged Superblock" you're lost . . . . . . . or not ?

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
# e2fsck -b 32768 /dev/hda5

B) Bruno

#202 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 14 August 2003 - 04:06 PM


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:

linux noapic ( skips part of hardware detection )
linux pci=noapic ( skips parts of the hardware detection on PCI cards )
linux ide=nodma ( disable DMA on all IDE drives )
linux mem=1536M ( if the memory has more then 1G memory )
linux vga=0 ( sets the vga to default )
linux acpi=off  ( skips parts of the hardware detection on PCI cards )

Here are a few more options you can add after the kernel version:
noagp ( skips hardware detetion on agp slot )
noaudio ( skips parts of the hardware detection )
noddc  ( skips parts of the hardware detection )
noapic ( skips parts of the hardware detection )
nopcmcia ( skips parts of the hardware detection )
noscsi ( skips parts of the hardware detection )
nousb ( skips parts of the hardware detection )
nofirewire  ( skips parts of the hardware detection )
noapm ( disable Advanced Power Management )

The next ones are used without typing the kernel version first and only have effect on the installer itself:

vgahi  ( high resolution graphical install )
vgalo ( low resolution graphical install )
vga16 ( 640 x 480 in 16 colors install )
text ( text install instead of graphical )

I hope that one of these codes will do the trick for you if you have install problems


PS: Slackware has a special power-cheatcode, "the silver bullet" :
bare.i root=/dev/scd0 noapic


#203 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 15 August 2003 - 07:21 PM


So, now you've come this far in The Tips it might be time to get yourself and your box  registered ( see my sig and those of many others here on the forum  )  

Registered Linux User #299965  

The procedure is very simple and is free of charge  

The Linux Counter  

According to their website there are about 18,000,000 ( eighteen million ! ) Linux users on this planet. Only 134,177 of them are registered.  So let's push up those numbers ! ( I'm counting on you  )

NOTE: You will have to login on their site at least once a year to keep your Registration valid   

PS: Getting registered does NOT provide any extra benefits, but it's fun !

B) Bruno

#204 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 19 August 2003 - 05:47 PM


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 ):


411toppm    (1) - convert Sony Mavica .411 image to PPM
a2p (1) - Awk to Perl translatoraclocal: nothing appropriate
aclocal-1.4: nothing appropriate
aconnect    (1) - ALSA sequencer connection manager
acroread: nothing appropriate
activation-client: nothing appropriate
adddebug: nothing appropriate
addftinfo   (1) - add information to troff font files for use with groff
addr2line   (1) - convert addresses into file names and line numbers
addxface: nothing appropriate
alsamixer   (1) - soundcard mixer for ALSA soundcard driver, with ncurses interface
amixer (1) - command-line mixer for ALSA soundcard driver
amor: nothing appropriate
animate    (1) - animate a sequence of images
anytopnm    (1) - convert an arbitrary type of image file to PBM, PGM, or PPM

( For the very curious ones:  ls = list directory contents, xargs = build and execute command lines from standard input, less = opposite of more )

You can do this in any directory you like.

HINT: /bin, /usr/bin/, /sbin, /usr/sbin, and /usr/X11R6/bin are the most interesting directories to look for commands and their "whatis" explanation.

Have fun exploring !

B) Bruno

#205 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 21 August 2003 - 03:50 PM


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.

So next time you have to type a long command like this:
# cp synthesis.hdlist.update_source.cz /var/lib/urpmi/synthesis.hdlist.update_source.cz

You type:
# cp sy ( tab ) ( space ) /v ( tab ) li ( tab) u ( tab ) sy ( tab )

And you will see that the full command is on your screen :( ( This command works only if the file "synthesis.hdlist.update_source.cz" is in your /home direcotry )

More on the Tab key and commands:

If you don't remember exactly how a command was written, type in the first character or two and hit the tab, you will get a list of all the commands that start with that character(s).

If you wish to know what a certain command does ( ex: mkmanifest ), type:
$ whatis mkmanifest

This is what you get back to the screen :


mkmanifest   (1) - makes list of file names and their DOS 8+3 equivalent

All Linux commands and their descriptions can be found at O'Reilly

B) Bruno

#206 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 22 August 2003 - 02:46 PM


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.

B) Bruno

Yarg mailed us, "I found the windows command that would successfully combine the files":
# copy/b file1+file2+file3 newfile

#207 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 04 September 2003 - 04:42 PM


In most modern distros the USB-stick and digital camera are automounted on /mnt/removable . . . the "removable" directory is auto-created and removed after you plug out the device.

If this is not the case: USB sticks, digital cameras, and also memory sticks can be mounted as  "mass storage devices" . . . . there is a simple trick if they are not automounted:
$ su
# modprobe usb-storage[size=4]
# fdisk -l

( the -l is the letter L and not the number 1 )

This will show all the partitions on harddrisk and removable devices
Take a look on what /dev device the USB-storage is mounted ( we assume for this example /dev/sda1 )

# mkdir /mnt/storage

( make a directory for it )then mount it:
# mount /dev/sda1 -t vfat /mnt/storage

If anything is already stored on the memory stick:
# ls /mnt/storage

( will show you the files )

Now you can use the cp command to copy files to and from your memory stick

B) Bruno

PS: More in depth info Here and  Here

#208 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 08 September 2003 - 04:36 PM


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)

Mandrake: ( Pre kernel 2.6 !  . . . post kernel 2.6 see Making boot CD )
$ su
< password >
# uname -r
( will show you the kernel-version: probably 2.4.21-0.13mdk )  

# mkbootdisk --device /dev/fd0 2.4.21-0.13mdk

And put in a floppy and press enter  That's all !

The same as Mandrake ( only another kernel version  ) but you have to add /sbin:
# /sbin/mkbootdisk --device /dev/fd0 <kernel version>

$ su
< password >
# makebootdisk
And a dialog will pop up and make the floppy.

Same as Slackware

( 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

# 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 )

B) Bruno

#209 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 09 September 2003 - 03:18 PM


Imagine you can boot from your zip-drive and you want to put a distro on the zip, but distro's come "packed" as ISO, so how do you extract an ISO ?

Create a directory in /mnt called loop: ( as root )
# mkdir /mnt/loop

# mount -o loop /home/bruno/tmp/damnsmall-0.4.5.iso /mnt/loop

This will extract/show all the files of the ISO in /mnt/loop . . all you have to do is copy them to your zip drive and boot from it . . .

You can put a small distro like D Small Linux on your USB Memory Stick too, but booting from it is a bit more complicated . . . if you really want to give it a go Here and have a look . . . .

B) Bruno

#210 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 11 September 2003 - 02:33 PM


In some distros the Windows partitions are not automatically mounted. In that case we can mount them manually.

Most windows partitions have the FAT file system ( support long names for files ) A Linux partition typically has a Ext2 or Ext3 file system.

To mount a Fat file system on an Ext partition we have to give an extra argument to the mount command.

First we make a new directory in  /mnt:
$ su
< password >
# mkdir /mnt/windows

Then we can mount the Windows partition ( for this example Windows is on hda1 ) :
# mount -t vfat /dev/hda1 /mnt/windows
( or "mount -t ntfs /dev/hda1 /mnt/windows" for NTFS partitions )

( With  "fdisk -l /dev/hda" as root  you can see on what partition Windows lives )

# umount /mnt/windows
( this is NO typo: umount and not unmount )

With most modern distros, however, you do not need all this because the Windows partitions will be auto-mounted every time you access them.

B) Bruno

#211 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 17 September 2003 - 04:15 PM


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.  

These are the entries for /etc/lilo.conf:  
- - - - - - -  
image=/boot/DSmall/vmlinuz-2.4.20-xfs (this is the path to the vmlinuz you moved)
. . . label="DamnSmall"  
. . . root=/dev/hdb9 (hdb9 should be the hdb you used)  
. . . vga=788 (use the same number here as Mandrake)  
. . . read-only  
- - - - - - - -  
# /sbin/lilo
is the last action to check if all is well . . .  and write the new lilo to the MBR

NOTE: Next versions can be installed and booted without changing lilo as long as the kernel-version ( vmlinuz ) used in DSL stays the same.


Then boot in DSmall . . . . that should go smooth . . . Now there are 2 more things to do:  

1). There are 3 lines in /usr/X11R6/bin/startx that should be removed:  ( in the DSmall terminal "rxvt" )
$ sudo vi /usr/X11R6/bin/startx  ( DSL uses the "sudo" prefix for root commands )
< i > ( to put vi in insert mode )  

These lines should be deleted:
export TEMP=/var/tmp
export TMP=/var/tmp
export TMPDIR=/var/tmp  

( put the cursor on the lines to remove and press the delete key )  

Save and close the file:  

2). We will save the start-up settings:  
$ sudo xsetup.sh  

Follow the on screen instructions and the job is done !

UPDATE: In the new version 0.4.8: 1). the adaption of startx ( temp directories ) and 2). xsetup, are not needed anymore. The HD install script was adapted.  

B) Bruno

PS: It is possible to add packages with MyDSL . . . see Tip MyDSL

#212 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 24 September 2003 - 04:29 PM

RSS FEEDS ( Linux related )

Here are a few RSS feeds you can add to your RSS-reader:
( Firebird has an extension for RSS feeds here )

Distrowatch Latest News: http://www.distrowatch.com/news/dw.rdf
Distrowatch Latest Distro's: http://www.distrowat...om/news/dwd.rdf
Distrowatch Latest Packages: http://www.distrowat...om/news/dwp.rdf
Slashdot: http://slashdot.org/slashdot.rss
Freshmeat: http://freshmeat.net/backend/fm.rdf
also: http://www.freshmeat...fm-releases.rdf
or Freshmeat-search: http://freshmeat.net...xml/?q=xml feed
Linux magazine: http://www.linux-mag.com/lm.rss
Linux.com: http://www.linux.com/index.rss
NewsForge: http://newsforge.com/newsforge.rss
LinuxJournal: http://www.linuxjournal.com/news.rss
KDE: http://dot.kde.org/rdf
Linux Today: http://linuxtoday.co...ckend/biglt.rss
SourceForge: http://sourceforge.n.../rss_sfnews.php
The Register: http://www.theregist...ys/slashdot.rdf
Lockergnome PenguinShell: http://lockergnome.c...enguinshell.php
Think Geek: http://www.thinkgeek.com/thinkgeek.rdf
The Linux Documentation Project: http://www.karakas-o...pwn/latest.html
Linux compatible has several, look: Here
MozillaZine - http://mozillazine.org/contents.rdf
Mozilla - http://www.mozilla.org/news.rdf
FootNotes (GNOME news) - http://www.gnomedesk...org/backend.php
gDesklets - http://gdesklets.gno...top.org/rss.php
Rssnewsapps: http://rssnewsapps.z...vis.com/msw.xml
Rssnewsapps extreme: http://rssnewsapps.z...com/extreme.xml
Rssnewsapps tech: http://rssnewsapps.z...is.com/tech.xml
Arstechnica: http://arstechnica.com/etc/rdf/ars.rdf
OSnews: http://www.osnews.com/files/recent.rdf
Geeknews: http://www.geeknewz....m...on=rdf&id=1
Geeknews: http://www.geeknewsc...l.com/index.xml
neowin: http://www.neowin.ne...d.php?page=main
Wired.com: http://www.wired.com.../0,2610,,00.xml
Rss.com http://rss.com.com/2547-1_3-0-20.xml
The Register: http://www.theregist...ys/slashdot.rdf

B) Bruno

PS: if you know another feed , please send me a PM . . :ermm: . . . and I will add it to the list.

#213 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 30 September 2003 - 06:01 PM


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 )

# 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- ( Also in this case: check the path ).
# ln -s /usr/lib/jvm/java-1.6.0-sun- /usr/lib/mozilla/plugins

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.

B) Bruno

#214 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 02 October 2003 - 04:58 PM

VI  ( Revisited )

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:


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.  

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. )  


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.  

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 !

NOTE: Have a look Here how you can tweak vi to your own preferences.

Owyn, on Sep 28 2003, said:

Rute pointed me to "vimtutor". A worthwhile exercise. Teachs by doing.
I found this to be a usefull help for Vim.

Here is another really good tutorial: First Steps: VI

And a good overview of all the commands: Advanced Vi Cheat Sheet

B) Bruno  

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.

#215 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 07 October 2003 - 02:44 PM


The / File System

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/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 )

/mnt   ( where devices are mounted )
     /mnt/win_c ( if you dualboot windows )  
     /mnt/cdrom /mnt/floppy

/opt    ( some 3rd party programs that got there at install like Acrobat Reader)

/proc   (  a direct reflection of the system kept in memory )

/root    ( where konqueror opens as root )
      /root/drakx ( only in case you run Mandrake )

/sbin    ( most executables that need root permission )

/tmp ( system temp files )

     /usr/bin ( most executables for programs with user permission )
     /usr/local/bin ( programs the user installs himself )

/usr/src ( for extra kernel sources and downloaded rpm's )

     /var/log ( all the log files, and there are many)

More elaborate info see:
$ man hier

B) Bruno

#216 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 09 October 2003 - 05:08 PM


0Here is a clever trick Jason ( linuxdude32 ) brought to my attention:

For doing the checksum, if both the .ISO file and the .md5 file are downloaded to the same directory:
( first "cd" to that directory )
$ md5sum -c damnsmall-0.4.8.md5

ill return to the screen:


damnsmall-0.4.8.iso : OK

Then you can immediately do:
$ cdrecord dev=/dev/hdc damnsmall.iso
( NOTE:The dev=/dev/hdc can be different on your system, see Tip cdrecord )

This burns the ISO to a fresh CD, then if you leave the CD in the burner and reboot, you will be in the new D Small Linux the minute after.

B) Bruno

NOTE: This fancy trick works only if both iso and md5 file are in the right condition . . . . if not, you better try it the old way:
$ cat name_of_ file.md5$ md5sum name_of_file.iso
And compare the two strings you get from those commands.

#217 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 15 October 2003 - 05:12 PM

SU AND ROOT  ( the difference )

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 . . .

B) Bruno

#218 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 21 October 2003 - 05:53 PM


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:


# 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 specification
root  ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# 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:
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom[/size]
[size=4]# %users localhost=/sbin/shutdown -h now

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

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

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

An extract of the man page on security:


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,
  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

  does not inadvertantly give the user an effective root shell.

Also see /usr/share/doc/sudo for more examples and information.

B) Bruno

#219 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 23 October 2003 - 04:34 PM



Formatting a floppy in Linux has a lot more options then you might suspect . . The normal way to do it is:
$ fdformat /dev/fd0u1440

But, and here is the fine print, you can also get more bytes on your floppy:
$ fdformat /dev/fd0u1722

( for 1722kB, but even up to 1920 kB is possible )

Here are all the formats:
fd0u1440  fd0u1722  fd0u1840  fd0u720   fd0u830
fd0u1040  fd0u1600  fd0u1743  fd0u1920 fd0u800
fd0u1120  fd0u1680  fd0u1760  fd0u360   fd0u820

NOTE: For a Mandrake 9.2 boot floppy you will need a 1722kB floppy
See also: Making a Boot Floppy


Now for the zip disk, usually on /dev/sda, for making a Linux native filesystem:
# mke2fs /dev/sda

Or make a DOS FAT filesystem:
# mkfs -t fat /dev/sda

Most distro's have these commands too ( they all have to be run as root ):

See "mkfs.vfat --help" for the full info on those commands.

So, that was pretty simple wasn't it ?

B) Bruno

#220 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 30 October 2003 - 06:26 PM


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.


Distro specific:
http://wwwnew.mandri...om/en/hardware/ ( Mandrake )
http://hardware.redh...l/?pagename=hcl ( RedHat )
http://cdb.novell.com/  ( SuSE )


Pcmcia cards:

WLAN adapters:



USB devices:

This will give you plenty of information before you spend your hard earned money on hardware.If you know of any other good sites, send me a PM and I will add it to the list.

B) Bruno

#221 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 04 November 2003 - 03:30 PM

( replacement for the boot floppy )

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 ):
$ su
< password >
# mkrescue --iso --initrd /boot/initrd-2.4.22-10mdk.img --kernel /boot/vmlinuz-2.4.22-10mdk

If you use a kernel other than the default kernel such as the 4GB RAM kernel you will have to adapt the numbers for intrd and vmlinuz :
# mkrescue --iso --initrd /boot/initrd-2.4.22-21mdk-i686-up-4GB.img --kernel /boot/vmlinuz-2.4.22-21mdk-i686-up-4GB

After running the command you will find an rescue.iso file in your /home and can simply burn it:
$ cdrecord dev=0,0,0 rescue.iso

That will burn the CD . . . I tested it and it boots fine from the CD ( even quicker than from a floppy )

In Slackware 9.1 its even more simple:
$ su
< password >
# mkrescue --iso

This will do the trick and read the lines from lilo.conf to know what files to put in the rescue.iso

NOTE: With the new kernels and initrd.img becoming larger, the chances are that you will need this technique in other distros soon.

B) Bruno

#222 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 06 November 2003 - 05:10 PM


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.

B) Bruno

#223 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 11 November 2003 - 06:23 PM


Not yet available for OpenOffice 2.0

There is a new version of the Open Office Quickstarter and this one works !
Any OpenOffice document or new file opens in just one or two seconds!

Here is the page on Freshmeat: http://freshmeat.net...topic_id=57,131

Get the latest .tar.gz file

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 . .

No more complaining about slow starting OpenOffice: really believe me . . under 2 seconds for opening any OOo file . . .

B) Bruno

#224 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 14 November 2003 - 03:57 PM


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.

# check the downloads
cd official/updates/2006.0
wget ftp://ftp.nluug.nl/pub/os/Linux/distr/Mandrakelinux/official/updates/2006.0/md5sums
md5sum -c md5sums
# NOTE: the end of the list gives errors for the srpms that you did not download because you do not need them.

# Go back to temp directory
cd ../../..

# create ISO for burning
mkisofs -R -o update2006.iso official

# burn the CD
# first check your recordable device. On my system the device is /dev/hdc
dmesg | grep CD
# Now burn it
cdrecord dev=/dev/hdc update2006.iso[/code]

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.

B) Bruno

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

The original thread can be found here:http://forums.scotsn...h...f=14&t=3879

#225 OFFLINE   Bruno


    Le Professeur Pingouin

  • Admin Emeritus
  • 37,904 posts

Posted 24 November 2003 - 06:35 PM

TAR, Unpacking Packages

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

$ tar -xvzf package_name.tar.gz
( x= extract v=verbose z=(un)compress f=file )

$ tar -xvzf package_name.tgz

$ tar -xvzf package_name.tar.z

$ tar -jxvf package_name.tar.bz2
( j=bzip2 )

$ gunzip package_name.gz

$ 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 )

More info: tar --help

B) Bruno

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users