Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

This chapter is from the book

This chapter is from the book

List the Contents of Other Folders

ls [folder]

You don’t have to be in a directory to find out what’s in it. Let’s say that you’re in your home directory, but you want to find out what’s in the music directory. Simply type the ls command, followed by the folder whose contents you want to view, and you’ll see this:

$ ls music
Buddy_Holly  Clash  Donald_Fagen  new

In the previous example, a relative path is used, but absolute paths work just as well.

$ ls /home/scott/music
Buddy_Holly  Clash  Donald_Fagen  new

The ability to specify relative or absolute paths can be incredibly handy when you don’t feel like moving all over your file system every time you want to view a list of the contents of a directory. Not sure if you still have that video of a Bengal Tiger your brother took at the zoo? Try this (~ represents your home directory):

$ ls ~/videos

Yes, there it is: tiger.wmv.

  • + Share This
  • 🔖 Save To Your Account