Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKalidh Mohamed
5,995 PointsThe "ls /etc" command.
I tried using the ls /<directory> command on my mac and I was able to list all files and folders under the Applications directory, but did not work for any other directory like Documents for example. But, reversing the slash symbol from / -> \ displayed all the files and folders under the Documents directory. What gives?
2 Answers
Emil Rais
26,873 PointsYou have most likely been located in your user directory also known as ~ or /Users/%username%/. Documents is a folder within your user directory: ~/Documents or /Users/%username%/Documents. /etc points to a folder named etc at the top level; it is not relative to your terminal's current location.
When you do ls \Documents that is really just the same as doing ls Documents; and it is relative to your current position. Incidentally it works because your terminal was located in a folder that contained a Documents folder.
Note that ls / should not list all the files and folders of the Applications directory but rather all the files and folders of the top level directory. If you open a Finder window and "go out" all the way, that's where you will end up short of leaving the harddrive. You can try for yourself; use cmd + up-arrow whilst in Finder to go up a level. Continue until right before you leave the harddrive.
Kalidh Mohamed
5,995 PointsHey, thanks for the answer. It helped clear some of the confusion I was facing. Because, incidentally, my terminal app is stored in my Applications folder.
Emil Rais
26,873 PointsIt should not matter where the Terminal.App is stored. I apologise for my confusing terminology. When you've got an active session in the terminal, "you" will be located in a specific directory. You can move around with cd (for change directory). It's like being in the Finder, you can list the files and you can move around. Whenever you open the terminal it will default to ~ (your user directory). If you move to documents with cd Documents, you should be able to see the change in the terminal. Your prompt should update your location to reflect where you are now located. If you stray away unable to find your way back, just close the terminal and open it again and you should be back to ~.