Cerca


stampa pdf

Aministrare la macchina da SSH (Shell su bash)



Introduzione

Bash è un programma che si esegue quando si accede in SSH alla macchina. Si può scegliere un altro programma Shell come sh, asd, ecc...
root@kazik root# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash

Si possono trovare molti siti sull'argomento anche da una semplice ricerca su Google.


Alcuni suggerimenti

1. In bash per completare i nomi dei file che sono all'interno delle DIR si può usare il tasto tab. Ad esempio:
root@kazik root# ls -l a
tab
tab
a2ps-4.13-3.i386.rpm align.ps analog apaon
alaska.mp3 anaconda-ks.cfg apaoff apare
root@kazik root# ls -l a
root@kazik root# ls -l an
tab
root@kazik root# ls -l ana
tab
tab
anaconda-ks.cfg analog
root@kazik root# ls -l anal
tab
root@kazik root# ls -l analog

2. bash accetta gli alias. Se per esempio digitate spesso ls -l è possibile creare un alias e digitare direttamente:

root@kazik root# alias ll="ls -l --color


Ora, se si digita ll, sarà come scrivere ls -l --color. Si può aggiungere questo alias al file .bashrc in modo che le prossime volte che userete il comando ll, questo verrà preso in automatico:

root@kazik root# cat >> .bashrc
alias ll="ls -l --color"
ctrl+d
root@kazik root#


Monitorare il Sistema

Quando vi collegate alla macchina, potete verificare rapidamente cosa succede. Se il risultato visualizzato non è quello abituale, potrete vedere rapidamente che c'è un problema.
root@ns root# w
3:40am up 99 days, 9:08, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 ping.ovh.net 3:40am 0.00s 0.13s 0.03s w

il comando w permette di vedere immediatamente l'uptime, il carico della macchina e il numero di persone che sono connesse. Qui vediamo che sono le 3:40 della mattina. La macchina ha un uptime di 99 giorni, al momento c'è solo una persona collegata e il carico è 0.00. In breve, è tutto normale.

Il Carico è il livello di utilizzo della CPU nel tempo. Vuol dire 1 minuto, 5 minuti e 15 minuti. Si dice che il carico della CPU non deve superare 1. Ovviamente tutto dipende da ciò che si fa girare sulla macchina.
root@ns root# free
total used free shared buffers cached
Mem: 254696 249608 5088 0 95688 83616
-/+ buffers/cache: 70304 184392
Swap: 522104 3808 518296


Free mostra l'utilizzo della RAM. Vediamo che la RAM è di 256MB e ne viene utilizzato quasi il 100%. Questo è normale anche se sulla macchina non vi è nulla in esecuzione, perché Linux utilizza tutta la RAM per accelerare l'esecuzione dei processi e memorizzazioni varie. E' sempre utilizzato il 100%. Se, in qualsiasi momento, vi un processo avesse bisogno di RAM, Linux cancellerà alcune informazioni e permetterà al processo di utilizzare la RAM necessaria. Sono (nell'esempio) 70MB che sono realmente utilizzate dal processo ed i restanti 184MB sono per Linux.

La swap (la RAM sul disco) è di 512 MB. E' utilizzata quando serve più RAM rispetto a quella a disposizione sulla macchina. E' necessario sapere che la memoria swap è nettamente più lenta della RAM vera e propria. Se la macchina utilizza molto spazio swap, probabilmente c'è qualche problema, in quanto l'esecuzione dei processi sarà più lenta del normale. Il server sarà quindi rallentato, fino ad un completo arresto della macchina. Questo è un problema che accade spesso agli inesperti. La soluzione consiste nel Reboot hard della macchina, come riportato nella guida Come riavviare la vostra macchina?.


Cosa c'è in esecuzione sulla macchina?

Per sapere quali processi sono attivi sul server, potete utilizzare il comando ps auxw:
root@ns root# ps auxw
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? SW Jun26 0:00 [keventd]
root 3 0.0 0.0 0 0 ? SWN Jun26 0:35 [ksoftirqd_CPU0]
root 4 0.0 0.0 0 0 ? SW Jun26 0:33 [kswapd]
root 5 0.0 0.0 0 0 ? SW Jun26 0:00 [bdflush]
root 6 0.0 0.0 0 0 ? SW Jun26 0:28 [kupdated]
root 7 0.0 0.0 0 0 ? SW< Jun26 0:00 [mdrecoveryd]
root 8 0.0 0.0 0 0 ? SW Jun26 5:50 [kjournald]
root 113 0.0 0.0 0 0 ? SW Jun26 28:29 [kjournald]
root 354 0.0 0.0 0 0 ? SW Jun26 0:00 [eth0]
root 453 0.0 0.1 1444 480 ? S Jun26 0:03 syslogd -m 0
root 458 0.0 0.1 1372 324 ? S Jun26 0:00 klogd -2
root 640 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 644 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 645 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 650 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 651 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 652 0.0 0.1 3612 408 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/authlib/authdaemond.ldap start
root 654 0.0 0.1 1600 432 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/couriertcpd -address=0 -stderrlogger=/usr/lib/courier-imap/libexec/l
root 660 0.0 0.1 1360 392 ? S Jun26 0:00 /usr/lib/courier-imap/libexec/logger imapd
root 678 0.0 0.2 1568 544 ? S Jun26 0:03 crond
daemon 717 0.0 0.1 1416 480 ? S Jun26 0:00 /usr/sbin/atd
root 743 0.0 0.5 1424 1424 ? SL Jun26 0:13 watchdog
root 749 0.0 0.0 1348 16 ? S Jun26 0:10 /usr/local/clockspeed/bin/clockspeed
root 779 0.0 0.0 1356 4 tty1 S Jun26 0:00 /sbin/mingetty tty1
root 780 0.0 0.0 1356 4 tty2 S Jun26 0:00 /sbin/mingetty tty2
root 781 0.0 0.0 1356 4 tty3 S Jun26 0:00 /sbin/mingetty tty3
root 782 0.0 0.0 1356 4 tty4 S Jun26 0:00 /sbin/mingetty tty4
root 785 0.0 0.0 1356 4 tty5 S Jun26 0:00 /sbin/mingetty tty5
root 786 0.0 0.0 1356 4 tty6 S Jun26 0:00 /sbin/mingetty tty6
root 788 0.0 0.0 1368 4 ttyS0 S Jun26 0:00 /sbin/agetty ttyS0 9600
root 515 0.0 0.3 2148 776 ? S Jun26 0:00 xinetd -stayalive -reuse -pidfile /var/run/xinetd.pid
root 29469 0.0 0.3 2208 912 ? S< Jun27 0:08 /usr/local/etc/ncftpd/ncftpd -q /usr/local/etc/ncftpd/general.cf /usr/local/etc/ncftpd/domain.cf
root 29470 0.0 0.2 2008 704 ? SN Jun27 0:00 /usr/local/etc/ncftpd/ncftpd -q /usr/local/etc/ncftpd/general.cf /usr/local/etc/ncftpd/domain.cf
named 4681 0.0 0.9 11984 2448 ? S Jun27 0:00 named -u named
named 4683 0.0 0.9 11984 2448 ? S Jun27 0:08 named -u named
named 4684 0.0 0.9 11984 2448 ? S Jun27 6:52 named -u named
named 4685 0.0 0.9 11984 2448 ? S Jun27 0:03 named -u named
named 4686 0.0 0.9 11984 2448 ? S Jun27 1:11 named -u named
root 17592 0.0 0.6 4856 1600 ? S Aug31 0:06 /usr/bin/perl /usr/libexec/webmin/miniserv.pl /etc/webmin/miniserv.conf
root 7798 0.0 1.5 8500 3844 ? S Sep16 0:01 /usr/local/apache/bin/httpd
root 8849 0.0 0.4 2260 1036 ? S Sep16 0:00 /bin/sh /usr/bin/safe_mysqld --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/ns.witbebenchmark6
mysql 8868 0.0 0.4 10584 1040 ? S Sep16 0:00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/ns.wi
mysql 8870 0.0 0.4 10584 1040 ? S Sep16 0:00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/ns.wi
mysql 8871 0.0 0.4 10584 1040 ? S Sep16 0:00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/ns.wi
root 20539 0.0 0.5 2980 1356 ? S Sep28 0:00 /usr/sbin/sshd
nobody 28146 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28210 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28340 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28600 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28756 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28992 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 28994 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 29123 0.0 1.6 8704 4076 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 29384 0.0 1.6 8772 4084 ? S Oct03 0:00 /usr/local/apache/bin/httpd
nobody 29908 0.0 1.5 8704 4048 ? S 01:58 0:00 /usr/local/apache/bin/httpd
nobody 30037 0.0 1.6 8704 4076 ? S 02:28 0:00 /usr/local/apache/bin/httpd
root 30108 0.0 0.3 2208 948 ? S< 02:44 0:00 /usr/local/etc/ncftpd/ncftpd -q /usr/local/etc/ncftpd/general.cf /usr/local/etc/ncftpd/domain.cf
nobody 30300 0.0 1.5 8704 4048 ? S 03:28 0:00 /usr/local/apache/bin/httpd
root 30355 0.0 0.8 3792 2048 ? S 03:40 0:00 sshd: root@pts/0
root 30358 0.0 0.5 2452 1292 pts/0 S 03:40 0:00 -bash
root 30421 0.0 0.2 2652 764 pts/0 R 03:44 0:00 ps auxw


Possiamo vedere che il comando ps auxw da i risultati in piu' colonne.
La 1a colonna e' l' user o l'utilizzatore che gestisce la macchina.
La 2a colonna e' il pid del processo.
La 3a colonna e' l'utilizzo CPU del processo.
La 4a colonna e' l'utilizzo RAM del processo.
La penultima colonna e' il tempo di esecuzione accumulato, vuale a dire il tempo di utilizzo al 100% della CPU.
L'ultima colonna e' il nome del processo. Se scrivete ps auxwwww avrete i nomi delle applicazioni completi.

root 1 0.0 0.1 1376 452 ? S Jun26 0:14 init [3]

init Gestisce il funzionamento di tutta la macchina. Questo e' il primo processo che viene eseguito.
Esso consente la gestione di 6 livelli tramite /etc/inittab. I livelli che ci interessano sono:
0 - arresto o spegnimento della macchina
1 - singolo o modalità di reparazione (nessuna rete)
3 - funzionamento normale
6 - reboot della macchina

Il livello in cui la vostra macchina funziona normalmente è 3.

Si consiglia vivamente di non giocare con questi file. Se si modifica, la macchina potrebbe non avviarsi correttamente. La rete funziona solo nel livello 3.

I file di avvio di ogni livello sono in /etc/rc.d/ e quindi per il livello 3 è /etc/rc.d/rc3.d/.
Si può vedere ciò che si avvia (con suffisso S) e ciò che viene killato (chiuso) (con suffisso K).
root@ns root# cd /etc/rc.d/rc3.d/
root@ns rc3.d# ls -l
total 0
lrwxrwxrwx 1 root root 20 mai 15 14:22 K15postgresql -> ../init.d/postgresql
lrwxrwxrwx 1 root root 18 mai 15 14:23 K45arpwatch -> ../init.d/arpwatch
lrwxrwxrwx 1 root root 15 mai 15 14:22 K45named -> ../init.d/named
lrwxrwxrwx 1 root root 16 mai 15 14:22 K65identd -> ../init.d/identd
lrwxrwxrwx 1 root root 14 mai 15 12:32 K74nscd -> ../init.d/nscd
lrwxrwxrwx 1 root root 14 mai 15 14:22 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx 1 root root 17 mai 15 14:21 S10network -> ../init.d/network
lrwxrwxrwx 1 root root 14 mai 15 14:22 S11sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 16 mai 15 14:20 S12syslog -> ../init.d/syslog
lrwxrwxrwx 1 root root 22 mai 15 12:54 S13named -> /etc/rc.d/init.d/named
lrwxrwxrwx 1 root root 18 mai 15 14:20 S17keytable -> ../init.d/keytable
lrwxrwxrwx 1 root root 16 mai 15 14:21 S20random -> ../init.d/random
lrwxrwxrwx 1 root root 16 mai 15 14:22 S56xinetd -> ../init.d/xinetd
lrwxrwxrwx 1 root root 22 mai 15 12:45 S80qmail -> /etc/rc.d/init.d/qmail
lrwxrwxrwx 1 root root 22 mai 15 12:43 S85httpd -> /etc/rc.d/init.d/httpd
lrwxrwxrwx 1 root root 22 mai 15 12:54 S85imapd -> /etc/rc.d/init.d/imapd
lrwxrwxrwx 1 root root 15 mai 15 14:22 S90crond -> ../init.d/crond
lrwxrwxrwx 1 root root 15 mai 15 12:33 S90mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 13 mai 15 14:20 S95atd -> ../init.d/atd
lrwxrwxrwx 1 root root 25 mai 15 12:33 S95watchdog -> /etc/rc.d/init.d/watchdog
lrwxrwxrwx 1 root root 11 mai 15 14:21 S99local -> ../rc.local
lrwxrwxrwx 1 root root 18 aoû 31 19:26 S99webmin -> /etc/init.d/webmin

Trovato in ordine così: avvio di rete (network), sshd, syslog, named, xinetd, qmail, httpd, imapd, mysql e webmin.
Gli altri ovviamente sono admistrativi (crond, atd, local, etc)
root 4 0.0 0.0 0 0 ? SW Jun26 0:33 [kswapd]

il processo che gestisce la swap.
root 8 0.0 0.0 0 0 ? SW Jun26 5:51 [kjournald]
root 113 0.0 0.0 0 0 ? SW Jun26 28:29 [kjournald]

Questi sono processi che gestiscono le partizioni del vostro disco.
root@ns root# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda1 2016016 794996 1118608 42% /
/dev/hda2 37033060 848540 34303312 3% /home
none 127348 0 127348 0% /dev/shm

Possiamo vedere che la partizione / e /home si trovano su un disco ide (hd) montato come primario (hda). /dev/shm è la RAM che può essere utilizzata sul disco (l'inverso di swap).
root@ns root# mount
/dev/hda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda2 on /home type ext3 (rw,usrquota)
none on /dev/shm type tmpfs (rw)

La partizione /dev/hda1 è montata in ext3 ed è in modalità rw (read and write). ext3 è la versione aggiornata di ext2, un sistema di partizionamento molto utilizzato su Linux. La registrazione consiste nel creare un file di registrazione nel sistema, con le informazioni sulle operazioni da effettuare. In caso di riavvio il sistema non deve verificare tutto il disco alla recerca di errori. E' sufficiente avviare il file di registrazione.

Esempi di [df] su un disco SCSi

a. in raid-5 soft scsi con una scheda Adaptec:
root@ftp root# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda1 2016016 890216 1023388 47% /
/dev/hda2 12484192 381124 11468904 4% /home
none 257804 0 257804 0% /dev/shm
/dev/md0 141113720 46991780 86953764 36% /ftp
[root@ftp root]# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid5]
read_ahead 1024 sectors
md0 : active raid5 sde1[4] sdd1[3] sdc1[1] sdb1[0] sda1[2]
143363584 blocks level 5, 64k chunk, algorithm 0 [5/5] [UUUUU]
unused devices:


b. in raid-1 hard scsi con una scheda mylex:
root@sql root# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/rd/c0d0p1 2015808 1395020 518392 73% /
/dev/rd/c0d0p2 15364496 814668 13769336 6% /home
root@sql root# cat /proc/rd/c0/current_status
DAC960 RAID Driver Version 2.4.11 of 11 October 2001
Copyright 1998-2001 by Leonard N. Zubkoff
Configuring Mylex DAC960PRL PCI RAID Controller
Firmware Version: 4.08-0-37, Channels: 1, Memory Size: 4MB
PCI Bus: 1, Device: 10, Function: 1, I/O Address: Unassigned
PCI Address: 0xF6AFE000 mapped at 0xE0800000, IRQ Channel: 6
Controller Queue Depth: 124, Maximum Blocks per Command: 128
Driver Queue Depth: 123, Scatter/Gather Limit: 33 of 33 Segments
Stripe Size: 64KB, Segment Size: 8KB, BIOS Geometry: 128/32
Physical Devices:
0:0 Vendor: IBM Model: DNES-318350W Revision: SA30
Serial Number: AKFJ0356
Disk Status: Online, 35840000 blocks
0:4 Vendor: IBM Model: DNES-318350W Revision: SA30
Serial Number: AKFJ5804
Disk Status: Online, 35840000 blocks
Logical Drives:
/dev/rd/c0d0: RAID-1, Online, 35831808 blocks, Write Thru
No Rebuild or Consistency Check in Progress


c. in nfs (network file system):
root@xxx /root# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda1 2016016 1001556 912048 52% /
/dev/hda5 17496684 11502724 5105168 69% /var/log
xx.xx.xx.xx:/parti
184320000 175846984 8473016 95% /home

root 453 0.0 0.1 1444 480 ? S Jun26 0:03 syslogd -m 0
root 458 0.0 0.1 1372 324 ? S Jun26 0:00 klogd -2


E' il processo syslog che si occupa di registrare tutti i messaggi che il sistema invia. Conserva i log in /var/log.
root@ns log# tail -f /var/log/messages
Oct 2 04:02:00 ns syslogd 1.4.1: restart.
Oct 2 04:02:00 ns syslogd 1.4.1: restart.
Oct 3 04:02:00 ns syslogd 1.4.1: restart.
Oct 3 04:02:00 ns syslogd 1.4.1: restart.
Oct 3 09:30:23 ns telnetd[25601]: ttloop: peer died: EOF
Oct 3 09:30:23 ns telnetd[25602]: ttloop: peer died: EOF
Oct 4 03:40:20 ns sshd[30355]: Accepted keyboard-interactive/pam for root from 213.186.33.13 port 44298 ssh2
Oct 4 03:40:20 ns sshd(pam_unix)[30358]: session opened for user root by root(uid=0)
Oct 4 04:02:00 ns syslogd 1.4.1: restart.
Oct 4 04:02:00 ns syslogd 1.4.1: restart.

In /var/log/messages potrete trovare i messaggi che inviano i principali processi quali telnet, sshd, named etc. Usando tail-f, potete leggere un file e vedere le nuove registrazioni.


Chi fa cosa?

E' quindi possibile visualizzare tutti i processi che gestiscono i server: Apache, qmail, sshd, che possono essere recuperati col comando netstat -tanpu.
root@ns root# netstat -tanpu
Connexions Internet actives (serveurs et établies)
Proto Recv-Q Send-Q Adresse locale Adresse distante Etat PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 8868/mysqld
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 654/couriertcpd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7798/httpd
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN 17592/perl
tcp 0 0 213.186.36.76:53 0.0.0.0:* LISTEN 4681/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 4681/named
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 29469/ncftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 20539/sshd
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 515/xinetd
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 4681/named
tcp 0 0 213.186.36.76:33206 65.57.234.3:6667 ESTABLISHED -
tcp 0 0 213.186.36.76:22 213.186.33.13:44298 ESTABLISHED 30355/0
tcp 0 0 213.186.36.76:80 81.88.96.9:39804 TIME_WAIT -
udp 0 0 0.0.0.0:10000 0.0.0.0:* 17592/perl
udp 0 0 0.0.0.0:32804 0.0.0.0:* 4681/named
udp 0 0 213.186.36.76:53 0.0.0.0:* 4681/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 4681/named
udp 0 0 0.0.0.0:56125 0.0.0.0:* -

Vediamo, ad esempio, che vi è un processo in ascolto sulla porta 0.0.0.0:80 chiamato httpd avente pid 7798.
Verifichiamo:
root@ns root# ps auxw | grep 7798
root 7798 0.0 1.5 8500 3844 ? S Sep16 0:01 /usr/local/apache/bin/httpd

La porta 80 è quella per l'accesso alla rete. Controlliamo se funziona:
root@ns root# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 04 Oct 2003 02:29:15 GMT
Server: Apache/1.3.28 (Unix) mod_gzip/1.3.19.1a PHP/4.3.3 mod_ssl/2.8.15 OpenSSL/0.9.6i
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Thu, 15 May 2003 10:34:33 GMT
ETag: "18446-a71-3ec36d39;3ec37100"
Accept-Ranges: bytes
Content-Length: 2673
Connection: close
Content-Type: text/html
Content-Language: en
Expires: Sat, 04 Oct 2003 02:29:15 GMT

Connection closed by foreign host.

Ora chiudiamo l'accesso alla rete:
root@ns root# kill 7798
root@ns root# ps auxw | grep 7798
root@ns root# ps auxw | grep httpd

quindi controlliamo che sia effettivamente chiusa:
root@ns root# telnet localhost 80
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

Dopo aver verificato che è realmente stata chiusa, possiamo riavviarla:
root@ns root# /etc/rc.d/init.d/httpd start
Démarrage de httpd: [OK]


Verifichiamo alcune informazioni:
root@ns root# ps auxw | grep httpd | grep root
root 30899 0.4 1.4 8472 3820 ? S 04:31 0:00 /usr/local/apache/bin/httpd
rroot@ns root]# netstat -tanpu | grep ":80"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 30899/httpd
[root@ns root]# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 04 Oct 2003 02:32:18 GMT
Server: Apache/1.3.28 (Unix) mod_gzip/1.3.19.1a PHP/4.3.3 mod_ssl/2.8.15 OpenSSL/0.9.6i
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Thu, 15 May 2003 10:34:33 GMT
ETag: "18446-a71-3ec36d39;3ec37100"
Accept-Ranges: bytes
Content-Length: 2673
Connection: close
Content-Type: text/html
Content-Language: en
Expires: Sat, 04 Oct 2003 02:32:18 GMT

Connection closed by foreign host.

E' nuovamente operativa.


Amministrazione in tempo reale

Se si desidera utilizzare ps auxw permanentemente, potete utilizzare top:
root@ns root# top
4:34am up 99 days, 10:03, 1 user, load average: 0,03, 0,07, 0,02
65 processes: 64 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 0,1% user, 0,5% system, 0,0% nice, 99,2% idle
Mem: 254696K av, 245660K used, 9036K free, 0K shrd, 95316K buff
Swap: 522104K av, 3808K used, 518296K free 79948K cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
30937 root 17 0 1048 1048 824 R 0,5 0,4 0:00 top
30355 root 12 0 2064 2064 1692 S 0,1 0,8 0:00 sshd
1 root 8 0 484 452 424 S 0,0 0,1 0:14 init
2 root 9 0 0 0 0 SW 0,0 0,0 0:00 keventd
3 root 19 19 0 0 0 SWN 0,0 0,0 0:35 ksoftirqd_CPU0


Potete usare shift-m per ordinare secondo il consumo di RAM. Se la vostra macchina si blocca, potete lanciare top e attendere che si blocchi nuovamente.
Vedrete sullo schermo l'ultimo top e quindi saprete quale processo fa bloccare il server.