WhileNetworking

  • Home
  • CCNA
  • Cisco Packet Tracer Download
    • Cisco packet tracer 6.3
    • cisco packet tracer 6.2
    • Cisco Packet Tracer 7
  • Linux Server Management
  • About Us
  • Privacy Policy
  • Contact Us

Compression file folder in Linux

You are most welcome to this post.
ls command in Linux
Really thanks to you for your interest in this topics. :)

Hope that you are enjoying Linux !! Now in this post, we’ll see Compression file folder technique.

Compression file folder in Linux

Generally, compression file folder in windows is known as zip, rar, 7zip.
And in Linux, compression file folder is known as .gz, .bz2, .xz etc.
The archive file in Linux is known as .tar

Now lets see some example:

At first we logged in as super user and after that we changed our directory to home, our main target is to go to the directory named “lnx” which we created previously.
[root@localhost ~]# cd /home ;
[root@localhost home]# cd lnx

Now we’ll see the files/folders located in this directory:
[root@localhost lnx]# ls
file1 passwd ; can able to see the two files which is located here.

Now we’ll copy the passwd folder to our current directory.

[root@localhost lnx]# cp /etc/passwd .
[root@localhost lnx]# cp -rv /etc /lnx ; copy command
‘/etc’ -> ‘/lnx’
‘/etc/fstab’ -> ‘/lnx/fstab’
‘/etc/crypttab’ -> ‘/lnx/crypttab’
‘/etc/mtab’ -> ‘/lnx/mtab’
‘/etc/resolv.conf’ -> ‘/lnx/resolv.conf’
‘/etc/fonts’ -> ‘/lnx/fonts’
.
.
.
.
.
.

 

Now lets see the lists by using “ls” command
[root@localhost lnx]# ls
file1 passwd

Now through this command we’ll see the size of file/folder located in “lnx” folder.
[root@localhost lnx]# du -ch * ; See the size of the files/folder
4.0K file1
4.0K passwd
8.0K total

Now we’ll make archive through this command

[root@localhost lnx]# tar -cvf ar1.tar file1

file1

Yes, we’ve made a compression of this file. Lets see this:
[root@localhost lnx]# ls
ar1.tar file1 passwd

Finally successfully we can able to create and see the archive file. See ar1.tar is our file.

Now lets see the size of our compressed file.

[root@localhost lnx]# du -ch * ; See the size of the file/folder
12K ar1.tar
4.0K file1
4.0K passwd
20K total

rm command
[root@localhost lnx]# rm -rf etc
[root@localhost lnx]# ls
ar1.tar file1 passwd

Now if we want to extract the archive, then can use this command.

[root@localhost lnx]# tar -xvf ar1.tar
file1

Now see the list, see we can also see the extracted files here
[root@localhost lnx]# ll
total 20
-rw-r–r– 1 root root 10240 May 8 02:00 ar1.tar
-rw-r–r– 1 root root 35 May 8 00:19 file1
-rw-r–r– 1 root root 3004 May 7 23:51 passwd

[root@localhost lnx]# ls
ar1.tar file1 passwd

This is the command for archive + compression.

[root@localhost lnx]# tar -czvf ar1.tar.gz passwd
passwd

[root@localhost lnx]#
[root@localhost lnx]# ls
ar1.tar ar1.tar.gz file1 passwd

See the size.
[root@localhost lnx]# du -ch ar1.tar.gz
4.0K ar1.tar.gz
4.0K total

[root@localhost lnx]# rm -rf passwd

[root@localhost lnx]# tar -xzvf ar1.tar.gz ; extract
passwd

[root@localhost lnx]# ls ; See the list
ar1.tar ar1.tar.gz file1 passwd

[root@localhost lnx]# seq 1000000 > number ; Only compress

[root@localhost lnx]#

[root@localhost lnx]# ls ; Lets see the listar1.tar ar1.tar.gz file1 number passwd

See the file name

[root@localhost lnx]# gzip number
[root@localhost lnx]# ls
ar1.tar ar1.tar.gz file1 number.gz passwd

See the list, yeh !! you can able to see a file named number.gz

Want to see the size??
[root@localhost lnx]# du -sh number.gz
2.1M number.gz
[root@localhost lnx]# gunzip number.gz ; Unzip number
[root@localhost lnx]# ls
ar1.tar ar1.tar.gz file1 number passwd

Now we’ll view the contents of the tar file
[root@localhost lnx]# tar -tvf ar1.tar
-rw-r–r– root/root 35 2016-05-08 00:19 file1

[root@localhost lnx]# tar -cvf ar1.tar passwd
passwd

[root@localhost lnx]# tar -xvf ar1.tar
passwd

[root@localhost lnx]#

 

Lets see some of the screenshot of this command, I’ve made it for you.:)

Linux file compression

Linux file compression

Linux file compression

Linux file compression

Linux compression

Linux file compression

Hope that you’ve enjoyed this section. If you’ve any questions, the comment please.

May 29, 2016Himadri
 

Share with friends :

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to email a link to a friend (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to print (Opens in new window)

Related

Linux basic command--Discussion about text editorPartition management in Linux (CentOS/Red Hat)

Leave a Reply Cancel reply

13 + eleven =

Himadri

Hi, I'm Himadri. I love blogging with tech topics, specially computer networking. We'll have more fun in the upcoming day. Stay with me. :)

May 29, 2016 Linux installation and server managementcompression in centOS/RedHat, compression in linux, linux file folder compression basic, Linux file folder compression technique231
Feel Free to Share :)
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Find Us on Facebook
Choose a category !!
  • CCNA
  • Cisco Certification Exam
  • cisco packet tracer 6.2
  • Cisco packet tracer 6.3
  • Cisco Packet Tracer 7
  • Cisco Packet Tracer 7.1
  • Cisco Packet Tracer 7.2.1
  • Cisco Packet Tracer 7.3
  • Cyber Security
  • Engineering Ebooks
  • Excel
  • IELTS Ebook
  • Internet
  • Know computer
  • Know your computer
  • Laser Processing of Material
  • Linux installation and server management
  • PDF
  • Technology
  • Uncategorized
Top posts
  • Packet tracer 6.2 student version for Linux - Free download
  • Free download cisco packet tracer 6.3 for Linux, with tutorial version
  • Autonomous and light weight access point
Archieves
Get latest updates by Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 19 other subscribers
W
SC
wordpress counter
Analytics
Recent Comments
    Browse by categories
    Cyber SecurityLinux installation and server managementCCNAKnow your computerKnow computerCisco Packet Tracer 7UncategorizedCisco Certification ExamInternetPDFCisco Packet Tracer 7.3Engineering EbooksCisco packet tracer 6.3cisco packet tracer 6.2Cisco Packet Tracer 7.1TechnologyExcelLaser Processing of MaterialCisco Packet Tracer 7.2.1IELTS Ebook
    Feel free to contact with us

    Hi, any kind of comment or suggestion is valuable to us. So feel free to contact with us.

    Email: himadri.shekhar.bd@gmail.com

    Name: WhileNetworking.com

    2021 © WhileNetworking
     

    Loading Comments...