Command line filesystem

I’m taking the lesson on command line and have a general question.
In the exercise, as we’re using commands, such as cd, cd …, and mkdir, we have an illustration of the file tree structure to refer to, as we are “moving” up and down the branches. When using the Finder on the computer, we get a kind of an illustration (of lists of folders and files to click on).
The ls offers only the directories in the current location. Is there a way to get a fuller picture than that? How can the file system be really conveniently managed just with text moving one or two steps at a time?

Thank you for your teaching!


1 Like

Hi! Great question!

It takes a bit of getting used to but once you have some tools, navigating from the command-line can be quicker in many instances (particularly since you do powerful searches with grep).

I don’t know if you’re using mac or windows or linux. But for example in linux and mac we have something called a root directory which can be called viewed with

ls ~/

Root is called thus because it contains all other directories. From there you can quickly jump to wherever you need to go.

The neat thing is: if you have this typed (but not entered). You can press the tab key to list everything in the directory (and if you keep pressing it it will cycle through the files.

But say I write

ls ~/D

and press tab i get:

Desktop/    Documents/  Downloads/

all the files/folders in root that start with D (note that it’s case-sensitive).

There’s a ton of little techniques to make navigation pain-free. It just takes a bit of patience at first, and a bit of research. When I was getting my bearings with vim I found a youtube channel I really liked for very basic linux content: Linux Command Line (01) What Is The Linux Command Line - YouTube


It’s worthwhile starting from this basis when you’re learning to use the shell regardless. It is a bit awkward and clunky at first but is also very useful to learn.

Long term even in your terminal window there are tools that do allow what you’re looking for to a greater or lesser degree. If you’re missing the GUI experience tools like ranger and midnight commander are brilliant which let you navigate the directory structure with ease.

Get some popcorn and start hitting up YT channels for some useful tips like the ones @toastedpitabread provided.

These would be my basic suggestions to get started. I got a bit carried away here but this is still only a very brief overview of your options :laughing:

Globbing and simple searches are very useful, e.g. ls /path/to/folder *.sh for example to list all files ending in .sh in the folder directory, or simply viewing the current and next level of directories with ls *.

ls also has a recursive option which would attempt to list the current and EVERY child directory in the file structure but if you ran that in your HOME directory you’re going to have a bad time.

grep and find are often far more useful than ls. They are search tools instead. find can hunt down files or directory names directly and has all sorts of tricks to make life easier, e.g. executing various command in located directories-

# a naive approach to checking the status of multiple git repos for example
find projects -name .git -type d -execdir git status {} \;

grep allows for regular expression pattern matching inside files. Say I know I have a file I wrote containing import antigravity but I can’t remember where it is, I can search recursively for it and I can pass the filename to my favourite text editor, or whatever I please.

Combining tools like the fuzzy matching fzf with searches can make searching the filesystem very straightforward. Personally I would genuinely choose to do something like this in a quick terminal window over ever opening a GUI file explorer. However, it does take time and effort to learn.


Thank you so much for answering my question and for the link.
I’m using a Mac, but am only taking my first steps in coding… I have a lot to learn.

The linux commands will work mostly the same on mac! :slight_smile:

1 Like