How to navigate files and folders on a terminal (2024)

Table of contents

  • Introduction
  • Prerequisites
  • Let’s get started!
  • Navigating folders
  • Viewing file contents
  • Conclusion

Introduction

This guide is intended to teach you the basics of navigating files and folders on a terminal. As you follow these instructions, keep in mind that your computer’s files and folders likely will be different from the samples. If you already have a lot of experience with the terminal, check out the commands on the homepage for quick reference material.

Prerequisites

In order follow this guide, you will need:

  • Access to a Unix terminal on any Linux or a macOS environment.
  • To know how to open a terminal window. If you are not sure, visit the instructions for macOS or Linux (coming soon).

Let’s get started!

Start by opening your terminal.

When using terminal, you do work from inside of a specific folder on your computer. You can always access items from other folders on your computer, but terminal will keep track of the folder you are currently inside of. This is known as your working directory.

As soon as you open terminal, you will be inside of a working directory. Type pwd in the terminal and press Enter. pwd stands for “print working directory”. The output from this command tells you which folder is your current working directory.

In the sample screenshot below, our working directory is a folder called examples:

How to navigate files and folders on a terminal (1)

Next, you can explore the contents of the working directory. Type ls into your terminal and press Enter. ls stands for “list”. This command lists all the files and folders in your working directory. In our sample, it shows all of the files and folders in examples:

How to navigate files and folders on a terminal (2)

This is similar to opening your file browser application and examining at the contents of your working directory folder:

How to navigate files and folders on a terminal (3)

You can list all the contents in folders that aren’t your working directory by typing ls [FOLDER_NAME]. This is like taking a peek inside another folder, without changing our working directory. In the example below, we are examining at the contents of folder1. We can observe that folder1 has only one file called file3.pdf:

How to navigate files and folders on a terminal (4)

This is similar to examining at the contents of a folder within your working directory in your file browser application:

How to navigate files and folders on a terminal (5)

The ls command has additional options that can change how it functions.

Try typing ls -a and pressing Enter to display all files, including hidden files. On many computers, these files begin with a period and are hidden by default. Common examples of these files include things like “.DS_Store” (on macOS), “.profile” (on Linux), and “.gitignore” (when using Git for your projects).

Note how we can now observe .hidden-file, which wasn’t being displayed with the previous ls command:

How to navigate files and folders on a terminal (6)

Another option for listing files is typing ls -l and pressing Enter. This option generates a long listing. This means that it displays additional details for the files and folders. In addition to the names of files and folders, it will also show attributes, such as when they were last modified and their size:

How to navigate files and folders on a terminal (7)

Similar to many terminal commands, you can combine these two options. To do this, type ls -la and press Enter, which will list all items in long format:

How to navigate files and folders on a terminal (8)

Navigating folders

You may have noticed that our working directory has multiple parts in the name. In general, the / (slash) character means that you are within a folder. So, when you observe /home/user/examples as your working directory, that means that:

  • You are inside of the examples folder, which is your working directory.
  • The examples folder is inside of the user folder.
  • The user folder is inside of the home folder.
  • The home folder is inside of your computer file system and there is nothing beyond it.

Now we can change our working directory. In our example, we saw two folders when using ls to list everything (folder1 and folder2).

Type cd [FOLDER_NAME] and press Enter. Your working directory is now changed. cd stands for “change directory”. You can type pwd again and press Enter to verify that you changed your working directory. In our sample, we changed our working directory to folder1:

How to navigate files and folders on a terminal (9)

This is similar to clicking into a folder in your file browser application. You have completely switched the folder you are in:

How to navigate files and folders on a terminal (10)

If you wanted to go “up” to our previous folder, you can type cd .. and press Enter. This will bring you up one folder level:

How to navigate files and folders on a terminal (11)

This idea of going “down” into a folder or “up” out of a folder is very common when using terminal. When terminal commands, you use the names of folders when going “down” a level and .. to mean going “up” a level.

Viewing file contents

You are probably excited to start working with files with terminal. This can depend on the type of file, since viewing a picture file is different from reading a document file.

For text files, a useful command when working in terminal is typing cat [FILE_NAME] and pressing Enter. The command cat is short for “concatenate” and it has multiple uses.

One of the most common uses is to display the contents of a text file in the terminal. In the screenshot below, we are displaying the contents of hello.txt in our working directory:

How to navigate files and folders on a terminal (12)

Conclusion

Well done! You now know the essentials of navigating files and folders in your terminal. This includes changing your working directory, listing files and folders, and viewing the contents of a text file.

In a future guide, you will learn how to create and modify files and folders.

How to navigate files and folders on a terminal (2024)
Top Articles
Best iOS Crypto Wallets for Apple Devices
What's the difference between an ASIN, SKU, FNSKU, UPC/EAN?
Ups Stores Near
4-Hour Private ATV Riding Experience in Adirondacks 2024 on Cool Destinations
What to Do For Dog Upset Stomach
DL1678 (DAL1678) Delta Historial y rastreo de vuelos - FlightAware
Nikki Catsouras Head Cut In Half
Sinai Web Scheduler
Helloid Worthington Login
Audrey Boustani Age
Hope Swinimer Net Worth
Nier Automata Chapter Select Unlock
Where does insurance expense go in accounting?
Hartland Liquidation Oconomowoc
Inside the life of 17-year-old Charli D'Amelio, the most popular TikTok star in the world who now has her own TV show and clothing line
Parentvue Clarkston
Mychart Anmed Health Login
Halo Worth Animal Jam
Apple Original Films and Skydance Animation’s highly anticipated “Luck” to premiere globally on Apple TV+ on Friday, August 5
Pokemon Unbound Shiny Stone Location
How to Download and Play Ultra Panda on PC ?
Bjerrum difference plots - Big Chemical Encyclopedia
Little Rock Skipthegames
Coomeet Premium Mod Apk For Pc
When Does Subway Open And Close
What Is a Yurt Tent?
Safeway Aciu
Angel Haynes Dropbox
The Clapping Song Lyrics by Belle Stars
Martins Point Patient Portal
Ezstub Cross Country
Pixel Combat Unblocked
Halsted Bus Tracker
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Grays Anatomy Wiki
47 Orchid Varieties: Different Types of Orchids (With Pictures)
Steven Batash Md Pc Photos
The best Verizon phones for 2024
„Wir sind gut positioniert“
Linda Sublette Actress
Qlima© Petroleumofen Elektronischer Laserofen SRE 9046 TC mit 4,7 KW CO2 Wächter • EUR 425,95
The Listings Project New York
Arcane Bloodline Pathfinder
LoL Lore: Die Story von Caitlyn, dem Sheriff von Piltover
Busted Newspaper Mcpherson Kansas
Foxxequeen
Interminable Rooms
2487872771
How to Get a Check Stub From Money Network
Basic requirements | UC Admissions
The Love Life Of Kelsey Asbille: A Comprehensive Guide To Her Relationships
Latest Posts
Article information

Author: Jamar Nader

Last Updated:

Views: 6239

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.