Next Previous Contents

2. Suntomes Ypodeijeis

2.1 Proxeiro Syslog Tryk Paul Anderson, Synthrhths toy Tips-HOWTO

Anoijte to arxeio /etc/syslog.conf, kai pros8este thn parakatw grammh:

# Dump everything on tty8
*.*                                     /dev/tty8
PROEIDOPOIHSH: MHN 3EXASETE NA XRHSIMOPOIHSETE TABS! sto syslog den aresoyn ta kena...

2.2 Script gia na blepete ta sympiesmena HOWTOs. Didier Juges, dj@destin.nfds.net

Ap' ton ena arxario ston allo, proekyce ayto to mikro script poy dieykolunei to cajimo kai to diabasma keimenwn howto. Ta howto arxeia moy briskontai sto /usr/doc/faq/howto/ kai einai sympiesmena. Ta onomata twn arxeiwn einai XXX-HOWTO.gz, opoy XXX einai to 8ema toy howto. Dhmiourghsa to script me onoma "howto" ston katalogo the /usr/local/sbin :


#!/bin/sh
if [ "$1" = "" ]; then
    ls /usr/doc/faq/howto | less
else
    gunzip -c /usr/doc/faq/howto/$1-HOWTO.gz | less
fi

Otan kaleitai xwris parametroys, emfanizei o katalogos twn dia8esimwn arxeiwn howto. Otan kaleitai me parametro to prwto tmhma toy onomatos toy arxeioy (prin thn paula), to aposympiezei (kratwntas to arxiko arxeio anepafo) kai meta emfanizei to keimeno.

Gia paradeigma, gia na deite to keimeno Serial-HOWTO.gz , gracte:

$ howto Serial

2.3 Yparxei arketos eleu8eros xwros;;; Hans Zoebelein, zocki@goldfish.cube.net

Akoloy8ei ena mikro script to opoio elegxei periodika an yparxei arketos eleu8eros xwros dia8esimos se otidhpote emfanizetai sto mount (diskoi, cdrom, disketa...)

An o xwros ejantleitai, typwnetai ena mhnyma ka8e X deyterolepta sthn o8onh kai stelnetai 1 mhnyma me mail gia ka8e gemath syskeyh.


#!/bin/sh

#
# $Id: check_hdspace,v 1.18 1996/12/11 22:33:29 root Exp root $
#

#
# Since I got mysterious error messages during compile when
# tmp files filled up my disks, I wrote this to get a warning
# before disks are full.
#
# If this stuff saved your servers from exploding,
# send praising email to zocki@goldfish.cube.net.
# If your site burns down because of this, sorry but I
# warned you: no comps.
# If you really know how to handle sed, please forgive me :)
#

#
# Shoot and forget: Put 'check_hdspace &' in rc.local.
# Checks for free space on devices every $SLEEPTIME sec.
# You even might check your floppies or tape drives. :)
# If free space is below $MINFREE (kb), it will echo a warning
# and send one mail for each triggering device to $MAIL_TO_ME.
# If there is more free space than trigger limit again,
# mail action is also armed again.
#

# TODO: Different $MINFREE for each device.
# Free /*tmp dirs securely from old junk stuff if no more free space.


DEVICES='/dev/sda2 /dev/sda8 /dev/sda9'         # device; your put disks here
MINFREE=20480                                   # kb; below this do warning
SLEEPTIME=10                                    # sec; sleep between checks
MAIL_TO_ME='root@localhost'                     # fool; to whom mail warning


# ------- no changes needed below this line (hopefully :) -------

MINMB=0
ISFREE=0
MAILED=""
let MINMB=$MINFREE/1024         # yep, we are strict :)

while [ 1 ]; do
        DF="`/bin/df`"
                for DEVICE in $DEVICES ; do
                ISFREE=`echo $DF | sed s#.\*$DEVICE" "\*[0-9]\*""\*[0-9]\*" "\*## | sed s#" ".\*##`
                
                if [ $ISFREE -le $MINFREE ] ; then
                        let ISMB=$ISFREE/1024
                        echo  "WARNING: $DEVICE only $ISMB mb free." >&2
                        #echo "more stuff here" >&2
                        echo -e "\a\a\a\a"
                        
                        if [ -z  "`echo $MAILED | grep -w $DEVICE`" ] ; then
                                echo "WARNING: $DEVICE only $ISMB mb free.      (Trigger is set to $MINMB mb)" \
                                | mail -s "WARNING: $DEVICE only $ISMB mb free!" $MAIL_TO_ME
                                MAILEDH="$MAILED $DEVICE"
                                MAILED=$MAILEDH
                                # put further action here like cleaning
                                # up */tmp dirs...
                        fi
                        elif [ -n  "`echo $MAILED | grep -w $DEVICE`" ] ; then
                                # Remove mailed marker if enough disk space
                                # again. So we are ready for new mailing action.
                                MAILEDH="`echo $MAILED  | sed s#$DEVICE##`"
                                MAILED=$MAILEDH
                        fi
                        
                done
                sleep $SLEEPTIME

done

2.4 Boh8htikh efarmogh gia na ka8arizete ta log arxeia sas. Paul Anderson, Synthrhths toy Tips-HOWTO >

An eiste san ki emena, exete mia lista me 250 eggegrammenoys, kai 100+ mhnumata na erxontai ka8hmerina mesw UUCP. Loipon, ti mporei na kanei enas xaker me ayta ta terastia logs; Na sthsei to chklogs. To Chklogs grafthke apo ton Emilio Grimaldo, grimaldo@panama.iaehv.nl, kai h trexoysa ekdosh 1.8 einai dia8esimh sto ftp.iaehv.nl:/pub/users/grimaldo/chklogs-1.8.tar.gz. H diadikasia egkatastashs einai aplh (8a diabasete, fysika, tis plhrofories ston ypokatalogo sub). Otan to egkatasthsete, pros8este mia eggrafh crontab san thn parakatw:

# Run chklogs at 9:00PM daily.
00 21 * * *       /usr/local/sbin/chklogs -m
Mia kai to xrhsimopoihsate, mhn jexasete na anaferete ston syggrafea poso wraio programmataki einai ayto :)

2.5 Proxeiro Script gia na ka8arizete ta Core arxeia. Otto Hammersmith, ohammers@cu-online.com

Dhmioyrghste ena arxeio me onoma rmcores (o syggrafeas to apokalei handle-cores) poy na periexei ton parakatw kwdika:


#!/bin/sh
USAGE="$0 <directory> <message-file>"

if [ $# != 2 ] ; then
        echo $USAGE
        exit
fi

 echo Deleting...
find $1 -name core -atime 7 -print -exec rm {} \;

echo e-mailing
for name in `find $1 -name core -exec ls -l {} \; | cut -c16-24`
do
        echo $name
        cat $2 | mail $name
done

Dhmioyrghste mia ergasia cron na to trexei periodika.

2.6 Metaferontas katalogoys metaju susthma arxeiwns. Alan Cox, A.Cox@swansea.ac.uk

Grhgoros tropos na metaferete ena oloklhro dendro arxeiwn apo ena disko se enan allo

(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp -)
[ AAllajte apo to /source/directory. Kante tar....klp. wste na apofugete thn pi8anothta na axrhsteusete to directory se periptwsh katastrofhs. Eyxaristw ton Jim Dennis, jadestar@rahul.net, poy moy to eipe. -Synt. ]

2.7 Breite toys megaluteroys katalogoys poy exete. Mick Ghazey, mghazey@miso.lowdown.com

Exete anarwth8ei pote poioi einai oi megaluteroi katalogoi ston ypologisth sas; Oriste pws 8a to ma8ete.

du -S | sort -n

2.8 To Linux Gazette

Doja kai times ston John Fisk, to dhmioyrgo toy Linux Gazette. Einai ena ejairetiko hlektroniko periodiko kai epipleon, einai DWREAN!!! Ti perissotero mporeite na zhthsete; Deite monoi sas:

http://www.ssc.com/lg
Epi thn eykairia, fainetai oti (1) to LG bgainei se mhniaia ekdosh, kai (2) den to synthrei pia o John Fisk , alla oi synergates ths SSC.

2.9 Deikths sto patch gia to GNU Make 3.70 gia na allajete th symperifora toy VPATH. Ted Stern, stern@amath.washington.edu

Den jerw an exoyn polloi an8rwpoi ayto to problhma, alla yparxei ena "xarakthristiko" toy GNU make ekdosh 3.70 to opoio de moy aresei. Einai oti to VPATH symperiferetai perierga an dwsete to apolyto onoma arxeioy. Yparxei ena ejairetika plhres patch poy dior8wnei to problhma, to opoio mporeite na breite apo ton Paul D. Smith <psmith@wellfleet.com>. Aytos stelnei thn tekmhriwsh kai to patch meta apo ka8e epanekdosh toy GNU make sto newsgroup gnu.utils.bug. Genika, efarmozw ayto to patch kai kanw jana compile to gmake se ka8e susthma poy exw prosbash.

2.10 Pws stamatw to susthma moy na kanei fsck se ka8e epanekkinhsh; Dale Lutz, dal@wimsey.com

Q: Pws stamatw to e2fsck na elegxei to disko moy ka8e fora poy kanw boot.

A: Otan janaxtisete ton pyrhna, to susthma arxeiwn markaretai san 'brwmiko' kai etsi o diskos sas 8a elegxetai se ka8e ekkinhsh. Gia na to ftiajete ayto trejte to:

rdev -R /zImage 1

Ayto dior8wnei ton pyrhna apo to na pisteuei oti to susthma arxeiwn einai brwmiko.

Shmeiwsh: An xrhsimopoieite lilo, tote pros8este to read-only sthn egkatastash toy sto arxeio ru8mishs toy lilo (synh8ws sto /etc/lilo.conf)

2.11 Pws na apofugete ta fscks poy prokalountai apo "device busy" thn wra ths epanekkinhshs. Jon Tombs, jon@gtex02.us.es

An blepete syxna la8h device busy kata to shutdown poy kanoyn to susthma arxeiwn na xreiazetai fsck kata thn epanekkinhsh, oriste mia mikrh dior8wsh :

Pros8este thn parakatw grammh sto /etc/rc.d/init.d/halt h /etc/rc.d/rc.0

mount -o remount,ro /mount.dir
gia ola ta prosarthmena (mounted) systhmata arxeiwn ektos toy /, prin thn klhsh umount -a. Ayto shmainei oti an, gia kapoio logo, to shutdown apotuxei na skotwsei oles tis diergasies kai apoprosarthsei toys diskoys 8a einai akomh ka8aroi sthn epanekkinhsh. Etsi ejoikonomw polu xrono sthn epanekkinhsh.

2.12 Pws na breite ta megalutera arxeia sto disko sas.

Simon Amor, simon@foobar.co.uk

ls -l | sort +4n

H, gi' aytous poy einai pragmatika scrunched gia xwro, mporei na argei ligo alla doyleuei mia xara:

cd /
ls -lR | sort +4n

2.13 Pws na typwsete selides kai na afhsete peri8wrio gia to diakoreyth. Mike Dickey, mdickey@thorplus.lib.purdue.edu


        #!/bin/sh
        # /usr/local/bin/print
        # a simple formatted printout, to enable someone to
        # 3-hole punch the output and put it in a binder

        cat $1 | pr -t -o 5 -w 85 | lpr

2.14 Enas tropos gia na caxnete mesa se dendra arxeiwn gia mia sygkekrimenh kanonikh ekfrash. Raul Deluth Miller, rockwell@nova.umd.edu

Onomazw ayto to script 'forall'. Xrhsimopoihste to ws ejhs :

forall /usr/include grep -i ioctl
forall /usr/man grep ioctl
Na to script forall:

#!/bin/sh
if [ 1 = `expr 2 \> $#` ]
then
        echo Usage: $0 dir cmd [optargs]
        exit 1
fi
dir=$1
shift
find $dir -type f -print | xargs "$@"

2.15 Ena script gia na ka8arizei ta arxeia autosave kai backup poy dhmioyrgoun diafora programmata. Barry Tolnas, tolnas@nestor.engr.utk.edu

Ena aplo programma duo-grammwn poy katebainei anadromika thn ierarxia enos katalogoy afairwntas ta arxeia emacs auto-save (#) kai backup (~), ta arxeia .o , kai ta TeX .log. Epishs sympiezei ta arxeia .tex kai ta README. To exw onomasei 'squeeze' sto susthma moy.


#!/bin/sh
#SQUEEZE removes unnecessary files and compresses .tex and README files
#By Barry tolnas, tolnas@sun1.engr.utk.edu
#
echo squeezing $PWD
find  $PWD \( -name \*~ -or -name \*.o -or -name \*.log -or -name \*\#\) -exec
rm -f {} \;
find $PWD \( -name \*.tex -or -name \*README\* -or -name \*readme\* \) -exec gzip -9 {} \;

2.16 Pws na breite poia diergasia apaitei thn perissoterh mnhmh. Simon Amor, simon@foobar.co.uk

ps -aux | sort +4n
-H-
ps -aux | sort +5n

2.17 Ejopliste to vi gia programmatismo se C , Paul Anderson,Tips-HOWTO Synthrhths

Exw programmatisei polu se C ston eleu8ero moy xrono, kai edwsa xrono gia na ejoplisw to vi wste na einai filiko me th C. Oriste to arxeio moy .exrc:


set autoindent
set shiftwidth=4
set backspace=2
set ruler

Ti kanei ayto; To autoindent anagkazei to vi na kanei indent aytomata ka8e grammh poy akoloy8ei thn prwth poy egine indent, to shiftwidth 8etei thn apostash toy ^T (tab) se 4 kena, to backspace 8etei to backspace mode, kai to ruler deixnei ton ari8mo grammhs. Na 8ymaste, oti gia na pate se ena sygkekrimeno ari8mo grammhs, as poume thn 20, xrhsimopoihste to:


vi +20 myfile.c

2.18 Giati to sendmail kollaei epi 5 lepta kata thn ekkinhsh sto RedHat; Paul Anderson, paul@geeky1.ebtech.net

Ayto einai ena sxedon koino problhma, se shmeio na ginei FAQ. Den jerw an to RedHat dior8wse ayto to bug sth dianomh toys, alla mporeite na to dior8wsete kai monoi sas. An koitajete sto arxeio /etc/hosts , 8a deite oti moiazei kapws san :

127.0.0.1               localhost       yourbox

Otan jekina to sendmail, caxnei sto hostname poy exete (se ayth thn periptwsh, to yourbox). Ekei briskei oti to IP toy yourbox einai 127.0.0.1, ayto den aresei sto sendmail, kai caxnei pali. Synexizei me ayto gia ligo mexris otoy na egkataleicei kai na stamathsei. To na dior8wsete ayto to problhma einai polu aplo, anoijte to arxeio /etc/hosts kai allajte to se kati san to:

127.0.0.1               localhost
10.56.142.1             yourbox

2.19 Pws ry8mizw to RedHat gia na xrhsimopoiei thn color-ls; Paul Anderson, paul@geeky1.ebtech.net

H dianomh RedHat erxetai me color-ls, parolayta den jerw giati den th ry8mizoyn gia xrhsh me xrwmata. Na pws 8a to dior8wsete.

Prwta, gracte eval `DIRCOLORS`

Meta, alias ls='ls --color=yes'

Kai pros8este to 'alias.....' sto arxeio /etc/bashrc

2.20 Pws briskw poia biblio8hkh sto /usr/lib exei mia sygkekrimenh synarthsh; Pawel Veselow, vps@unicorn.niimm.spb.su

Ti kanete an kanete compile kai de kanate link mia biblio8hkh poy xreiazetai; Ola ta gcc reports einai onomata synarthsewn... Na mia entolh deigma poy 8a brei ayto poy caxnete:

for i in *; do echo $i:;nm $i|grep tgetnum 2>/dev/null;done

opoy tgetnum einai to onoma ths synarthshs poy caxnete.


Next Previous Contents