Dimensione: 25429
Commento: reimpostate le sezioni, aggiunte note, tradotto qualcosa qua e la, typo
|
Dimensione: 25473
Commento: style dei comandi
|
Le cancellazioni sono segnalate in questo modo. | Le aggiunte sono segnalate in questo modo. |
Linea 124: | Linea 124: |
{{{grep "82.211.81.166" /var/log/apache2/access.log | less}}} | {{{grep "82.211.81.166" /var/log/apache2/access.log | less }}} |
Linea 128: | Linea 129: |
{{{grep "Mac OS X" /var/log/apache2/access.log | less}}} | {{{grep "Mac OS X" /var/log/apache2/access.log | less }}} |
Linea 132: | Linea 134: |
{{{grep "shutting down" /var/log/apache2/error.log | less}}} | {{{grep "shutting down" /var/log/apache2/error.log | less }}} |
Linea 136: | Linea 139: |
{{{grep error /var/log/apache2/error.log | less}}} | {{{grep error /var/log/apache2/error.log | less }}} |
Linea 142: | Linea 146: |
{{{less /var/log/cups/error_log}}} | {{{less /var/log/cups/error_log }}} |
Linea 146: | Linea 151: |
{{{grep reload /var/log/cups/error_log | less}}} | {{{grep reload /var/log/cups/error_log | less }}} |
Linea 152: | Linea 158: |
{{{less /var/log/rkhunter.log}}} | {{{less /var/log/rkhunter.log }}} |
Linea 156: | Linea 163: |
{{{grep WARNING /var/log/rkhunter.log | less}}} | {{{grep WARNING /var/log/rkhunter.log | less }}} |
Linea 167: | Linea 175: |
{{{less /var/log/samba/log.nmbd}}} | {{{less /var/log/samba/log.nmbd }}} |
Linea 171: | Linea 180: |
{{{grep "master browser" /var/log/samba/log.nmbd | less}}} | {{{grep "master browser" /var/log/samba/log.nmbd | less }}} |
Linea 175: | Linea 185: |
{{{less /var/log/samba/log.smbd}}} | {{{less /var/log/samba/log.smbd }}} |
Linea 179: | Linea 190: |
{{{grep started /var/log/samba/log.smbd | less}}} | {{{grep started /var/log/samba/log.smbd | less }}} |
Linea 183: | Linea 195: |
{{{less /var/log/samba/log.192.168.99.99}}} | {{{less /var/log/samba/log.192.168.99.99 }}} |
Linea 189: | Linea 202: |
{{{less /var/log/Xorg.0.log}}} | {{{less /var/log/Xorg.0.log }}} |
Linea 193: | Linea 207: |
{{{grep freetype /var/log/Xorg.0.log | less}}} | {{{grep freetype /var/log/Xorg.0.log | less }}} |
Linea 203: | Linea 218: |
{{{faillog}}} | {{{faillog }}} |
Linea 209: | Linea 225: |
{{{lastlog | less}}} | {{{lastlog | less }}} |
Linea 215: | Linea 232: |
{{{who}}} | {{{who }}} |
Linea 233: | Linea 251: |
{{{logger This Pizza from Vinnys Gourmet Rocks}}} | {{{logger This Pizza from Vinnys Gourmet Rocks }}} |
Linea 281: | Linea 300: |
'''NOTE:''' You may also rotate system log files via the {{{cron.daily}}} script {{{/etc/cron.daily/sysklogd}}} instead of using logrotate. Actually, the utility {{{savelog}}} may produce unexpected results on log rotation which configuring {{{logrotate}}} seems to have no effect on. In those cases, you should check the cron.daily {{{sysklogd}}} script in {{{/etc/cron.daily/sysklogd}}} and read the {{{savelog}}} manual page to see if {{{savelog}}} is not in fact doing the rotation in a way that is not what you are specifying with {{{logrotate}}}. | '''NOTE:''' You may also rotate system log files via the {{{cron.daily}}} script {{{/etc/cron.daily/sysklogd}}} instead of using logrotate. Actually, the utility {{{savelog}}} may produce unexpected results on log rotation which configuring {{{logrotate}}} seems to have no effect on. In those cases, you should check the cron.daily '''sysklogd''' script in {{{/etc/cron.daily/sysklogd}}} and read the '''savelog''' manual page to see if '''savelog''' is not in fact doing the rotation in a way that is not what you are specifying with '''logrotate'''. |
Linea 291: | Linea 310: |
{{{head /var/log/auth.log}}} | {{{head /var/log/auth.log }}} |
Linea 295: | Linea 315: |
{{{head -n 25 /var/log/auth.log}}} | {{{head -n 25 /var/log/auth.log }}} |
Linea 301: | Linea 322: |
{{{tail /var/log/kern.log}}} | {{{tail /var/log/kern.log }}} |
Linea 305: | Linea 327: |
{{{tail -n 30 /var/log/kern.log}}} | {{{tail -n 30 /var/log/kern.log }}} |
Linea 311: | Linea 334: |
Another neat use for the {{{tail}}} command is to use it for watching a log in 'real-time' by specifying the {{{-f}}} switch. For example, if you wished to watch in real-time as clients access your Apache2 server, issuing a command such as this from a terminal prompt would allow you to do so: {{{tail -f /var/log/apache2/access.log}}} You will see the log spit out, then stop, and as the Apache2 server is accessed, log entries will fly by in real-time! If you have a very busy server, they will fly by too fast for you to read them! You can use the {{{-f}}} switch to view any log file in this manner. |
Another neat use for the {{{tail}}} command is to use it for watching a log in 'real-time' by specifying the «-f» switch. For example, if you wished to watch in real-time as clients access your Apache2 server, issuing a command such as this from a terminal prompt would allow you to do so: {{{tail -f /var/log/apache2/access.log }}} You will see the log spit out, then stop, and as the Apache2 server is accessed, log entries will fly by in real-time! If you have a very busy server, they will fly by too fast for you to read them! You can use the «-f» switch to view any log file in this manner. |
Introduzione
Uno degli aspetti fondamentali dei sistemi GNU/Linux è la registrazione di tutto ciò che accade nel sistema (logging).
Queste informazioni hanno un valore inestimabile per utilizzare il sistema in modo cosciente, e dovrebbero essere fra le prime risorse utilizzate per la risoluzione dei problemi e la ricerca delle soluzioni. I file di log memorizzano tutte le informazioni riguardanti lo stato di salute del sistema e delle applicazioni.
Ubuntu fornisce informazioni essenziali su eventi, operazioni ed altre funzionalità attraverso la registrazione di diversi file di log.
Tali file non sono altro che semplici file di testo in formato ASCII standard: generalmente vengono memorizzati nella sottodirectory di sistema /var/log.
La maggior parte file di log viene generata dal demone di sistema syslogd, altri vengono invece creati e gestiti direttamente dalle applicazioni che ne salvano una propria copia direttamente in /var/log.
La presente guida descrive i principali log di sistema ed il loro contenuto con degli esempi. Inoltre, verranno descritti alcuni esempi sul modo di estrarre le informazioni utili da tali registri, facendo uso dei soli strumenti disponibili da [:RigaDiComando:riga di comando], come grep e less.
Viene illustrato, inoltre, il funzionamento e la configurazione del demone di registrazione del sistema syslogd.
System Log
Questa sezione della guida si occupa dei cosiddetti log di sistema, ovvero dei file di log che hanno a che fare con il funzionamento del sistema Ubuntu e non necessariamente con le altre applicazioni aggiunte dall'Amministratore del Sistema o dagli altri Utenti.
Esempi di questo tipo di logs sono quelli relativi ai meccanismi di autorizzazione, ai demoni di sistema, ai messaggi di sistema ed ai log di sistema veri e propri, detti anche syslog (da non confondere con il demone syslogd di cui ci occuperemo in seguito).
Log di Autorizzazione
Il log di Autorizzazione rintraccia l'uso dei sistemi di autorizzazione, cioè tutti i quei meccanismi di Ubuntu che permettono autorizzare gli utenti che richiamano le password dell'utente, come ad esempio il sistema del Modulo di Autenticazione Pluggable (PAM), il comando sudo, l'accesso remoto da sshd, e così via. Il log file di Autorizzazione può essere raggiunto qua /var/log/auth.log. Questo log è utile, per esempio, a conoscere i login dell'utente, ed usare il comando sudo sul tuo sistema Ubuntu.
È possibile esaminare il log, dal punto di rotazione più recente, (se è applicabile) una pagina per lo schermo, usando il seguente comando:
less /var/log/auth.log
Premere la BARRA SPAZIATRICE per passare alla pagina seguente, o INVIO per passare una linea alla volta. il tasto b permette di tornare indietro di una pagina intera, e il tasto q chiude il programma.
Le informazioni specifiche possono essere raggiunte attraverso il log Autorizazzione usando comandi del tipo grep. Per esempio, per vedere soltanto le informazioni del log Autorizzazione pertinenti al login sshd, usare il seguente comando in un terminale:
grep sshd /var/log/auth.log | less
Log di Debug
Il log di Debug è presente in /var/log/debug e fornisce dettagli, messaggi di debug dal sistema Ubuntu, ed applicazioni che loggano syslogd a livello di DEBUG. Questi messaggi sono utili per controllare le edizioni con ogni cosa dai driver dell'hardware, al server daemons.
È possibile esaminare il log, dal punto di rotazione più recente, (se è applicabile) una pagina per lo schermo, usando il seguente comando:
{{{less /var/log/debug }}}
Le informazioni specifiche possono essere raggiunte attraverso il Log Debug usando comandi come: grep, e less. Per esempio, per vedere soltanto le informzaioni del Log Debug pertinenti alla Configurazione Avanzata e alla Power Interface (ACPI), usare il seguente comando in un terminale:
{{{grep ACPI /var/log/debug | less }}}
Kernel Log
Il log del kernel: /var/log/kern.log fornisce in dettagliato messaggi provenienti dal kernel di Ubuntu Linux. Questi messaggi possono risultare utili,per esempio, for trouble-shooting a new, o modifiche del kernel.
È possibile esaminare il log, dal punto di rotazione più recente, (se è applicabile) una pagina per lo schermo, usando il seguente comando:
{{{less /var/log/kern.log }}}
Le informazioni specifiche possono essere raggiunte attraverso il log del Kernel usando comandi come: grep, e less. Per esempio, per vedere solo le informazione nel log del Kernel Log pertinenti alla CPU (computer's Central Processing Unit), usare il seguente comando in un terminale:
{{{grep CPU /var/log/kern.log | less }}}
Kernel Ring Buffer
Il kernel ring buffer in se non è un reale file di log, ma piuttosto una zona nel kenrel corrente che può essere quirelato per i messaggi del bootup del kernel attraverso il programma dmesg. È possibile vedere tutti i messaggi bootup del kernel usando il seguente comando in un terminale:
{{{dmesg | less }}}
È possibile usare il prgramma dmesg anche per esaminare le informazioni specifiche dai messaggi bootup del kernel, come i messaggi Plug and Play (PNP) usando il seguente comando in un terminale:
{{{dmesg | grep pnp | less }}}
In relation to the Kernel Ring Buffer, the default behavior of the /etc/init.d/bootmisc.sh system initialization script is to use the dmesg command to log all bootup messages to the file /var/log/dmesg as well. This file may be used as any other log file for examining Kernel bootup messages via commands grep, less, and others.
Messages Log
Il log "messages" contiene messaggi di informazioni delle applicazioni, e delgi strumenti di sistema, ed è raggiungibile in /var/log/messages. Questo log è utile per esaminare messaggi di output dalle applicazioni, e dai strumenti di sistema che loggano a syslog / demone sysklog a livello di INFO.
È possibile esaminare il log, dal punto di rotazione più recente, (se è applicabile) una pagina per lo schermo, usando il seguente comando:
{{{less /var/log/messages }}}
Le informazioni specifiche possono essere raggiunte attraverso il Log "Messages" usando comandi come: grep, e less. Per esempio, per vedere solo le informazione nel log "Messages" pertinente alla Configurazione di Gnome (gconfd), usare il seguente comando in un terminale:
{{{grep gconfd /var/log/messages | less }}}
System Log
Il log "system" contiene tipicamente parecchie delle informazione predefineite del vostro sitema Ubuntu. È localizzato in /var/log/syslog, e può contenere le informazioni di altri log che non spiegheremo. È possibile consultare il log "System" quando sei incapace di localizzare le informzioni di un log in un altro log.
Application Logs
Oltre alla miriade di log specifici al sistema disponibili sul vostro sistema di Ubuntu, potete anche accedere ai diversi log che possono essere usati da determinate applicazioni. Se si elenca il contenuto della sottodirectory /var/log ,vedrete i nomi delle applicazioni che potete installare , come /var/log/apache2 rappresenta il log del server Apache2 (HTTP), o /var/log/samba, che contiene i logs del server Samba (SMB). Questa sezione della guida introduce alcuni esempi specifici dei logs di applicazioni e le informazioni contenute all'interno di loro.
Apache HTTP Server Logs
L'installazione predefinita di Apache2 in Ubuntu crea una sottodirectory del log: /var/log/apache2, ed all'interno di questa sottodirectory, ci sono due file log con due scopi distinti::
/var/log/apache2/access.log : Contiene le annotazioni di tutti gli accessi al server HTTP dei clients
/var/log/apache2/error.log : Contiene le annotazioni di tutti gli errori segnalati dal server HTTP
Con queste informazioni in mente, e la padronanza degli strumenti grep, e less diviene possibile ottenere da questi log informazioni fondamentali.
Per esempio, ed in termini di accesso , if you wished to see log records for every recorded access to your Apache2 server from the client IP address 82.211.81.166, and display the results as one page per screen, you would simply use a command such as the following at a terminal prompt:
{{{grep "82.211.81.166" /var/log/apache2/access.log | less }}}
Or, if you wished to determine if any clients using your Apache2 server were using Mac OS X, a simple command such as the following, typed into a terminal window would suffice:
{{{grep "Mac OS X" /var/log/apache2/access.log | less }}}
On the other side of the coin, suppose you wished to see information from the /var/log/apache2/error.log. This log can be used to search for instances of the Apache2 server being shut down, by using a command such as the following from a terminal prompt:
{{{grep "shutting down" /var/log/apache2/error.log | less }}}
You may also see all log entries which are considered errors by Apache2 with a command such as the following entered at a terminal prompt:
{{{grep error /var/log/apache2/error.log | less }}}
CUPS Print System Logs
The Common Unix Printing System (CUPS) uses the default log file /var/log/cups/error_log to store informational and error messages. If you need to solve a printing issue in Ubuntu, then this log may be a good place to start. You may examine the log, from its most recent rotation point, (if applicable) one page per screen, using a command such as the following from a terminal prompt:
{{{less /var/log/cups/error_log }}}
Specific information may be accessed from the CUPS Log by using such commands as grep, and less. For example, to see only information in the CUPS Log pertaining to Full reloads, you might use a command such as the following at a terminal prompt:
{{{grep reload /var/log/cups/error_log | less }}}
Rootkit Hunter Log
The Rootkit Hunter utility (rkhunter) checks your Ubuntu system for backdoors, sniffers, and so-called "rootkits", which are all signs of compromise of your system. The log which rkhunter uses is located at /var/log/rkhunter.log You may examine the log, from its most recent rotation point, (if applicable) one page per screen, using a command such as the following from a terminal prompt:
{{{less /var/log/rkhunter.log }}}
Specific information may be accessed from the Rootkit Hunter Log by using such commands as grep, and less. For example, to see only information in the Rootkit Hunter Log pertaining to Warnings, you might use a command such as the following at a terminal prompt:
{{{grep WARNING /var/log/rkhunter.log | less }}}
Samba SMB Server Logs
The Server Message Block Protocol (SMB) server, Samba is popularly used for sharing files from your Ubuntu computer to other computers which support the SMB protocol. Samba keeps three distinct types of logs in the subdirectory /var/log/samba:
log.nmbd : Logs all messages related to Samba's NETBIOS over IP functionality (the network stuff)
log.smbd : Logs all messages related to Samba's SMB/CIFS functionality (the file, print, etc. sharing stuff)
log.[IP_ADDRESS] : Logs messages related to requests for services from the IP address contained in the log file name, for example, log.192.168.1.1.
To view all information related to Samba's networking, you could use a command such as the following at a terminal prompt:
{{{less /var/log/samba/log.nmbd }}}
If you wanted only to see information logged about Master Browsers, then you might use a command like this at a terminal prompt:
{{{grep "master browser" /var/log/samba/log.nmbd | less }}}
If you would like to see details related to the SMB functionality of Samba, you can view the appropriate log in its entirety with a command similar to the following at a terminal prompt:
{{{less /var/log/samba/log.smbd }}}
To see only messages related to the start up of the Samba server, a command like the following at a terminal prompt may be used:
{{{grep started /var/log/samba/log.smbd | less }}}
To view all the details on connections from the client system with IP address 192.168.99.99 you could use a command such as the following at a terminal prompt:
{{{less /var/log/samba/log.192.168.99.99 }}}
X11 Server Log
The default X11 Windowing Server in use with Ubuntu is the Xorg X11 server, and assuming your computer has but one display defined, it stores log messages in the file /var/log/Xorg.0.log. This log is helpful for diagnosing issues with your X11 environment. You may examine the log, from its most recent rotation point, (if applicable) one page per screen, using a command such as the following from a terminal prompt:
{{{less /var/log/Xorg.0.log }}}
Specific information may be accessed from the Xorg Log by using such commands as grep, and less. For example, to see only information in the Xorg Log pertaining to the freetype font engine, you might use a command such as the following at a terminal prompt:
{{{grep freetype /var/log/Xorg.0.log | less }}}
Log non umanamente intellegibili
Tra i vari file presenti in /var/log ve ne sono alcuni che vengono creati per essere letti da particolari applicazioni, non necessariamente da essere umani. Quelli che seguono sono degli esempi di questo particolare tipo di log.
Login Failures Log
The login failures log located at /var/log/faillog is actually designed to be parsed, and output by the faillog command. For example, to print recent login failures using the faillog command, simply enter the following at a terminal prompt: