- List Files and Folders
- List the Contents of Other Folders
- List Folder Contents Using Wildcards
- View a List of Files in Subfolders
- View a List of Contents in a Single Column
- View Contents As a Comma-Separated List
- View Hidden Files and Folders
- Visually Display a File's Type
- Display Contents in Color
- List Permissions, Ownership, and More
- Reverse the Order Contents Are Listed
- Sort Contents by Date and Time
- Sort Contents by Size
- Express File Sizes in Terms of K, M, and G
- Display the Path of Your Current Directory
- Change to a Different Directory
- Change to Your Home Directory
- Change to Your Previous Directory
- Conclusion
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 airhorn_surprise.wmv apple_knowledge_navigator.mov b-ball-e-mail.mov carwreck.mpg nerdtv_1_andy_hertzfeld nerdtv_2_max_levchin_paypal nerdtv_3_bill_joy tiger.wmv Ubuntu_Talk-Mark_Shuttleworth.mpeg
Yes, there it is: tiger.wmv.