Working with computers or programming is more than having the brains to come up with code and programs. You'll notice more than one coding instructor going backspace letter by letter to fix a typo, or someone dragging their mouse from the top of the document until the bottom to select everything (just press Ctrl+A
for the love of Shia Labeouf, just do it). I have found out that using the mouse incredibly hinders your speed and makes us think more than twice even the most simplest of decisions.
I would like to teach you a set of skills that will improve your speed and performance and help you be anywhere as cool as this guy:
Disclaimer: This guide is meant to work on Windows with WSL (Windows Subsystem for Linux), any Linux distro and MacOS.
distro
means distributable, and its just a tailored version of Linux for certain specific needs. For example, Red Hat is the enterprise version, Mint is a general customizable build, and Raspbian is optimized for Raspberry PIs.
I recommend Ubuntu 20.04 since it's user friendly and has a lot of support.
Think of your terminal as the manual way to operate your computer without a graphic interface. Everything can be controlled via keyboard, you just have to know how to access what you need.
Typing is the Hackerman way.
Ergo, lesson 1: Learn them hotkeys.
Now, how can I navigate around if I can't see anything or don't have anything to click?
The first command you'll enter will be pwd
.
$ pwd
/user/kweizar
This is a path, it's the address that leads to your Present Working Directory on the computer's file system. Paths are case sensitive, so mind what you type.
You can move between directories by using the cd path
command, cd stands for Change Directory.
There are many options you can pass as the cd command argument.
$ cd
/ : go to the root directory of your system.
.. : go to the parent directory // /user in this case
/user/kweizar/photos : an absolute path.
~/photos
// or } these two are relative paths.
./photos
More on absolute and relative paths later on.
Assume you are on the D/ folder, invoking
cd ..
would take you to C/,cd ~
would take you to A/ since it's assigned as your home directory.
The commandcd /
would take you to the root folder and invokingcd .
wouldn't do anything since you'd be navigating to the same folder.
This concludes the Navigation part, we're now able to go to any directory we require.
It's important to note that everything on your computer are files. These follow a parent/child hierarchy starting from root (/) and keep branching out like a tree.
Directories are files too; they possess extra metadata that greets them their "folder" properties.
Tip: File extensions are actually not required, they just help the OS associate the program that's meant to open that specific type of file.
Now, we'll want to get some Information of our surroundings. Let's use the ls
command to list the content of the current directory
$ ls
photos/
documents/
main.go
calculator
Our terminal prints out all of the files in /user/kweizar
We can also combine the command with a path and check remotely the content of that directory.
$ ls ./photos/event/
photo1.jpg
photo2.jpg
Wait, what the heck is .
? This is an alias that represents the directory you're currently at. There are others like ..
which as mentioned above, goes to the parent directory.
We printed out information that's already irrelevant to us, let's clear the screen out for less clutter. You can type clear
or press ctrl + L
and reset your console prompt screen.
đŸª§ To open the console's manual use the
man man
command. It will contain the instructions to open the multiple sections of the manual.
This contains information for the shell commands (like ls, cd, etc.), system calls, the C and C++ libraries and their specifications, and many others. Combineman
with other commands to get their specific manual pages.
Always refer to this guide first when you need thorough documentation.
Once you start building a project, you're going to have to create files and folders.
To create a file, use the touch
command. This will create a blank file with the specified name.
To create a folder, use the mkdir
command.
đŸ“¢ Avoid using spaces in names, preferably use a naming format system like camelCase or snake_case and stick to it!
You will combine 99% of the commands with a filepath. I will introduce two news pattern for commands though, take for example the cp
command.
// Pattern 1:
// command source_path destination_path
$ cp ./photos/event/photo1.jpg .
You guessed correctly, cp is the copy command. Now a copy photo1.jpg exists in my current directory.
You can also move files with mv, this is also the command to rename a file, just specify the new name at the destination path!
$ mv ./photos/event/photo1.jpg ./movedpicture.jpg
now photo1.jpg will be moved and renamed to my current directory as movedpicture.jpg
I'll use the mkdir
command for our second pattern.
// Pattern 2:
// command destination_path1 destination_path2 destination_path3 ...
$ mkdir music videos pictures
This will create three separate folders called music, videos and pictures.
We've learned enough for today, in no time you will be speedily hacking into any mainframe.
Takeaway:
-Use the keyboard!
-Learn the shortcuts.
Information commands:
-pwd
-ls
-man
Navigation:
-cd
File Management:
-touch
-mkdir
-mv
-cp
-Command Patterns
-Aliases
This is my first part of the How to be a Hackerman
series. I hope to cover more themes like programs, Vim, Bash Scripts, Piping, Regex, more hotkeys and tips to control your shell, your editor and your OS.
Thanks for reading and let me know if you'd like me to expand on an topic of your interest.
Top comments (3)
Very helpful article, shared!
Good article! This is a really important skill to master if you want to expand your career into AWS, GCP or Azure since most of the time you will be using a virtual terminal over the net.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.