432 words
2 minutes
Shell basics

Now that we’ve covered Linux filesystem layout, we have a clear idea where to navigate in Linux, In this post we’ll cover the following commands

  • pwd
  • mkdir
  • ls
  • cd

Understanding your Location with pwd#

The pwd command shows your current location in the Linux filesystem

Usage

pwd

Example Output

/home/poly

In this example, I’m currently in my user home directory. The command is simple yet invaluable, especially when you’re deep in the directory tree and need to confirm your location

Creating a directory with mkdir#

The mkdir command basically creates a new directory in your current location, think of it as creating a new folder on windows

Usage

mkdir homework

mkdir does not give you an output. In this example, it simply creates the directory “homework”. We can store anything in this directory, your homework files or anything else.

Listing directory content with ls#

The ls command displays files and directories in your current location. It’s highly versatile with numerous options

Usage

ls

Example Output

homework

Remember, the homework directory we created earlier? Yep, ls will display that such a directory exists in our current location.

There are also other useful options that ls provides for example:

  • ls -l: Long format with detailed information (permissions, owner, size, date)
  • ls -a: Show all files, including hidden ones (those starting with .)
  • ls -h - Human-readable file sizes (KB, MB, GB)
  • ls -t - Sort by modification time, newest first
  • ls -R - Recursive listing of subdirectories

You can also combine options. For instance:

ls -lah

This shows all files (including hidden ones) in a detailed, human-readable format, a very common and practical command in daily use.

Changing Directories with cd#

The cd (Change Directory) command is how you navigate through the filesystem. It’s one of the most frequently used commands you’ll encounter.

Basic usage:

cd homework

This command moves you into the homework directory we created earlier.

Common patterns:

  • cd ~ or just cd: Go to your home directory
  • cd ..: Move up one directory level
  • cd ../..: Move up two directory levels
  • cd -: Return to the previous directory
  • cd /: Go to the root directory

Example workflow:

pwd                    # Shows: /home/poly
cd homework           # Navigate to homework directory
pwd                    # Shows: /home/poly/homework
cd ..                  # Go back to parent directory
pwd                    # Shows: /home/poly

Pro tip: Use Tab completion to speed up navigation. Type the first few letters of a directory name and press Tab to auto-complete.

Conclusion#

Now that we’ve covered the absolute basics of creating directories, changing directories and listing directories in Linux, you can experiment on your own and navigate through your Linux filesystem with confidence.

CommandPurposeExample Usage
pwdShow current directorypwd
mkdirCreate directorymkdir homework
lsList filesls -lah
cdChange directorycd homework

In the next guide, we’ll cover about basic text editors like nano and vi. We’ll also be introducing more shell commands like cat and cp to complement what we’ve learnt here.

alt text