SlideShare a Scribd company logo
1 of 34
(Practical) Linux 104
Arie Bregman
Senior Software Engineer @RedHat
Agenda
● Package Management
● Job Scheduling
● Interview Questions Examples
Package Management
● What is it good for?
○ Better distribution of software
○ Dependency resolution
○ Updates
Types of package managers
● RPM
○ Red Hat Operating Systems. Also the base for other package managers such as zypper
● dpkg
○ Past: debian. Today: Ubuntu
● pip
○ Python packages
● Google Play
○ Android OS
How it (usually) works
Base vs Tools
● If you are using Red Hat OSs you might ask yourself:
○ Should I use RPM or dnf/yum?”
● If you are using Ubuntu you might ask yourself:
○ Should I use dpkg or apt?
● Short answer: you’ll probably use both
Enough talking. Practice Time!
Open your terminal
List packages
● List all installed packages on the system
● Do you know how to count how many packages installed on the system?
● Query specific package
[arie@fedora ~]$ rpm -qa [arie@ubuntu ~]$ dpkg -l
# or you can use apt list
[arie@fedora ~]$ rpm -q at
at-3.1.20-10.fc28.x86_64
[arie@ubuntu ~]$ dpkg -l at
ii at 3.1.18-2ubuntu1
Package name
● at 3.1.20-10 fc28 x86_64
Software name Version Release Architecture
● More examples
○ python-requests-2.3.4-1.el7.i686
○ zlib-6.2-1.noarch
Package Installation
● Install a new package on your system
● Will it work in a script?
[arie@fedora ~]$ sudo dnf install python-requests [arie@ubuntu ~]$ sudo apt-get install python-requests
[arie@fedora ~]$ sudo dnf install -y python-requests [arie@ubuntu ~]$ sudo apt-get install -y python-requests
Package Removal
● Remove installed package from the system
[arie@fedora ~]$ sudo dnf remove python-requests [arie@ubuntu ~]$ sudo apt-get remove python-requests
Update system packages
● Updates all the installed packages on your system
● Why?
○ Keeps your system up to date
○ Usually Mandatory step for upgrading the system
■ Upgrade = increase in major version
■ Update = increase in minor version
[arie@fedora ~]$ sudo dnf update [arie@ubuntu ~]$ sudo apt-get update
Searching for packages
● Check if package is available for installation by specifying name or description
[arie@fedora ~]$ sudo dnf search ansible [arie@ubuntu ~]$ sudo apt-cache search ansible
Tips
● You can install or remove multiple packages by specifying their names separated
by a space
● Don’t forget to specify ‘-y’ in scripts
● Each command we saw so far, can be used with additional parameters
Explore the options with ‘man’
[arie@fedora ~]$ sudo dnf install -y python-requests zlib vim
[arie@fedora ~]$ sudo dnf install -v zlib
[arie@ubuntu ~]$ sudo apt-get install -d zlib
Exercise
● Make sure the packages python-virtualenv, git and groovy are installed on your
system
● If they are not installed, install them
● Remove the package groovy
● Check if the package ‘ansible’ is available for installation
Solution
[arie@fedora ~]$ rpm -qa | grep -E -w 'virtualenv|^git|^groovy'
[arie@fedora ~]$ sudo dnf install -y groovy git python-virtualenv
[arie@fedora ~]$ sudo dnf remove -y groovy
[arie@fedora ~]$ sudo dnf search ansible # or install without -y :)
Where the packages are coming from?
● Repository = a directory which contains one or more packages
● Ubuntu
○ /etc/apt/sources.list
○ /etc/apt/sources.list.d/*
● Red Hat Based OSs
○ /etc/yum.repos.d/*
[arie@fedora ~]$ sudo cat /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
List repositories
● Ubuntu
● Red Hat Based OSs
[arie@fedora ~]$ sudo dnf repolist
repo id repo name status
Fedora-27-Workstation Fedora-27-Workstation 3,004
docker-ce-edge Docker CE Edge - x86_64 4
docker-ce-stable Docker CE Stable - x86_64 2
[arie@ubuntu ~]$ sudo apt-cache policy
500 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages release v=16.04
Creating your own custom repository - Ubuntu
● Install the package that allows you to create the repository
● Create a directory for storing the packages and move some packages there
● Create Packages.gz which “describes” the repository
● Add it to repositories list
[arie@ubuntu ~]$ sudo apt-get install - y dpkg-dev
[arie@ubuntu ~]$ sudo mkdir -p /usr/local/my_repo
[arie@ubuntu ~]$ sudo chmod 777 /usr/local/my_repo
[arie@ubuntu ~]$ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
[arie@ubuntu ~]$ sudo vi /etc/apt/sources.list
deb file:/usr/local/my_repo ./
Creating your own custom repository - Red Hat
● Install the package that allows you to create the repository
● Create a directory for storing the packages
● Run createrepo
● Add it to repositories list
[arie@fedora ~]$ sudo dnf install -y createrepo
[arie@fedora ~]$ sudo mkdir -p /usr/local/my_repo
[arie@fedora ~]$ sudo chmod 777 /usr/local/my_repo
[arie@fedora ~]$ sudo createrepo /usr/local/my_repo
[arie@fedora ~]$ vi /etc/yum.repos.d/some.repo
[my_repo]
name=my_repo
baseurl=file:///usr/local_my_repo
enabled=1
Packaging - Suggestions for Next Steps
● Package Building
● Explore base limitations compared to extended tools
● Cache
Job Scheduling
● What is it good for?
○ Running tasks at any given date and time
○ Periodic task execution
● Use cases
○ Removing old data
○ Performing updates
○ Configuring systems
Types of job schedulers
● Cron
○ Most known and used job scheduler
○ Has many flavors
● Anacron
○ Works well for systems that may be turned
off some of the time
● Systemd Timers
○ Relatively new
○ Supports calendar time events
Schedule your first job
● We’ll use crontab to install the cron files which define what to run and when
[arie@fedora ~]$ crontab -e
*/2 * * * * /bin/ls
● Save the file and exit
What just happened?
● We created a cron file which tell crond what to run and when
○ Ubuntu: /var/spool/cron/crontabs/<user>
○ Red Hat: /var/spool/cron/<user>
● crond daemon is responsible for executing the jobs
● List your crontab tasks with the following command
[arie@fedora ~]$ crontab -l
*/2 * * * * /bin/ls
Cron Syntax
* * * * * [command to execute]
Minutes Hours Day of month Month Day of week
0-59 0-23 1-31 1-12 0-6
*/2 Every two _____ (minutes, hours, …)
1,6,8 Specific values
0-5 Range
More examples
● Do you understand what is the interval in each of the following examples?
0 0 * * * Every night
0 0 1 */3 * Every quarter
30 15 * 2 5 15:30 on Friday in February
* * * 1,6,10 * Every minute at January, June and October
Exercise
● Schedule the following jobs:
○ Runs every second month and executes ls
○ Runs every hour between 14:00 and 17:00 and executes ‘w’
○ Run every hour on Tuesday and saves the output of date to /tmp/date.log
Solution
* * * */2 * /bin/ls Runs every second month and executes ls
0 14-17 * * * /usr/bin/w Runs every hour between 14:00 and 17:00 and executes ‘w’
0 * * * 2 /bin/date > /tmp/date.log Runs every hour between 14:00 and 17:00 and
executes ‘w’
Remove Cron Jobs
● crontab can be used for creating, listing and removing cron jobs
Note: be careful, in some flavors it will not ask for confirmation
[arie@fedora ~]$ crontab -r
Job Scheduling - Suggestions for Next Steps
● Explore systemd timers
● Explore anacron
● Cron
○ How to load cron jobs from a file
○ Special keywords (e.g. @reboot)
Break
● Any questions on Packaging?
● Any questions on Job Scheduling?
● Good. Now let’s see a couple of questions you should be able to easily
answer after practicing and gaining more experience in the mentioned
subjects
Interview Questions Examples
● Given a file path, how do you know which package owns it?
○ If no package owns it, what does it mean?
● Did you build a package in the past? Can you describe the process?
● How do you create your own repository of packages?
● How to schedule a job to run every Sunday at 18:30?
● A scheduled job was supposed to run yesterday at morning but the server was
down. How can you overcome such situation in the future?
Thank You
● You can find this presentation on GitHub and SlideShare
● Questions?

More Related Content

What's hot

Automating with ansible (Part c)
Automating with ansible (Part c) Automating with ansible (Part c)
Automating with ansible (Part c) iman darabi
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overviewAmeer Sameer
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係Kiwamu Okabe
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linuxkishore1986
 
Unix Commands
Unix CommandsUnix Commands
Unix CommandsDr.Ravi
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Ahmed El-Arabawy
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Ahmed El-Arabawy
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commandsswtjerin4u
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012rivierarb
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpAhmed El-Arabawy
 
Docker & CoreOS at Utah Gophers
Docker & CoreOS at Utah GophersDocker & CoreOS at Utah Gophers
Docker & CoreOS at Utah GophersJosh Braegger
 

What's hot (20)

Perl Programming - 03 Programming File
Perl Programming - 03 Programming FilePerl Programming - 03 Programming File
Perl Programming - 03 Programming File
 
Automating with ansible (Part c)
Automating with ansible (Part c) Automating with ansible (Part c)
Automating with ansible (Part c)
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
Unix Commands
Unix CommandsUnix Commands
Unix Commands
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
Docker & CoreOS at Utah Gophers
Docker & CoreOS at Utah GophersDocker & CoreOS at Utah Gophers
Docker & CoreOS at Utah Gophers
 
Puppet
PuppetPuppet
Puppet
 

Similar to (Practical) linux 104

Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetPuppet
 
Software Packaging for Cross OS Distribution
Software Packaging for Cross OS DistributionSoftware Packaging for Cross OS Distribution
Software Packaging for Cross OS DistributionJian-Hong Pan
 
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordOSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordNETWAYS
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMAlexander Shopov
 
Ubuntu Practice and Configuration
Ubuntu Practice and ConfigurationUbuntu Practice and Configuration
Ubuntu Practice and ConfigurationManoj Sahu
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Isham Rashik
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Jun Hong Kim
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talkPrince Raj
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Sian Lerk Lau
 
Python_Session
Python_SessionPython_Session
Python_Sessionsiva ram
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from githubAntony Gitomeh
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactAlessandro Selli
 
Setting up LAMP for Linux newbies
Setting up LAMP for Linux newbiesSetting up LAMP for Linux newbies
Setting up LAMP for Linux newbiesShabir Ahmad
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1Lilesh Pathe
 

Similar to (Practical) linux 104 (20)

Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Linux
LinuxLinux
Linux
 
Adhocr T-dose 2012
Adhocr T-dose 2012Adhocr T-dose 2012
Adhocr T-dose 2012
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Software Packaging for Cross OS Distribution
Software Packaging for Cross OS DistributionSoftware Packaging for Cross OS Distribution
Software Packaging for Cross OS Distribution
 
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew FordOSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPM
 
Ubuntu Practice and Configuration
Ubuntu Practice and ConfigurationUbuntu Practice and Configuration
Ubuntu Practice and Configuration
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)
 
Python_Session
Python_SessionPython_Session
Python_Session
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
Odoo V8 Installation
Odoo V8 InstallationOdoo V8 Installation
Odoo V8 Installation
 
Setting up LAMP for Linux newbies
Setting up LAMP for Linux newbiesSetting up LAMP for Linux newbies
Setting up LAMP for Linux newbies
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 

(Practical) linux 104

  • 1. (Practical) Linux 104 Arie Bregman Senior Software Engineer @RedHat
  • 2. Agenda ● Package Management ● Job Scheduling ● Interview Questions Examples
  • 3. Package Management ● What is it good for? ○ Better distribution of software ○ Dependency resolution ○ Updates
  • 4. Types of package managers ● RPM ○ Red Hat Operating Systems. Also the base for other package managers such as zypper ● dpkg ○ Past: debian. Today: Ubuntu ● pip ○ Python packages ● Google Play ○ Android OS
  • 6. Base vs Tools ● If you are using Red Hat OSs you might ask yourself: ○ Should I use RPM or dnf/yum?” ● If you are using Ubuntu you might ask yourself: ○ Should I use dpkg or apt? ● Short answer: you’ll probably use both
  • 7. Enough talking. Practice Time! Open your terminal
  • 8. List packages ● List all installed packages on the system ● Do you know how to count how many packages installed on the system? ● Query specific package [arie@fedora ~]$ rpm -qa [arie@ubuntu ~]$ dpkg -l # or you can use apt list [arie@fedora ~]$ rpm -q at at-3.1.20-10.fc28.x86_64 [arie@ubuntu ~]$ dpkg -l at ii at 3.1.18-2ubuntu1
  • 9. Package name ● at 3.1.20-10 fc28 x86_64 Software name Version Release Architecture ● More examples ○ python-requests-2.3.4-1.el7.i686 ○ zlib-6.2-1.noarch
  • 10. Package Installation ● Install a new package on your system ● Will it work in a script? [arie@fedora ~]$ sudo dnf install python-requests [arie@ubuntu ~]$ sudo apt-get install python-requests [arie@fedora ~]$ sudo dnf install -y python-requests [arie@ubuntu ~]$ sudo apt-get install -y python-requests
  • 11. Package Removal ● Remove installed package from the system [arie@fedora ~]$ sudo dnf remove python-requests [arie@ubuntu ~]$ sudo apt-get remove python-requests
  • 12. Update system packages ● Updates all the installed packages on your system ● Why? ○ Keeps your system up to date ○ Usually Mandatory step for upgrading the system ■ Upgrade = increase in major version ■ Update = increase in minor version [arie@fedora ~]$ sudo dnf update [arie@ubuntu ~]$ sudo apt-get update
  • 13. Searching for packages ● Check if package is available for installation by specifying name or description [arie@fedora ~]$ sudo dnf search ansible [arie@ubuntu ~]$ sudo apt-cache search ansible
  • 14. Tips ● You can install or remove multiple packages by specifying their names separated by a space ● Don’t forget to specify ‘-y’ in scripts ● Each command we saw so far, can be used with additional parameters Explore the options with ‘man’ [arie@fedora ~]$ sudo dnf install -y python-requests zlib vim [arie@fedora ~]$ sudo dnf install -v zlib [arie@ubuntu ~]$ sudo apt-get install -d zlib
  • 15. Exercise ● Make sure the packages python-virtualenv, git and groovy are installed on your system ● If they are not installed, install them ● Remove the package groovy ● Check if the package ‘ansible’ is available for installation
  • 16. Solution [arie@fedora ~]$ rpm -qa | grep -E -w 'virtualenv|^git|^groovy' [arie@fedora ~]$ sudo dnf install -y groovy git python-virtualenv [arie@fedora ~]$ sudo dnf remove -y groovy [arie@fedora ~]$ sudo dnf search ansible # or install without -y :)
  • 17. Where the packages are coming from? ● Repository = a directory which contains one or more packages ● Ubuntu ○ /etc/apt/sources.list ○ /etc/apt/sources.list.d/* ● Red Hat Based OSs ○ /etc/yum.repos.d/* [arie@fedora ~]$ sudo cat /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1
  • 18. List repositories ● Ubuntu ● Red Hat Based OSs [arie@fedora ~]$ sudo dnf repolist repo id repo name status Fedora-27-Workstation Fedora-27-Workstation 3,004 docker-ce-edge Docker CE Edge - x86_64 4 docker-ce-stable Docker CE Stable - x86_64 2 [arie@ubuntu ~]$ sudo apt-cache policy 500 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages release v=16.04
  • 19. Creating your own custom repository - Ubuntu ● Install the package that allows you to create the repository ● Create a directory for storing the packages and move some packages there ● Create Packages.gz which “describes” the repository ● Add it to repositories list [arie@ubuntu ~]$ sudo apt-get install - y dpkg-dev [arie@ubuntu ~]$ sudo mkdir -p /usr/local/my_repo [arie@ubuntu ~]$ sudo chmod 777 /usr/local/my_repo [arie@ubuntu ~]$ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz [arie@ubuntu ~]$ sudo vi /etc/apt/sources.list deb file:/usr/local/my_repo ./
  • 20. Creating your own custom repository - Red Hat ● Install the package that allows you to create the repository ● Create a directory for storing the packages ● Run createrepo ● Add it to repositories list [arie@fedora ~]$ sudo dnf install -y createrepo [arie@fedora ~]$ sudo mkdir -p /usr/local/my_repo [arie@fedora ~]$ sudo chmod 777 /usr/local/my_repo [arie@fedora ~]$ sudo createrepo /usr/local/my_repo [arie@fedora ~]$ vi /etc/yum.repos.d/some.repo [my_repo] name=my_repo baseurl=file:///usr/local_my_repo enabled=1
  • 21. Packaging - Suggestions for Next Steps ● Package Building ● Explore base limitations compared to extended tools ● Cache
  • 22. Job Scheduling ● What is it good for? ○ Running tasks at any given date and time ○ Periodic task execution ● Use cases ○ Removing old data ○ Performing updates ○ Configuring systems
  • 23. Types of job schedulers ● Cron ○ Most known and used job scheduler ○ Has many flavors ● Anacron ○ Works well for systems that may be turned off some of the time ● Systemd Timers ○ Relatively new ○ Supports calendar time events
  • 24. Schedule your first job ● We’ll use crontab to install the cron files which define what to run and when [arie@fedora ~]$ crontab -e */2 * * * * /bin/ls ● Save the file and exit
  • 25. What just happened? ● We created a cron file which tell crond what to run and when ○ Ubuntu: /var/spool/cron/crontabs/<user> ○ Red Hat: /var/spool/cron/<user> ● crond daemon is responsible for executing the jobs ● List your crontab tasks with the following command [arie@fedora ~]$ crontab -l */2 * * * * /bin/ls
  • 26. Cron Syntax * * * * * [command to execute] Minutes Hours Day of month Month Day of week 0-59 0-23 1-31 1-12 0-6 */2 Every two _____ (minutes, hours, …) 1,6,8 Specific values 0-5 Range
  • 27. More examples ● Do you understand what is the interval in each of the following examples? 0 0 * * * Every night 0 0 1 */3 * Every quarter 30 15 * 2 5 15:30 on Friday in February * * * 1,6,10 * Every minute at January, June and October
  • 28. Exercise ● Schedule the following jobs: ○ Runs every second month and executes ls ○ Runs every hour between 14:00 and 17:00 and executes ‘w’ ○ Run every hour on Tuesday and saves the output of date to /tmp/date.log
  • 29. Solution * * * */2 * /bin/ls Runs every second month and executes ls 0 14-17 * * * /usr/bin/w Runs every hour between 14:00 and 17:00 and executes ‘w’ 0 * * * 2 /bin/date > /tmp/date.log Runs every hour between 14:00 and 17:00 and executes ‘w’
  • 30. Remove Cron Jobs ● crontab can be used for creating, listing and removing cron jobs Note: be careful, in some flavors it will not ask for confirmation [arie@fedora ~]$ crontab -r
  • 31. Job Scheduling - Suggestions for Next Steps ● Explore systemd timers ● Explore anacron ● Cron ○ How to load cron jobs from a file ○ Special keywords (e.g. @reboot)
  • 32. Break ● Any questions on Packaging? ● Any questions on Job Scheduling? ● Good. Now let’s see a couple of questions you should be able to easily answer after practicing and gaining more experience in the mentioned subjects
  • 33. Interview Questions Examples ● Given a file path, how do you know which package owns it? ○ If no package owns it, what does it mean? ● Did you build a package in the past? Can you describe the process? ● How do you create your own repository of packages? ● How to schedule a job to run every Sunday at 18:30? ● A scheduled job was supposed to run yesterday at morning but the server was down. How can you overcome such situation in the future?
  • 34. Thank You ● You can find this presentation on GitHub and SlideShare ● Questions?