DEV Community

Cover image for Shell We Begin? Discover the Power of the Command Line
Jimmy McBride
Jimmy McBride Subscriber

Posted on • Updated on • Originally published at jimmymcbride.dev

Shell We Begin? Discover the Power of the Command Line

Alright, let’s talk about the command line, or what some like to call the shell. If you’re like most developers, you've probably dabbled in the terminal a bit—navigating directories, running a few commands here and there. But what if I told you that this "text-based interface" can actually become one of your most powerful tools?

I’m not exaggerating. Learning the command line isn't just about looking cool in front of your peers (though that’s definitely a bonus 😎). It’s about efficiency, automation, and really understanding what’s happening under the hood of your system. You stop relying on GUIs, and instead, you get to tell your machine exactly what to do—without all the hand-holding.

Why Bother with the Shell?

Let’s be real—when you’re used to point-and-click interfaces, the shell might seem like overkill. But once you start grasping its power, the game changes completely. Here’s why:

  1. Efficiency: When you know the right commands, you can perform tasks way faster than with a mouse. Need to rename 100 files? No problem, that’s one command away.

  2. Control: The shell gives you fine-grained control over your system. You’re no longer just clicking through menus—you’re sending precise instructions.

  3. Automation: If there’s one thing the shell excels at, it’s automation. Tasks that would normally take hours (or worse, be painfully repetitive) can be handled with a single script.

  4. Remote Access: GUIs are great... until you need to access a server halfway across the world. The shell lets you connect to and manage remote systems as if you were sitting right in front of them.

  5. It Makes You a Better Developer: Yeah, I said it. The shell is a direct link between you and the guts of your machine. Understanding how to use it gives you deeper insight into how software really works. It’s a game-changer, especially if you’re into development or systems administration.

Navigating the Shell

Before we dive into more advanced shell wizardry, let’s start with the basics: navigation. Trust me, once you’ve mastered the fundamental commands, everything else gets way easier.

1. Listing Files and Directories (ls)

Want to see what’s in the directory you’re currently in? ls is your friend:

ls
Enter fullscreen mode Exit fullscreen mode

If you want a little more detail (file permissions, sizes, etc.), you can run:

ls -l
Enter fullscreen mode Exit fullscreen mode

And if you want to see hidden files:

ls -a
Enter fullscreen mode Exit fullscreen mode

2. Moving Around Directories (cd)

Navigating between directories is something you’ll be doing constantly in the shell. The cd command is how you move around.

To change to the directory called "projects":

cd projects
Enter fullscreen mode Exit fullscreen mode

To go back to the previous directory:

cd ..
Enter fullscreen mode Exit fullscreen mode

Want to go straight to your home directory? Just use:

cd ~
Enter fullscreen mode Exit fullscreen mode

3. Knowing Where You Are (pwd)

Sometimes it’s easy to get lost in the maze of directories. If you ever need to know where you are, pwd (print working directory) will remind you:

pwd
Enter fullscreen mode Exit fullscreen mode

4. Creating Directories (mkdir)

If you need to create a new directory, mkdir is your go-to:

mkdir new_folder
Enter fullscreen mode Exit fullscreen mode

Need to create multiple directories at once? Easy:

mkdir -p projects/new_folder/subfolder
Enter fullscreen mode Exit fullscreen mode

This command creates all the necessary directories in one go.

5. Moving, Copying, and Deleting Files (mv, cp, rm)

Let’s say you need to move, copy, or delete files:

  • Move a file from one location to another:
  mv file.txt new_location/
Enter fullscreen mode Exit fullscreen mode
  • Copy a file:
  cp file.txt new_copy.txt
Enter fullscreen mode Exit fullscreen mode
  • Delete a file (careful with this one):
  rm file.txt
Enter fullscreen mode Exit fullscreen mode

And here’s where we get into some dangerous territory. If you need to delete a directory that isn’t empty, you’ll use:

rm -rf folder_name
Enter fullscreen mode Exit fullscreen mode

But BE CAREFUL! The rm command deletes files permanently. There’s no trash bin—once it’s gone, it’s gone forever. It’s a permanent change, so triple-check before hitting Enter. This command is powerful, but use it wisely!


Start Small, Aim Big

At this point, you might be thinking, “Yeah, okay, I get it, but this seems pretty basic.” That’s the point! You can’t master shell wizardry overnight. Start with the basics. Get comfortable moving around, creating files, deleting things (carefully!). Once you’ve got these basics down, we’ll start diving into the deeper stuff—automation, scripting, and building your very own tools.

This is just the beginning. Soon, you’ll stop looking at the shell as a hassle and start seeing it as the magical tool it really is.

Next Up: I’ll be breaking down the core commands you’ll use daily and how to combine them like a pro. We’ll make the terminal work for you.


If you enjoyed this post and want more content on Linux, scripting, and app building, check out my website and connect with me on LinkedIn. Also, join my **Discord* for more discussions with like-minded shell wizards! Click here to join!*

Top comments (2)

Collapse
 
pengeszikra profile image
Peter Vivo

rm -rf ./node_modules - are so common in my workflow
vi ~/.bashrc - VIM will be your favorite editor when nothing are left.
z foo-work - zoxide a smart cd replacer

Collapse
 
jimmymcbride profile image
Jimmy McBride

Do you have any alias for these commands. I personally have alias zshrc="nvim ~/.zshrc" so that I can pull up my config from anywhere and make quick changes.

Then I use alias reload="source ~/.zshrc && clear" to refresh the terminal with the new config changes. Silky smooth!