gzip

Updated: 04 October 2024

Create a gzip file of backup.sql and keep the original file

gzip --keep backup.sql

Decompress an archive

gzip -d backup.sql.gz

unzip

Updated: 27 May 2023

List, test and extract compressed files in a ZIP archive

Unzip a zip file

unzip wordpress-seo-premium-20.8.zip

zip

Updated: 18 March 2024

Zip a file

zip -r curl-debug-wp-plugin.zip ./curl-debug-wp-plugin --exclude '*.git*'

Zip a folder without including the root folder

zip -rj ctd-wp-theme.zip ./ctd-wp-child-theme

rm

Updated: 04 June 2023

rm – remove files or directories.

Delete file, skip warning if file doesn’t exist

rm -f app.js

Empty a directory

rm -r /my/directory/*

tree

Updated: 01 November 2023

List contents of directories in a tree-like format.

Install

sudo apt install tree

Ignore .git folder but show other dot folders/files, starting from current directory

tree -I .git -a .

Also show user, group and file permission

tree -ugp dir

Create tree 2 levels deep only

tree -L 2 .

ls

Updated: 16 November 2023

Show only directories matching glob, but not their contents

ls -d /a/path/foo*

Show first 7 rows only

ls | head -7

Order by date

ls -t

Order by date, most recent at bottom

ls -tr

List all files in a directory and sub-directories

ls -R

List directories first (tab completion possible)

ls -l --group-directories-first

List filename only, in one column

ls -1

Turn on colour

ls --color=always -la