SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Linux CLI

Kenneth Oraegbunam, Software Development Service




                                                   www.iita.org
Shell

• User interface to operating system
  – Text shell (cmd, sh, ash, bsh, bash, ...)
  – GUI shell (Aqua, Windows, GNOME)
• Choice of shell depends on how computer
  is used
  – Text shell for speed and experienced users
  – GUI shell for ease of use




                                                www.iita.org
Command line interface

• User input is text input
• Does not require graphics or mouse, less
  resource intensive
• Generally faster (for experienced users)
  than GUI
• Examples of CLI
  – Quake 1/2/3/4 pressing ~ key brings CLI
  – R (statistical package) is CLI
  – cmd.exe
  – Matlab
                                              www.iita.org
Command line interface

•   User input is interpreted
•   … and executed
•   Results rendered as text
•   … or as graphics

• In this session we will focus on Linux CLI
  “bash”



                                           www.iita.org
bash

• Default shell on Ubuntu
• Runs on OSX, Windows, any *NIX
• Compatible with predecessor bsh
  – Bourne shell
  – Bourne-again shell
• Command line completion (tab key)
• Wikipedia Article



                                      www.iita.org
Programs

• Programs do things
• Programs
  – Compiled programs, bash scripts, other scripts
    (#!/path/to/interpreter)
  – Executable +x flag
• PATH variable
  – Where to look for matching program
• Executing programs
  – In path: # ls
  – Not in path: # /home/user/runscript.sh
                                              www.iita.org
Program arguments and data streams

• Arguments to program
  – Anything that follows the command
• Arguments alter the way program behaves
• Any program has
  – One standard input stream STDIN
  – One standard output stream STDOUT
  – One error output stream STDERR
• System call exec, execve
  – int execve(const char *filename, char *const
    argv[], char *const envp[]);
                                               www.iita.org
Program execution

• Shell will provide
  – Running directory
  – Arguments
  – Stream redirection
     • STDIN from console
     • STDOUT to console
     • STDERR to console
• Run the command # ls -la
  – ls is the program /bin/ls
  – -la is one argument, but two flags
                                         www.iita.org
Bash built-ins

• Shell built in commands
  – cd change directory
  – pwd print current directory to STDOUT
  – echo print to STDOUT
  – exec execute command and replace current
    shell
  – exit
  – history show command line history
  – alias register alias command
  – set and unset
  – … plenty more                          www.iita.org
Other programs

• Other useful programs, not part of shell
  – ls list files in current directory
  – ps list processes
  – man display manual pages: # man ls
  – kill send signal to process
  – nano friendly text editor
  – vi, vim unfriendly text editor
  – screen text-mode window manager
  – grep filter input stream
  – cat concatenate files and print to STDOUT
  – head and tail print first/last X lines to STDOUT
                                                  www.iita.org
Hands-on Training

•   Start the terminal
•   What's the current directory?
•   Create a folder “training”
•   Navigate to folder
•   Create “README” file in “training” folder
•   Create “deleteme.txt” file
•   Remove deleteme.txt file
•   Wipe “training” folder
•   Find help for using command rmdir
                                            www.iita.org
Expansions

•   . expands to current directory
•   ~ expands to user's home directory
•   .. expands to parent directory
•   Brace expansion
    – # mkdir {old,new,current}
• Parameter expansion
    – $0, $1, $@
• Command substitution
    – # `which ls`
                                         www.iita.org
Useful commands

• Grep is used to filter lines matching a
  pattern
  – # grep PATTERN file1 file2 file3
• Cat is used to concatenate files and output
  to STDOUT
  – # cat file1 file2
• Find is used to search for matching files
  – # find /home/ubuntu (list all files there)
  – # find . (list all files from current directory)

                                                       www.iita.org
Output stream redirection

• Command # ls -1 will list files in current
  directory
• ls command writes the list of files to
  STDOUT
• Instruct bash to redirect STDOUT to a file:
  – # ls -1 > filelist.txt
• View file contents
  – # cat filelist.txt
• Filter list contents
  – # grep 'something' filelist.txt
                                          www.iita.org
Appending to file

• Instruct bash to redirect STDOUT to a file:
  – # ls -1 > filelist.txt
  – Will overwrite contents of filelist.txt
• Instruct bash to append to file
  – # ls -1 >> filelist.txt


• Redirecting both STDERR and STDOUT
  – # command &> filename
  – # command &>> filename

                                              www.iita.org
Input stream redirection

• Input stream can be replaced by file input
• grep will use STDIN if no file argument
  given
  – # grep 'test'
  – Expects input on STDIN, type something and
    press enter
• Following commands are equivalent
  – grep 'D' filename.txt
  – grep 'D' < filename.txt

                                            www.iita.org
Pipelining

• Sequence of commands where STDOUT
  (or STDERR) is attached to STDIN of
  following command
• # cat filename.txt | grep 'D'
  – cat writes filename.txt to STDOUT
  – grep will filter STDIN for lines containing D




                                                    www.iita.org

Weitere ähnliche Inhalte

Was ist angesagt?

Compression Commands in Linux
Compression Commands in LinuxCompression Commands in Linux
Compression Commands in Linux
Pegah Taheri
 

Was ist angesagt? (20)

Linux: Everyting-as-a-service
Linux: Everyting-as-a-serviceLinux: Everyting-as-a-service
Linux: Everyting-as-a-service
 
Course 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesCourse 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment Variables
 
UNIX Basics and Cluster Computing
UNIX Basics and Cluster ComputingUNIX Basics and Cluster Computing
UNIX Basics and Cluster Computing
 
Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1) Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1)
 
Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Intro to Python programming and iPython
Intro to Python programming and iPython Intro to Python programming and iPython
Intro to Python programming and iPython
 
Compression Commands in Linux
Compression Commands in LinuxCompression Commands in Linux
Compression Commands in Linux
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring
 
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
 
Basic commands
Basic commandsBasic commands
Basic commands
 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
 
Linux Fundamentals
Linux FundamentalsLinux Fundamentals
Linux Fundamentals
 
Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
 

Andere mochten auch

Andere mochten auch (14)

Linux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procLinux fundamental - Chap 08 proc
Linux fundamental - Chap 08 proc
 
Windows7 Vs Linux
Windows7 Vs LinuxWindows7 Vs Linux
Windows7 Vs Linux
 
Linux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fsLinux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fs
 
The linux command line for total beginners
The linux command line  for total beginnersThe linux command line  for total beginners
The linux command line for total beginners
 
Linux fundamental - Chap 01 io
Linux fundamental - Chap 01 ioLinux fundamental - Chap 01 io
Linux fundamental - Chap 01 io
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regx
 
Linux fundamental - Chap 07 vi
Linux fundamental - Chap 07 viLinux fundamental - Chap 07 vi
Linux fundamental - Chap 07 vi
 
Linux fundamental - Chap 03 file
Linux fundamental - Chap 03 fileLinux fundamental - Chap 03 file
Linux fundamental - Chap 03 file
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
Linux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permLinux fundamental - Chap 02 perm
Linux fundamental - Chap 02 perm
 
Importance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation readingImportance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation reading
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 

Ähnlich wie Linux CLI

001 linux revision
001 linux revision001 linux revision
001 linux revision
Sherif Mousa
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
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
 

Ähnlich wie Linux CLI (20)

Linux
LinuxLinux
Linux
 
cisco
ciscocisco
cisco
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
3. intro
3. intro3. intro
3. intro
 
LinuxCommands (1).pdf
LinuxCommands (1).pdfLinuxCommands (1).pdf
LinuxCommands (1).pdf
 
Linux
LinuxLinux
Linux
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
 
proj2-the UNIX SYSTEM.ppt
proj2-the UNIX SYSTEM.pptproj2-the UNIX SYSTEM.ppt
proj2-the UNIX SYSTEM.ppt
 
redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
 
Unix _linux_fundamentals_for_hpc-_b
Unix  _linux_fundamentals_for_hpc-_bUnix  _linux_fundamentals_for_hpc-_b
Unix _linux_fundamentals_for_hpc-_b
 
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
 
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
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
unit 3 ppt file represented system......
unit 3 ppt file represented system......unit 3 ppt file represented system......
unit 3 ppt file represented system......
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Ericas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-GuideEricas-Linux-Plus-Study-Guide
Ericas-Linux-Plus-Study-Guide
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
linux cmds.pptx
linux cmds.pptxlinux cmds.pptx
linux cmds.pptx
 

Mehr von International Institute of Tropical Agriculture

Mehr von International Institute of Tropical Agriculture (20)

Make your research visible and create more impact using DataCite DOIs
Make your research visible and  create more impact using  DataCite DOIsMake your research visible and  create more impact using  DataCite DOIs
Make your research visible and create more impact using DataCite DOIs
 
Induction of early flowering in cassava through light supplementation and CM...
Induction of early flowering in cassava  through light supplementation and CM...Induction of early flowering in cassava  through light supplementation and CM...
Induction of early flowering in cassava through light supplementation and CM...
 
Producing yam mother plants to collect vines for propagation
Producing yam mother plants to collect  vines for propagationProducing yam mother plants to collect  vines for propagation
Producing yam mother plants to collect vines for propagation
 
Effects of moult and breeding on the body condition of some forest birds in s...
Effects of moult and breeding on the body condition of some forest birds in s...Effects of moult and breeding on the body condition of some forest birds in s...
Effects of moult and breeding on the body condition of some forest birds in s...
 
Conserving Nigeria’s rarest endemic bird: Ibadan Malimbe, Malimbusibadanensis
Conserving Nigeria’s rarest endemic bird: Ibadan Malimbe, MalimbusibadanensisConserving Nigeria’s rarest endemic bird: Ibadan Malimbe, Malimbusibadanensis
Conserving Nigeria’s rarest endemic bird: Ibadan Malimbe, Malimbusibadanensis
 
Cassava brown streak epidemiology in Eastern Democratic Republic of the Congo
Cassava brown streak epidemiology in Eastern Democratic  Republic of the CongoCassava brown streak epidemiology in Eastern Democratic  Republic of the Congo
Cassava brown streak epidemiology in Eastern Democratic Republic of the Congo
 
Assessment of genetic diversity among Rwandan cassava (Manihot esculenta) ger...
Assessment of genetic diversity among Rwandan cassava (Manihot esculenta) ger...Assessment of genetic diversity among Rwandan cassava (Manihot esculenta) ger...
Assessment of genetic diversity among Rwandan cassava (Manihot esculenta) ger...
 
9 osunbade identification of end users preferences of a cassava product
9 osunbade identification of end users preferences of a cassava product9 osunbade identification of end users preferences of a cassava product
9 osunbade identification of end users preferences of a cassava product
 
7 helen ufondu perception of yam landraces quality among value chain actors i...
7 helen ufondu perception of yam landraces quality among value chain actors i...7 helen ufondu perception of yam landraces quality among value chain actors i...
7 helen ufondu perception of yam landraces quality among value chain actors i...
 
8 kazeem quality attributes and consumer acceptability of cookies flavoured
8 kazeem quality attributes and consumer acceptability of cookies flavoured8 kazeem quality attributes and consumer acceptability of cookies flavoured
8 kazeem quality attributes and consumer acceptability of cookies flavoured
 
6 anajekwu ekpereka chemical, functional and pasting properties of flours pro...
6 anajekwu ekpereka chemical, functional and pasting properties of flours pro...6 anajekwu ekpereka chemical, functional and pasting properties of flours pro...
6 anajekwu ekpereka chemical, functional and pasting properties of flours pro...
 
5 seun olowote effect of drying method on caroteniod content of yellow maize
5 seun olowote effect of drying method on caroteniod content of yellow maize5 seun olowote effect of drying method on caroteniod content of yellow maize
5 seun olowote effect of drying method on caroteniod content of yellow maize
 
4 ayodele adenitan survey of dried plantain (musa paradisiaca) chips processo...
4 ayodele adenitan survey of dried plantain (musa paradisiaca) chips processo...4 ayodele adenitan survey of dried plantain (musa paradisiaca) chips processo...
4 ayodele adenitan survey of dried plantain (musa paradisiaca) chips processo...
 
2 akin olagunju does crop diversification influenc e food and nutrition secur...
2 akin olagunju does crop diversification influenc e food and nutrition secur...2 akin olagunju does crop diversification influenc e food and nutrition secur...
2 akin olagunju does crop diversification influenc e food and nutrition secur...
 
3 akinsola carotenoid apparent retention in ogi flour made from different pro...
3 akinsola carotenoid apparent retention in ogi flour made from different pro...3 akinsola carotenoid apparent retention in ogi flour made from different pro...
3 akinsola carotenoid apparent retention in ogi flour made from different pro...
 
1 pearl amadi assessing the level of consumption of pro vitamin a cassava pr...
1 pearl amadi assessing the level of consumption of pro  vitamin a cassava pr...1 pearl amadi assessing the level of consumption of pro  vitamin a cassava pr...
1 pearl amadi assessing the level of consumption of pro vitamin a cassava pr...
 
Prof janice olawoye
Prof janice olawoyeProf janice olawoye
Prof janice olawoye
 
Inqaba biotech presentation
Inqaba biotech presentationInqaba biotech presentation
Inqaba biotech presentation
 
Iarsaf symposium adaptation to climate change
Iarsaf symposium adaptation to climate changeIarsaf symposium adaptation to climate change
Iarsaf symposium adaptation to climate change
 
Bimaf iita iarsaf presentation-ibadan 21.05.19
Bimaf  iita iarsaf presentation-ibadan 21.05.19Bimaf  iita iarsaf presentation-ibadan 21.05.19
Bimaf iita iarsaf presentation-ibadan 21.05.19
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Linux CLI

  • 1. Linux CLI Kenneth Oraegbunam, Software Development Service www.iita.org
  • 2. Shell • User interface to operating system – Text shell (cmd, sh, ash, bsh, bash, ...) – GUI shell (Aqua, Windows, GNOME) • Choice of shell depends on how computer is used – Text shell for speed and experienced users – GUI shell for ease of use www.iita.org
  • 3. Command line interface • User input is text input • Does not require graphics or mouse, less resource intensive • Generally faster (for experienced users) than GUI • Examples of CLI – Quake 1/2/3/4 pressing ~ key brings CLI – R (statistical package) is CLI – cmd.exe – Matlab www.iita.org
  • 4. Command line interface • User input is interpreted • … and executed • Results rendered as text • … or as graphics • In this session we will focus on Linux CLI “bash” www.iita.org
  • 5. bash • Default shell on Ubuntu • Runs on OSX, Windows, any *NIX • Compatible with predecessor bsh – Bourne shell – Bourne-again shell • Command line completion (tab key) • Wikipedia Article www.iita.org
  • 6. Programs • Programs do things • Programs – Compiled programs, bash scripts, other scripts (#!/path/to/interpreter) – Executable +x flag • PATH variable – Where to look for matching program • Executing programs – In path: # ls – Not in path: # /home/user/runscript.sh www.iita.org
  • 7. Program arguments and data streams • Arguments to program – Anything that follows the command • Arguments alter the way program behaves • Any program has – One standard input stream STDIN – One standard output stream STDOUT – One error output stream STDERR • System call exec, execve – int execve(const char *filename, char *const argv[], char *const envp[]); www.iita.org
  • 8. Program execution • Shell will provide – Running directory – Arguments – Stream redirection • STDIN from console • STDOUT to console • STDERR to console • Run the command # ls -la – ls is the program /bin/ls – -la is one argument, but two flags www.iita.org
  • 9. Bash built-ins • Shell built in commands – cd change directory – pwd print current directory to STDOUT – echo print to STDOUT – exec execute command and replace current shell – exit – history show command line history – alias register alias command – set and unset – … plenty more www.iita.org
  • 10. Other programs • Other useful programs, not part of shell – ls list files in current directory – ps list processes – man display manual pages: # man ls – kill send signal to process – nano friendly text editor – vi, vim unfriendly text editor – screen text-mode window manager – grep filter input stream – cat concatenate files and print to STDOUT – head and tail print first/last X lines to STDOUT www.iita.org
  • 11. Hands-on Training • Start the terminal • What's the current directory? • Create a folder “training” • Navigate to folder • Create “README” file in “training” folder • Create “deleteme.txt” file • Remove deleteme.txt file • Wipe “training” folder • Find help for using command rmdir www.iita.org
  • 12. Expansions • . expands to current directory • ~ expands to user's home directory • .. expands to parent directory • Brace expansion – # mkdir {old,new,current} • Parameter expansion – $0, $1, $@ • Command substitution – # `which ls` www.iita.org
  • 13. Useful commands • Grep is used to filter lines matching a pattern – # grep PATTERN file1 file2 file3 • Cat is used to concatenate files and output to STDOUT – # cat file1 file2 • Find is used to search for matching files – # find /home/ubuntu (list all files there) – # find . (list all files from current directory) www.iita.org
  • 14. Output stream redirection • Command # ls -1 will list files in current directory • ls command writes the list of files to STDOUT • Instruct bash to redirect STDOUT to a file: – # ls -1 > filelist.txt • View file contents – # cat filelist.txt • Filter list contents – # grep 'something' filelist.txt www.iita.org
  • 15. Appending to file • Instruct bash to redirect STDOUT to a file: – # ls -1 > filelist.txt – Will overwrite contents of filelist.txt • Instruct bash to append to file – # ls -1 >> filelist.txt • Redirecting both STDERR and STDOUT – # command &> filename – # command &>> filename www.iita.org
  • 16. Input stream redirection • Input stream can be replaced by file input • grep will use STDIN if no file argument given – # grep 'test' – Expects input on STDIN, type something and press enter • Following commands are equivalent – grep 'D' filename.txt – grep 'D' < filename.txt www.iita.org
  • 17. Pipelining • Sequence of commands where STDOUT (or STDERR) is attached to STDIN of following command • # cat filename.txt | grep 'D' – cat writes filename.txt to STDOUT – grep will filter STDIN for lines containing D www.iita.org