Questions tagged [ls]

The ls command lists the contents of a directory.

ls is a command to list files and their metadata (time, size, owner, etc.). Some implementations can show files in color.

ls does not expand wildcards: this is done by the .

It is very nearly always a mistake to use ls in a script. If you're just expanding wildcards, the shell does it already. If you're looking for files based on criteria such as their size or time, use (or 's glob qualifiers if you have zsh).

External references

Further reading

1357 questions
347
votes
4 answers

What do the fields in ls -al output mean?

The ls -al command shows the following output; -rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe What are all the fields in the preceding display?
Mr. White
  • 3,657
182
votes
5 answers

How to get only files created after a date with ls?

With the ls command, is it possible to show only the files created after a specific date, hour...? I'm asking it because I have a directory with thousand of files. I want so see all files that were created since yesterday. I use ls -ltr but I have…
Luc M
  • 4,095
  • 5
  • 30
  • 29
105
votes
4 answers

The ls command is not working for a directory with a huge number of files

I had a directory which had around 5 million files. When I tried to run the ls command from inside this directory, my system consumed a huge amount of memory and it hung after sometime. Is there an efficient way to list the files other than using…
Ramesh
  • 39,297
104
votes
2 answers

What do the symbols displayed by ls -F mean?

I noticed that if I run ls -F on a directory, some of the entries have a * or a @ after them. spuder@ubuntu:~$ ls -F /sbin acpi_available* getpcaps* lvmconf* ntfscp* start-stop-daemon* agetty* getty* …
spuder
  • 18,053
82
votes
1 answer

Alias for directory listing sorted by time modified in reverse order

When I need to find my recently used files, this command: ls -lt lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because won't fit in terminal screen. After finding out that tac…
linux-newbie
  • 859
  • 1
  • 7
  • 4
59
votes
2 answers

What is the number between file permission and owner in ls -l command output?

The output of ls -l command yields the following result: What is the number field between file permission and owner? i.e. what are those 1, 1, 1, and 2? I checked the --help but that doesn't explain it. [EDIT] I thought it was the number of files…
KMC
  • 739
32
votes
10 answers

How can I list files by type with ls?

When I use the ls command with the option -l, the first string of letters gives the info about each file, and the first letter in this string gives the file's type. (d = directory, - = standard file, l = link, etc.) How can I filter the files…
27
votes
3 answers

What is "total" in the output of "ls" command?

I have an empty directory. I am using following command to view the contents of that directory. ls -lart The output I get is below. total 12 drwxr-xr-x 5 root root 4096 Oct 2 12:26 .. drwxr-xr-x 2 apx aim 4096 Nov 29 18:40 . I don't have…
g4ur4v
  • 1,764
  • 8
  • 29
  • 34
27
votes
2 answers

Want to sort files by update date including sub-directories

I want to sort only files by update dates including sub-directories. I found out ls -lrtR | grep ^-. but it doesn't seem to sort by update dates. And I need to save this list into a file. Is it possible? Apr 01 2010 InsideDoosanServiceImpl.class …
Deckard
  • 391
24
votes
1 answer

ls: how do I list directories sorted by timestamps of the files it contains

How do I list directories by their access time in the sense that some new files/directories are created (say, directories containing the most recently created files).
Ketan
  • 9,226
20
votes
5 answers

listing files with pattern with starting and ending

I want to list all files in a directory that start with 'abc' and end with '.zip' I'm trying to use ls. The directory has a lot of zip files starting with abc and xvz. I only want to get the list of the abc.zip
unix_dude
  • 231
19
votes
4 answers

What is the Linux equivalent of DOS "dir /s /b filename"?

List all files/dirs in or below the current directory that match 'filename'.
mackenir
  • 293
15
votes
4 answers

How to add new line between `ls -l` output

This is standard ls -l output. user@linux:~$ ls -l total 0 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file01 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file02 -rw-rw-r-- 1 user user 0 Nov 1 00:00 file03 user@linux:~$ Would it be possible to add new line…
user264359
13
votes
1 answer

Find the disk-space usage of a directory and all it's files

Possible Duplicate: How to know the size of a directory? If I run ls -lh then any given directory is just shown as 4.0K. How can I can make it consider the files the directory refers to as well?
oadams
  • 2,335
13
votes
4 answers

List only file size and name and symlinks

When I use ls -lah I get lots of information for each file. How can I get only the name and filesize? Additionally I would like to keep the listing of symlinks with the arrow like lrwxrwxrwx 1 rubo77 rubo77 4 Nov 21 01:53 test2 -> test
rubo77
  • 28,966
1
2 3 4 5 6 7