Some of us feel stressed when it is about to work with a terminal. However, learning how to use command line is worth every penny. Developers who understand the command line would claim that this is one of the best tools at our disposal. Let's see some important commands!
pwd
commandThis command stands for print working directory. It shows us which directory we are currently located at.
ls
commandIt gives a list of the contents of our current directory.
cd
commandWe use it for navigating between directories and folders. We type cd <name of folder>
to go into the specific folder. We can check with pwd
whether we are in the right folder.
If we want to go back to the previous directory, we type cd ..
into terminal.
If we want to go to the root directory, we use cd /
.
cp
commandIt stands for copy files. We can make a copy of a file if we type cp <name of file>
<new name of file>
. As the image below shows, there is a new file in the directory after using
cp
command.
We can copy files and immediately place them into another directory with giving cp
<name of file> <path to directory>
. Our example shows that the copy is in the other
directory.
rm
commandIt is used for removing or deleting files. As the example below shows, by using rm
command
Slack_introduction2.png has been deleted from the directory.
We can also delete a non-empty folder by using rm -r <name of folder>
command.
touch
commandWe can create files by using touch
command. To do this, we need to type touch <name
of new file>
.
mv
commandWe can move our files to other directories by typing mv <name of file> <path to
directory>
.
mkdir
commandWe use this command to create new folders. When we type mkdir
<name of new folder>
, it creates an empty folder in the current directory.
rmdir
commandThis command deletes only empty folders. As we can see, our example shows that TestFolder is not located in WebSystem anymore; it has been deleted.
clear
commandIt clears the screen of the terminal.
man
commandIt stands for manuals. If we want to know more about a command, we can use this command to help us. We
type man
<name of command>
, and the terminal will give us a detailed description about the searched
command.