Learn Python and related technologies

ADS

The Command Line Interface (CLI)


The CLI is a text-based user  interface that can be used to administer numerous commands  to the computer. These commands can be used to install and run programs/executables, manage computer files, check  and set system configurations and generally interact with the computer.  The commands administered through the CLI  usually have a definite  structure and specific syntax. Most of the commands are also case-insensitive.

While a Graphical user interface(GUI) might supports visually appealing features such as modal windows, drop-downs and various input formats, the CLI is purely text-based and doesn't  support cosmetic features. The CLI is especially useful in instances where automation is required   and is therefore more popular among  IT professionals , software developers and network administrators   than to an average user. 

Mastering the CLI  is an invaluable skill that a programmer can possess, because many development software like programming languages , version controls and Cloud providers  extensively uses it for various operations. 

Advantages of the command line interface
  • Offers  a robust environment for  automation 
  • It is lighter than most GUI's thus uses less memory
  • Can run effectively on low-resolution monitors
  • Requires less processing power 
  • It is fast at executing commands.
Disadvantages of the command line interface
  • Most of the commands executed cannot be undone; therefore, one needs to be more vigilant on what he is doing
  • Doesn't offer features to help the user in executing various commands like GUI's do.
  • It is less friendly to users and will raise errors on simple mistakes like misspelling commands

Command interface in different operating systems 

Most operating systems like  Windows , Linux and macOS comes with a command line interface .  Windows has the command prompt application as well as  the Powershell while Linux and macOS has Bash . This command interfaces are usually in form of  apps  and a user can open them  like other applications.

To open windows command prompt , you can search CMD using the windows search bar  

windows search bar

Alternatively you can press "Windows key + R"   to open the run dialog box and then press OK.

windows run dialog

The windows command prompt looks like the one shown below:

windows cmd

 

To open the Linux bash shell you can press "Ctrl-Alt-T"

or search 'terminal' in the Linux search box.

Some useful windows commands

There are over 200 commands on windows CMD , we will only look at a handful of them.

command usage format
cd Changing directory cd <directory>
mkdir create a new folder/directory  mkdir <options> <name>
rmdir delete a non-empty folder rmdir <options>  <name>
del delete one or more files del <options> <file>
copy Copying files from one location to another copy <options>  <file>
comp compare two files comp <file1> <file2> <options>
echo Used to write on files echo <message> <file>
compact compress a given file compact <options> <file>
exit Exit the command prompt exit  <options>
shutdown shutdown the computer on various ways depending on options given shutdown <option> 
date For showing or changing the current date date <options>
color Change the color of text  color  <options> <hexcode>