Hello Command-Line 👋 : An Introduction

1. What is Command-Line?

The command line allows the user to type in commands/instructions for immediate execution. CLI is basically a blank window with a cursor on the screen. The command line is also called the command screen, or text interface.

For example, the Windows folder in a Windows command line is “C:\Windows>”.

2. Why should I learn Command-Line?

Using a command line, you can perform the same tasks that can be done with a GUI (like a mouse). But, many tasks can be performed quicker and can be much easier to automate if we use CLI. Also occupies much less memory as compared to GUI. Other uses of CLI includes:

✔ Git –Version Control System

✔ Back-End Development

✔ Package Installation, etc.

3. How to use Command-line?

So, The first step is to open a command prompt/terminal/Git Bash.

If you want to use Command Prompt. Follow these steps to open it on your system :

  1. Click on the Start button.
  2. Go to the Windows System.
  3. Open Command Prompt.

Here we are going to learn some basic yet important commands which are very useful. So, let’s proceed ..

  1. pwd -This command returns the name of present working directory.
    Syntax : pwd
  2. mkdir -This command is used to create a directory/folder.
    Syntax : mkdir directory_name
  3. touch -This command is used to create a file.
    Syntax : touch file_name
  4. cd -This command is used to change directory (folder) in the file system. It represents the current directory.
    Syntax : cd pathname
  5. cd .. -This command is used to move one level up (one folder) in the file system.
    Syntax : cd ..
  6. ls -This command is used to list the directory (folder) system.
    Syntax : ls
  7. cp -This command is used to copy the contents of one file to another file.
    Syntax : cp file_to_copy new_file_name
  8. mv -This command is used to move a file to another folder and rename a file.
    Syntax : mv file_to_move destination_directory
    mv old_file_name new_file_name
  9. rm -This command is used to remove a file or a directory (folder).
    Syntax : rm file_name
    rm -r directory_to_remove
  10. cat -This command is used to display the content of a file.
    Syntax : cat file_name
  11. clear -This command is used to clear the CLI window.
    Syntax : clear
  12. exit -This command is used to exit the CLI window.
    Syntax : exit

Useful Shortcuts :

  • up arrow key → will bring up the last command that was executed.
  • history → will print out a list of the previous commands executed.
  • tab key → pressing the tab key can be used to auto-complete the directory and file names while typing paths or filenames.

Thanks for reading :) I hope that you were able to get some insights on what is CLI, why we should use CLI, and how to use CLI.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store