Basic Command Line Usage 💻

Ömral Cörüt
4 min readJan 15, 2021

Simply, the command-line interface (CLI) is a tool that performs some tasks via text-based commands in an operating system. Probable, you perform a double click to open a folder in your OS. However, you would type cd folderName and enter to open this folder in CLI. So, why is it important? Why should I use CLI? There are many reasons to use it, but you mostly use it for version control, package management, navigation, and executing commands to run and test programs as a developer.

On the Windows side, you should open Command Prompt that is CLI app in Windows. To open it, click the start menu and type cmd in the Search or Run line, then press the enter. On the Mac or Linux side, you should open the Terminal app from Applications.

Use Cases

There are many commands to use CLI, but I will show you just the most used ones for general purposes. Also, I will compare CLI and Graphical User Interface (GUI) for better understanding.

$ pwd // Display what directory you are.
$ ls // Display a list of files in the current directory.
$ ls -l // Display a detailed list of files in the current directory.
$ cd <directory> // Change the current directory to a new directory.
$ cd .. // Change the current directory to the parent directory.
$ clear // Clear the command-line interface window.
$ mkdir <folder-name> // Create new folder named \<folder-name\>.
$ touch <file> // Create new file named \<file\>.
$ cp <file> <directory> // Copy a file named \<file\> to a directory named \<directory\>.
$ cp -r <folder> <directory> // Copy a folder named \<folder\> to a directory named \<directory\>.
$ mv <current-name> <new-name> // Rename a file or folder named \<current-name\> to \<new-name\>.
$ mv <file-or-folder> <directory> // Move a file or folder named \<file-or-folder\> to a directory named \<directory\>.
$ rm <file> // Remove a file named \<file\>.
$ rm -r <folder-name> // Remove a folder named \<folder-name\>.

Shortcuts

There are some shortcuts to use the command-line interface. The 3 of them are being most used.

TAB // Auto complete the file, directory, or command you are typing.
CTRL + A // Move the cursor to the start of the line.
CTRL + E // Move the cursor to the end of the line.

Finally, we learned some basics of terminal usage. Maybe this is just a drop in the ocean, but it is a good starting. You can search more according to your needs. I just put some of the resources below that you can check out.

Have a good coding.

Resources

--

--

Ömral Cörüt
Ömral Cörüt

Written by Ömral Cörüt

I develop mobile applications with the passion of the first day. I am experienced at Native Android & iOS and Flutter development.

No responses yet