DEV Community

Cover image for [1/4] Beginners BASH basics - becoming one with the shell
Hayden Rouille
Hayden Rouille

Posted on • Updated on

[1/4] Beginners BASH basics - becoming one with the shell

Part 1 of a 4 part series

View part 2 here and part 3 here

When I first started using the command line it seemed quite daunting to me. I didn't know what I should know and I didn't know what benefits investing time into learning more would give me. My job required me to learn more Ruby, so why learn bash?

bash who?

I have since learnt that having knowledge of just some basic commands improves your workflow tenfold, and for me in particular increased my confidence when sshing to a server or even just having to navigate around my own environment.

By the end of this series I hope you'll feel at home when navigating the command line and won't feel a need to use the file manager GUI again!

Here are some of my most commonly used commands:


man provides you with the manual documentation for a utility. Use man the same way you would when using programming documentation - it will tell you all the available flags for a command and what it can be used for. The main source of truth when questioning how to use a tool!

Example usage: man ls (use q to exit)

Equally, you could also use info ls to view this information too.


ls will list the files in your cwd (current working directory).

If you use man ls, you can see that ls offers many flags. The most common usage however, are (in my opinion) lah. Executing ls -lah will give you a list of all files in your CWD (current working directory) including hidden (.files), with their file-sizes, permissions and dates when they were updated.

Example usage: ls -lah

You can then use the file command on a file to view the details of it!


cat will spit the contents of a file out to the command line.

Example usage: cat myfile


mkdir creates a directory at the specified location. As with ls, mkdir has many useful flags that you can see in the manual. The most notable being -p, which will recursively create the directories as specified.

Example usage: mkdir -p ~/my_directory/my_subdirectory


rm is used to remove a file or directory.
Warning: paired with sudo, or even on it's own, this can be a very dangerous command if used incorrectly.

You may want to use the following flags:
-r for recursive
-v for verbose (it will give feedback to what is happening)
-f for force

Example usage: rm -rvf ~/asd


grep will allow you to search for specific content from a file or result list.

Example usage: grep 'my_search', you will see all the lines containing my_search within

You can view lines around them by using the -C 3, or get all lines not containing the match with -v.


sudo will execute the following command as a superuser. You'll often need to use sudo to run certain commands, for instance commands that will affect the system.

Example usage: sudo systemctl status mysql


And that's it for part 1 of my beginners bash series! If all of the above is below you... stay tuned for some more advanced tips!

Dive into curl, chmod and more in Part 2 - here

Feel free to ask any questions or if you're interested in how I've customised my environment, head over to my repository below.

GitHub logo haydenrou / dotfiles

i3, Vim, Bash, Ruby, Typescript & React, Elixir, Golang & more!

Top comments (11)

jcolombo profile image
Juan Colombo

Great!,now I'm Hackerman.

webreflection profile image
Andrea Giammarchi

(use q to exit)

if there's something worth a meme, is people trapped inside less, vim, etc ... where q is for quit, or at least that's how I used to remember how to exit.

(use q to quit/exit) is what I'd write, as it's the most common key to quit many programs ;-)

hayden profile image
Hayden Rouille

Very true, a missed meme opportunity!

hayden profile image
Hayden Rouille

Absolutely, they'll be coming up soon. Thanks!

fennecdjay profile image
Jérémie Astor

Thank you. Can I suggest you add info?
Things like info gcc we're a game changer when I found this command.

hayden profile image
Hayden Rouille

Sure! I chose man because it's more widely known, but I'll add info below.

bohyun611kim profile image

Absolutely Coooooool~

maxart2501 profile image
Massimo Artizzu

I'm a simple person.
I see a Kung Fury reference, I click on ❤️.

jpalala profile image
jose palala

For beginners, is also really useful :) It's like man pages but more succinct!

hayden profile image
Hayden Rouille

That's a cool package, I'll have to try it out myself!