1 | 2 | 3 | 4 | 5 | 6 | 7 | Current Level: 8
ls
You don’t have to be inside a folder to look at what’s in it. You can use ls
to view the contents of any directory by passing its path as an argument.
List the contents of another directory From your home folder, try:
ls -F Desktop
This shows what’s inside the Desktop
folder without changing your current location.
Example output:
shell-lesson-data/
What if it doesn’t work?
If Desktop
doesn’t exist in your current directory, you’ll see an error like:
ls: cannot access 'Desktop': No such file or directory
Make sure you’re in your home directory first by running:
cd ~
Look inside a subfolder
If you see shell-lesson-data/
in your Desktop, you can list what’s inside it like this:
ls -F Desktop/shell-lesson-data
Example output:
exercise-data/ north-pacific-gyre/
ls
a path to any folder — not just the current one.Use the /
symbol to explore nested folders like:
ls -F Desktop/shell-lesson-data/exercise-data