Show Menu
Cheatography

linux commands Cheat Sheet (DRAFT) by

commands and keys

This is a draft cheat sheet. It is a work in progress and is not finished yet.

find (search for files in directory hierarchy)

[TESTS]
+n for greater than n
-n for less than n
n for exactly n
-mindepth -maxdepth [level]
-regex [pattern]
-name [pattern]
-size [n]
 k for kilobytes, M for megabytes, G for gigabytes
-type [c]
 b c d p f l s (same as in ls command)
-amin -atime -cmin -ctime -mmin -mtime [n]
 a - aceessed, m - modified, c - status changed
 min - n minutes age, time - n24 hours ago*
-newerXY [ref]
 at mt ct if ref is a date. Or a m c if ref is a file
-perm [mode] -perm /[mode]
 mode example: 220, g+w,u+w

operators: ! for not, -o for or

[ACTIONS]
-delete
-exec -execdir [command] ;
 may need to be escaped with \, or quoted
 execdir runs coomnd from subdir­ectory
 {} is replaced with file name. {} + append each file to the end
-print -printf -print0 -fprint -fprintf [file format]
 %a %Ak - access time, %b - size in blocks, %c %Ck - status change, %t %Tk - modifi­cation time, %p - file name, %u %U - uid (strin­g/n­umber), %y - file type, %f - file name w/o directory, %s - size in bytes
 k format: H - hour (00..23), I - hour (01..12), k - hour (0..23), l - hour (1..12), M - min, p - AM/PM, r - hh:mm:ss, Z - timezone, @ - seconds, a A - weekday, b B m - month, y Y - year, d - day, D - mm/dd/yy
 

Disk commands

du disk usage
-h human readable
-s summarize only
-d depth
--excl­ude­=PA­TTERN --X=FILE
-a all files
-c grand total
df fs disk space usage
-a all fs types
--total grand total
-h human readable
-H human readable but with 1000 power