10 Basic Mac Terminal/Linux commands
(in my experience)
Welcome to my blog, dude! 😆
Today, we're going to take a look at some basic Mac Terminal/Linux commands in my experience.
So, don't roast me friends😅 I'm a n00b at this stuff, so I haven't used shit like
Without further ado, let's get fuckin started!!
✨ Contents ✨
You can use the
pwd command to find out your current location in the filesystem/name of the folder currently open in your terminal window.
The output of
pwd will look something like this:
After executing the
pwd command, the terminal tells us that we're in the folder called
Yuri inside of the folder
Users at root.
ls command is used to list all the folders/files under the location specified, or if not specified, under the current location.
Here, we're listing all the directories/files inside
Also, we can add options/flags to our
ls command, such as:
-l is the lowercase letter L, and it stands for long. It lists all contents in a long list format.
Here, terminal will output more information about the listed files when we use the
This is out the scope of this article, but the long format shows information, such as, permissions, file owner, file size, date, etc.
a stands for 'all'. The
ls -a command lists the all of the files inside the current folder/directory, including hidden files.
The photo below shows all of the files inside the
As you saw on the photo above, there's a full-stop (period) at the beginning of certain files. Filenames with a full-stop at the beginning are hidden files.
You can put options/flags together:
This will produce the same result as doing each option alone, as we saw above.
However, combining two options/flags together outputs both results:
On the photo above, terminal output a long list format with additional information for both regular files and hidden files.
mkdir command stands for 'make directory'. This creates a new folder on your current location (current directory).
mkdir command with the name of the new file you want to create:
On the photo above, we made a new directory called
for_twitter, then we checked if it was created by using the
You can also make multiple directories. If you want to add spaces in directory name, write between quotation marks:
cd command stands for 'change directory'. This allows you to change your current location (current directory) to another directory.
You use the
cd command alongside the other file/directory name you want to change to.
Here, we changed from the
~ directory to the
touch command creates a new empty file.
touch with the new name of the new file.
Check the terminal below:
There's a couple things going on in this image, let me walk you through it:
On the photo above, we change from the
~ directory to the
for_twitter directory. Then, we created a new HTML file inside. Finally, we verify what's inside the
for_twitter directory with the
rm command stands for 'remove'.
rm removes a FILE from the system completely.
For example, check out the photo below:
On the photo above, we're listing the contents inside the
for_twitter directory, and we see that there's the
index.html file. Then, we remove the
index.html file with the
When we check the contents of
for_twitter once again, we see that the
index.html file is gone.
rmdir command stands for 'remove directory', and you guessed it, It removes an empty directory. It's very similar to the
rm command. You type the name of the directory/folder you want to remove after the
rmdir command and press enter.
Also, you can quickly delete a folder/directory and its contents within with the
rm -rf command.
-rf stands for 'recursively' &
f stands for 'force.
So, be VERY careful with this command, as it's forcing deletion. Using this wrongly can cause system damage.
The example below removes
dir1 and all of its contents without any warning.
cp command stands for 'copy', and it copies a file from one location to another.
cp with the name of the file you want to copy, then the name of the new file.
If you want to copy a directory/folder, use the
-R option/flag as well.
On the example below, we copy the
for_twitter directory into a new directory/folder called
mv command stands for 'move'. The
mv command moves a file to another directory/folder, or (if directory name doesn't exist), it renames the file.
Check this photo below: we moved the
index.html file inside the folder
On the photo above, we first listed all the content inside the
~ using the
Then, we moved the
index.html file inside the
dir2 folder. We do this by using the
mv command followed by the name of the html file we wanted to move, in this case, the
index.html file, followed by the new location, in this case,
When we check the contents of
dir2, we can see that we successfully moved the
index.html file inside.
man command stands for 'manual'. It displays all the information about commands that we can run on the terminal. Also, it shows all options/flags you can use.
Below, I typed
man ls, and terminal shows me the manual of the
sudo command allows you to run programs with admin privileges. You'll be required to enter your personal password to execute these commands.
We're done! 🥳 🎉
You're probably tired AF reading this long ass post, but at least, you learned the 10 most basic terminal/Linux commands!
So that's it! Thank you for making it through this long ass post😆