Subscribe to our free newsletter

To make sure you won't miss any valuable content we share with our community.

Top 15 commands every developer must know

If you are a newbie developer or you are not sure if you know all the useful commands that will help you navigate through directories or work faster, this tutorial is for you! In this tutorial, we will see how we can navigate through the directories, create files and folders, open files, remove them or apply any other kind of manipulation by just writing one phrase or two as a command in the terminal. Terminal is not the only term that developers call when referring to the window where you enter the commands. Console, terminal, command line interface, command window, command prompt, shell, etc are all the names that can refer to a terminal depending on which operating system the user is working on. Follow along with tutorial and we will show you how these commands will make your life easier and faster as developer. Not to mention that if you use them quite often in the workplace, everyone will notice you as a pro! Notice that the default operating system that we use for this tutorial is Linux, but most of commands could be used in other operating systems as well.

What is FHS?

In nearly all the Linux based operating systems, we have the universal standard for File-system standard for directory structure known as the Filesystem Hierarchy Standard (FHS). The FHS defines a set of directories, each of which serve their own special function. The forward slash (/) is used to indicate the root directory in the filesystem hierarchy defined by the FHS. When a user logs in to the shell, they are brought to their own user directory, stored within /home/. This is referred to as the user’s home directory. The FHS defines /home/ as containing the home directories for regular users. The root user has its own home directory specified by the FHS: /root/. Note that / is referred to as the “root directory”, and that it is different from root/, which is stored within /. Since the FHS is the default filesystem layout on Linux machines, and each directory within it is included to serve a specific purpose, it simplifies the process of organizing files by their function.

What Are the navigation commands?

In most operating systems such as Linux, filesystems are based on a directory tree. This means that you can create directories (which are functionally identical to folders found in other operating systems) inside other directories, and files can exist in any directory. The first command that we will work with is pwd. To see what directory you are currently active in you can run the pwd command, which stands for “print working directory”:

What Are the navigation commands?

In most operating systems such as Linux, filesystems are based on a directory tree. This means that you can create directories (which are functionally identical to folders found in other operating systems) inside other directories, and files can exist in any directory. The first command that we will work with is pwd. To see what directory you are currently active in you can run the pwd command, which stands for “print working directory”: pwd Result: /home/mohamad As you can see the command shows the directory that you are in. On Linux, all the directories are rooted in home, meaning that the main directory is home and then every other directories are a part of it. This example output indicates that the current active directory is Mohamad which is inside the home/ directory, which lives in the root directory, /. As mentioned previously, since the Mohamad / directory is stored within the home/ directory, sammy/ represents the Mohamad user’s home directory. Now, if you want to see the list of the directories ( folders ) and files inside the current active directory, you can use ls command: ls This will return a list of the names of any files or directories held in your current working directory. If you’re following this guide and have just installed your operating system, though, this command may not return any output, because you have no folder or file in it. You can create one or more directories using the mkdir command. This command stands for make a directory and using it, you can create one or more that one folder or directory inside of your current active directory. mkdir Project1 Project2 This will create two folders with the names Project1 and Project2. If you enter one name, it will only create one folder or directory. Now, let’s check if the new directory exist by listing the contents of the current directory: ls Result: Project1 Project2 Now, If you want to enter one of these directories, you can use the cd command which stands for change directory: cd Project1 You can also enter any directory regardless of the current active directory: cd /home/Mohamad/Project1 And if you want to exit the directory to a level higher, for instance if you want to return to Mohamad, you can enter the following command: cd .. And you will get back to where you had been before entering the cd command.

What Are the File Manipulation commands?

Up to here, we have worked with navigation commands to create folders and change the directories. Now, we want to see how we can manipulate files. These files could be any type file such as a python or JavaScript file format or just a simple .txt file for writing text in it. The first command we will use, is touch. We use it for creating a new file. touch Script.py This will create a python file where you can write your own python scripts. If you want to rename it, you can use the mv command: mv Script.py NewScript.py And the name will change to NewScript.py. Now, if you would like to copy the files you can use the cp command: cp Script.py CopyOfScript.py Also, consider that you can open the file using the nano command: nano script.py There are other editors like VSCode. If you are on a VSCode terminal, you can use: code . The code . command will open up all of the files of the current active directory and show the list of them on the left hand side bar. Now, if you want to show the contents of the code inside of the terminal, you can use the cat command: cat Script.py The less command will do the same in a different manner: less Script.py If you want to remove a file, you can use rm command: rm Script.py And if you want to remove an empty directory you can use: rm -d Project1 You can also use the following command instead: rmdir Project1 And if the directory is not empty, you can use the following command: rm -r Project1 In the end if you are looking for a manual of a certain command, you can use the man command: man NameOfTheCommand This will give the manual of the command that you are looking for and help you use it in the way that you like.

Conclusion

In this tutorial, we have become familiar with the different commands we can use on Linux ( or other operating systems ) in order to interact with the directories and the files. These commands will help you quickly create or delete files, rename them, copy, and open them. Also there were commands that would create folders, remove them, and open them. These commands will make your life easier and faster as a developer. Also, if you get used to apply them instead of manually do those actions, you will look more like pro and a senior developer.

Download this Article in PDF format

3d websites

Arashtad Custom Services

In Arashtad, we have gathered a professional team of developers who are working in fields such as 3D websites, 3D games, metaverses, and other types of WebGL and 3D applications as well as blockchain developemnet.

Arashtad Serivces
Drop us a message and tell us about your ideas.
Fill in the Form
Blockchain Development