Updated: 23 May 2023

Display the current time


Convert a timestamp to human readable date

date -d @641288145

Print Coordinated Universal Time

date --utc


Updated: 07 February 2023

Report file system disk space usage.

Show free space on usb or external hard disk

tom@laptop:/media/tom$ df -kh *


Updated: 10 September 2022

Use No Hangup to kick-off a long running task, then disconnect
nohup bin/behat --out results.txt features &

grep basic usage

Updated: 13 January 2023

Find all occurrences of foo in directories and files recursively, from the current directory

grep -irn --exclude-dir=dir --text foo *
-i: case insensitive
-r: recursive but don't follow symlinks
-n: show line number
--text: treat binary files as text

Interpret PATTERNS as --fixed-strings, not regular expressions

grep -F './dir/dir2' file.txt


Updated: 07 February 2023

Estimate file space usage.

Show size of sub-directories in current directory

du -h --max-depth=1 . | sort -n


Updated: 21 November 2023

Write output to file instead of stdout

curl http://some.url --output <file>

Basic HTTP server authorisation

curl -u user:pass http://some.url
# or
curl http://user:pass@some.url

Make the operation more talkative

curl --verbose

By default, every secure connection curl makes is verified to be secure before the transfer takes place. The --insecure option makes curl skip the verification step and proceed without checking.

curl --insecure

Follow redirects

curl --location


Updated: 05 February 2024

Find directories with either foo or bar in their name

find . -type d \( -iname '*foo*' -or -iname '*bar*' \) | sort

Find files modified within the last 6hrs i.e. 0.25 of 1 day

find /home/chris -type f -mtime -0.25

Find files where name (case insensitive) matches ‘*.exe’

find ~/.nuget/packages -iname "*.exe"

Find directories where name starts with ‘site’

find . -type d -name 'site*'

Find any of the named files (risky, test first)

find this-dir -type f \( -name "foo" -o -name "bar" -o -name "log" \)

Find all files not in the git directory

find . -type f -not -path "./.git/*"


find uses ; or + to terminate the -exec command. Therefore \; must be used because ; is one of the operators (also && or ||) which separates shell commands.

Find files by text in the file.

find . -type f -name "*.java" -exec grep -il string {} \;

-i: ignore case
-l: show filenames, not the match.


Updated: 21 May 2023

Copy files and directories

Copy the entire contents of a directory. Using a dot at the end of the source directory indicates that everything within the directory should be copied, including hidden files

cp -a /tmp/wordpress/. /var/www/wordpress

Copy and rename a file

cp program3.cpp homework6.cpp

Copy file into a folder

cp chris-taylor-cv.pdf marketing/
cp image.jpg folder/sameImageNewName.jpg

Preserve the file modify time, when copying

cp --preserve=timestamps ~/.tmux.conf ~/my-dot-files/