"ls -ltu"コマンドは、最後のアクセス時間に基づいてフォルダ/ファイルを一覧表示しません。

まず、Linuxデスクトップに2つのフォルダを作成します。

a
b

今ターミナルで実行してみてください

ls -ltu

明らかにする

drwxr-xr-x 2 root root 4096 Aug 30 20:33 b
drwxr-xr-x 2 root root 4096 Aug 30 20:33 a

aをクリックしてやり直してみましょう。
上記とまったく同じ結果です。

bをクリックしてやり直してみましょう。
上記とまったく同じ結果です。

最後にクリックしたフォルダに基づいてフォルダを並べ替えようとしています。彼らはそれをお勧めしましたが、ls -ltu効果がありませんでした。

ベストアンサー1

このコマンドを使用して、statファイルとディレクトリに関する時間関連情報を表示できます。

はい

$ mkdir a b

$ ll
total 8
drwxrwxr-x 2 saml saml 4096 Aug 31 00:08 a
drwxrwxr-x 2 saml saml 4096 Aug 31 00:08 b

$ ls -ltu
total 8
drwxrwxr-x 2 saml saml 4096 Aug 31 00:08 a
drwxrwxr-x 2 saml saml 4096 Aug 31 00:08 b

統計出力

次に、次のコマンドを使用してこれらのディレクトリを見てみましょうstat

$ stat a b
  File: `a'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643285     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:08:03.621936538 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400
  File: `b'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643286     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:08:03.621936538 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400

入場a

それでは、ディレクトリにアクセスしてみましょうa

$ ls a

それでは、ディレクトリをもう一度確認してみましょうstat

$ stat a b
  File: `a'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643285     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:08:33.221267791 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400
  File: `b'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643286     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:08:03.621936538 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400

ディレクトリ統計に影響を与えたことがわかりますls a

今後

Access: 2013-08-31 00:08:03.621936538 -0400

後ろに

Access: 2013-08-31 00:08:33.221267791 -0400

入場b

bこれでディレクトリにアクセスすると、次のようになりますls b

$ ls b

$ ls -ltu
total 8
drwxrwxr-x 2 saml saml 4096 Aug 31 00:17 b
drwxrwxr-x 2 saml saml 4096 Aug 31 00:08 a

統計出力

ls -ltuアクセス時間が変更され、上記の出力が次のようになることを確認できます。

$ stat a b
  File: `a'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643285     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:08:33.221267791 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400
  File: `b'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 5643286     Links: 2
Access: (0775/drwxrwxr-x)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-08-31 00:17:15.279776957 -0400
Modify: 2013-08-31 00:08:03.621936538 -0400
Change: 2013-08-31 00:08:03.621936538 -0400

ls bアクセス時間の更新が発生する簡単な状況を再確認できます。

今後

Access: 2013-08-31 00:08:03.621936538 -0400

後ろに

Access: 2013-08-31 00:17:15.279776957 -0400

一般化する

上記の分析から、ls -ltu予想される接続時間に基づいてソートされたディレクトリを表示しない理由はありません。

だからどうしたの?

アクセス時間が追跡されないようにディレクトリをマウントした可能性があります。これはなぜ変化がなかったのかを説明します。

mountコマンドのマニュアルページを見ると、次の2つのオプションが定義されていることがわかります。

atime     Update inode access time for each access. See also the 
          strictatime mount option.

noatime   Do not update inode access times on this filesystem (e.g, 
          for faster access on the news spool to speed up news servers).

このコマンドを使用して、ファイルシステムがどのようにマウントされているかを確認できますmount。デバイスのインストール後にnoatimeこのオプションが表示された場合、デバイスのインストール後の接続時間は追跡されません。これは通常、パフォーマンスを向上させるために行われます。

はい

$ mount
/dev/mapper/vg_grinchy-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda5 on /boot type ext4 (rw)
/dev/mapper/vg_grinchy-lv_home on /home type ext4 (rw)
gvfs-fuse-daemon on /home/saml/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=saml)

おすすめ記事