<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Aldolat.it &#8212; Post con tag Stat</title>
        <link>https://www.aldolat.it/tags/stat/</link>
        <description>Ultimi post pubblicati nel tag Stat &#8212; aldolat.it</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>it</language>
        <managingEditor>aldolat@gmail.com (Aldo Latino)</managingEditor>
        <webMaster>aldolat@gmail.com (Aldo Latino)</webMaster>
        <copyright>Creative Commons BY-SA 4.0</copyright>
        <lastBuildDate>Tue, 14 Jan 2025 21:40:55 +0100</lastBuildDate>
        <atom:link href="https://www.aldolat.it/tags/stat/index.xml" rel="self" type="application/rss+xml" />
        <item>
            <title>Conoscere la data di creazione di un file in GNU/Linux</title>
            <link>https://www.aldolat.it/posts/2011/conoscere-data-creazione-file-linux/</link>
            <pubDate>Fri, 19 Aug 2011 21:16:53 +0000</pubDate>
            <author>aldolat@gmail.com (Aldo Latino)</author>
            <guid>https://www.aldolat.it/posts/2011/conoscere-data-creazione-file-linux/</guid>
            <description>Questo post non sarebbe mai nato se non fosse stato per Lorenzo, che si è trovato davanti alla necessità di risalire alla data di creazione di un file. E si è accorto che questo dato non è di immediata reperibilità. Vista l&amp;rsquo;importanza di quel suo post, mi sembra giusto darne ulteriore visibilità.&#xA;Nota di aggiornamentoCon le recenti versioni di stat è possibile reperire questa informazione:&#xA;$ stat filename File: filename Dim.: 487350 Blocchi: 952 Blocco di IO: 4096 file regolare Device: 8,17 Inode: 56368081 Links: 1 Accesso: (0644/-rw-r--r--) Uid: ( 1000/ aldo) Gid: ( 1000/ aldo) Accesso : 2022-12-18 09:08:16.340484099 +0100 Modifica : 2019-05-07 12:17:11.000000000 +0200 Cambio : 2021-11-13 23:14:06.304345519 +0100 Creazione: 2020-10-18 07:55:44.026567659 +0200 È anche possibile farlo con ls:</description>
            <content:encoded>&lt;figure class=&#34;aligncenter&#34;&gt;&lt;img src=&#34;https://www.aldolat.it/images/2011/08/orologio.jpg&#34;&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p class=&#34;dc&#34;&gt;Q&lt;span class=&#34;allsc&#34;&gt;uesto post&lt;/span&gt; non sarebbe mai nato se non fosse stato per &lt;a href=&#34;http://wiki.ubuntu-it.org/LorenzoSfarra&#34;&gt;Lorenzo&lt;/a&gt;, che si è trovato davanti alla necessità di risalire alla data di creazione di un file. E si è accorto che questo dato non è di immediata reperibilità. Vista l&amp;rsquo;importanza di quel suo post, mi sembra giusto darne ulteriore visibilità.&lt;/p&gt;&#xA;&lt;div class=&#34;note longnote&#34;&gt;&#xA;    &lt;div class=&#34;title-note&#34;&gt;Nota di aggiornamento&lt;/div&gt;&lt;p&gt;Con le &lt;a href=&#34;https://unix.stackexchange.com/questions/50177/birth-is-empty-on-ext4/407305#407305&#34;&gt;recenti versioni&lt;/a&gt; di &lt;code&gt;stat&lt;/code&gt; è possibile reperire questa informazione:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ stat filename &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  File: filename&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  Dim.: 487350          Blocchi: 952        Blocco di IO: 4096   file regolare&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Device: 8,17    Inode: 56368081    Links: 1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Accesso: (0644/-rw-r--r--)  Uid: ( 1000/    aldo)   Gid: ( 1000/    aldo)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Accesso  : 2022-12-18 09:08:16.340484099 +0100&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Modifica : 2019-05-07 12:17:11.000000000 +0200&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Cambio   : 2021-11-13 23:14:06.304345519 +0100&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Creazione: 2020-10-18 07:55:44.026567659 +0200&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;È anche possibile farlo con &lt;code&gt;ls&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ls -l --time&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;birth filename&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;che restituisce:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- 1 aldo aldo 487350 18 ott  2020 filename&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;In Ext4 è possibile farlo con:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ls -i filename&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;che restituisce l&amp;rsquo;&lt;em&gt;inode&lt;/em&gt; del file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;6029808 filename&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;e quindi:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo debugfs -R &lt;span class=&#34;s1&#34;&gt;&amp;#39;stat 6029808&amp;#39;&lt;/span&gt; /dev/sda3&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;dove &lt;code&gt;/dev/sda3&lt;/code&gt; è la partizione in cui risiede il file. Ed infatti, creando un&#xA;file di test e dando quel comando, l&amp;rsquo;output è:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Inode: 6029808 Type: regular Mode: 0644 Flags: 0x80000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; Generation: 3337172570 Version: 0x00000000:00000001&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; User: 1000 Group: 1000 Size: 0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; File ACL: 0 Directory ACL: 0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; Links: 1 Blockcount: 0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; Fragment: Address: 0 Number: 0 Size: 0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  ctime: 0x4e47fa9b:c3e1fd20 -- Sun Aug 14 18:40:59 2011&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  atime: 0x4e47fa9b:c3e1fd20 -- Sun Aug 14 18:40:59 2011&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  mtime: 0x4e47fa9b:c3e1fd20 -- Sun Aug 14 18:40:59 2011&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; crtime: 0x4e47fa9b:c3e1fd20 -- Sun Aug 14 18:40:59 2011&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; Size of extra inode fields: 28&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; EXTENTS:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; (END)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;dove la quartultima riga contiene il dato che ci interessa, cioè &lt;code&gt;crtime&lt;/code&gt;&#xA;(&lt;em&gt;creation time&lt;/em&gt;).&lt;br&gt;&#xA;&lt;br&gt;&#xA;Gli altri sono:&lt;/p&gt;&#xA;&lt;dl&gt;&#xA;&lt;dt&gt;&lt;code&gt;ctime&lt;/code&gt; (change time)&lt;/dt&gt;&#xA;&lt;dd&gt;Ora del cambiamento, che può includere anche solo una modifica ai permessi senza apertura del file.&lt;/dd&gt;&#xA;&lt;dt&gt;&lt;code&gt;atime&lt;/code&gt; (access time)&lt;/dt&gt;&#xA;&lt;dd&gt;Ora di accesso al file.&lt;/dd&gt;&#xA;&lt;dt&gt;&lt;code&gt;mtime&lt;/code&gt; (modification time)&lt;/dt&gt;&#xA;&lt;dd&gt;Ora di modifica del file.&lt;/dd&gt;&#xA;&lt;/dl&gt;&#xA;&lt;p&gt;Schematicamente, ecco cosa avviene (la &lt;code&gt;x&lt;/code&gt; indica un cambio del &lt;em&gt;timestamp&lt;/em&gt;):&lt;/p&gt;&#xA;&lt;table class=&#34;full&#34;&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: center&#34;&gt;ctime&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: center&#34;&gt;atime&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: center&#34;&gt;mtime&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: center&#34;&gt;crtime&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Creazione file&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Apertura file&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Modifica file&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Cambio permessi&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;×&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p class=&#34;table-caption&#34;&gt;&lt;span class=&#34;sc&#34;&gt;Tabella 1.&lt;/span&gt; Quali attributi di un file vengono modificati a seconda dell&amp;rsquo;azione eseguita.&lt;/p&gt;&#xA;&lt;p&gt;&lt;br&gt;&#xA;Grazie a Lorenzo per le &lt;a href=&#34;http://lorenzosfarra.blogspot.com/2011/08/ma-veramente-cronaca-del-crtime-su.html&#34;&gt;preziose informazioni&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p class=&#34;photo-credits&#34;&gt;Photo credits:&#xA;    &lt;span class=&#34;photo-author&#34;&gt;ToniVC&lt;/span&gt;,&#xA;    &#xA;        &lt;span class=&#34;photo-title&#34;&gt;&lt;a href=&#34;http://www.flickr.com/photos/tonivc/2283676770/&#34; class=&#34;photo-link&#34;&gt;The Passage of Time&lt;/a&gt;&lt;/span&gt;,&#xA;    &#xA;    &lt;span class=&#34;photo-license&#34;&gt;CC by-nc-nd&lt;/span&gt;,&#xA;    &#xA;    &lt;span class=&#34;photo-year&#34;&gt;2008&lt;/span&gt;.&#xA;&lt;/p&gt;&#xA;&lt;p&gt;L&#39;articolo &lt;a href=&#34;https://www.aldolat.it/posts/2011/conoscere-data-creazione-file-linux/&#34;&gt;Conoscere la data di creazione di un file in GNU/Linux&lt;/a&gt; è uno scritto di &lt;a href=&#34;https://www.aldolat.it/&#34;&gt;aldolat.it&lt;/a&gt;. Rispettane le &lt;a href=&#34;https://www.aldolat.it/info/#licenza&#34;&gt;condizioni di licenza&lt;/a&gt;.&lt;/p&gt;</content:encoded>
        </item>
    </channel>
</rss>
