Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$has_disclaimer is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_meta_box_present is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_send_notification is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_modify_title_and_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_heading is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_blz_affiliation_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskeywords is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_keywordsynonyms is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$response_body is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_indexnow_last_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
dmesg aiuta a scoprire cosa non funziona su Linux: come usarlo | IlSoftware.it

dmesg aiuta a scoprire cosa non funziona su Linux: come usarlo

Il comando dmesg su Linux è uno strumento diagnostico potente che consente di visualizzare i messaggi del kernel, utili per risolvere problemi legati a driver, hardware e configurazioni di sistema.

Rispetto a qualche anno fa, il kernel Linux e le principali distribuzioni hanno compiuto enormi passi in avanti per garantire il più ampio supporto hardware. Che Linux offra sufficiente compatibilità hardware è quindi un falso mito. Permangono però problemi che possono essere legati alla presenza di conflitti o all’utilizzo di driver inadeguati. dmesg è un comando utilizzabile sui sistemi GNU/Linux che aiuta a scoprire cosa non funziona, in modo da porvi rimedio.

Abbreviazione di display message, dmesg visualizza i messaggi del kernel ring buffer. Quest’ultimo è una memoria circolare in cui il kernel registra messaggi relativi a eventi di sistema, come il caricamento dei moduli, errori hardware, problemi di driver, gestione della memoria e altro ancora. Il buffer è di tipo “circolare” perché gli eventi più vecchi sono via via rimossi per far posto alle informazioni nuove.

Come usare dmesg su Linux e quando è utile

La possibilità di accedere a un registro delle attività svolte in tempo reale dal kernel Linux è un vantaggio indiscutibile. E non si pensi che l’utilizzo del terminale sia penalizzante: anzi, con pochi semplici comandi è spesso possibile farsi un’idea di ciò che è avvenuto o sta accadendo sul sistema.

Il comando dmesg permette infatti di accedere facilmente ai messaggi prodotti dal kernel e, soprattutto, permette di attivare filtri per estrarre soltanto le informazioni più utili dall’enorme mole di dati registrati.

Per “sbirciare” tra i messaggi del kernel Linux, basta digitare dmesg | more quindi premere il tasto freccia giù o Pag.down per muoversi alla schermata successiva del log. Per avanzare di una sola riga, basta premere Invio. Per uscire, basta premere CTRL+C e poi Invio.

Trovare la lista delle unità di memorizzazione rilevate

Filtrando l’output del comando dmesg usando grep, è possibile ad esempio accedere alla lista delle unità di memorizzazione rilevate dal kernel quindi abilitate per l’utilizzo.

Basta impartire il comando dmesg | grep sd e premere Invio.

Il prefisso sd è infatti comunemente utilizzato per riferirsi ai dispositivi di archiviazione su Linux, inclusi dischi fissi e unità SSD: esempio /dev/sda, /dev/sdb e così via.

Come cercare il rilevamento di uno specifico dispositivo con dmesg

Considerando la dimensione del log prodotto dal kernel Linux, risulterebbe particolarmente difficoltoso spulciarlo tutto per individuare ciò che serve. Ad esempio per identificare errori hardware o conflitti a livello di driver.

Come abbiamo visto al paragrafo precedente, quindi, si possono usare semplici filtri per estrarre le informazioni rilevanti:

I comandi che hai fornito sono utilizzati per filtrare e cercare specifiche informazioni nei log del sistema, in particolare nei messaggi del kernel visualizzabili con il comando `dmesg`. Ecco cosa fanno:

dmesg | grep -i usb Comando utile per monitorare il rilevamento e l’attività dei dispositivi USB connessi al sistema.

dmesg | grep -i dma DMA (Direct Memory Access) è una tecnologia che permette a dispositivi di accedere direttamente alla memoria del sistema, senza l’intervento del processore. Il comando è utile per diagnosticare eventuali problemi o attività relativi a DMA.

dmesg | grep -i tty La sigla tty si riferisce ai terminali o alle porte seriali del sistema, ed è utile per monitorare i dispositivi di input/output seriale.

dmesg | grep -i memory Il comando è utilizzabile per diagnosticare e visualizzare informazioni relative a errori di memoria, allocazioni e altre attività legate alla gestione della memoria.

A tutti i comandi, dopo dmesg è eventualmente possibile aggiungere l’opzione -T in modo da ottenere riferimenti temporali umanamente leggibili. Così facendo si può avere ad esempio conferma dell’ora in cui si è verificato il problema con uno specifico dispositivo hardware.

Filtrare l’output del kernel alla ricerca di errori

L’attività diagnostica sul sistema Linux può essere supportata anche da un comando come dmesg --level=warn che estrae la lista degli avvisi restituiti dal kernel. A salire in termini di gravità delle segnalazioni ci sono le indicazioni err, crit e alert.

Sostituendo le tre stringhe a warn, si può avere contezza di eventuali situazioni di maggiore severità.

Attivare la visualizzazione in tempo reale delle informazioni con dmesg

Supponiamo che un problema di presenti in maniera ricorrente quando si collega o si scollega un dispositivo hardware. Oppure quando di comincia a utilizzarlo.

Alcune distribuzioni permettono di impartire il comando tail -f /var/log/dmesg per ricevere una notifica in tempo reale su ciò che sta accadendo lato kernel.

In alternativa si può usare il comodo watch "dmesg | tail -20" per estrarre sempre le ultime 20 occorrenze aggiuntesi al registro delle attività svolte dal kernel Linux.

Qual è il rapporto tra udev e dmesg?

Su Linux il componente chiamato udev è il responsabile della gestione dinamica dei dispositivi hardware rilevati dal kernel.

Quando un dispositivo è aggiunto o rimosso (si pensi a una chiavetta USB o una scheda di rete), udev si occupa di creare o rimuovere file corrispondente nella directory /dev, applicare regole personalizzate per configurare il device, assegnare permessi, nomi ed eseguire script.

Un messaggio raccolto da dmesg che segnala l’identificativo di una chiavetta USB, può essere usato per creare una regola udev che assegna un collegamento simbolico personalizzato.

Conclusioni

In definitiva, il comando dmesg è uno strumento fondamentale per diagnosticare e monitorare il funzionamento di un sistema Linux, offrendo un accesso diretto e in tempo reale ai messaggi del kernel. Grazie alla sua capacità di filtrare e visualizzare specifici eventi, come errori di driver o problemi hardware, permette di risolvere tempestivamente i conflitti e le problematiche che possono compromettere la stabilità e le prestazioni del sistema.

Nonostante i notevoli progressi nel supporto hardware su Linux, dmesg può essere determinante per individuare malfunzionamenti, specialmente in presenza di dispositivi particolari o configurazioni complesse.

Ti consigliamo anche

Link copiato negli appunti