[lf icon]

Short Articles and Tips


1 Resetting Terminal/Shell 2 Linux Networking Guide 3 Resetting your terminal/shell window
4 EZ Email Security With Stunnel 5 Mounting ISO images (no CD-R required) 6 klick any key to continue
7 Swapping CTRL key with CAPS_LOCK key (X11 and console mode) 8 Having fun with BIND Version number. 9 Howto log in to your server passwordless via ssh ( rsa version )
10 http://www.portico.org/ 11 Removing ^M from file 12 Hide your Bind version
13 How to delete and recreate /tmp 14 Mojolin, The Linux Job Site, goes international 15 Blocking anyone to su to root
16 Disable rreboot,halt ,shutdown for users 17 Create /dev/null 18 How to create many subdirectories in one time
19 Translating articles from/to English, French, German and Spanish from within Netscape. 20 How to ispell a german text file? 21 How to easily shutdown your Linuxbox without beeing root?
22 How to delete all files from /tmp? 23 How to make Linux ignore a ping? 24 Resetting your terminal/shell window
25 Finding out what libraries a program requires 26 Mtools 27 Colors in the command prompt
28 2 vi tricks 29 Finding Netscape bookmarks  

Short articles can now be submitted directly online by everybody. Just click here and follow the instructions.


 
1)   category: UNIX Basics Language:English,  article number: 2002-01-03:3

Resetting Terminal/Shell
by Walt R.

Typing "stty sane "enter key"" into the shell
will normally recover an unreadable terminal.

See man stty, for explanation of what sane does.


 
2)   category: System Administration Language:English,  article number: 2001-11-20:1

Linux Networking Guide
by Eran Levy , homepage: http://levy.dyn.dhs.org

Looking for a comprehensive Networking guide? Here it is:
http://www15.brinkster.com/liloboot/linux/linetworking.txt


 
3)   category: UNIX Basics Language:English,  article number: 2001-10-17:1

Resetting your terminal/shell window
by Buffer_7

When accidentally doing a :
cat /bin/somefile_binary
you can end up with a "broken terminal". The binary file may possibly contain characters that
put a terminal into a mode where the output becomes unreadable. To put the terminal back to
normal you can type blindly:
reset
and it's normal.
best regards



 
4)   category: System Administration Language:English,  article number: 2001-10-11:10

EZ Email Security With Stunnel
by Pat Parsons

This is a little crash course in how to setup email over SSL painlessly using Stunnel. First you need to have installed a mail transfer agent to handle the SMTP portion of the mail. Then you need to have installed either an IMAP server or a POP3 server. Many distributions come with Stunnel, if yours does not you can get it from http://www.stunnel.org. Stunnel requires that you have OpenSSL or SSLeay installed first. This should come with your distribution. Generally if you have SSH installed you also have a SSL library.

Get and install Stunnel. I am not going into detail on that because if you are at this point you probably already know how to do so. Make a SSL certificate for use with Stunnel. OpenSSL provides a makefile to do just that. In my distribution it is located in /usr/share/ssl/certs . CD to that directory and type make stunnel.pem to create the certificate that is named stunnel.pem. Now you need to a few lines to your rc.local file to start Stunnel at bootup (assuming you ever reboot that is) these lines are:
/usr/sbin/stunnel -d 995 -r 110
/usr/sbin/stunnel -d 465 -r 25
This will start stunnel listening on port 995 for POP3 and 465 for SMTP. Now all you need to do is edit the options for your mail client and there you go. No need to worry about cleartext email passwords. If you are too impatient to wait for the next reboot you can type the commands given previously to start Stunnel right away. There may be some problems with certificate validation for some email clients. Make sure when asked by the makefile you get the server name correct. If your email client will not let you add certificates you may need to change or obtain a certificate from a certification authority. If you cannot get the certificate vaidation worked out there is no way to ensure that you are connecting to the correct machine. Have a nice day.


 
5)   category: UNIX Basics Language:English,  article number: 2001-07-23:1

Mounting ISO images (no CD-R required)
by

You've just downloaded a 650MB ISO file, ready for burning to a CD-R. The MD5 hash checks out, but you're still not sure if the image contains what you want. If you're too impatient to wait for the CD-R to burn, you can browse the actual downloaded file via the loopback device. First create a mount point

  bash# mkdir /mnt/iso

Then mount the .iso file:

  bash# mount -t iso9660 -o loop Mandrake80-inst.iso /mnt/iso

Now browse the directory tree mounted on /mnt/iso. This is useful as a space saving measure when you want access to both the directory tree and to the raw .iso image on the same machine.


 
6)   category: UNIX Basics Language:English,  article number: 2001-05-25:3

klick any key to continue
by erkan yanar

In shell-programming you often want to continue a programm, when the user clicks any button. Normaly "read" is used if you would like to continue with any key then use this:

stty raw; dd if=$(tty) of=/dev/null bs=1 count=1; stty -raw

It just waits for any key


 
7)   category: UNIX Basics Language:English,  article number: 2001-05-13:1

Swapping CTRL key with CAPS_LOCK key (X11 and console mode)
by

X11 environment:

Enter into /etc/X11/XF86Config (REDHAT 6.2) the following line:

Section "Keyboard"
XkbOptions "ctrl:swapcaps"
EndSection

Console

The solution from above does not swap keys in console Here is the solution for console: You have to modify the file "us.kmap.gz" (if you use US keyboard maping)
keycode 58 = Caps_Lock
to
keycode 58 = Control
AND from
keycode 29 = Control
to
keycode 29 = Caps_Lock
And life is nice again :)))

file "us.kmap.gz" is here (REDHAT 6.2) /usr/lib/kbd/keymaps/i386/qwerty



 
8)   category: System Administration Language:English,  article number: 2001-04-18:1

Having fun with BIND Version number.
by

Often when you have a large amount of DNS servers you tend to forget wich version of BIND you were running in each of them. With this little tips you will learn how to know wich version of bind you are running and how to change that version to show up anything you like. Ok.. start nslookup and type: > server target.host > set query=txt > set class=chaos > version.bind Server: localhost Address: 127.0.0.1 VERSION.BIND text = "8.2.3-REL" Ok this thing above is nice to show up to your friends to show them "the real BIND mastaH" inside you, but for usefullnes use the following script. #!/bin/bash for i in `cat iplist.txt`;do dig @$i txt chaos version.bind done It is obvious from the above that there NEEDS to exist a file named iplist in wich you specify the IP addresses of the name servers you want to check. Now comes the second part: Changing the BIND version shown by the above script. Fire up you prefered editor(vi) and edit /etc/named.conf and in the op options section type something similar to: version ":******"; Restart your bind and there yoy are. Mario Rafael.


 
9)   category: System Administration Language:English,  article number: 2001-03-08:1

Howto log in to your server passwordless via ssh ( rsa version )
by  , homepage: http://www.enderunix.org/

Create your private and public keys via ssh-keygen program
$ ssh-keygen
Computing keys
Testing the keys..
Key generation complete..
Enter the file in which to save the key (/usr/home/murat/.ssh/identity)

Press enter for the default value...

Your identification has been saved in /usr/home/murat/.ssh/identity
Your public ket is:
blah....blah...blah....
Your public key has been saved in /usr/home/murat/.ssh/identity.pub

Now that we have created our `public` key, take your
public key which is ~/.ssh/identity.pub to your server,
in the ~/.ssh/ directory, create a file named authorized_keys
and append the content of identity.pub file to your authorized_keys file
now, in your machine, type
$ ssh -l username your_remote_machine.domain.com
Boom, no password, no headache, you're in the other side...;)


 
10)   category: Community Language:English,  article number: 2001-03-02:1

http://www.portico.org/
by Guido Socher

There is a Linux site with a lot of tips and tricks: http://www.portico.org/


 
11)   category: UNIX Basics Language:English,  article number: 2001-02-13:9

Removing ^M from file
by  , homepage: http://www.enderunix.org

if you have transferred a file from MS Windows to UNIX, you might find that the file looks like this:
bleh bleh ^M
leh leh ^M
tey tey tey^M

This is because Windows uses carridge return and newline to indicate a new line.
Here are a number of ways to get rid of the ^M characters:
1- cat filename1 | tr -d "^V^M" > newfile
2- sed -e "s/^V^M//" filename > outputfilename
where ^V is actually control-V and ^M is actually control-M (you must type these yourself, don't just copy and paste this command from this web page)
3-vi solution : open file with vi
   1. hit the ESC key
    2. :%s/^V^M//

3 - some distributions contain a command called dos2unix which removes these carridge return characters

4- use the texteditor vim (www.vim.org) and edit the file. If all the lines (not only some) contain consistently the carridge return characters then vim will show [textmode] and when you change the mode with the command
:set notextmode
it will remove them.



 
12)   category: System Administration Language:English,  article number: 2001-02-13:5

Hide your Bind version
by  , homepage: http://www.enderunix.org

Any user can get your bind version using following command:
$ nslookup -q=txt -class=CHAOS version.bind. remote.dns.server
Server: remote.dns.server
Address: 212.2.2.3
VERSION.BIND text = "8.2.2-P5"
to hide you version add folowing value to named.conf

version "[Secured !!! Please Go away idiot lamer ! ]";
in the options section as follows:
options {
directory "/var/named";
version "[Secured !!! Please Go away idiot lamer ! ]";
};

and restart your named. Finally when anyuser writes
$ nslookup -q=txt -class=CHAOS version.bind. remote.dns.server
Server: remote.dns.server
Address: 212.2.2.3
VERSION.BIND text = "Secured !!! Please Go away idiot lamer"
That's all


 
13)   category: System Administration Language:English,  article number: 2001-02-08:1

How to delete and recreate /tmp
by

The directory /tmp is a special one. When you "stat" it, it shows a 1777 mod ie drwxrwxrwt. Well, it's the same for .X0-lock, .X11-unix and .font-unix.

    "t" means that the files in the directory can only be deleted by the owner even though the directory is world writable.

So after a "mv /tmp /no_more_room/tmp or a rm /tmp", just do:
  • mkdir /tmp
  • chmod 1777 /tmp

To re-create it with the correct permissions. You have to do that if you want your x font server (xfs) to be working properly.


 
14)   category: Community Language:English,  article number: 2001-01-04:1

Mojolin, The Linux Job Site, goes international
by Dan Barber , homepage: http://mojolin.com

article image
Mojolin (http://www.mojolin.com) has added international support to its full featured online Job/Resume database. Job listings and resumes can now be entered with full location specifics. This new ability is complemented by a feature that allows an individual to search by countries, and by states and provinces in the United States and Canada. In addition, links have been provided to BabelFish for translation of the site into five different languages: German, French, Italian, Spanish and Portuguese. Other features include a nightly email agent which informs job seekers of the latest opportunities, and the ability for Webmasters to include Mojolin's job listings on their own sites.


 
15)   category: System Administration Language:English,  article number: 2000-11-16:2

Blocking anyone to su to root
by Ismail YENIGUL , homepage: http://apache.cslab.itu.edu.tr

The su (Substitute User) command allows you to become other existing
users on the system. For example you can temporarily
become "root" and execute commands as the super-user "root". If
you don't want anyone to su to root or restrict "su" command to
certain users then add the following two lines to the top of
your "su" configuration file in the "/etc/pam.d/" directory.
1- Edit the su file (vi /etc/pam.d/su) and add the following two
lines to the top of the file:

auth sufficient /lib/security/pam_rootok.so debug 
auth required /lib/security/pam_wheel.so group=wheel
After adding the two lines above, the "/etc/pam.d/su" file should
look like this:
#%PAM-1.0
auth sufficient /lib/security/pam_rootok.so debug
auth required /lib/security/pam_wheel.so group=wheel

auth required /lib/security/pam_pwdb.so shadow nullok
account required /lib/security/pam_pwdb.so
password required /lib/security/pam_cracklib.so
password required /lib/security/pam_pwdb.so shadow use_authtok nullok
session required /lib/security/pam_pwdb.so
session optional /lib/security/pam_xauth.so
Which means only those who are a member of the "wheel" group can su to root;
and to add a user to wheel group use:
root# usermod -G10 username
Ok, now everybody can not be root using su. When an user that is not in wheel group runs su command ,he/she can not be root even if he/she writes correct root password.



 
16)   category: System Administration Language:English,  article number: 2000-11-16:1

Disable rreboot,halt ,shutdown for users
by  , homepage: http://apache.cslab.itu.edu.tr

On Redhat
[root@apache /]# rm -f /etc/security/console.apps/halt
[root@apache /]# rm -f /etc/security/console.apps/poweroff
[root@apache /]# rm -f /etc/security/console.apps/reboot
[root@apache /]# rm -f /etc/security/console.apps/shutdown
[root@apache /]# rm -f /etc/security/console.apps/xserver (if removed, root will be the only user able to start X).


 
17)   category: UNIX Basics Language:English,  article number: 2000-10-09:1

Create /dev/null
by Mariusz Zinowicz

I have moved a file to /dev/null and now my system doesn't work

If you move a file with the mv command to "/dev/null" then it will be overwritten with an ordinary file.
How to fix it:
Boot your system. If it doesn't boot take a one disk distribution like Toms rtbt and mount your /dev/hdXX partition.
Now type in a shell "mknod /dev/null c 1 3" to create a nod file. /dev/null is the path where the nod file will be saved. The c stands for a character device and the two numbers are the major and the minor numbers for the null device.
After that you must change with "chmod 666 /dev/null" the read, write and execute permissions.

With "ls -alF /dev/" you will see all nod files with it's own three parameters like
"crw-rw-rw- 1 root root 1, 3 Oct 4 11:34 null ".
You will see a "c" in the near of the rwx flags an a " 1, 3" left of the date.


 
18)   category: UNIX Basics Language:English,  article number: 2000-05-19:1

How to create many subdirectories in one time
by

Sometimes, we want to create 2 or 3 (or more) directories at the same time.
For example, you are in "rep1" directory ("rep1" doesn't contain any subdirectory) and want to create rep1/rep2/rep3
With "p" option of the mkdir command , it's very easy :

mkdir -p rep1/rep2/rep3


 
19)   category: Webdesign Language:English,  article number: 2000-04-10:1

Translating articles from/to English, French, German and Spanish from within Netscape.
by

Webpages can conveniently be translated from English to French, Italian, German, Spanich and Portoguese or visa versa by means of Babelfish.

Altavista has a website where you can have a text translated. Alternatively you can have a website translated.

If you add the link below to your bookmarks (name it "translate"), you can translate any page by choosing this "translate" bookmark while visiting a website:

 
Example english to french: 

javascript:location.href=
'http://babel.altavista.com/tr?lin=en&lout=fr&translate_me=yes
&urltext='+escape(window.location);
The above should be written as one line. I just split it into a couple of lines for easy reading.

Translations are not very good, but it will give a very good clue about the content of the page.

An other interesting site for online translation is www.freetranslation.com.



 
20)   category: Applications Language:English,  article number: 2000-03-24:2

How to ispell a german text file?
by Dino Korn

Solution:
ispell -T latin1 -d deutsch textfile.txt
The -T latin1 causes ispell to handle Umlaute correctly.


 
21)   category: UNIX Basics Language:English,  article number: 2000-03-24:1

How to easily shutdown your Linuxbox without beeing root?
by Bernd Muller

People who do not boot to run-level 5 (grapical login) but use normal startx to start the window system I have the following trick:

Edit /etc/inittab and search for ctrlaltdel
ca::ctrlaltdel:/sbin/shutdown -t1 -r now
Replace the -r by -h:
ca::ctrlaltdel:/sbin/shutdown -t1 -h now
After that reboot once. Now you can shutdown and halt your computer by typing CTRL-ALT-DELETE. And this can be done by anybody without root rights.


 
22)   category: UNIX Basics Language:English,  article number: 2000-03-01:2

How to delete all files from /tmp?
by

Simple question? Well, how do you delete files in directories that start with a dot in the name?
Rm -r /tmp/.* WILL DELETE THE WHOLE DISK as it selects also the file /tmp/.. Therefore never try this. The solution is to add two question marks before the '*'-wildcard:

rm -rf /tmp/.??* /tmp/*

You can put this into /etc/rc.d/init.d/syslog into the "stop)" section. This will clean up /tmp at every shutdown and keep your disk tidy.
Do not run the above command while running X11 or before you run startx. X11 needs the /tmp/.font-unix which is created by xfont server and X11 it self creates the directory /tmp/.X11-unix which is needed to talk to the X11 windows.


 
23)   category: Kernel Corner Language:English,  article number: 2000-03-01:1

How to make Linux ignore a ping?
by

Sometimes it can be useful to hide a Linux machine a bit. Here is how you can make Linux ignore a ping:

Simple, to turn answers to icmp_echo off type:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
to turn it on again use:
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all



 
24)   category: UNIX Basics Language:English,  article number: 2000-02-15:3

Resetting your terminal/shell window
by  , homepage: http://www.oche.de/~bearix/g

When accidentally doing a :
cat /bin/somefile_binary
you can end up with a "broken terminal". The binary file may possibly contain characters that put a terminal into a mode where the output becomes unreadable. To put the terminal back to normal you can type
/bin/echo -ne "\017"
To make it easier you can put this into a small shell script and call it kscreen. When your terminal is again in this funny mode you just type blindly kscreen and it is back to normal.


 
25)   category: UNIX Basics Language:English,  article number: 2000-02-15:2

Finding out what libraries a program requires
by Guido Socher

  1. First find out where the program is located:
    In bash use: type yourprogram
    In tcsh use: which yourprogram

  2. To find out which shared libraries a program requires, type:
    ldd /the/path/to/yourprogram

Example:
> which gnome-terminal
/usr/bin/gnome-terminal

> ldd /usr/bin/gnome-terminal
        libart_lgpl.so.2 => /usr/lib/libart_lgpl.so.2 (0x400e1000)
        libgdk_imlib.so.1 => /usr/lib/libgdk_imlib.so.1 (0x400ef000)
        libgtk-1.2.so.0 => /usr/lib/libgtk-1.2.so.0 (0x40131000)
        libgdk-1.2.so.0 => /usr/lib/libgdk-1.2.so.0 (0x40251000)
        libgmodule-1.2.so.0 => /usr/lib/libgmodule-1.2.so.0 (0x40283000)
        libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40286000)
        libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40292000)
        libgnome.so.32 => /usr/lib/libgnome.so.32 (0x4032f000)
        libgnomesupport.so.0 => /usr/lib/libgnomesupport.so.0 (0x40345000)
        libaudiofile.so.0 => /usr/lib/libaudiofile.so.0 (0x40350000)
        ....


 
26)   category: UNIX Basics Language:English,  article number: 2000-02-15:1

Mtools
by Guido Socher , homepage: http://www.oche.de/~bearix/g

article image
mtools is a collection of programs to access ms-dos files on floppy disks without mounting them. You can read dos floppy disks in Linux by mounting them somewhere but mtools are usually easier and faster to use. An advantage is also that the floppy does not need to be mounted because accidentally ejecting a mounted floppy under Linux can be quite fatal.

Using mtools

mtools work basically like msdos commands. The command names are identical with the corresponding msdos command except that a "m" is prepended. Mtools understand also long file names. The most important commands are:
  • mcopy
  • mdel
  • mdir
  • mformat
Make sure that the device /dev/fd0 is writable for you before you use them. You many make the /dev/fd0 device writable for everybody. To do that log in as root and type "chmod 666 /dev/fd0".

To get a directory listing of the floppy in /dev/fd0 (drive a:) you type:
mdir a:
Note the device specifier. It is "a:" and not the normal Linux name /dev/fd0.

To copy the files a.txt and b.txt to the floppy you use:
mcopy a.txt b.txt a:


To copy all files (not directories) from the floppy to your current directory you use:
mcopy "a:*" .
Note the quotes. They are important because you want the star to go to the mcopy command and avoid that it gets expanded by the shell.

To delete all files that have a filename which starts with a "x" you type:
mdel "a:x*"
Again remember to put quotes.

To remove all files from the floppy you can use mformat
mformat a:

The mtools are included in almost every distribution. If they are not yet installed then install them from cdrom. Otherwise mtools are available from
http://www.tux.org/pub/tux/knaff/mtools/index.html


 
27)   category: UNIX Basics Language:English,  article number: 2000-02-14:5

Colors in the command prompt
by

article image
All terminal windows for Linux understand Ansi color codes and with these codes it is possible to have colors in the shell prompt.

The color codes are:

  • Foreground colors: 30=black, 31=red, 32=green, 33=yellow, 34=blue 35=purple, 36=turquoise, 37=white
  • Background colors: 0=transparent, 40=back, 41=red, 42=green, 43=yellow, 44=blue 45=purple, 46=turquoise, 47=white
The syntax to print the codes is "Esc[background;foreground;1m" for bold print and "Esc[background;foreground m" for normal print. The Esc is a literal Esc character (octal 33). The coloring is switched off with "Esc[m"

This command prints e.g Linux in yellow on a red background:
/bin/echo '\033[41;33;1m Linux \033[m'
Just try it out copying the command into the next shell.

To insert special characters such as (a literal Esc) into the shell prompt you must include them in %{ %} for tcsh and \[ \] for bash

This gives e.g the tcsh prompt that you can see in the picture above:
set prompt='%{^[[44;33;1m%}%!\-%n@%m%{^[[m%} \n%{^[[44;37;1m%}(%~)%#%{^[[m%} '

A yellow prompt for bash is e.g:
PS1='\[^[[40;33;1m\]\u@\h:\w\$\[^[[m\] '

In both cases the literal Esc character is shown as ^[. Note: You can not copy and paste these lines from the web browser to the shell. To get a literal Esc in Vi you type crtl-v Esc and in Emacs this is crtl-q Esc.

Happy color command prompts!



 
28)   category: UNIX Basics Language:English,  article number: 2000-02-14:1

2 vi tricks
by  , homepage: http://www.oche.de/~bearix/g

article image
Here are 2 interesting tricks for the VI editor.

  1. While editing something in VI you suddenly get a phone call. You need to go to the shell type a few commands and then go back to VI and continue working. What do you do? It's easy with VI. Hit Crtl-z to suspend VI then type the commands and afterwards type fg to continue the suspended VI process in foreground.

  2. The commands in makefiles must be preceded by a tab-character. Unfortunately it is not easy to distinguish tabs from spaces but a makefile with spaces just wont work. In VI you just type:
    :set list
    to see the tab characters as ^I. This way you can see all tabs at once and verify that the makefile is correct. When done you type:
    :set nolist


 
29)   category: Webdesign Language:English,  article number: 2000-02-13:1

Finding Netscape bookmarks
by  , homepage: http://www.oche.de/~bearix/g

article image

Searching through bookmarks

Sometimes you are looking for a bookmark in netscape and you can only remember that the URL or title did contain some key word. A little perl script, I called it showbook, can help in that case.

showbook linux
does e.g list all your bookmarks that contain the string Linux somewhere.

Click here to download the script.
(Note: If you download the script under windows then you must convert the dos textfile first to a unix textfile before it will run under Linux.)

Copy paste a url while not online

Somehow it is not possible to copy/paste a URL from your bookmark list into an other program. You can click on the bookmark go to the page and then copy the URL from the location entry at the top of the window in netscape. The problem is that you need to be online to do that. Again the above showbook program helps. It just lists the URL in the terminal window and you can easily copy/paste from there.