- 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
Change to Your Previous Directory
cd -
Another interesting possibility is cd -, which takes you back to your previous directory and then runs the pwd command for you, printing your new (or is it old?) location. It’s the shell equivalent of the Back button in a GUI file navigator window. You can see it in action in this example:
$ pwd /home/scott $ cd music/new $ pwd /home/scott/music/new $ cd - /home/scott
Using cd - can be useful when you want to jump into a directory, perform some action there, and then jump back to your original directory. The additional printing to the screen of the information provided by pwd is just icing on the cake to make sure you’re where you want to be.