CommandPurposeOptions to knowExamples
echoRepeats back whatever you tell itecho ~

echo “This is a string of text”
catReads the contents of a file and prints it out to the terminal
headReads a certain number of lines from the top or start of the fileYou can specify the number of lines to read with -X, for example -2 or -54. -n X also works.head -20

head -n 20

head -35
tailReads a certain number of lines from the bottom or end of a fileAll head options

You can tell tail to “follow” or keep reading from the end of a file with -f
tail -20

tail -n 20

tail -f apachelogfile.txt
grepSearches through text for a given string of charactersYou can either send text to grep with | or point it at a text file by giving it a filename as its second argument. If your search string has spaces in it, quote it or grep will assume you’re giving it a list of filenames.cat file.txt | grep “my password is”

echo “This is a string of text | grep “text

grep “my password is” file.txt
cutSplits each line of text into columns based on a given delimiter (space, comma, semicolon, tab, period, etc.) and selects a column or columns to show-d to specify a delimiter

-f to specify the column or columns to show
cat apache.log | cut -d “ “ -f 10

cat apache.log | cut -d : -f 3-8
sortSorts lines of text in alphabetical order-n to sort according to numerical value instead of alphabetical order
uniqRemoves duplicate lines in the text you feed it-c to keep count of how many duplicate lines it removes instead of just silently removing. You have to sort text before feeding it to uniq.
wcCounts the number of words in the text you give it-l to count lines of text instead of words.cat apache.log | grep “Authentication Failure” | wc -l
more/lessShows output one page at a time, allows you to scroll up and down with arrow keysPress q to exit.cat log.txt | less

less log.txt
nanoInteractive text editorCtrl+o to “write out” or save a file

Ctrl+x to exit
nano

nano magnumopus.txt
pwdPrint Working Directory (tells you the full path to the folder you’re in)
cdChange Directorycd workfolder

cd ~

cd /etc/ssh
rmRemoves files and folders-r to remove recursively, deleting folders as well as files
mkdirMakes a folder
rmdirDeletes an empty folder
findLooks for files by listing each folder and looking inside-name to specify a filenamefind / -name *.log

find /home/student -name Homework.docx
locateLooks for files based on a local database of filenames that’s updated every 24 hours.locate *.log

locate Homework.docx
touchCreates an empty file or updates the “last modified” timestamp on an existing file
fileReads the first few bytes of a file and makes an educated guess about what file format it is
stringsLooks through a binary file for any text that looks human-readablestrings ctfmemorydump.bin
lsLists the folders and files in the current directory or a target directory-a to show hidden files

-l for the long version of file info including file permissions

-H to convert bytes into human-readable sizes like KB, MB, GB
treeShows folders and files in a tree structure
chmodChanges the “mode” (permissions) of a filechmod 777 file.txt

chmod u=rwx file.txt
chownChanges the owner of a file-R to recursively change permissions on a folder and every file/folder under itchown student file.txt

chown -R student /home/student
chgrpChanges the group that owns a file
whoamiTells you the username you’re logged in as
groupsLists the groups you’re a member of
freeShows the amount of memory used and available-h to show human-readable sizes like KB, MB, GB instead of showing just bytesfree -h
dfStands for Disk Free, shows the amount of storage used and availableAgain, -h to show human-readable sizesdf -h
df -h /
df -h /tmp
tarCombines multiple files into a single file and vice versa. Short for Tape Archive.Compression and archiving