Getting Started with Command Line

 

User Interface

Graphical User Interface

Graphical User Interface (GUI) commonly referred as the User Interface (UI).

Command Line Interface

  • Command Line Interface (CLI) facilitates the users to perform powerful operations on a computer with simple commands.
  • Command is a text instruction to a computer program to perform a specific task.

What is Shell?

  • Shell is the software that interprets and executes the various commands that we provide.

  • Terminal is a text input/output environment.

Different Shells

  • Bourne Shell (sh)

  • Bourne-Again Shell (bash)

  • C Shell (csh)

  • Korn Shell (ksh)

  • Z Shell (zsh)

Opening Terminal

Bash is one of the most commonly used shell in Linux distributions.

  • Open the Dash (Super Key) or Applications and type terminal.

  • Shortcut: Ctrl + Alt + T

Opening Terminal (in MAC)

  • Open Launchpad and search for terminal.

  • Press command(⌘) + space, type "terminal".

For Windows Operating System

For windows install WSL2 (Windows Subsystem for Linux).

Note
Note: It is suggested to try the commands taught bash. As they will not work in Windows Powershell & Command Prompt.

Opening WSL2 Ubuntu Terminal

Click Start and search for "Ubuntu".

Using Cloud

Alternatively you can use Google Cloud Shell.

Bash

Commands

Listing Files & Directories

ls
is used to list files and directories.

ls

Using Additional Options

  • -l -h option provides details in human readable format.

  • Some options require values arguments/values to be passed.
    • --block-size option rounds the file size to nearest values.
    • Inputs : KB , MB

Get Options for Commands

help
displays a list of options that you can use with the command.

ls --help

This Command will be helpful when you don’t know about its parameters and return type etc.

Clear the Screen

  • clear
     command clears the terminal.
  • Shortcut: 
    Ctrl+L
     .
clear

Get User Manual for Commands

  • man
     displays the user manual of a command .
  • Here we pass the command as an argument.

Syntax:

man <command>

Example:

man ls
  • Type q to exit the manual

Get System Date & Time

date
displays the system date and time.

date

Get Current User

whoami
displays the current logged in user.

whoami

Previous Commands

  • Shell keeps track of the commands you have typed in.
  • Use up ( ) and down ( ) arrows to access the commands.

History

  • history
     display the history of the commands you have typed in so far.
  • By default, It shows the last 500 recent commands.
history

Bash History

Bash maintains the history to . bash_history file.

cat .bash_history

exit

exit
to close/end a shell session.

exit

Summary

CommandDescription
lsList files & directories
dateDisplays the system date and time
whoamiDisplays current logged in user
--helpDisplays list of options for a given command
manDisplays user manual for a given command
clearClears the shell
historyIt will show you the last five hundred commands you have entered.
exitEnds the shell

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form