Agentic AI with Java: Live Cohort
LinuxLinux Fundamentals

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:

TypeDescriptionExample
Regular FileStores data such as text, configuration, or source code.file.txt, config.yml, main.tf
DirectoryA container used to organize files and other directories./home, /etc, telusko/
LinkA 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.

pwd

Example output:

/home/ubuntu

This 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 telusko

This creates a directory named telusko in your current location.

You can verify it with:

ls

Example:

telusko

Creating Multiple Directories

You can also create multiple directories with one command:

mkdir projects notes backups

This creates three directories in the current location.


ls - List Directory Contents

The ls command displays the files and directories in your current location.

ls

Example output:

projects  notes  telusko

You can also specify a directory:

ls telusko

This lists the contents of the telusko directory without moving into it.

A Useful Option

To see more detailed information:

ls -l

This 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 telusko

Now check your location:

pwd

Output:

/home/ubuntu/telusko

You 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/ubuntu

You can verify the change with:

pwd

Go to Your Home Directory

You can return to your home directory using:

cd ~

You can also simply use:

cd

For the ubuntu user, this will typically take you to:

/home/ubuntu

touch - Create an Empty File

The touch command can be used to create an empty file.

touch alien.txt

Verify that the file exists:

ls

Output:

alien.txt

You can create files with different names and extensions:

touch config.yml
touch main.tf
touch data.json

Linux does not determine a file's type simply from its extension. An extension such as .txt or .json is 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:

pwd

Create a directory:

mkdir telusko

Check that it was created:

ls

Move into the directory:

cd telusko

Confirm your location:

pwd

Create an empty file:

touch alien.txt

Verify the file:

ls

Move back to the parent directory:

cd ..

Finally, confirm your location:

pwd

This 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

CommandPurposeExample
pwdShow the current directorypwd
lsList directory contentsls
mkdirCreate a directorymkdir projects
cdMove to another directorycd projects
cd ..Move to the parent directorycd ..
cd ~Go to the home directorycd ~
touchCreate an empty filetouch 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