Tips-And-Tricks/Computer/Linux/Shell-Commands: Difference between revisions
Created page with "Linux is a growing and popular operating system, especially for us citizen mycologists, and unknown to a lot of first-time users, it has an extensive set of wonderful tools that can do things that are nearly black magic in Windows or even to the casual Macintosh user. As a MacOS user, you too have access to most of these commands as well (surprisingly without having to pay an exhorberant fee to use them too!). Mac OS is based on an offshoot of the original AT&T Unix cal..." |
No edit summary |
||
| Line 31: | Line 31: | ||
zip -r docs.zip Documents | zip -r docs.zip Documents | ||
</code> | </code> | ||
==== Extraction ==== | |||
The <code>unzip</code> command does the opposite of zip and extracts files. It does have a set of flags you can use in special sitautions, but there is really only one important one in every day use | |||
<code>-l</code> | |||
The -l flag says to list the contents instead of actually extracting the files. | |||
<code>unzip -l zipfile.zip</code> Will list all of the files in the archive | |||
<code>unzip zipfile.zip</code> Will extract the files from the archive into the current directory | |||
=== tar === | |||
The <code>tar</code> command basically operates the same as the zip command but can provide multiple types of compression. It stands for "Tape ARchive" and heralds from the early days when computers literally had reel to reel tapes. | |||
<code>tar [flags] archive [file1 file2 file3]</code> | |||
The most commonly used flags are: | |||
* <code>c</code> Create the archive | |||
* <code>x</code> Extract the archive | |||
* <code>v</code> Be verbose (display the files extracted / added) | |||
* <code>f filename</code> Filename to create or extract from | |||
* <code>z</code> Compress using zlib (fast, decent compression) | |||
* <code>j</code> Compress using bzip2 (medium speed, better compression) | |||
* <code>J</code> Compress using xz (medium speed, good compression) | |||
Revision as of 02:25, 28 February 2026
Linux is a growing and popular operating system, especially for us citizen mycologists, and unknown to a lot of first-time users, it has an extensive set of wonderful tools that can do things that are nearly black magic in Windows or even to the casual Macintosh user.
As a MacOS user, you too have access to most of these commands as well (surprisingly without having to pay an exhorberant fee to use them too!). Mac OS is based on an offshoot of the original AT&T Unix called BSD (Berkeley Software Distribution), and as such has most of the core shell commands at your disposal.
File Compression / Extraction
There are two main compression utilities out there that can take a directory and compress it all into a single file, allowing you to move it to another computer, either in your home or on the internet, and then extract it there. Depending on the source or destination computer may make the decision as to the best.
zip/unzip - Compatible with Micro$oft Windows since Windows XP tar - Compatible with Linux, or any Unix-compatible operating system, including macOS.
zip/unzip
Compression
The zip command packs files into a zip archive, which can be read on the host machine pretty much universally.
The general format is
zip [flags] destination[.zip] file list
Where the .zip extension is optional. To zip a list of files in the SAME directory, you can use
zip filename.zip file1 file2 file3 ...
To zip an entire directory structure you can use the "r" flag and it will descend through the whole structure adding everything found to the archive.
zip -r docs.zip Documents
Extraction
The unzip command does the opposite of zip and extracts files. It does have a set of flags you can use in special sitautions, but there is really only one important one in every day use
-l
The -l flag says to list the contents instead of actually extracting the files.
unzip -l zipfile.zip Will list all of the files in the archive
unzip zipfile.zip Will extract the files from the archive into the current directory
tar
The tar command basically operates the same as the zip command but can provide multiple types of compression. It stands for "Tape ARchive" and heralds from the early days when computers literally had reel to reel tapes.
tar [flags] archive [file1 file2 file3]
The most commonly used flags are:
cCreate the archivexExtract the archivevBe verbose (display the files extracted / added)f filenameFilename to create or extract fromzCompress using zlib (fast, decent compression)jCompress using bzip2 (medium speed, better compression)JCompress using xz (medium speed, good compression)