How can I list folders from within the terminal, which command should I use?
to list only folders try:
ls -d */
list directories themselves, not their contents. To explain this, consider what happens if we type
lsgoes one layer down, into each subdirectory, and lists all the files in each of those sequentially
*/ is known as a "glob" in UNIX. (see Wikipedia for more details). But basically, it means "any file name ending in a forward slash." In UNIX, directories are really just files, fundamentally. But they are specially named ending in a forward slash so the operating system knows they are directories (or folders, in everyday-person-speak). And the asterisk
* is technically a wildcard standing for "any string of characters."
What is a glob?
This paragraph will not pertain specifically to your question, but if you've never read about this, it'll be good to see it. Globs are different from Regular Expressions, as (partially) explained in What is the difference between Regular Expressions and Globbing? There have been whole books written on regular expressions, but tl;dr there are a bunch of different ways to encode pattern-matching expressions.
As I am a very inexperienced user I love this website. It tells you all you want to know about bash commands, in some cases it even gives you examples. Very useful.
In your case:
lsto list the files
ls -ato include hidden files
ls -lfor a long listing format
ls -al | grep ^d
include hidden files '-a' grep ^d get start with 'd' wich means directory when name starts with dot directory is hidden
to list recursively see this
find ./ -type d | less ./ ..................... means starts find in current folder -type .................. indicates the type to be searched d ...................... means directory | ...................... redirects the command less ................... enables paging using the keyboard arrows and leave with q
To view home directory folders the
lscommand is enough - this will keep it simple.
$ ls Desktop Downloads hadoop Pictures Templates Documents examples.desktop Music Public Videos
You can even specify multiple directories
ls ~ /usr
$ ls ~ /usr /home/hadoop1: Desktop Downloads hadoop Pictures Templates Documents examples.desktop Music Public Videos /usr: bin games include lib local locale sbin share src
To get the output in long format we can use the
$ ls -l total 48 drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Desktop drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Documents drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Downloads -rw-r--r-- 1 hadoop1 hadoop1 8980 Jul 1 2017 examples.desktop drwxr-xr-x 10 hadoop1 hadoop1 4096 Jul 1 2017 hadoop drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Music drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Pictures drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Public drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Templates drwxr-xr-x 2 hadoop1 hadoop1 4096 Jul 1 2017 Videos