- 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
View a List of Files in Subfolders
ls -R
You can also view the contents of several subdirectories with one command. Say you’re at a Linux Users Group (LUG) meeting and installations are occurring around you fast and furious. “Hey,” someone hollers out, “does anyone have an ISO image of the new Kubuntu that I can use?” You think you downloaded that recently, so to be sure, you run the following command (instead of ls -R, you could have also used ls --recursive):
$ ls -R ~/iso /home/scott/iso: debian-6.0.4-i386-CD-1.iso knoppix ubuntu /home/scott/iso/knoppix: KNOPPIX_V7.2.0CD-2013-06-16-EN.iso KNOPPIX_V7.4.2DVD-2014-09-28-EN.iso /home/scott/iso/ubuntu: kubuntu-15.04-desktop-amd64.iso ubuntu-15.04-desktop-amd64.iso ubuntu-14.04.3-server-amd64.iso
There it is, in ~/iso/ubuntu: kubuntu-15.04-desktop-amd64.iso. The -R option traverses the iso directory recursively, showing you the contents of the main iso directory and every subdirectory as well. Each folder is introduced with its path—relative to the directory in which you started—followed by a colon, and then the items in that folder are listed. Keep in mind that the recursive option becomes less useful when you have many items in many subdirectories, as the listing goes on for screen after screen, making it hard to find the particular item for which you’re looking. Of course, if all you want to do is verify that there are many files and folders in a directory, it’s useful just to see everything stream by, but that won’t happen very often.