Simple console commands that everyone should know

Terminal skills help to be more productive.


Every modern developer is trying to improve and be more productive. The terminal is a tool that allows you to work faster. Instead of clicking with the mouse to move around the graphical interface, you can just do the same work in the terminal, but much faster. Although, this will require some knowledge of the console commands that you can use.

This article is for those who would like to learn console command ninjutsu, but so far have no significant experience with the command line. Well, for those who just want to know more and better understand the wide range of commands available in the terminal, something new will suddenly come across.

Immediately move on to the list of console commands, which I hope will make developers a little easier and improve productivity.

List of basic commands:


pwd - directory information
cd - directory change
ls - list of files in the directory
cp & mv - copy / move file / directory
mkdir & touch - create directory / file
rmdir & rm - delete directory / file
cat, tail & head - read
grep file - search for text in a file by regular expression
find - search for file / directory
EDISON Software - web-development
This article has been translated with the support of EDISON.

We program servers , both managed through the console, and having a convenient user interface .

We love working with interfaces! ;-)

1.pwd ⇑ β†’


The pwd command gives some context about the current working directory. pwd is short for p rint w orking d irectory i.e. print the working directory . The result of the command is the full system path for the current directory.


Although pwd does not have as many parameters as most other commands (since it is quite simple), it can be used to ignore symbolic links. To do this, pass the -P option .

This is one of the most commonly used commands along with the next two commands on this list.

2.cd ← ⇑ β†’


Another commonly used command is cd . cd is short for c hange d irectory , i.e. change of directory. As the name suggests, it allows you to change the current working directory.


It is also possible to move to several levels at once. To do this, specify the full path to the directory to which you need to go.

In this example, we go to the project folder, which is located inside the "Downloads" folder:


To move to the parent folder, you must use two points .. . In the following example, we go to the project folder, which is located in the "Downloads" folder. When you run cd .. you will see that the current working directory changes to the specified folder.


I think you noticed that I used tilde ~ quite often in the previous examples. This is the home directory. It's funny, but you can see the physical path to the ~ folder using the two commands that you have already examined.



3. ls ← ⇑ β†’


The next command is ls , short for l i s t , i.e. the list . It lists all the files in the directory. You can also specify a directory to get a list of files in it. If no directory is specified, the current working directory is used.


Please note that there are some very useful options with which you can extract even more valuable information. The -a option , for example. This option allows you to see hidden files in the list (whose names begin with a dot). The -l option produces a long list, which, among other things, indicates file sizes and permissions.

Options can be combined:

ls -al

4. cp & mv ← ⇑ β†’


The cp command comes from the word c o p y , i.e. copying . Allows you to copy files and directories. The first specified file / directory is the source (which we copy), in second place - the destination (where we copy). In the following example, we move the image to the Downloads folder.


When copying a directory, you can use the -R option to recursively copy (that is, along with subfolders). Please note that hidden files will also be copied.

There are quite a few variations on how to copy files and directories. For example, it is possible to copy only files with a specific extension. In the following example, all files with the jpg extension are copied to the Downloads folder.


In addition to the cp command, there is also the mv command , which stands for m o v e , i.e. moving . This command is used to move files and directories. Works in general the same way as cp . However, there are differences. For example, the mv command does not come with the -R option .

To examine all the options available for the mv command , simply type:

man mv

5. mkdir & touch ← ⇑ β†’


To create a directory, you can use the mkdir command , which stands for m a k e dir ectory , i.e. creating a directory . This command requires a required argument: the name of the new directory. Check if the command was successful, you can use ls , discussed above.


Creating a file is as easy as creating a directory. Instead of mkdir, you need to use the touch command to create a new file.


You should be aware that the newly created file will be empty. And again, if you want to check whether the command was successful, use the ls command .

6. rmdir & rm ← ⇑ β†’


Just as there are two different commands for creating files and directories, there are also two separate commands when it comes to deleting files and directories.

To delete a directory, you can use the rmdir command , which is short for r e m ove dir ectory , i.e. directory removal . Keep in mind - the command deletes only empty directories.


More powerful is the rm command . As you probably guessed, this is a reduction from r e m ove , i.e. removal. The rm command deletes each specified file. Although directories can also be deleted with this command, by default it does not.


When rm is run with the -r option , the corresponding directories, their subdirectories, and all the files that are contained there are recursively deleted.

To ignore non-existent files and never ask for confirmation of their removal, you can use the -f option .



7. cat, tail & head ← ⇑ β†’


When it comes to reading the contents of a file, there are several options. The first is the cat command , short for con cat enate , i.e. concatenation . Although the command can be used for different purposes, one of the things it can do is show the contents of the file.



Please note: the entire file is displayed. There are also cases where you only need the first or last X lines of a file. To do this, use the tail and head commands . tail prints the last 10 lines of the file, while head prints the first 10 lines.


Using the -n option , you can specify how many lines to print. Here is an example with tail , for head it works exactly the same.



8. grep ← ⇑ β†’


The grep command is short for g lobal r egular e xpression p rint , i.e. global regex output. Used to search for text. The file will be scanned for the information you want to receive, and the result will be presented in the specified format.

Let's start with a very simple example. There is a file containing the names of all countries. We want to check whether there is a word of Netherlands Netherlands ( Netherlands ) in the list. Note that grep is case sensitive by default .

The first argument passed is the word we are looking for. And the second is the file in which we will search.


For case insensitive searches, use the -i option . In the following example, there is BeL and bel and BEL .


Please note that in the above examples it can be seen that grep displays the entire string matching the pattern in the terminal. To limit the number of matching lines, use the -c option .



9. find ← ⇑


The last team to date - the find ( search ), allows you to quickly find the file or directory. Suppose you need all the CSS files in the current directory. We could get their list using the find command .


Note that the find command searches in subfolders as well.





Now that we have gone through the whole list, I hope that you have deepened your knowledge for working with the terminal. Maybe something will come in handy for you, or even find out for yourself about a new team or an option to it.

If you think that there is no team in this list or you just have a great addition to this list, please let me know.

Thank you for the attention!

Technical translations on Edison's blog:


All Articles