Posted: . At: 9:43 AM. This was 1 month ago. Post ID: 19363
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to create a zip file on Ubuntu with the command line.


Creating a zip file on Linux is very easy with the command line. The -xi parameter allows a user to define the list of files to add to the compressed archive.

┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents/Doom II$ zip basetech.zip -xi basetech.*
  adding: basetech.txt (deflated 56%)
  adding: basetech.wad (deflated 58%)

This created a zipfile very easily. Use the zipinfo command to get information on a zipfile and the contents.

┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents/Doom II$ zipinfo basetech.zip 
Archive:  basetech.zip
Zip file size: 1879271 bytes, number of entries: 2
-rwxr-xr-x  3.0 unx     2550 tx defN 24-Feb-24 11:28 basetech.txt
-rw-rw-r--  3.0 unx  4462308 bx defN 24-Mar-15 08:42 basetech.wad
2 files, 4464858 bytes uncompressed, 1878945 bytes compressed:  57.9%

To get much more information about a zipfile, use the zipdetails program.

┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents/Doom II$ zipdetails basetech.zip 
 
000000 LOCAL HEADER #1       04034B50
000004 Extract Zip Spec      14 '2.0'
000005 Extract OS            00 'MS-DOS'
000006 General Purpose Flag  0000
       [Bits 1-2]            0 'Normal Compression'
000008 Compression Method    0008 'Deflated'
00000A Last Mod Time         58585B8A 'Sat Feb 24 22:28:20 2024'
00000E CRC                   CFE56EE8
000012 Compressed Length     00000469
000016 Uncompressed Length   000009F6
00001A Filename Length       000C
00001C Extra Length          001C
00001E Filename              'basetech.txt'
00002A Extra ID #0001        5455 'UT: Extended Timestamp'
00002C   Length              0009
00002E   Flags               '03 mod access'
00002F   Mod Time            65D93823 'Sat Feb 24 11:28:19 2024'
000033   Access Time         65F3778E 'Fri Mar 15 09:17:50 2024'
000037 Extra ID #0002        7875 'ux: Unix Extra Type 3'
000039   Length              000B
00003B   Version             01
00003C   UID Size            04
00003D   UID                 000003E8
000041   GID Size            04
000042   GID                 000003E8
000046 PAYLOAD
 
0004AF LOCAL HEADER #2       04034B50
0004B3 Extract Zip Spec      14 '2.0'
0004B4 Extract OS            00 'MS-DOS'
0004B5 General Purpose Flag  0000
       [Bits 1-2]            0 'Normal Compression'
0004B7 Compression Method    0008 'Deflated'
0004B9 Last Mod Time         586F455C 'Fri Mar 15 19:42:56 2024'
0004BD CRC                   D0558F8E
0004C1 Compressed Length     001CA738
0004C5 Uncompressed Length   004416E4
0004C9 Filename Length       000C
0004CB Extra Length          001C
0004CD Filename              'basetech.wad'
0004D9 Extra ID #0001        5455 'UT: Extended Timestamp'
0004DB   Length              0009
0004DD   Flags               '03 mod access'
0004DE   Mod Time            65F36F60 'Fri Mar 15 08:42:56 2024'
0004E2   Access Time         65F36F6E 'Fri Mar 15 08:43:10 2024'
0004E6 Extra ID #0002        7875 'ux: Unix Extra Type 3'
0004E8   Length              000B
0004EA   Version             01
0004EB   UID Size            04
0004EC   UID                 000003E8
0004F0   GID Size            04
0004F1   GID                 000003E8
0004F5 PAYLOAD

This prints a lot of very useful information about the zip file and each file therein.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.