Common Commands (ls, cd, pwd)

2 minute read

Ahoy, brave Bash script navigator! As you set sail on the command line seas, let’s expand your arsenal beyond the trusty ls, cd, pwd, mkdir, touch, and rm. Brace yourself for a more comprehensive guide to conquer the Bash seas.

ls - Charting the Waters

As a reminder, ls remains your compass, unveiling the treasures hidden within directories. Let’s delve deeper into its capabilities.

Additional Options

  • -R: Uncover the secrets of subdirectories with a recursive listing.

    ls -R
  • --color: Add a splash of color to distinguish between file types.

    ls --color

cd - Navigating with Finesse

The cd ship’s wheel is versatile. Expand your navigation skills with additional tricks.

Additional Usages

  • cd /: Sail directly to the root directory.

    cd /
  • cd -: Return to the previous directory you sailed from.

    cd -

pwd - Triangulating Your Position

The navigator’s sextant, pwd, helps you maintain situational awareness. Explore more of its capabilities.

Additional Options

  • -P: Print the physical directory, excluding symbolic links.

    pwd -P
  • -L: Include symbolic links in the printed path.

    pwd -L

mkdir - Forging New Paths

When uncharted territories beckon, the mkdir command carves out new paths.


Create a new directory named “island_of_dreams”:

mkdir island_of_dreams

touch - Crafting Treasures

The touch command crafts files, turning your coding dreams into reality.


Create a new file named “hidden_treasure.txt”:

touch hidden_treasure.txt

rm - Conquering Obstacles

The rm command, or “Remove,” helps you conquer obstacles by annihilating files.


Remove the file named “unwanted.txt”:

rm unwanted.txt

Caution: Use with care, as this command is irreversible.

cp - Duplicating Scrolls

The cp command, or “Copy,” enables you to duplicate files and directories, creating copies of your precious scrolls.


Create a copy of “map.txt” and name it “map_backup.txt”:

cp map.txt map_backup.txt

mv - Shifting Tides

The mv command, or “Move,” allows you to shift files and directories, orchestrating a graceful dance across the command line seas.


Move the file “treasure_chest.jpg” to the “island_of_dreams” directory:

mv treasure_chest.jpg island_of_dreams/

cat - Reading the Scrolls

The cat command, or “Concatenate,” unveils the content of files, allowing you to read the ancient scrolls of code.


Display the content of the file “adventure_log.txt”:

cat adventure_log.txt

grep - Searching for Lore

The grep command searches for specific patterns within files, helping you uncover hidden lore in the vast expanse of your scripts.


Search for the term “dragon” in the file “fantasy_story.txt”:

grep "dragon" fantasy_story.txt

chmod - Fortifying Defenses

The chmod command, or “Change Mode,” fortifies file permissions, ensuring that only the worthy can access your guarded treasures.


Grant read, write, and execute permissions to the owner of the file “”:

chmod u+rwx


With ls, cd, pwd, mkdir, touch, rm, cp, mv, cat, and grep at your command, you’ve become a seasoned navigator, adept at creating, manipulating, and searching through the command line seas. As you continue your odyssey, may these commands empower you to navigate, explore, and safeguard your digital treasures. Onward, fearless explorer, to new horizons in the realm of Bash scripting!