SlideShare a Scribd company logo
1 of 25
Chapter 2
Introduction to UNIX concepts
Meenal K Jabde
Modern College of Arts, Science and Commerce
Ganeshkhind, Pune 16
Agenda
1. Introduction to Unix Operating System.
2. Features of Unix.
3. Architecture of the Unix Operating System.
4. Introduction to File System and Process Environment.
5. Working with Unix
The login prompt.
General features of Unix commands/ command structure.
Command arguments and options.
Understanding of some basic commands such as echo, printf, ls,
who,
date, passwd, cal, Combining commands
Introduction to Unix Operating System.
 Unix is an Operating System that is truly the base of
all Operating Systems like Ubuntu, Solaris, POSIX,
etc.
 It was developed in the 1970s by Ken Thompson,
Dennis Ritchie, and others in the AT&T Laboratories.
 It was originally meant for programmers developing
software rather than non-programmers.
 Unix was the heart of the operating System.
Unix Architecture
 Layer-1: Hardware – It consists of all hardware related
information.
 Layer-2: Kernel –
It interacts with hardware and most of the tasks like
memory management, task scheduling, and management
are done by the kernel.
 Layer-3: Shell commands –
Shell is the utility that processes your requests. When you
type in a command at the terminal, the shell interprets the
command and calls the program that you want.
There are various commands like cp, mv, cat, grep, id, wc,
nroff, a.out and more.
 Layer-4: Application Layer –
It is the outermost layer that executes the given external
applications.
kernel and its block diagram
 The system call and library interface represent the border between user programs and the kernel. System
calls look like ordinary function calls in C programs. Assembly language programs may invoke system
calls directly without a system call library. The libraries are linked with the programs at compile time.
 The set of system calls into those that interact with the file subsystem and some system calls interact
with the process control subsystem. The file subsystem manages files, allocating file space, administering
free space, controlling access to files, and retrieving data for users.
 Processes interact with the file subsystem via a specific set of system calls, such as open (to open a file
for reading or writing), close, read, write, stat (query the attributes of a file), chown (change the record of
who owns the file), and chmod (change the access permissions of a file).
 The file subsystem accesses file data using a buffering mechanism that regulates data flow between the
kernel and secondary storage devices. The buffering mechanism interacts with block I/O device drivers to
initiate data transfer to and from the kernel.
 Device drivers are the kernel modules that control the operator of peripheral devices. The file subsystem
also interacts directly with “raw” I/O device drivers without the intervention of the buffering mechanism.
Finally, the hardware control is responsible for handling interrupts and for communicating with the
machine. Devices such as disks or terminals may interrupt the CPU while a process is executing. If so,
the kernel may resume execution of the interrupted process after servicing the interrupt.
 Interrupts are not serviced by special processes but by special functions in the kernel, called in the
context of the currently running process.
Features of Unix Operating System
Introduction to File System and Process Environment.
 Unix file system is a logical method of organizing and
storing large amounts of information in a way that
makes it easy to manage.
 A file is a smallest unit in which the information is
stored. Unix file system has several important
features.
 All data in Unix is organized into files. All files are
organized into directories. These directories are
organized into a tree-like structure called the file
system.
 Files in Unix System are organized into multi-level
hierarchy structure known as a directory tree.
 At the very top of the file system is a directory called
“root” which is represented by a “/”. All other files are
“descendants” of root.
Types of Unix files –
The UNIX files system
contains several
different types of files.
 1. Ordinary files – An ordinary file is a file on the system that
contains data, text, or program instructions.
 2. Directories – Directories store both special and ordinary files.
 3. Special Files – Used to represent a real physical device such as
a printer, tape drive or terminal, used for Input/Output (I/O)
operations.
 4. Pipes – UNIX allows you to link commands together using a
pipe.
 5. Sockets – A Unix socket (or Inter-process communication
socket) is a special file which allows for advanced inter-process
communication.
 6. Symbolic Link – Symbolic link is used for referencing some
other file of the file system. Symbolic link is also known as Soft
link.
Unix Command Line Structure
 A command is a program that tells the Unix system to do something. It has the
form:
 command [options] [arguments]
 where an argument indicates on what the command is to perform its action,
usually a file or series of files. An option modifies the command, changing the
way it performs.
 Commands are case sensitive. command and Command are not the same.
 Options are generally preceded by a hyphen (-), and for most commands, more
than one option can be strung together, in the form:
 command -[option][option][option]
Basic Commands
 Listing Files- To list the files and directories stored in the current directory, use
the following command −
 $ls
 Here is the sample output of the above command −
 $ls
 bin hosts lib res.03
 ch07 hw1 pub test_results
 ch07.bak hw2 res.01 users
 docs hw3 res.02 work
 The command ls supports the -l option which would help you to get more information
about the listed files −
 $ls -l
 total 1962188
 drwxrwxr-x 2 amrood amrood 4096 Dec 25 09:59 uml
 -rw-rw-r-- 1 amrood amrood 5341 Dec 25 08:38 uml.jpg
 drwxr-xr-x 2 amrood amrood 4096 Feb 15 2006 univ
 drwxr-xr-x 2 root root 4096 Dec 9 2007 urlspedia
 -rw-r--r-- 1 root root 276480 Dec 9 2007 urlspedia.tar
 drwxr-xr-x 8 root root 4096 Nov 25 2007 usr
 drwxr-xr-x 2 200 300 4096 Nov 25 2007 webthumb-1.01
 -rwxr-xr-x 1 root root 3192 Nov 25 2007 webthumb.php
 -rw-rw-r-- 1 amrood amrood 20480 Nov 25 2007 webthumb.tar
 -rw-rw-r-- 1 amrood amrood 5654 Aug 9 2007 yourfile.mid
 -rw-rw-r-- 1 amrood amrood 166255 Aug 9 2007 yourfile.swf
 drwxr-xr-x 11 amrood amrood 4096 May 29 2007 zlib-1.2.3
echo Command
 echo command in linux is used to display line of text/string that
are passed as an argument . This is a built-in command that is
mostly used in shell scripts and batch files to output status text to
the screen or a file.
 Syntax :
 echo [option] [string]
 Displaying a text/string :
 Syntax :
 echo [string]
Printf command
 “printf” command in Linux is used to display the
given string, number or any other format
specifier on the terminal window. It works the
same way as “printf” works in programming
languages like C.
 Syntax:
 $printf [-v var] format [arguments]
 printf can have format specifiers, escape
sequences or ordinary characters.
 Format Specifiers: The most commonly used
printf specifiers are %s, %b, %d, %x and %f.
 %s specifier: It is basically a string specifier for string
output.
 $printf "%sn" "Hello, World!"
 %b specifier: It is same as string specifier, but it allows
us to interpret escape sequences with an argument.
Input : printf "%bn" "Hello, World! n" "From Geeks For
Geeksn"
Output: Hello, World!
From Geeks For Geeks
who command
who command is used to find out the following
information :
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
Description : The who command is used to get
information about currently logged in user on to system.
 Syntax : $who [options] [filename]
Examples :
 1. The who command displays the following information for each
user currently logged in to the system if no option is provided :
 Login name of the users
 Terminal line numbers
 Login time of the users in to system
 Remote host name of the user
 hduser@mahesh-Inspiron-3543:~$ who
 hduser tty7 2018-03-18 19:08 (:0)
 hduser@mahesh-Inspiron-3543:~$
Date command
 date command is used to display the system
date and time. date command is also used to
set date and time of the system. By default the
date command displays the date in the time
zone on which unix/linux operating system is
configured.You must be the super-user (root) to
change the date and time.
 Syntax:
 date [OPTION]... [+FORMAT]
 Command:
 $date
 Output:
 Tue Oct 10 22:55:01 PDT 2017
Passwd command
 passwd command in Linux is used
to change the user account
passwords. The root user
reserves the privilege to change
the password for any user on the
system, while a normal user can
only change the account
password for his or her own
account.
 Syntax:
 passwd [options] [username]
cal command
 If a user wants a quick view of calendar
in Linux terminal, cal is the command
for you. By default, cal command shows
current month calendar as output.
 cal command is a calendar command in
Linux which is used to see the calendar
of a specific month or a whole year.
 Syntax:
 cal [ [ month ] year]
 Rectangular bracket means it is optional,
so if used without option, it will display
a calendar of current month and year.
 cal : Shows current month calendar on
the terminal
Combining commands
This will give you a listing of the
current directory ( ls ), find out
which directory you’re currently in (
pwd ), and display your login name (
whoami ) all at once.
The Logical AND
Operator (&&)
 If you want the second command to only
run if the first command is successful,
separate the commands with the logical
AND operator, which is two ampersands
( && ). For example, we want to make a
directory called MyFolder and then
change to that directory–provided it was
successfully created. So, we type the
following on the command line and
press Enter.
 mkdir MyFolder && cd MyFolder
 The folder was successfully created, so
the cd command was executed, and we
are now in the new folder.
Option Three: The
Logical OR Operator (||)
 Sometimes you might want to execute a second
command only if the first command does not
succeed. To do this, we use the logical OR
operator, or two vertical bars ( || ). For example,
we want to check to see if the MyFolder
directory exists ( [ -d ~/MyFolder ] ) and create
it if it doesn’t ( mkdir ~/MyFolder ). So, we
type the following command at the prompt and
press Enter.
 [ -d ~/MyFolder ] || mkdir ~/MyFolder
 Be sure there is a space after the first bracket
and before the second bracket or the first
command that checks if the directory exists will
not work.
Thank You

More Related Content

What's hot

What's hot (20)

Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Linux Booting Steps
Linux Booting StepsLinux Booting Steps
Linux Booting Steps
 
Introduction Linux Device Drivers
Introduction Linux Device DriversIntroduction Linux Device Drivers
Introduction Linux Device Drivers
 
Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2) Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2)
 
System call
System callSystem call
System call
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting Process
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 

Similar to Chapter 2 Introduction to Unix Concepts

Unix operating system
Unix operating systemUnix operating system
Unix operating system
midhunjose4u
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
Raghu nath
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
Julio Pulido
 

Similar to Chapter 2 Introduction to Unix Concepts (20)

Unix_Introduction_BCA.pptx the very basi
Unix_Introduction_BCA.pptx the very basiUnix_Introduction_BCA.pptx the very basi
Unix_Introduction_BCA.pptx the very basi
 
84640411 study-of-unix-os
84640411 study-of-unix-os84640411 study-of-unix-os
84640411 study-of-unix-os
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
Unix notes
Unix notesUnix notes
Unix notes
 
Unix environment [autosaved]
Unix environment [autosaved]Unix environment [autosaved]
Unix environment [autosaved]
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and Github
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
Unix1
Unix1Unix1
Unix1
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
Linux
LinuxLinux
Linux
 
Basic Commands-part1.pptx
Basic Commands-part1.pptxBasic Commands-part1.pptx
Basic Commands-part1.pptx
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
 
3. intro
3. intro3. intro
3. intro
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
cisco
ciscocisco
cisco
 
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiIntroduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 

Chapter 2 Introduction to Unix Concepts

  • 1. Chapter 2 Introduction to UNIX concepts Meenal K Jabde Modern College of Arts, Science and Commerce Ganeshkhind, Pune 16
  • 2. Agenda 1. Introduction to Unix Operating System. 2. Features of Unix. 3. Architecture of the Unix Operating System. 4. Introduction to File System and Process Environment. 5. Working with Unix The login prompt. General features of Unix commands/ command structure. Command arguments and options. Understanding of some basic commands such as echo, printf, ls, who, date, passwd, cal, Combining commands
  • 3. Introduction to Unix Operating System.  Unix is an Operating System that is truly the base of all Operating Systems like Ubuntu, Solaris, POSIX, etc.  It was developed in the 1970s by Ken Thompson, Dennis Ritchie, and others in the AT&T Laboratories.  It was originally meant for programmers developing software rather than non-programmers.  Unix was the heart of the operating System.
  • 4. Unix Architecture  Layer-1: Hardware – It consists of all hardware related information.  Layer-2: Kernel – It interacts with hardware and most of the tasks like memory management, task scheduling, and management are done by the kernel.  Layer-3: Shell commands – Shell is the utility that processes your requests. When you type in a command at the terminal, the shell interprets the command and calls the program that you want. There are various commands like cp, mv, cat, grep, id, wc, nroff, a.out and more.  Layer-4: Application Layer – It is the outermost layer that executes the given external applications.
  • 5. kernel and its block diagram
  • 6.  The system call and library interface represent the border between user programs and the kernel. System calls look like ordinary function calls in C programs. Assembly language programs may invoke system calls directly without a system call library. The libraries are linked with the programs at compile time.  The set of system calls into those that interact with the file subsystem and some system calls interact with the process control subsystem. The file subsystem manages files, allocating file space, administering free space, controlling access to files, and retrieving data for users.  Processes interact with the file subsystem via a specific set of system calls, such as open (to open a file for reading or writing), close, read, write, stat (query the attributes of a file), chown (change the record of who owns the file), and chmod (change the access permissions of a file).  The file subsystem accesses file data using a buffering mechanism that regulates data flow between the kernel and secondary storage devices. The buffering mechanism interacts with block I/O device drivers to initiate data transfer to and from the kernel.  Device drivers are the kernel modules that control the operator of peripheral devices. The file subsystem also interacts directly with “raw” I/O device drivers without the intervention of the buffering mechanism. Finally, the hardware control is responsible for handling interrupts and for communicating with the machine. Devices such as disks or terminals may interrupt the CPU while a process is executing. If so, the kernel may resume execution of the interrupted process after servicing the interrupt.  Interrupts are not serviced by special processes but by special functions in the kernel, called in the context of the currently running process.
  • 7. Features of Unix Operating System
  • 8. Introduction to File System and Process Environment.  Unix file system is a logical method of organizing and storing large amounts of information in a way that makes it easy to manage.  A file is a smallest unit in which the information is stored. Unix file system has several important features.  All data in Unix is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the file system.  Files in Unix System are organized into multi-level hierarchy structure known as a directory tree.  At the very top of the file system is a directory called “root” which is represented by a “/”. All other files are “descendants” of root.
  • 9. Types of Unix files – The UNIX files system contains several different types of files.
  • 10.  1. Ordinary files – An ordinary file is a file on the system that contains data, text, or program instructions.  2. Directories – Directories store both special and ordinary files.  3. Special Files – Used to represent a real physical device such as a printer, tape drive or terminal, used for Input/Output (I/O) operations.  4. Pipes – UNIX allows you to link commands together using a pipe.  5. Sockets – A Unix socket (or Inter-process communication socket) is a special file which allows for advanced inter-process communication.  6. Symbolic Link – Symbolic link is used for referencing some other file of the file system. Symbolic link is also known as Soft link.
  • 11. Unix Command Line Structure  A command is a program that tells the Unix system to do something. It has the form:  command [options] [arguments]  where an argument indicates on what the command is to perform its action, usually a file or series of files. An option modifies the command, changing the way it performs.  Commands are case sensitive. command and Command are not the same.  Options are generally preceded by a hyphen (-), and for most commands, more than one option can be strung together, in the form:  command -[option][option][option]
  • 12. Basic Commands  Listing Files- To list the files and directories stored in the current directory, use the following command −  $ls  Here is the sample output of the above command −  $ls  bin hosts lib res.03  ch07 hw1 pub test_results  ch07.bak hw2 res.01 users  docs hw3 res.02 work
  • 13.  The command ls supports the -l option which would help you to get more information about the listed files −  $ls -l  total 1962188  drwxrwxr-x 2 amrood amrood 4096 Dec 25 09:59 uml  -rw-rw-r-- 1 amrood amrood 5341 Dec 25 08:38 uml.jpg  drwxr-xr-x 2 amrood amrood 4096 Feb 15 2006 univ  drwxr-xr-x 2 root root 4096 Dec 9 2007 urlspedia  -rw-r--r-- 1 root root 276480 Dec 9 2007 urlspedia.tar  drwxr-xr-x 8 root root 4096 Nov 25 2007 usr  drwxr-xr-x 2 200 300 4096 Nov 25 2007 webthumb-1.01  -rwxr-xr-x 1 root root 3192 Nov 25 2007 webthumb.php  -rw-rw-r-- 1 amrood amrood 20480 Nov 25 2007 webthumb.tar  -rw-rw-r-- 1 amrood amrood 5654 Aug 9 2007 yourfile.mid  -rw-rw-r-- 1 amrood amrood 166255 Aug 9 2007 yourfile.swf  drwxr-xr-x 11 amrood amrood 4096 May 29 2007 zlib-1.2.3
  • 14. echo Command  echo command in linux is used to display line of text/string that are passed as an argument . This is a built-in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.  Syntax :  echo [option] [string]  Displaying a text/string :  Syntax :  echo [string]
  • 15. Printf command  “printf” command in Linux is used to display the given string, number or any other format specifier on the terminal window. It works the same way as “printf” works in programming languages like C.  Syntax:  $printf [-v var] format [arguments]  printf can have format specifiers, escape sequences or ordinary characters.  Format Specifiers: The most commonly used printf specifiers are %s, %b, %d, %x and %f.
  • 16.  %s specifier: It is basically a string specifier for string output.  $printf "%sn" "Hello, World!"  %b specifier: It is same as string specifier, but it allows us to interpret escape sequences with an argument. Input : printf "%bn" "Hello, World! n" "From Geeks For Geeksn" Output: Hello, World! From Geeks For Geeks
  • 17. who command who command is used to find out the following information : 1. Time of last system boot 2. Current run level of the system 3. List of logged in users and more. Description : The who command is used to get information about currently logged in user on to system.  Syntax : $who [options] [filename]
  • 18. Examples :  1. The who command displays the following information for each user currently logged in to the system if no option is provided :  Login name of the users  Terminal line numbers  Login time of the users in to system  Remote host name of the user  hduser@mahesh-Inspiron-3543:~$ who  hduser tty7 2018-03-18 19:08 (:0)  hduser@mahesh-Inspiron-3543:~$
  • 19. Date command  date command is used to display the system date and time. date command is also used to set date and time of the system. By default the date command displays the date in the time zone on which unix/linux operating system is configured.You must be the super-user (root) to change the date and time.  Syntax:  date [OPTION]... [+FORMAT]  Command:  $date  Output:  Tue Oct 10 22:55:01 PDT 2017
  • 20. Passwd command  passwd command in Linux is used to change the user account passwords. The root user reserves the privilege to change the password for any user on the system, while a normal user can only change the account password for his or her own account.  Syntax:  passwd [options] [username]
  • 21. cal command  If a user wants a quick view of calendar in Linux terminal, cal is the command for you. By default, cal command shows current month calendar as output.  cal command is a calendar command in Linux which is used to see the calendar of a specific month or a whole year.  Syntax:  cal [ [ month ] year]  Rectangular bracket means it is optional, so if used without option, it will display a calendar of current month and year.  cal : Shows current month calendar on the terminal
  • 22. Combining commands This will give you a listing of the current directory ( ls ), find out which directory you’re currently in ( pwd ), and display your login name ( whoami ) all at once.
  • 23. The Logical AND Operator (&&)  If you want the second command to only run if the first command is successful, separate the commands with the logical AND operator, which is two ampersands ( && ). For example, we want to make a directory called MyFolder and then change to that directory–provided it was successfully created. So, we type the following on the command line and press Enter.  mkdir MyFolder && cd MyFolder  The folder was successfully created, so the cd command was executed, and we are now in the new folder.
  • 24. Option Three: The Logical OR Operator (||)  Sometimes you might want to execute a second command only if the first command does not succeed. To do this, we use the logical OR operator, or two vertical bars ( || ). For example, we want to check to see if the MyFolder directory exists ( [ -d ~/MyFolder ] ) and create it if it doesn’t ( mkdir ~/MyFolder ). So, we type the following command at the prompt and press Enter.  [ -d ~/MyFolder ] || mkdir ~/MyFolder  Be sure there is a space after the first bracket and before the second bracket or the first command that checks if the directory exists will not work.