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/*


Updated: 01 November 2023

List contents of directories in a tree-like format.


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 .


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