This content originally appeared on DEV Community and was authored by Pirci
If you want to get into web development, knowing what the Terminal is and how to use it is very beneficial. But there are some essential commands that we'll go over, so we feel comfortable using it.
In today's article, we will be going over the 10 need to know Mac Terminal commands - #10 is a fun one! 🙂
What is the Terminal?
The Terminal. So what is it?
The most basic use of the Terminal is being able to navigate throughout your computer's folders and files.
There are commands that you can run inside the Terminal that can create a new ReactJS application, install a new npm package, and so on, but we are not going to discuss those in this article.
Let's focus on the basic commands when navigating your computer using the Terminal.
pwd
The command, pwd
, stands for "Print Working Directory." Essentially, you type in that command, and it will spit out the exact file path for the file or folder you are in.
cd
This stands for "change directory" or, in simpler terms, change which folder we are in.
When using the command, cd, we can tell it which way to move by adding more to the command.
cd
or cd ~
- Takes us to the home directory.
cd <folder name>
- Takes us forward one step to the folder that is typed in.
cd ..
- Moves us back one level to the parent folder.
cd ../..
- Moves us back two levels. Add more /..
for each level we want to navigate up.
ls
Now that we are in a folder, we might want to see what is in that folder. When running the command, ls
, it will show us everything in that folder.
clear
This command does exactly what it sounds like; it "clears" your terminal out. Sometimes a clean slate is easier when trying to focus.
mkdir
If we were to right-click directly onto our Desktop view, that little menu would pop up, we could click on "New Folder", and then a brand new folder would pop up for us to name. This command does that same functionality.
mkdir
stands for "Make Directory" or simply, make a new folder.
Wherever this command is ran from, it will create the new folder in that spot. So navigate to the desired location using cd
commands, and then type in mkdir <folder name>.
To get into that new folder, we would run the command: cd <folder name>.
touch
Now that we know how to create a folder let's create some files within that folder. If we followed the commands above:
mkdir new-folder
cd new-folder
We should now be in the "new-folder" directory/folder. Let's create a file within that folder. By running the following command, that would create a file:
touch new-file
- this has no extension, so we would want to add .html, .txt,
or whichever extension needed.
open
Open a file or folder by typing in the command:
open <folder/file name>
history
Want to know all the commands that have been ran in the current terminal session? Run the command, history
to see them.
Another trick! Use the "up" and "down" arrows to navigate through previous commands.
cat
This command allows us to see the contents of a particular file. We would need to declare the particular file for this command to work.
If we know the path of to the file, we could run:
cat /Desktop/new-folder/new-file
Or we could navigate from our home folder to new-folder
and then run the command.
cd Desktop
cd new-folder
cat new-file
say
This one is a fun one. Not necessary for navigation, but it makes your computer SPEAK to you!
Type in: say "anything here"
and your computer will say that. Don't forget the quotes in this command!
If you like the article, do not forget to follow for future articles.You can also share it with your friends who you think will like it.Please feel free to comment!
This content originally appeared on DEV Community and was authored by Pirci
Pirci | Sciencx (2022-02-08T13:21:01+00:00) 10 Need to Know Mac Terminal Commands. Retrieved from https://www.scien.cx/2022/02/08/10-need-to-know-mac-terminal-commands/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.