The command line, or CLI, is a powerful tool that provides direct access to the core functionalities of your operating system. While graphical interfaces are widely used, understanding the command line and its basic usage is essential for quickly navigating file systems, managing source control, and running programs.
For this section, GitBash will be used as the command line interface. GitBash is a command line interface that is included with Git for Windows. It is a Bash shell emulator that provides a Linux-like CLI environment on Windows. GitBash can be downloaded from https://gitforwindows.org/ .
GitBash will open in the current directory. The command line prompt will be displayed, followed by the current directory. The prompt will be different depending on the operating system. For Windows, the prompt will be $. For Linux and Mac, the prompt will be %.
Command lines allow users to interact with the operating system by entering commands. Commands are entered into the command line, and then executed by pressing the Enter key. Commands can be entered one at a time, or multiple commands can be entered on the same line by separating them with a semicolon.
Arguably the most important command is cd, which is used to change directories. Directories are the folders that contain files. The current directory is displayed in the command line prompt. To change directories, enter cd followed by the name of the directory. For example, to change to the src directory, enter cd src.
In order to navigate into a parent directory - that is, the directory that contains the current directory - use cd ... For example, if the current directory is src, then cd .. will change to the parent directory.
Next, the ls command is used to list the contents of the current directory. This command will list the files and directories in the current directory. For example, if the current directory contains the files main.py and README.md, then ls will list these files. Folders, when listed, will not have a file extension, and instead will be followed by a forward slash. For example, if the current directory contains the folder src, then ls will list src/.
To remove a file, use the rm command. For example, to remove the file main.py, enter rm main.py. Be warned, this command will permanently delete the file.