Linux Software

Boot
isolinux
lilo
grub
 
 
Kernel
iptables
iptables -L -v -n
iptables -t nat -L -v -n
 
iptables -t nat -I PREROUTING -p tcp -s 1.2.3.4 --dport 10550  -j DNAT --to-destination 10.11.12.13:10550
iptables -I FORWARD -s 1.2.3.4 -d 10.11.12.13 -j ACCEPT
iptables -t nat -I POSTROUTING -s 1.2.3.4 -d 10.11.12.13 -j SNAT --to-source 10.11.12.1

iptables -t nat -I PREROUTING -p tcp -s 1.2.3.4 --dport 10521  -j DNAT --to-destination 10.11.12.13:21
iptables -t nat -I POSTROUTING -s 1.2.3.4 -d 10.11.12.13 -j SNAT --to-source 10.11.12.1
iptables -I FORWARD -s 1.2.3.4 -d 10.11.12.13 -j ACCEPT
 
Chroot:
rescuecd chroot problem - je treba nastavit vychozi shell :
chroot /mnt/gentoo /bin/bash
 
pro funkcnost beznych prikazu chrootu:
mount -t proc proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
 
Netstat - list all processes with port numbers and pids
netstat -anp
 
Gentoo
reset crashed/stuck service
/etc/init.d/service zap
get all crashed services
for i in /etc/init.d/*; do $i status 2>&1 > /dev/null; j=$?; if [ "$j" -eq 32 ]; then echo CRASHED $i; fi; done
 
Samba
							# vi /etc/samba/smb.conf
[public]
        browsable = yes
        path = /mnt/share
        public = yes
        writable = no
        write list = myuser
        guest ok = yes
[global]
        guest account = myuser
        map to guest = bad user

konfigurace myusera:
# adduser myuser
# smbpasswd -an myuser

connecting and disconnecting in win machine:
net use p: \\192.168.x.y\prenosy
net use p: /delete

Postfix
 ssl SSL
        yum install postfix cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5

        main.cf
        myorigin = server.address.cz
        relayhost = smtp.address.cz
        inet_interfaces = all
        home_mailbox = Maildir/

        virtual_alias_maps = hash:/etc/postfix/virtual
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/password
        smtp_sasl_security_options =


        /root/.forward
        user@address.cz

        /etc/postfix/virtual
        user@server.address.cz     userlocalhost

        /etc/postfix/password
        smtp.address.cz user@address.cz:<plaintext_passwd>


        postmap /etc/postfix/virtual
        postmap /etc/postfix/password
        chkconfig saslauthd on
        chkconfig postfix on
        /etc/init.d/postfix restart
        /etc/init.d/saslauthd start

        mail test

        echo test | mail -s test root
        echo test | mail -s test user@address.cz



Sendmail
        v sendmail.mc se ma definovat
        define(`SMART_HOST', `mailserver.sk')dnl
        FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
        (ja jsem dal - FEATURE(`authinfo')dnl pro zjednoduseni)
        a jeste musi byt toto:
        TRUST_AUTH_MECH(`PLAIN LOGIN')dnl
        define(`confAUTH_MECHANISMS', `PLAIN LOGIN')dnl


        (ve verzi smtp >8.12 nemusi byt a bere se pry
        /etc/mail/access.db ale to nejelo, )

        m4 sendmail.mc > sendmail.cf

        je treba mit nainstalovany sendmail-cf.xxx.rpm

        vyeditovat access (nebo auth/client-info)
        AuthInfo:mailserver.sk "U:smmsp" "I:user@adresa.sk" "P:password"

        potom makemap hash access.db < access
        (nebo auth/client-info, ja dal authinfo)


Vi editor
Useful commands
substitute : for - in mac address selected block
:'<,'>g/-/s//:/g
visual block indent - odsazeni tabulatorem - > nebo <
Colors of comments in putty
into .vimrc:
hi Comment ctermfg=LightBlue
 
disable auto indenting
							:setlocal noautoindent
:setlocal nocindent
:setlocal nosmartindent
:setlocal indentexpr=
 
thttpd
/etc/thttpd/thttpd.conf
default port 80, default web directory /etc/thttpd
 
 
kickstart
linux ks=floppy     (pokud kernel nezna sitovku, na floppy musi byt "ks.cfg")
            pokud zna a mame web server
            linux ks=http://10.1.1.1/ks.cfg
            pozor! - rozdeleni disku nefunguje jak by melo (casto vubec)
            pokud chceme jinou ip (misto nfs muze byt http)
            linux ks=nfs:1.2.3.4/my/ks ip=9.9.9.9 gateway=9.9.9.1
        netmask=255.255.255.0 ....
            nebo pro jinou eth
            linux ks=nfs:10.32.14.46:/KS/ks.cfg ksdevice=eth0
linux ks=hd:fd0/anaconda.ks
pokud mam konfiguraci libovolneho jmena na nejakem zarizeni, napr. i na fd0
 
 
mdadm
cat /proc/mdstat
mdadm -A /dev/md0 /dev/sda1
mdadm -S /dev/md0
mdadm --zero-superblock /dev/sda1
 
less - gentoo lessopen problem (shows hexdump output)
LESSOPEN="" or unset LESSOPEN
 
serial over net
ser2net - allows network port connection to local serial port
socat PTY,link=/dev/YPort TCP:127.0.0.1:33600 - creates local virtual serial port from remote networked serial port
minicom -D /dev/YPort - test real connection (crtl-A X leaves minicom)
 
generovani hesla
head -c 8 /dev/urandom | uuencode  -m /dev/stdin