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 :
- Click on the Start button.
- Go to the Windows System.
- Open Command Prompt.
Here we are going to learn some basic yet important commands which are very useful. So, let’s proceed ..
- pwd -This command returns the name of present working directory.
Syntax : pwd
- mkdir -This command is used to create a directory/folder.
Syntax : mkdir directory_name
- touch -This command is used to create a file.
Syntax : touch file_name
- cd -This command is used to change directory (folder) in the file system. It represents the current directory.
Syntax : cd pathname
- cd .. -This command is used to move one level up (one folder) in the file system.
Syntax : cd ..
- ls -This command is used to list the directory (folder) system.
Syntax : ls
- cp -This command is used to copy the contents of one file to another file.
Syntax : cp file_to_copy new_file_name
- 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
- rm -This command is used to remove a file or a directory (folder).
Syntax : rm file_name
rm -r directory_to_remove
- cat -This command is used to display the content of a file.
Syntax : cat file_name
- clear -This command is used to clear the CLI window.
Syntax : clear
- exit -This command is used to exit the CLI window.
Syntax : exit
Useful Shortcuts :
up arrowkey → will bring up the last command that was executed.
history→ will print out a list of the previous commands executed.
tabkey → 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.