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
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!
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)
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.
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.
mkdir creates a directory at the specified location. As with
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.
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
rm -rvf ~/asd
grep will allow you to search for specific content from a file or result list.
grep 'my_search' test.md, you will see all the lines containing
You can view lines around them by using the
-C 3, or get all lines not containing the match with
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.
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!
Feel free to ask any questions or if you're interested in how I've customised my environment, head over to my repository below.