Difference between revisions of "Ls"
m (fix devices->device) |
(listing atime, ctime, mtime) |
||
Line 12: | Line 12: | ||
here we replace the t with file '''S'''ize, and it will also list the largest files in '''r'''everse order, with the largest last. | here we replace the t with file '''S'''ize, and it will also list the largest files in '''r'''everse order, with the largest last. | ||
+ | |||
+ | == listing atime, ctime and mtime == | ||
+ | |||
+ | A user sometimes has need to know when a file was read last, or modified last. Listing [[atime]], [[ctime]] and [[mtime]]. | ||
+ | |||
+ | mimas$ cd /bin | ||
+ | mimas$ ls -lc ls # ctime | ||
+ | -r-xr-xr-x 1 root bin 222328 May 21 19:17 ls | ||
+ | mimas$ ls -l ls # mtime | ||
+ | -r-xr-xr-x 1 root bin 222328 Mar 18 03:35 ls | ||
+ | mimas$ ls -lu ls # atime, this means now | ||
+ | -r-xr-xr-x 1 root bin 222328 Aug 14 14:49 ls | ||
+ | |||
+ | To find files that were changed in the last X hours or days see [[find]] |
Latest revision as of 06:00, 14 August 2010
ls
is the basic "LiSt me the contents in the filesystem" command used in a unix shell. It operates on the current directory by default, and displays a list of all files, directories, named pipes (FIFO), sockets, symlinks, and devices.
There are many, many options to ls
, and they can vary greatly from system to system. Check the local manual pages for details on each argument. You want to install gnuls if you want ls with colour.
$ ls -lart
is a popular usage with arguments. A long listing which shows .files, reversed by time. You can alternatively shell:alias this if you use it a lot.
$ ls -laSr
here we replace the t with file Size, and it will also list the largest files in reverse order, with the largest last.
listing atime, ctime and mtime
A user sometimes has need to know when a file was read last, or modified last. Listing atime, ctime and mtime.
mimas$ cd /bin mimas$ ls -lc ls # ctime -r-xr-xr-x 1 root bin 222328 May 21 19:17 ls mimas$ ls -l ls # mtime -r-xr-xr-x 1 root bin 222328 Mar 18 03:35 ls mimas$ ls -lu ls # atime, this means now -r-xr-xr-x 1 root bin 222328 Aug 14 14:49 ls
To find files that were changed in the last X hours or days see find