Command Line – Essential Commands
Professional programmers love working in the command line, and these skills should not be missing from a programmer's toolbox.
Fortunately, working in the command line is not designed only for executing advanced commands, but also for running simple commands for basic operations.
To work in the command line, there are several methods.
In this tutorial, I will use PowerShell, a powerful and flexible environment provided by Windows.
To open PowerShell:
- 1. I right-click on the Start button in the taskbar (bottom-left corner of the screen).
- 2. From the menu that appears, I choose the Run option.
- 3. A window called “Run” opens. In the text box I type:
powershell
- 4. I press Enter or click OK.
This command will open the PowerShell window, where I can enter commands and interact directly with the operating system.

In this article, we show you how to execute commands such as changing the current directory, switching the storage drive, viewing the contents of a folder, creating and renaming folders, copying and deleting files and folders, as well as launching applications directly from the Command Line.
In the next module, I will show you how to install a local server, and we need to already be familiar with working in the command line.
When working in the command line, any command executed is applied to the current directory (current folder).
Anything we do on the computer in graphical mode–GUI (using the mouse), we can also do in the command line. It's practically another working method, using the same resources stored on the computer's hard disk.
After each command written in the terminal, the "Enter" key must be pressed.
To see which is the current directory we execute the command print working directory: pwd
pwd

How to Navigate Using the Terminal
To change the current directory, we execute the command change directory: cd + (directory name):
cd Desktop

Because I know there is another directory named "web-projects" on the Desktop, and I want to go there, I will change the directory again:
cd web-projects

Once inside the "web-projects" directory, I want to see what it contains. To list the contents of the current directory and possible directories we can navigate to, we execute the command list content of current directory: ls.
ls

We observe that in the web-projects directory, there are three other directories: project-1 project-2 project-3
To create a new directory, we execute the command: make directory: mkdir + (directory name). Then we execute the ls command again and observe that the project-4 directory has been created.
mkdir project-4

Now I would like to create a text file named test.txt in the current directory.
To create a new file, we execute the command: "" > + (filename.extension). Then we execute the ls command again and observe that the test.txt file has been created.
"" > test.txt

There is no "rename" command for renaming a directory or file, which may seem strange.
To rename a directory, we execute the command move: mv (current_name) (new_name).
mv project-4 project-renamed-4
To rename a file, we execute the command move: mv (current_name.extension) (new_name.extension).
mv test.txt renamed.txt

To make a copy of a file (we must also change its name), we execute the command copy: cp (filename.txt) (new_name.extension)
cp renamed.txt test.txt

To navigate one level up (into the parent folder of the current folder), we execute the command: cd ..

To navigate one level up, into another folder located in the parent folder, we execute the command: cd ../folder_name
For this, I will navigate back to the web-projects folder, then into the project-1 folder, and from there I will navigate into the project-2 folder and list its contents:
cd web-projects cd project-1 cd ../project-2 ls

To move a file from one folder to another, depending on the situation, we execute one of the move: mv commands:
- mv (file_to_move.extension) (..) – the file is moved into the parent directory (one level up);
- mv (file_to_move.extension) (target_folder_name) – we move a file into another folder;
- mv (file_to_move.extension) (../target_folder_name) – we move a file into another directory located at the same level as the current one.
mv file.txt .. mv file.txt project-2 mv file.txt ../project-1
To delete a file, we execute the command remove: rm filename.extension.
Warning! Deletion is permanent. The file is not moved to the recycle bin.
rm test.txt
To delete a folder, we execute the command rm -rf folder_name.
rm -rf project-4
To navigate faster through the directory structure, we can type:
cd Directory1/Directory2 – to reach Directory2
Arguments and Flags
Many programs allow specially formatted arguments, known as flags or options, which modify the default behavior.
Keeping the analogy with natural language, flags are adverbs, while other arguments are complements.
The ls command with the -l flag displays the contents of the directory along with many other details:
ls -l
The following command will also display hidden files (./ or ../):
ls -a ls ./ ls ../
The same can also be done like this:
ls -a -l or ls -la or ls -al
To list the contents of a folder (from the current directory) without navigating into that folder:
ls -la folder_name
If I want to list the contents of a file (for example, index.html), I will execute the command:
cat index.html

Putting everything together, we can copy a file from one directory to another, changing the name of that file, using one command and two relative paths (with arguments), like this:
cp (source-folder-name/file-name.extension(to copy)) (destination-folder/new-name.extension)
For example, to copy fisier.txt from the project-1 directory to the project-2 directory, renaming it to copy.txt, we will execute the command:
cp project-1/fisier.txt project-2/copy.txt
The TAB key can be used for autocompletion — type the first letter and then press TAB. It can be used to see which directory we are in and what navigation options are available.
Using the arrow keys, we can navigate through the command history.
With the help of: (cd ../) or (ls ../) and repeatedly pressing the TAB key, all navigation possibilities will be displayed.
For now, this is enough. We've seen some of the most commonly used commands. Now create a folder structure and practice the commands above to memorize them. It's good to know that there are many other commands which you will use very rarely or never. You can find all available commands with a simple Internet search.