SlideShare a Scribd company logo
1 of 46
Download to read offline
Linux tar
Linux tar
By : Khawar Nehal
13 October 2021
Agenda
yum and apt-get to install tar
tar gzip
split and cat for multiple files
sed
useradd
groups
Install tar
RPM Based distributions like CentOS use yum
yum install tar gzip zip unzip bzip2
Debian Based distributions like
MX Linux use apt-get
apt-get install tar gzip zip unzip bzip2
Using tar
tar cvf FILENAME.tar DIRECTORY/
Replace FILENAME with whatever filename you
want and DIRECTORY with the path to the
directory you want to make into a tarball.
Command Flags Explanation
c: Create a TAR file.
v: Output verbosely (you'll be told exactly what is
happening in detail).
f: Specify a filename for the resulting TAR file.
Using tar
Put a Directory into a TAR file and Compress it with GZIP
Execute the following to create a single .tar.gz file
containing all of the contents of the specified directory:
tar cvfz FILENAME.tar.gz DIRECTORY/
Replace FILENAME with whatever filename you want
and DIRECTORY with the path to the directory you want
to make into a compressed tarball.
Tarred files compressed with GZIP sometimes use
the .tgz file extension.
Using tar
Command Flags Explanation
c: Create a TAR file.
v: Output verbosely (you'll be told exactly what is
happening in detail).
f: Specify a filename for the resulting TAR file.
z: Compress the TAR file with GZIP
Using tar
More for practice
https://www.hostdime.com/kb/hd/command-line/how-to-ta
r-untar-and-zip-files
Split and cat
We have discussed split and cat for making pieces of
files and combining them.
More for practice
https://ostechnix.com/split-combine-files-command-line-li
nux/
This can be used if the tar file is larger than the medium.
For example a DVD
Split and cat
tar cvfz /home /tmp/home_stuff.tgz
cd /tmp
split –bytes 4G home_stuff.tgz home_parts.
This shall create files as home_parts.aa .. ab ac and so
on
Split and cat
Split can use size letters
K,M,G,T,P,E,Z,Y
1K = Kilobyte
1G = 1 Gigabyte
P = petabyte = 1000 Terabytes
E = exabyte = 1 million Terabytes
Z = zetabyte = 1 billion Terabytes
Y = yotabyte = 1000 zetabytes = trillion terabytes
sed
$cat > geekfile.txt
unix is great os. unix is opensource. unix is free os.
learn operating system.
unix linux which one you choose.
unix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
sed
$sed 's/unix/linux/' geekfile.txt
Output :
linux is great os. unix is opensource. unix is free os.
learn operating system.
linux linux which one you choose.
linux is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
sed
$sed 's/unix/linux/g' geekfile.txt
Output :
linux is great os. linux is opensource. linux is free os.
learn operating system.
linux linux which one you choose.
linux is easy to learn.linux is a multiuser os.Learn linux .linux is a powerful.
sed
Replacing the nth occurrence of a pattern in a line : Use
the /1, /2 etc flags to replace the first, second occurrence
of a pattern in a line. The below command replaces the
second occurrence of the word “unix” with “linux” in a
line.
sed
$sed 's/unix/linux/2' geekfile.txt
Output:
unix is great os. linux is opensource. unix is free os.
learn operating system.
unix linux which one you choose.
unix is easy to learn.linux is a multiuser os.Learn unix .unix is a powerful.
sed
Replacing all the occurrence of the pattern in a line : The
substitute flag /g (global replacement) specifies the sed
command to replace all the occurrences of the string in
the line.
sed
Replacing from nth occurrence to all occurrences in a line
: Use the combination of /1, /2 etc and /g to replace all
the patterns from the nth occurrence of a pattern in a
line. The following sed command replaces the third,
fourth, fifth… “unix” word with “linux” word in a line.
sed
$sed 's/unix/linux/3g' geekfile.txt
Output:
unix is great os. unix is opensource. linux is free os.
learn operating system.
unix linux which one you choose.
unix is easy to learn.unix is a multiuser os.Learn linux .linux is a powerful.
sed
sed requires a lot of time and practice.
So we shall not be spending too much class time.
I have given an example of what it can look like and
longer tutorial which shall take things slowly but more
easily
sed
Parenthesize first character of each word :
This sed example prints the first character of every word
in parenthesis.
$ echo "Welcome To The Geek Stuff" | sed 's/(b[A-Z])/(1)/g'
Output:
(W)elcome (T)o (T)he (G)eek (S)tuff
sed
sed -e '/^[[:space:]]*$/ d'  # remove empty line
-e 's/^[[:space:]]*//'  # remove white space at the beginning
-e 's/[[:space:]]*$//'  # remove white space at the ending (EOL)
-e 's/[[:space:]][[:space:]]*/n/g'  # convert blanks between words to newline
-e '$a' # add a newline if missing at EOF
-e ..... # replace other patterns.
sed
This is the link to the tutorial. You can practice and ask questions later or on
slack. This shall require some time to explain each example or question and
may not be a good idea to bore everyone with sed examples.
https://www.tutorialspoint.com/sed/index.htm
You can use as much time as you want via slack for asking detailed questions
with the applications you want to practice on.
useradd
useradd [options] [LOGIN]
useradd
Adding a comment/GECOS value
-c : option assigns the value of GECOS field. For example:
Here the new user Steve is assigned the GECOS value as Steve Smith which is
the full name of the user.
useradd
Set Home Directory
-d : option creates a home directory with a name and path of your choice. By
default the home directory is created in /home directory with the same name as
the user’s name. But with –d option you can create a home directory of your
choice. For example:
useradd
Set UID of choice
-u : option assigns a user ID of your choice. For example:
The user David is given the UID 5555.
useradd
Assign a GID of choice
-g : option assigns the user to an existing group rather than creating a new
group for it. For example:
using -g option with useradd command using -g option with useradd
The user David is assigned to the group with GID 1007 which is an existing
group. Steve is already a member of 1007.
groups
A group in Linux is a collection of accounts that
can be given special permissions on the system.
For example, you can give one group the Read
permission on a file and another group the Read/
Write permissions on the same file.
This way, the users in the first group can only read
the file while the users in the second group can
read and modify it.
groups
Every user in Linux must have a primary group
assigned.
In most Linux distributions, the primary group is a
group with the same name as the user.
When a user creates files or launch programs,
those files and running programs are associated
with that group.
groups
In the next example we will create a file while
logged in as the user bob:
In the picture above you can see that the file
we’ve just created is associated with the group
named bob (the fourth field from the left
represents the group the file is associated with).
groups
The /etc/group file is a configuration file that
stores group information.
This file is readable by all users.
groups
To create groups in Linux, you can use a tool
called addgroup. addgroup is a friendlier front-end
to the low level tool groupadd.
The syntax of this command is simple: you just
type addgroup, followed by the name of the group.
You can also provide a specific GID (Group ID) for
the group with the –gid NUMBER parameter. If
you omit this parameter, addgroup will use the
next available GID.
groups
Let’s create a group called test_group with the
GID of 2000:
groups
Groups are created with no users.
To add a user to the group, use the adduser
command with two parameters: the username and
group. For instance, to add the user jowilliams to
the group test_group, we would use the following
command:
groups
To delete a group in Linux, you can use a tool
called delgroup. delgroup is a friendlier front-end
to the groupdel program.
The delgroup command takes a single parameter:
the group name.
Note that you can’t delete the primary group of an
existing user: you must delete the user first or
change its primary group.
groups
Let’s delete the group we’ve created in the
previous section:
groups
You can also delete a group by editing the
/etc/group file, but it is recommended to use the
delgroup command.
delgroup checks whether the group is any user’s
primary group and if it is, refuses to remove the
group.
Modify groups
To modify an existing group in Linux, the
groupmod command is used.
Using this command you can change the GID of a
group, set the group password and change the
name of a group.
Modify groups
Here is a list of groupmod’s options:
Modify groups
Here is a simple example of this command’s
usage. To change the name of the group from
test_gr to test_group, we can use the following
command:
Modify groups
Add users to groups
Interestingly enough, you can’t use the groupmod
command to add a user to a group.
Instead, the usermod command with the -G option
is used.
When adding a user to a new group, be sure to
also list all of the user’s current groups.
Omitting any of the user’s current groups will
remove the user from those groups!
Modify groups
To add bob to the group test_group, we can use
the following command:
We can list the groups a user is in by using the
groups command:
Modify groups
If you don’t wont to list all the user’s current
groups when adding a user to a new group, you
can use the -a option.
For example, if we want to add jwilliams to the
group cdrom and keep the current group
membership, we can use the following command:
Practice
For more practice
https://geek-university.com/linux/linux-groups/
Summary
yum and apt-get to install tar
tar gzip
split and cat for multiple files
sed
useradd
groups

More Related Content

What's hot

Linux Administration
Linux AdministrationLinux Administration
Linux AdministrationHarish1983
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commandsSagar Kumar
 
Basic commands
Basic commandsBasic commands
Basic commandsambilivava
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linuxshravan saini
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structureSreenatha Reddy K R
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbookWave Digitech
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examplesIntroduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examplesNoé Fernández-Pozo
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformaticsBonnie Ng
 

What's hot (20)

Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Basic commands
Basic commandsBasic commands
Basic commands
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Linux
Linux Linux
Linux
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examplesIntroduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examples
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
 

Similar to Linux class 8 tar

Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3Gourav Varma
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux Harish R
 
Rhel 6.2 complete ebook
Rhel 6.2  complete ebookRhel 6.2  complete ebook
Rhel 6.2 complete ebookYash Gulati
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line ToolsDavid Harris
 
Rhel 6.2 complete ebook
Rhel 6.2 complete ebookRhel 6.2 complete ebook
Rhel 6.2 complete ebookYash Gulati
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsBITS
 
Sls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeSls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeQasim Khawaja
 
Devops for beginners
Devops for beginnersDevops for beginners
Devops for beginnersVivek Parihar
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdfMarsMox
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 

Similar to Linux class 8 tar (20)

Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
 
Rhel 6.2 complete ebook
Rhel 6.2  complete ebookRhel 6.2  complete ebook
Rhel 6.2 complete ebook
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line Tools
 
Rhel 6.2 complete ebook
Rhel 6.2 complete ebookRhel 6.2 complete ebook
Rhel 6.2 complete ebook
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Unix3
Unix3Unix3
Unix3
 
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
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
 
Sls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeSls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In Practice
 
Linux
LinuxLinux
Linux
 
Devops for beginners
Devops for beginnersDevops for beginners
Devops for beginners
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 

More from Khawar Nehal khawar.nehal@atrc.net.pk

More from Khawar Nehal khawar.nehal@atrc.net.pk (20)

Linux Class 1 Reasons to use linux
Linux Class 1 Reasons to use linux Linux Class 1 Reasons to use linux
Linux Class 1 Reasons to use linux
 
Same old lessons in investing
Same old lessons in investingSame old lessons in investing
Same old lessons in investing
 
Linux class 15 26 oct 2021
Linux class 15   26 oct 2021Linux class 15   26 oct 2021
Linux class 15 26 oct 2021
 
File systems linux class 8
File systems linux class 8File systems linux class 8
File systems linux class 8
 
Linux commands Class 5 - 8 oct 2021
Linux commands Class 5 - 8 oct 2021Linux commands Class 5 - 8 oct 2021
Linux commands Class 5 - 8 oct 2021
 
Linux course fhs file hierarchy standard
Linux   course   fhs file hierarchy standardLinux   course   fhs file hierarchy standard
Linux course fhs file hierarchy standard
 
Linux passwords class 4
Linux passwords class 4Linux passwords class 4
Linux passwords class 4
 
Using linux 5 oct 2021 3
Using linux 5 oct 2021 3Using linux 5 oct 2021 3
Using linux 5 oct 2021 3
 
Everyday uses of linux
Everyday uses of linux  Everyday uses of linux
Everyday uses of linux
 
Computing people
Computing people  Computing people
Computing people
 
Artificial Intelligence by Khawar Nehal
Artificial Intelligence by Khawar NehalArtificial Intelligence by Khawar Nehal
Artificial Intelligence by Khawar Nehal
 
Artificial Intelligence in Banking
Artificial Intelligence in BankingArtificial Intelligence in Banking
Artificial Intelligence in Banking
 
Electric Vehicles
Electric VehiclesElectric Vehicles
Electric Vehicles
 
Electric Vehicles
Electric VehiclesElectric Vehicles
Electric Vehicles
 
RevOps Revenue Operations
RevOps Revenue OperationsRevOps Revenue Operations
RevOps Revenue Operations
 
Management techniques of the world by khawar nehal 4 august 2020-1
Management techniques of the world by khawar nehal   4 august 2020-1Management techniques of the world by khawar nehal   4 august 2020-1
Management techniques of the world by khawar nehal 4 august 2020-1
 
Kona (TM) Autonomous Cars Anti Collision System
Kona (TM) Autonomous Cars Anti Collision SystemKona (TM) Autonomous Cars Anti Collision System
Kona (TM) Autonomous Cars Anti Collision System
 
What was learned about what works in distance learning in 2020
What was learned about what works in distance learning in 2020What was learned about what works in distance learning in 2020
What was learned about what works in distance learning in 2020
 
Values provided by businesses
Values provided by businesses  Values provided by businesses
Values provided by businesses
 
Effective and complete Cybersecurity HOWTO
Effective and complete Cybersecurity HOWTOEffective and complete Cybersecurity HOWTO
Effective and complete Cybersecurity HOWTO
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 

Recently uploaded (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 

Linux class 8 tar

  • 2. Linux tar By : Khawar Nehal 13 October 2021
  • 3. Agenda yum and apt-get to install tar tar gzip split and cat for multiple files sed useradd groups
  • 4. Install tar RPM Based distributions like CentOS use yum yum install tar gzip zip unzip bzip2 Debian Based distributions like MX Linux use apt-get apt-get install tar gzip zip unzip bzip2
  • 5. Using tar tar cvf FILENAME.tar DIRECTORY/ Replace FILENAME with whatever filename you want and DIRECTORY with the path to the directory you want to make into a tarball. Command Flags Explanation c: Create a TAR file. v: Output verbosely (you'll be told exactly what is happening in detail). f: Specify a filename for the resulting TAR file.
  • 6. Using tar Put a Directory into a TAR file and Compress it with GZIP Execute the following to create a single .tar.gz file containing all of the contents of the specified directory: tar cvfz FILENAME.tar.gz DIRECTORY/ Replace FILENAME with whatever filename you want and DIRECTORY with the path to the directory you want to make into a compressed tarball. Tarred files compressed with GZIP sometimes use the .tgz file extension.
  • 7. Using tar Command Flags Explanation c: Create a TAR file. v: Output verbosely (you'll be told exactly what is happening in detail). f: Specify a filename for the resulting TAR file. z: Compress the TAR file with GZIP
  • 8. Using tar More for practice https://www.hostdime.com/kb/hd/command-line/how-to-ta r-untar-and-zip-files
  • 9. Split and cat We have discussed split and cat for making pieces of files and combining them. More for practice https://ostechnix.com/split-combine-files-command-line-li nux/ This can be used if the tar file is larger than the medium. For example a DVD
  • 10. Split and cat tar cvfz /home /tmp/home_stuff.tgz cd /tmp split –bytes 4G home_stuff.tgz home_parts. This shall create files as home_parts.aa .. ab ac and so on
  • 11. Split and cat Split can use size letters K,M,G,T,P,E,Z,Y 1K = Kilobyte 1G = 1 Gigabyte P = petabyte = 1000 Terabytes E = exabyte = 1 million Terabytes Z = zetabyte = 1 billion Terabytes Y = yotabyte = 1000 zetabytes = trillion terabytes
  • 12. sed $cat > geekfile.txt unix is great os. unix is opensource. unix is free os. learn operating system. unix linux which one you choose. unix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
  • 13. sed $sed 's/unix/linux/' geekfile.txt Output : linux is great os. unix is opensource. unix is free os. learn operating system. linux linux which one you choose. linux is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
  • 14. sed $sed 's/unix/linux/g' geekfile.txt Output : linux is great os. linux is opensource. linux is free os. learn operating system. linux linux which one you choose. linux is easy to learn.linux is a multiuser os.Learn linux .linux is a powerful.
  • 15. sed Replacing the nth occurrence of a pattern in a line : Use the /1, /2 etc flags to replace the first, second occurrence of a pattern in a line. The below command replaces the second occurrence of the word “unix” with “linux” in a line.
  • 16. sed $sed 's/unix/linux/2' geekfile.txt Output: unix is great os. linux is opensource. unix is free os. learn operating system. unix linux which one you choose. unix is easy to learn.linux is a multiuser os.Learn unix .unix is a powerful.
  • 17. sed Replacing all the occurrence of the pattern in a line : The substitute flag /g (global replacement) specifies the sed command to replace all the occurrences of the string in the line.
  • 18. sed Replacing from nth occurrence to all occurrences in a line : Use the combination of /1, /2 etc and /g to replace all the patterns from the nth occurrence of a pattern in a line. The following sed command replaces the third, fourth, fifth… “unix” word with “linux” word in a line.
  • 19. sed $sed 's/unix/linux/3g' geekfile.txt Output: unix is great os. unix is opensource. linux is free os. learn operating system. unix linux which one you choose. unix is easy to learn.unix is a multiuser os.Learn linux .linux is a powerful.
  • 20. sed sed requires a lot of time and practice. So we shall not be spending too much class time. I have given an example of what it can look like and longer tutorial which shall take things slowly but more easily
  • 21. sed Parenthesize first character of each word : This sed example prints the first character of every word in parenthesis. $ echo "Welcome To The Geek Stuff" | sed 's/(b[A-Z])/(1)/g' Output: (W)elcome (T)o (T)he (G)eek (S)tuff
  • 22. sed sed -e '/^[[:space:]]*$/ d' # remove empty line -e 's/^[[:space:]]*//' # remove white space at the beginning -e 's/[[:space:]]*$//' # remove white space at the ending (EOL) -e 's/[[:space:]][[:space:]]*/n/g' # convert blanks between words to newline -e '$a' # add a newline if missing at EOF -e ..... # replace other patterns.
  • 23. sed This is the link to the tutorial. You can practice and ask questions later or on slack. This shall require some time to explain each example or question and may not be a good idea to bore everyone with sed examples. https://www.tutorialspoint.com/sed/index.htm You can use as much time as you want via slack for asking detailed questions with the applications you want to practice on.
  • 25. useradd Adding a comment/GECOS value -c : option assigns the value of GECOS field. For example: Here the new user Steve is assigned the GECOS value as Steve Smith which is the full name of the user.
  • 26. useradd Set Home Directory -d : option creates a home directory with a name and path of your choice. By default the home directory is created in /home directory with the same name as the user’s name. But with –d option you can create a home directory of your choice. For example:
  • 27. useradd Set UID of choice -u : option assigns a user ID of your choice. For example: The user David is given the UID 5555.
  • 28. useradd Assign a GID of choice -g : option assigns the user to an existing group rather than creating a new group for it. For example: using -g option with useradd command using -g option with useradd The user David is assigned to the group with GID 1007 which is an existing group. Steve is already a member of 1007.
  • 29. groups A group in Linux is a collection of accounts that can be given special permissions on the system. For example, you can give one group the Read permission on a file and another group the Read/ Write permissions on the same file. This way, the users in the first group can only read the file while the users in the second group can read and modify it.
  • 30. groups Every user in Linux must have a primary group assigned. In most Linux distributions, the primary group is a group with the same name as the user. When a user creates files or launch programs, those files and running programs are associated with that group.
  • 31. groups In the next example we will create a file while logged in as the user bob: In the picture above you can see that the file we’ve just created is associated with the group named bob (the fourth field from the left represents the group the file is associated with).
  • 32. groups The /etc/group file is a configuration file that stores group information. This file is readable by all users.
  • 33. groups To create groups in Linux, you can use a tool called addgroup. addgroup is a friendlier front-end to the low level tool groupadd. The syntax of this command is simple: you just type addgroup, followed by the name of the group. You can also provide a specific GID (Group ID) for the group with the –gid NUMBER parameter. If you omit this parameter, addgroup will use the next available GID.
  • 34. groups Let’s create a group called test_group with the GID of 2000:
  • 35. groups Groups are created with no users. To add a user to the group, use the adduser command with two parameters: the username and group. For instance, to add the user jowilliams to the group test_group, we would use the following command:
  • 36. groups To delete a group in Linux, you can use a tool called delgroup. delgroup is a friendlier front-end to the groupdel program. The delgroup command takes a single parameter: the group name. Note that you can’t delete the primary group of an existing user: you must delete the user first or change its primary group.
  • 37. groups Let’s delete the group we’ve created in the previous section:
  • 38. groups You can also delete a group by editing the /etc/group file, but it is recommended to use the delgroup command. delgroup checks whether the group is any user’s primary group and if it is, refuses to remove the group.
  • 39. Modify groups To modify an existing group in Linux, the groupmod command is used. Using this command you can change the GID of a group, set the group password and change the name of a group.
  • 40. Modify groups Here is a list of groupmod’s options:
  • 41. Modify groups Here is a simple example of this command’s usage. To change the name of the group from test_gr to test_group, we can use the following command:
  • 42. Modify groups Add users to groups Interestingly enough, you can’t use the groupmod command to add a user to a group. Instead, the usermod command with the -G option is used. When adding a user to a new group, be sure to also list all of the user’s current groups. Omitting any of the user’s current groups will remove the user from those groups!
  • 43. Modify groups To add bob to the group test_group, we can use the following command: We can list the groups a user is in by using the groups command:
  • 44. Modify groups If you don’t wont to list all the user’s current groups when adding a user to a new group, you can use the -a option. For example, if we want to add jwilliams to the group cdrom and keep the current group membership, we can use the following command:
  • 46. Summary yum and apt-get to install tar tar gzip split and cat for multiple files sed useradd groups