FAQ (Frequently Asked Questions)

How to read a man page with nroff

nroff -man ls.1m  | more

How to test internet conection behind a proxy

echo -ne 'GET http://www.big-up.org HTTP/1.0\n\r\n\r' | nc $proxy $port

How to mount a Solaris iso image under linux

  • Find out the partion layout in the iso file
# fdisk -l sol-9-u7-sparc-v1.iso

Disk sol-9-u7-sparc-v1.iso (Sun disk label): 1 heads, 640 sectors, 2048 cylinders
Units = cylinders of 640 * 512 bytes

Device Flag Start End Blocks Id System
sol-9-u7-sparc-v1.iso1 r 0 1018 325760 4 SunOS usr
sol-9-u7-sparc-v1.iso2 r 1018 2079 339520 2 SunOS root
sol-9-u7-sparc-v1.iso3 2079 2087 2560 0 Empty
sol-9-u7-sparc-v1.iso4 2087 2095 2560 0 Empty
sol-9-u7-sparc-v1.iso5 2095 2103 2560 0 Empty
sol-9-u7-sparc-v1.iso6 2103 2111 2560 0 Empty

The second partition offset is 1018 * 640 * 512 bytes = 333578240 bytes

  • Mount the partitions
# mkdir /mnt/s0
# mkdir /mnt/s1
# mount -t iso9660 -o loop,ro sol-9-u7-sparc-v1.iso /mnt/s0
# mount -t ufs -o ufstype=sun,loop,ro,offset=333578240 sol-9-u7-sparc-v1.iso /mnt/s1

How to creat a webserver without webserver

  • Creat a file named “www” /etc/xinetd.d
service socks
{
        disable = no
        socket_type     = stream
        wait            = no
        user            = www
        server          = /home/www/www.sh
}
  • Creat this script in /home/www
#!/bin/bash
echo "Content-Type: text/html"
echo

cat << EOF
<html>
    <body>
    Hello World
    </body>
</html>
EOF

Backspace or Delete print ^H or ^? or others instead of removing a char

The stty command sets certain terminal I/O options for the device that is the current standard input.

To fixe this issue you will have to redefine “erase”

stty erase ^H

To enter “^H” DO NOT ENTER “^” followed by “H”, this should be on sequence! you could press “backspace” to get the out put on screen or by doing “CTRL + V” and then “CTRL + h”

How to kill a frozzen X windows session (linux)

It can happen that your X session freezes and even “ctrl + backspace” or “ctrl + alt + F1” does not work! No need to reboot your system to fix it:

Note: I will use the notation “sys” for PrintScreen/SysRq (F13 on MAC)
  • alt-sys ctrl-alt-F1 (Or any other free console), then you will have to log on root and do ”/etc/init.d/gdm stop” and wait few seconds. (You will not be able to see the console as you type, but issue the commands above and this will kill the x session)
  • alt-sys-r :(raw mode) then retry ctl-alt-f1
  • alt-sys-e : Kill the process
  • alt-sys-i : Kill all process

Local network backup with Netcat & Tar

On your local network to backup data you don't need to use a secure conection (ssh, ssl…) which use cpu and bandwith.

Netcat is a very usefull network tool but in this case we just going to use it to backup data with tar.

destination host

Netcast listen on the port 6666, data received will be redirect in the file hostname.tgz untill EOF.

cd /backup
$ nc -l -p 6666 >> hostname.tgz

source host

tar / on STDOUT (-O), this output will be netcat. Wait 5 secondes (-w 5) to make sure than all data was send.

$ tar czvOp --same-owner / -X ~/dirtoexclude | nc -w 5 destination_host 6666

File transfer with Netcat

One file

Destination host

nc -l -p $RECIPIENT_PORT > $FILE

Sender host

cat $FILE | nc -q0 $RECIPIENT_ADDRESS $RECIPIENT_PORT

More than one file

Destination host

nc -l -p $RECIPIENT_PORT | gzip -c -d | tar -x

Sender host

tar -c $FILES | gzip -c | nc -q0 $RECIPIENT_ADDRESS $RECIPIENT_PORT

Encrypted Using ssh will be simpler but it's a solution!

Destination host

nc -l -p $RECIPIENT_PORT | gpg --decrypt | tar -x

Sender host

tar -c $FILES | gpg -s -e -r $RECIPIENT | nc -q0 $RECIPIENT_ADDRESS $RECIPIENT_PORT
 
faq.txt · Last modified: 2010/02/10 13:45 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki