tree draws everything under a directory. Often you only need one level. ls lists what is in one directory:
text
learner@tidepool:~$ ls
notes.txt shop
learner@tidepool:~$ ls shop
orders prices.txt reportsWith no argument, ls lists the current directory. With a path, it lists that directory.
ls -l: one line for each item
The flag -l gives the long form. Each item is on its own line, with more information:
text
learner@tidepool:~$ ls -l shop
total 12
drwxr-xr-x 2 learner learner 4096 Oct 9 14:02 orders
-rw-r--r-- 1 learner learner 21 Oct 11 09:15 prices.txt
drwxr-xr-x 2 learner learner 4096 Oct 10 17:40 reports-typerw-r--r-- 1 learner learnerlater chapters21size in bytesOct 11 09:15last changeprices.txtname
| First character | Type |
|---|---|
d | A directory |
- | A file |
- The size of a directory is the space for its list of names, often
4096. It is not the size of the files in it. - Ignore the first line,
total, for now. - The chapters "Users and Groups" and "File Permissions" explain the columns between the type and the size.
Change the order
By default, ls sorts by name. Two flags change the order:
| Flag | Order |
|---|---|
-t | By time of the last change, newest first |
-r | The reverse of the order |
Put them together with -l. ls -ltr puts the newest item at the bottom, next to your prompt:
text
learner@tidepool:~$ ls -ltr shop
total 12
drwxr-xr-x 2 learner learner 4096 Oct 9 14:02 orders
drwxr-xr-x 2 learner learner 4096 Oct 10 17:40 reports
-rw-r--r-- 1 learner learner 21 Oct 11 09:15 prices.txt