ls: List Files
Now that you know where you are with pwd, the next question is: what is
here?
The ls command (short for list) shows you the files and folders inside your current directory.
ls
If the folder contains a few items, it might print:
mission.txt reports tools
Each name is either a file (like mission.txt) or a folder / directory (like
reports and tools). With the plain ls command they can look similar. In a later
lesson you will learn how to tell them apart at a glance.
You can also list the contents of a folder without going into it by giving its
name to ls:
ls reports
january.log february.log
This peeks inside reports while you stay where you are.
Like pwd, ls only looks. It never changes or deletes anything. It is safe to
run any time you feel lost.
A useful habit: run ls whenever you arrive in a new directory, so you always know
what you are working with.
Mission: Inventory Check
The previous crew left behind files and folders in your home directory, and one of those folders holds their old reports. Before you can start your shift, you need to know what you are working with.
- Confirm where you are in the filesystem.
- List everything in your current directory to see what the previous crew left behind.
- Peek inside the
reportsfolder without entering it.
Expected result
You confirm you are in /home/student, the listing reveals what the previous crew left behind, and looking inside reports shows the report logs stored in that folder.