VOOZH about

URL: https://thenewstack.io/primer-get-to-know-linux-files-and-directories/

⇱ Primer: Get to Know Linux Files and Directories - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2019-11-30 06:00:59
Primer: Get to Know Linux Files and Directories
tutorial,

Primer: Get to Know Linux Files and Directories

Having a working knowledge, particularly on the Linux command line, of files and directories gives you latitude for configuring your system, automating processes, and easily manipulating data.
Nov 30th, 2019 6:00am by drtorq
👁 Featued image for: Primer: Get to Know Linux Files and Directories

Files and directories are fundamental concepts in Linux. Files contain content and data, while directories organize those files into meaningful and standardized groups. Having a working knowledge, particularly on the Linux command line, of files and directories gives you latitude for configuring your system, automating processes, and easily manipulating data.

Today, we’ll take a practical, real-world look at a few basics of Linux files and directories. I use this stuff all the time.

What’s in a File?

Files are simply containers of data. The data could be a program, binary numbers, digital audio, video, regular old text or whatever.

Log into your Linux machine, as a normal user and open a terminal window. Use ls on the command-line to get a listing of what’s in your home directory.

rob% ls -l

Here’s a portion of a typical user home directory.

👁 Image

A portion of a /home/rob directory

The left-most columns are the directory indicator and the file permissions. Moving right we then have the owner and group. A little further is the file size and creation date. Finally, the right-most column contains the file or directory name. If there is a “d” in the left-most column, that particular line actually lists a directory.

File names usually contain a combination of letters and numbers, typically without special characters. Upper and lower case letters in filenames have significance and can’t be used interchangeably in Linux. A “ROB.TXT” file is not the same as “rob.txt”, even though it might contain exactly the same data. They are entirely different file names. Likewise, “Rob.txt” is a different file than roB.Txt. You get the idea.

Most Linux configuration is performed through the use of text files. Using text files for configuration makes it easy to change things, using a simple command-line human-readable text editor, even if you aren’t using a desktop or window-type graphical user interface. I prefer to use vi, in a terminal window to edit text files. Other people like a program called nano.

Often the file name extension reflects what’s in the file. For example “rob.txt” contains human-readable text. A rob.wav file contains digital audio in a WAV format. Programs use standard filename extensions. For example, a .odt file is a LibreOffice document. In the Windows world, a .ppt file is a Microsoft PowerPoint slide stack.

Files can vary all over the map in size. A simple Linux shell script or a dozen-line text file might only be a few kilobytes (KB) in size. On the other hand, a current version of Linux, in the form of a .iso image file might be over 1.5 gigabytes (GB) in size. It’s always good to be aware of file sizes because over time, big files tend to accumulate and fill up your disk space. I like to use the -h option with ls to show the sizes in KB and GB.

rob% ls -lh

OK, so now we know a little more about files. Where the heck are they? Directories organize and group your files.

Where’s My File?

The Linux file system looks like an upside down tree. A directory is simply a branch on the Linux file system tree. Other operating systems call directories folders. They are one-in-the same. You might think of files as the leaves on a branch. You might also have smaller branches (sub-directories) with their collection of leaves (files) and even smaller branches (sub-sub-directories). Most of my directories never go more than four or five levels deep.

The top-most Linux directory is called the root directory and it is represented with a “/” (slash) symbol. The “/” symbol indexes lower-level directory names, as well. /etc is the name of the directory that contains auxiliary files used by the Linux operating system. My user files and lower-level directories reside in the /home/rob directory. Some common Linux system directories include /etc, /bin, /home, /dev and /sys. Some of my rob user directories include /home/rob/Downloads, /home/rob/music and /home/rob/webdocs. Logging in with your user name and password will automatically put you in your own “home” directory, typically /home/[your user name].

Here’s a screenshot of a typical root directory.

👁 Image

Typical Linux root directory

You can create a new directory with the mkdir command and call it whatever you like.

rob% mkdir tech

Executing this line in a terminal will create the “tech” directory, in my current directory.

How do I know where I am in the directory tree? Use the pwd (present working directory) command.

rob% pwd

Having created a new “tech” directory, we can move into it using the cd command.

rob% cd tech

Notice that I didn’t use /tech. That would put me up under the root (/) directory within a “tech” sub-directory, if it exists.

You could get to your tech directory, no matter where you are in the Linux file system tree by using the fully-qualified directory name. Say you are over in the /bin directory. Type the following.

rob% cd /home/rob/tech

Now you are back in your tech directory.

I could then go back up to my home directory by simply issuing a cd by itself. This works from anywhere too. You can also go up one directory (to my home directory) by issuing a cd .. command. I use this all the time. You can even get fancy and use cd ../.. to go up two directories.

Taking It Further

The best way to get familiar with Linux files and directories is to start using the cd, mkdir and ls commands to look around through the tree structure. Take a look inside some text files with cat or vi, too. Use “vi [file name.txt] to look at a text file. Hint: use the ESC key, then “:”, then “q” to get out of vi. Use vi –help to list out the command-line options.

You might also get your hands on a Raspberry Pi 4 and use it as your educational platform. Additionally, you’ll need an HDMI monitor, keyboard/mouse pad, 3-Amp power supply and at least a blank 16GB micro-SD card to get the Pi operational. Check out their “getting started” page. That way you can make the inevitable mistakes, without too much pain and keep all your personal and production work on your existing Linux, Windows or Mac notebook safe from inadvertent mishaps as you learn. The Pi product line was, after all, designed as a learning tool.

Contact Rob “drtorq” Reilly for consultation, speaking engagements and commissioned projects at doc@drtorq.com or 407-718-3274.

The Linux Foundation is a sponsor of The New Stack.

Feature image by TeeFarm from Pixabay.

TRENDING STORIES
Rob "drtorq" Reilly is an independent consultant, writer, and speaker specializing in Linux/OSS, physical computing, hardware hacking, the tech media, and the DIY/Maker movement. He provides a variety of engineering, business and special project services to individual clients and companies....
Read more from drtorq
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.