SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Introduction to
Linux
LINUX
• Linux is an operating system's kernel. It was actually created by Linus
Torvalds from Scratch. Linux is free and open-source, that means that
you can simply change anything in Linux and redistribute it in your
own name! There are several Linux Distributions, commonly called
“distros”.
• Ubuntu Linux
• Red Hat Enterprise Linux
• Linux Mint
• Debian
• Fedora
Linux Shell or “Terminal”
• So, basically, a shell is a program that receives
commands from the user and gives it to the OS to
process, and it shows the output. Linux's shell is
its main part. Its distros come in GUI (graphical
user interface), but basically, Linux has a CLI
(command line interface).
• To open the terminal, press Ctrl+Alt+T in Ubuntu
Installation
• Virtual box is free and open-source virtualization software from Oracle. It
enables us to install other operating systems in virtual machines. It is
recommended that our system should have at least 4GB of RAM to get decent
performance from the virtual operating system.​
• Then we need to go to the website of Oracle VirtualBox and get the latest
stable version from there.​Next, download Ubuntu. We can get this from the
official website of Ubuntu . Now we have installed VirtualBox, and we have
downloaded Ubuntu. We are now set to install Linux in VirtualBox.​
Shortcut keys to Open
and Close Ubuntu
Terminal
• In Ubuntu the terminal shortcut key is mapped to
ctrl+Alt+T to open the terminal and for closing ctrl+d.
Some Basic
Commands
• Echo : echo command in Linux is used to display line of
text/string that are passed as an argument. EX : echo
hello(it will return hello).
• ​Cal : To display current month's calendar. For all months we
must write cal 2021 then it will show all months of that
year.​
• Date : This command will show gives the present date ,
time and year. ​
• Clear : This command will clear your terminal.​Shortcut key
is ctrl+L
• History: To get history of the commands.
• Exit: Exit from terminal
• history –c; history –w : will clear the history of commands.
• Ls:- list the contents of the folder
• Cat:- It is used to create a file with content. It can concatenate two or more file contents.
• Touch:- it is used to create a file without content.
• Cp:- copies file from one location to another.
• Cd:- It is used for changing the directory.
• Mv:-It is used to move files from one location to another.
• Pwd:-It prints the current working directory with full path name from terminal
• mkdir:- It is used to create new directory.
• Whereis: It is used to locate the source and manual pages
of the command.
• Man:- It provides online documentation for all possible
commands and its options.
• WHOAMI:-It is used to find out the current user of the
terminal.
• Info:- It provides online documentation for all the
commands but in a better structured way.
• Bc :-It means the basic calculator, used for the basic calculations.
• Grep :- It searches the given file for lines containing a match to the given strings or
words.
• Head:- It prints the first 10 lines of the given file.
• Tail :-It prints the last 10 lines of the given file.
• Tac :-It prints content of the given file in reverse order.
• Df :- Report disk usages of file system. It is useful for user as well as System
Administrator to keep track of their disk usages.
• DU -Estimate files space usage. df only reports usage statistics on file systems,
while ‘du‘, on the other hand, measures directory contents.
• PS - ps (Process) gives the status of running processes with a unique Id called
PID.
• SUDO -It allows a permitted user to execute a command as the super user or
another user.
• SU -It is used to run shell with substitute user and group IDs.It helps to change
login session’s owner without the owner having to first logout of that session.
• PASSWD-It is used for changing the passwd.It is mandatory to know the current
passwd for the security reason.
Deleting Files
and
Directories
• rm <file> : Remove a file .e.g., rm ~/Desktop/file1.txt
• rm -r <directory> : Removes a directory. e.g., rm -r
~/newdir
• rm –i : Removes in an interactive manner. This is a good
safety measure.
• rmdir <empty directory> : Only remove empty directories
.e.g., rmdir ~/emptydir
Shell
• A shell is a user interface for access to an operating
system's services. Most often the user interacts with
the shell using a command-line interface (CLI).
The terminal is a program that opens a graphical
window and lets you interact with the shell.
• Shell is a program which processes commands and
returns output , like bash in Linux .
• Commands are case sensitive.
• We can use this technique to write commands in shell:-
CommandName -options input.
• commandName must be a valid program on the Shell’s Path. To check this, use the which command
like :
which commandName
• If a path is returned, then the commandName is valid and vice versa.
Example:-
• echo $Path: Path of the command Path.
• which cal: cal command was in which folder.
• Date –u/date --universal: gives universal standard time.
Short Form:-
• We can specify options for each command to customise the commands behaviour. These can be
either “short-form” options or “long-form” options.
• Each command behaves differently so check the command’s manual (man) page for the specifics of
each command’s behaviour.
• Short-form options are where a letter defines an option. Each option is prepended by a dash “-“
like:
commandName –a –b –c args
• To save typing, you could join together the options: commandName –abc args.
• Both of these formats are equivalent.
Long Form:-
• There are long-form options defined to make options easier to identify.
• Longform options are usually prepended by a double dash “--“.
• Long-form options cannot be joined together like short-form options can.
• If long form options are defined for options “a”, “b” and “c”, then: commandName –a –b -c
arguments is equivalent to commandName --alpha --beta --charlie arguments
Bash
Scripting
• Bash is a type of interpreter that processes shell commands. A
command is given in the form of plain text that calls operating
system services to perform a task.
• Commands like ls and cd are frequently used by programmers;
these commands are written in the terminal. The terminal acts as
an interface for the shell interpreter.
• A Bash script is a text file containing a series of commands.
• Bash scripts are given an extension of .sh
Piping
• Standard Data Streams can be redirected and are identified using their stream number. Redirection of the
standard output of one command to the standard input of another command is known as piping.
• Redirecting Standard Output: Standard output is stream number 1. There are 2 methods to redirect
standard output. The long form, using the stream number: commandName –options arguments 1>
destination Or the short form, with no stream number: commandName –options arguments >
destination
• Redirecting Standard Error: Standard error is stream number 2. Here is how to redirect standard error
commandName –options arguments 2> destination Standard error can be redirected at the same time as
standard output: commandName –options arguments 1> output_destination 2> error_destination
• Redirecting Standard Input: Standard Input is stream number 0. There are 2 methods to redirect
standard Input. The long form, using the stream number: commandName –options arguments 0<
input_source Or the short form, with no stream number: commandName –options arguments <
input_source
Aliases
• It is the nickname for a command/pipeline.
• It is a build in shell command that lets us assign name for a long command or frequently
used command.
• Aliases go in a .bash_aliases file in your home directory. If it does not exist, you need to
create it ,spelled exactly
• Example: alias aliasName=”ABCD”
Piping to an
Alias
• If the first command in an alias accepts standard input,
then the alias can be piped to; even if it is an entire
pipeline!
• Our alias is currently: alias calmagic=”cal –A 1 –B 1 12
2017”
• cal is the first command in this alias, but cal doesn’t
accept standard input.Therefore, this would not work:
commandOne –options arguments | calmagic
• However, if we adjust our alias so that it can accept
standard input:
alias calmagic=”xargs cal –A 1 –B 1 12 2017”
• This will now work: commandOne –options arguments |
calmagic
File Achieving
and
Compressing
• Archiving and compressing files in Linux is a two-step process.
• 1) Create a Tarball First, you will create what is known as a tar
file or “tarball”. A tarball is a way of bundling together the files
that you want to archive.
• 2) Compress the tarball with a compression
algorithm.Secondly, you will then compress that tarball with
one of a variety of compression algorithms.
• Creating a tarball
• tar –cvf <name of tarball> <file>…
• Checking a Tarball’s Contents
• tar –tf <name of tarball>
• Extracting a Tar ball’s Contents
• tar –xv <name of tarball>
• Compressing Tarballs
Tarballs are just containers for files. They don’t by themselves
do any compression, but they can be compressed using a
variety of compression algorithms.The main types of
compression algorithms are gzip and bzip2.
Compressing and Decompressing with gzip
Compressing with gzip:- gzip <name of tarball>
Decompressing with gzip:- gunzip <name of tarball>
• Compressing and Decompressing with bzip2
Compressing with bzip2: bzip2 <name of tarball>
Decompressing with bzip2 : bunzip2 <name of tarball>
Doing it all in one step
Creating a tarball and compressing via gzip: tar –cvzf <name of tarball> <file>
Decompressing a tarball and extracting via xzip: tar –xvzf <name of tarball>
Creating a tarball and compressing via bzip2: tar –cvjf <name of tarball> <file>
Decompressing a tarball and extracting via bzip2: tar –xvjf <name of tarball>
Creating a tarball and compressing via xzip : tar –cvJf<name of tarball> <file>
Decompressing a tarball and extracting via xzip : tar –xvJf<name of tarball>

Weitere ähnliche Inhalte

Was ist angesagt?

Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 

Was ist angesagt? (20)

Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Linux
LinuxLinux
Linux
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux OS presentation
Linux OS presentationLinux OS presentation
Linux OS presentation
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file system
 
Intro to linux
Intro to linuxIntro to linux
Intro to linux
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Linux
Linux Linux
Linux
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux
Linux Linux
Linux
 
Linux operating system - Overview
Linux operating system - OverviewLinux operating system - Overview
Linux operating system - Overview
 
Introduction 2 linux
Introduction 2 linuxIntroduction 2 linux
Introduction 2 linux
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Linux distributions
Linux    distributionsLinux    distributions
Linux distributions
 
Linux File System
Linux File SystemLinux File System
Linux File System
 

Ähnlich wie Linux

Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
Chander Pandey
 
Ericas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-GuideEricas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-Guide
Erica StJohn
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
QUONTRASOLUTIONS
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 

Ähnlich wie Linux (20)

LinuxCommands (1).pdf
LinuxCommands (1).pdfLinuxCommands (1).pdf
LinuxCommands (1).pdf
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Group13
Group13Group13
Group13
 
redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Unix cmc
Unix cmcUnix cmc
Unix cmc
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
Linux Basics.pptx
Linux Basics.pptxLinux Basics.pptx
Linux Basics.pptx
 
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
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linux commands
Linux commandsLinux commands
Linux commands
 
2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx
 
linux commands that might be helpful.pptx
linux commands that might be helpful.pptxlinux commands that might be helpful.pptx
linux commands that might be helpful.pptx
 
Ericas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-GuideEricas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-Guide
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
 
Unix _linux_fundamentals_for_hpc-_b
Unix  _linux_fundamentals_for_hpc-_bUnix  _linux_fundamentals_for_hpc-_b
Unix _linux_fundamentals_for_hpc-_b
 
Lpt lopsa
Lpt lopsaLpt lopsa
Lpt lopsa
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
 
Linux
LinuxLinux
Linux
 
Linux commands
Linux commandsLinux commands
Linux commands
 

Kürzlich hochgeladen

Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
chumtiyababu
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Kürzlich hochgeladen (20)

Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

Linux

  • 2. LINUX • Linux is an operating system's kernel. It was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”. • Ubuntu Linux • Red Hat Enterprise Linux • Linux Mint • Debian • Fedora
  • 3. Linux Shell or “Terminal” • So, basically, a shell is a program that receives commands from the user and gives it to the OS to process, and it shows the output. Linux's shell is its main part. Its distros come in GUI (graphical user interface), but basically, Linux has a CLI (command line interface). • To open the terminal, press Ctrl+Alt+T in Ubuntu
  • 4. Installation • Virtual box is free and open-source virtualization software from Oracle. It enables us to install other operating systems in virtual machines. It is recommended that our system should have at least 4GB of RAM to get decent performance from the virtual operating system.​ • Then we need to go to the website of Oracle VirtualBox and get the latest stable version from there.​Next, download Ubuntu. We can get this from the official website of Ubuntu . Now we have installed VirtualBox, and we have downloaded Ubuntu. We are now set to install Linux in VirtualBox.​
  • 5. Shortcut keys to Open and Close Ubuntu Terminal • In Ubuntu the terminal shortcut key is mapped to ctrl+Alt+T to open the terminal and for closing ctrl+d.
  • 6. Some Basic Commands • Echo : echo command in Linux is used to display line of text/string that are passed as an argument. EX : echo hello(it will return hello). • ​Cal : To display current month's calendar. For all months we must write cal 2021 then it will show all months of that year.​ • Date : This command will show gives the present date , time and year. ​ • Clear : This command will clear your terminal.​Shortcut key is ctrl+L • History: To get history of the commands. • Exit: Exit from terminal • history –c; history –w : will clear the history of commands.
  • 7. • Ls:- list the contents of the folder • Cat:- It is used to create a file with content. It can concatenate two or more file contents. • Touch:- it is used to create a file without content. • Cp:- copies file from one location to another. • Cd:- It is used for changing the directory. • Mv:-It is used to move files from one location to another. • Pwd:-It prints the current working directory with full path name from terminal
  • 8. • mkdir:- It is used to create new directory. • Whereis: It is used to locate the source and manual pages of the command. • Man:- It provides online documentation for all possible commands and its options. • WHOAMI:-It is used to find out the current user of the terminal. • Info:- It provides online documentation for all the commands but in a better structured way.
  • 9. • Bc :-It means the basic calculator, used for the basic calculations. • Grep :- It searches the given file for lines containing a match to the given strings or words. • Head:- It prints the first 10 lines of the given file. • Tail :-It prints the last 10 lines of the given file. • Tac :-It prints content of the given file in reverse order. • Df :- Report disk usages of file system. It is useful for user as well as System Administrator to keep track of their disk usages.
  • 10. • DU -Estimate files space usage. df only reports usage statistics on file systems, while ‘du‘, on the other hand, measures directory contents. • PS - ps (Process) gives the status of running processes with a unique Id called PID. • SUDO -It allows a permitted user to execute a command as the super user or another user. • SU -It is used to run shell with substitute user and group IDs.It helps to change login session’s owner without the owner having to first logout of that session. • PASSWD-It is used for changing the passwd.It is mandatory to know the current passwd for the security reason.
  • 11. Deleting Files and Directories • rm <file> : Remove a file .e.g., rm ~/Desktop/file1.txt • rm -r <directory> : Removes a directory. e.g., rm -r ~/newdir • rm –i : Removes in an interactive manner. This is a good safety measure. • rmdir <empty directory> : Only remove empty directories .e.g., rmdir ~/emptydir
  • 12. Shell • A shell is a user interface for access to an operating system's services. Most often the user interacts with the shell using a command-line interface (CLI). The terminal is a program that opens a graphical window and lets you interact with the shell. • Shell is a program which processes commands and returns output , like bash in Linux . • Commands are case sensitive.
  • 13. • We can use this technique to write commands in shell:- CommandName -options input. • commandName must be a valid program on the Shell’s Path. To check this, use the which command like : which commandName • If a path is returned, then the commandName is valid and vice versa. Example:- • echo $Path: Path of the command Path. • which cal: cal command was in which folder. • Date –u/date --universal: gives universal standard time.
  • 14. Short Form:- • We can specify options for each command to customise the commands behaviour. These can be either “short-form” options or “long-form” options. • Each command behaves differently so check the command’s manual (man) page for the specifics of each command’s behaviour. • Short-form options are where a letter defines an option. Each option is prepended by a dash “-“ like: commandName –a –b –c args • To save typing, you could join together the options: commandName –abc args. • Both of these formats are equivalent. Long Form:- • There are long-form options defined to make options easier to identify. • Longform options are usually prepended by a double dash “--“. • Long-form options cannot be joined together like short-form options can. • If long form options are defined for options “a”, “b” and “c”, then: commandName –a –b -c arguments is equivalent to commandName --alpha --beta --charlie arguments
  • 15. Bash Scripting • Bash is a type of interpreter that processes shell commands. A command is given in the form of plain text that calls operating system services to perform a task. • Commands like ls and cd are frequently used by programmers; these commands are written in the terminal. The terminal acts as an interface for the shell interpreter. • A Bash script is a text file containing a series of commands. • Bash scripts are given an extension of .sh
  • 16. Piping • Standard Data Streams can be redirected and are identified using their stream number. Redirection of the standard output of one command to the standard input of another command is known as piping. • Redirecting Standard Output: Standard output is stream number 1. There are 2 methods to redirect standard output. The long form, using the stream number: commandName –options arguments 1> destination Or the short form, with no stream number: commandName –options arguments > destination • Redirecting Standard Error: Standard error is stream number 2. Here is how to redirect standard error commandName –options arguments 2> destination Standard error can be redirected at the same time as standard output: commandName –options arguments 1> output_destination 2> error_destination • Redirecting Standard Input: Standard Input is stream number 0. There are 2 methods to redirect standard Input. The long form, using the stream number: commandName –options arguments 0< input_source Or the short form, with no stream number: commandName –options arguments < input_source
  • 17. Aliases • It is the nickname for a command/pipeline. • It is a build in shell command that lets us assign name for a long command or frequently used command. • Aliases go in a .bash_aliases file in your home directory. If it does not exist, you need to create it ,spelled exactly • Example: alias aliasName=”ABCD”
  • 18. Piping to an Alias • If the first command in an alias accepts standard input, then the alias can be piped to; even if it is an entire pipeline! • Our alias is currently: alias calmagic=”cal –A 1 –B 1 12 2017” • cal is the first command in this alias, but cal doesn’t accept standard input.Therefore, this would not work: commandOne –options arguments | calmagic • However, if we adjust our alias so that it can accept standard input: alias calmagic=”xargs cal –A 1 –B 1 12 2017” • This will now work: commandOne –options arguments | calmagic
  • 19. File Achieving and Compressing • Archiving and compressing files in Linux is a two-step process. • 1) Create a Tarball First, you will create what is known as a tar file or “tarball”. A tarball is a way of bundling together the files that you want to archive. • 2) Compress the tarball with a compression algorithm.Secondly, you will then compress that tarball with one of a variety of compression algorithms. • Creating a tarball • tar –cvf <name of tarball> <file>…
  • 20. • Checking a Tarball’s Contents • tar –tf <name of tarball> • Extracting a Tar ball’s Contents • tar –xv <name of tarball> • Compressing Tarballs Tarballs are just containers for files. They don’t by themselves do any compression, but they can be compressed using a variety of compression algorithms.The main types of compression algorithms are gzip and bzip2. Compressing and Decompressing with gzip Compressing with gzip:- gzip <name of tarball> Decompressing with gzip:- gunzip <name of tarball>
  • 21. • Compressing and Decompressing with bzip2 Compressing with bzip2: bzip2 <name of tarball> Decompressing with bzip2 : bunzip2 <name of tarball> Doing it all in one step Creating a tarball and compressing via gzip: tar –cvzf <name of tarball> <file> Decompressing a tarball and extracting via xzip: tar –xvzf <name of tarball> Creating a tarball and compressing via bzip2: tar –cvjf <name of tarball> <file> Decompressing a tarball and extracting via bzip2: tar –xvjf <name of tarball> Creating a tarball and compressing via xzip : tar –cvJf<name of tarball> <file> Decompressing a tarball and extracting via xzip : tar –xvJf<name of tarball>