Linux Navigation and Basic Commands
Now that we are connected to our Linux server through SSH, it's time to start working with the Linux command line.
One of the first skills you need is navigation - understanding where you are, viewing what's around you, creating directories and files, and moving between locations.
In this lecture, we'll learn a small set of commands that form the foundation for working with the Linux filesystem.
Everything is a File in Linux
One of the important concepts in Linux is that many system resources are represented through a file-like interface.
For everyday Linux usage, you'll commonly work with three types of filesystem objects:
| Type | Description | Example |
|---|---|---|
| Regular File | Stores data such as text, configuration, or source code. | file.txt, config.yml, main.tf |
| Directory | A container used to organize files and other directories. | /home, /etc, telusko/ |
| Link | A reference that points to another file or directory. | Symbolic link |
Note: A directory is technically a special type of filesystem object rather than an ordinary file. The phrase "everything is a file" is a useful Linux concept because many resources are accessed through file-like interfaces.
Understanding these objects makes Linux navigation much easier.
pwd - Print Working Directory
The pwd command displays the absolute path of your current directory.
pwdExample output:
/home/ubuntuThis tells you exactly where you are in the filesystem.
Why use pwd?
When working from the command line, there is no graphical folder window showing your current location. pwd gives you that information immediately.
Tip: If you're unsure where you are, run
pwd.
mkdir - Create a Directory
The mkdir command creates a new directory.
mkdir teluskoThis creates a directory named telusko in your current location.
You can verify it with:
lsExample:
teluskoCreating Multiple Directories
You can also create multiple directories with one command:
mkdir projects notes backupsThis creates three directories in the current location.
ls - List Directory Contents
The ls command displays the files and directories in your current location.
lsExample output:
projects notes teluskoYou can also specify a directory:
ls teluskoThis lists the contents of the telusko directory without moving into it.
A Useful Option
To see more detailed information:
ls -lThis displays details such as permissions, ownership, size, and modification time.
We'll explore these options in more detail when we learn Linux file permissions.
cd - Change Directory
The cd command is used to move from one directory to another.
For example:
cd teluskoNow check your location:
pwdOutput:
/home/ubuntu/teluskoYou have moved from /home/ubuntu into /home/ubuntu/telusko.
Move to the Parent Directory
To move one level up, use:
cd ..For example:
/home/ubuntu/telusko
|
cd ..
|
v
/home/ubuntuYou can verify the change with:
pwdGo to Your Home Directory
You can return to your home directory using:
cd ~You can also simply use:
cdFor the ubuntu user, this will typically take you to:
/home/ubuntutouch - Create an Empty File
The touch command can be used to create an empty file.
touch alien.txtVerify that the file exists:
lsOutput:
alien.txtYou can create files with different names and extensions:
touch config.yml
touch main.tf
touch data.jsonLinux does not determine a file's type simply from its extension. An extension such as
.txtor.jsonis mainly a naming convention. The actual contents and format of a file determine what it contains.
touch can also update a file's timestamps if the file already exists.
Putting the Commands Together
Let's combine everything into a small practice exercise.
Start by checking your current location:
pwdCreate a directory:
mkdir teluskoCheck that it was created:
lsMove into the directory:
cd teluskoConfirm your location:
pwdCreate an empty file:
touch alien.txtVerify the file:
lsMove back to the parent directory:
cd ..Finally, confirm your location:
pwdThis simple workflow introduces the basic pattern you'll use repeatedly when working with Linux:
check your location → create something → inspect it → navigate → verify
Quick Command Reference
| Command | Purpose | Example |
|---|---|---|
pwd | Show the current directory | pwd |
ls | List directory contents | ls |
mkdir | Create a directory | mkdir projects |
cd | Move to another directory | cd projects |
cd .. | Move to the parent directory | cd .. |
cd ~ | Go to the home directory | cd ~ |
touch | Create an empty file | touch notes.txt |
Remember: Don't try to memorize commands in isolation. Practise them together and build a mental picture of the filesystem. Once you understand where you are and how to move around, the rest of Linux becomes much easier to explore.
Written By: Muskan Garg
How is this guide?
Last updated on
