0% found this document useful (0 votes)
3 views

05 - Intro to Command Line Interface

The document provides an introduction to the Command Line Interface (CLI), explaining its historical context, differences from Graphical User Interface (GUI), and basic file management commands in Linux and Windows. It outlines how to open the CLI on different operating systems, execute commands, and manage files and directories. Additionally, it includes essential commands and interview questions related to CLI and GUI.

Uploaded by

Tushar Chandel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

05 - Intro to Command Line Interface

The document provides an introduction to the Command Line Interface (CLI), explaining its historical context, differences from Graphical User Interface (GUI), and basic file management commands in Linux and Windows. It outlines how to open the CLI on different operating systems, execute commands, and manage files and directories. Additionally, it includes essential commands and interview questions related to CLI and GUI.

Uploaded by

Tushar Chandel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Agenda

1. CLI Introduction

2. GUI vs CLI
3. Basic File Management Commands in Linux
4. Essential list of Commands

CLI Introduction
CLI stands for the command-line interface. It is a program that allows users to type text commands instructing the computer to do specific tasks.

The Roots of CLI


In the 1960s, CLI was used intensively.

Back then, people had only a keyboard as an input device and the computer screen could only display text information. Operating
systems like MS-DOS used the CLI as the standard user interface.

Note that interface has a much broader definition these days. For this session, however, we're only interested in the display and input of text an
commands via the command line.

CLI Display
The command line can be the default interface for a computer, but most personal computers use a program (like Terminal) within the desktop graphic
interface to provide the command line interface. Let's dissect the CLI's language for a moment.
Below is an example of the prompt on an Ubuntu Linux server:

ubuntu@chopin:~$

The above prompt follows this format:

[user]@[hostname]:[current_directory]$

CLI & GUI


CLI
CLI is the word form used for Command Line Interface. CLI permits users to put in writing commands associate degree exceedingly in terminal o
console window to interact with an operating system. CLI is a platform or medium wherever users answer a visible prompt by writing a command and g
the response from the system, for this users have to be compelled to kind command or train of command for performing the task.
Examples - Windows: Command Prompt, Ubuntu & MacOS: Terminal
GUI stands for Graphical User Interface. GUI permits users to use the graphics to interact with an operating system. In the graphical user interfac
menus are provided such as windows, scrollbars, buttons, wizards, painting pictures, alternative icons etc. It’s intuitive, simple to find out and reduce
psychological feature load. In GUI, the information is shown or presented to the user in any form such as plain text, videos, images, etc.

Examples - Microsoft Windows, macOS, Chrome OS, Linux variants like Ubuntu

CLI vs GUI
Open the command-line interface
To start some experiments we need to open our command-line interface first.
Opening: Windows
Depending on your version of Windows and your keyboard, one of the following should open a command window (you may have to experiment a bit, b
you don't have to try all of these suggestions):

Go to the Start menu or screen, and enter "Command Prompt" in the search field.
Go to Start menu → Windows System → Command Prompt.

Go to Start menu → All Programs → Accessories → Command Prompt.


Go to the Start screen, hover your mouse in the lower-left corner of the screen, and click the down arrow that appears (on a touch
screen, instead flick up from the bottom of the screen). The Apps page should open. Click on Command Prompt in the Windows System
section.
Hold the special Windows key on your keyboard and press the "X" key. Choose "Command Prompt" from the pop-up menu.
Hold the Windows key and press the "R" key to get a "Run" window. Type "cmd" in the box, and click the OK key.

Opening: OS X

Go to Applications → Utilities → Terminal.


Opening: Linux
It's under Applications → Accessories → Terminal or Applications → System → Terminal.

Prompt
You now should see a white or black window that is waiting for your commands.
Prompt: OS X and Linux
If you're on Mac or Linux, you probably see a $ , like this:
command-line

Prompt: Windows

On Windows, you probably see a > , like this:


command-line

>

Each command will be prepended by a $ or > and one space, but you should not type it. Your computer will do it for you.

Just a small note: in your case, there may be something like C:\Users\alma> or alma-MacBook-Air:~ alma$ before the prompt sign, and this is 100% OK

The part up to and including the $ or the > is called the command line prompt, or prompt for short. It prompts you to input something there.

Your first command


Let's start by typing this command:
Your first command: OS X and Linux
command-line

$ whoami

Your first command: Windows


command-line

> whoami

And then hit enter . This is our result:

command-line

$ whoami
almabetter-student

Basics
Each operating system has a slightly different set of commands for the command line, so make sure to follow instructions for your operating system. Let
try this, shall we?

Current directory
It'd be nice to know where are we now, right? Let's see. Type this command and hit enter :
Current directory: OS X and Linux
command-line

$ pwd
/Users/almabetter-student

Note: 'pwd' stands for 'print working directory'.


Current directory: Windows
command-line

> cd
Users\alambetter
C:\Users\alambetter-student

Note: 'cd' stands for 'change directory'. With PowerShell, you can use pwd just like on Linux or Mac OS X.

You'll probably see something similar on your machine. Once you open the command line you usually start at your user's home directory.

Learn more about a command


Many commands you can type at the command prompt have built-in help that you can display and read! For example, to learn more about the curre
directory command:
Command help: OS X and Linux
OS X and Linux have a man command, which gives you help on commands. Try man pwd and see what it says, or put man before other command
to see their help. The output of man is normally paged. Use the space bar to move to the next page, and q to quit looking at the help.
Command Help: Windows
Adding a /? suffix to most commands will print the help page. You may need to scroll your command window up to see it all. Try cd /? .

List files and directories


So what's in it? It'd be cool to find out. Let's see:

List files and directories: OS X and Linux


command-line

$ ls
Applications
Desktop
Downloads
Music
...

List files and directories: Windows


command-line

> dir
Directory of C:\Users
Users\almabetter
\almabetter-student
05/08/2020 07:28 PM <DIR> Applications
05/08/2020 07:28 PM <DIR> Desktop
05/08/2020 07:28 PM <DIR> Downloads
05/08/2020 07:28 PM <DIR> Music
...

Note: In PowerShell, you can also use 'ls' like on Linux and Mac OS X.

Change current directory


Now, let's go to our Desktop directory:

Change current directory: OS X


command-line

$ cd Desktop

Change current directory: Linux


command-line
$ cd Desktop

Change current directory: Windows


command-line

> cd Desktop

Check if it's really changed:


Check if changed: OS X and Linux

command-line

$ pwd
/Users/almabetter-student/Desktop

Check if changed: Windows


command-line

> cd
Users\almabetter
C:\Users\almabetter-student\
student\Desktop
Desktop

Here it is!

PRO tip: if you type cd D and then hit tab on your keyboard, the command line will automatically fill in the rest of the name so you can
navigate faster. If there is more than one folder starting with "D", hit the tab key twice to get a list of options.

Create directory
How about creating a practice directory on your desktop? You can do it this way:
Create directory: OS X and Linux
command-line

$ mkdir practice

Create directory: Windows


command-line

> mkdir practice

This little command will create a folder with the name practice on your desktop. You can check if it's there by looking on your Desktop or by runnin
a ls or dir command! Try it. :)

PRO tip: If you don't want to type the same commands over and over, try pressing the up arrow and down arrow on your keyboard to
cycle through recently used commands.

Clean up
We don't want to leave a mess, so let's remove everything we did until that point.
First, we need to get back to Desktop:
Clean up: OS X and Linux
command-line

$ cd ..

Clean up: Windows


command-line
> cd ..

Using .. with the cd command will change your current directory to the parent directory (that is, the directory that contains your current directory).
Check where you are:
Check location: OS X and Linux
command-line

$ pwd
/Users/almabetter-student/Desktop

Check location: Windows


command-line

> cd
C:\Users\almabetter-student\Desktop

Now time to delete the practice directory:

Attention: Deleting files using del, rmdir or rm is irrecoverable, meaning the deleted files will be gone forever! So be very careful with this
command.

Delete directory: Windows Powershell, OS X and Linux


command-line

$ rm -r practice

Delete directory: Windows Command Prompt


command-line

> rmdir /S practice


practice, Are you sure <Y/N>? Y

Done! To be sure it's actually deleted, let's check it:


Check deletion: OS X and Linux
command-line

$ ls

Check deletion: Windows


command-line

> dir

Exit
That's it for now! You can safely close the command line now.
Exit: OS X and Linux
command-line

$ exit

Exit: Windows
command-line

> exit
Essential Commands
Here is a summary of some useful commands:

Exhaustive list of commands


ss64.com contains a complete reference of commands for all operating systems.

Interview Questions
What is a CLI ?

CLI is a command line program that accepts text input to execute operating system functions.

A Command Line Interface connects a user to a computer program or operating system. Through the CLI, users interact with a system or application b
typing in text (commands). The command is typed on a specific line following a visual prompt from the computer.

What is the main difference between GUI and CLI ?

GUI lets a user interact with the device/system with the help of graphical elements, like windows, menus, icons, etc. The CLI, on the other hand, lets
user interact with their device/system with the help of various commands.

Thank you

You might also like