This is a draft cheat sheet. It is a work in progress and is not finished yet.
Navigation
ls list directory contents
|
ls -al -a = all -l = long listing format
|
cd <directory> change directory (~ = home / = root)
|
cd .. change to the parent of the current directory
|
pwd print working directory
|
File Commands
mkdir <directory> make a new directory (folder)
|
touch <file> make a new file
|
rm -r <directory> remove a folder (-r means recursive, delete folder + everything in it)
|
rm <file> remove a file
|
rm -f <file> force remove a file
|
cp <file1> <file2> copy file1 and paste as file2
|
mv <file to move> <place to move to> move file
|
mv <file1> <file3000> moving a file within the same folder will rename it
|
ln -s <file> name create a symbolic link called "name" to file
|
cmd > <file> puts standard output (stdout) of command into <file>
|
cmd >> <file> appends standard output (stdout) of command into <file>
|
|
|
Reading Files
cat <file> concatenate <file> and print to stdout (i.e. read the file)
|
less <file> prints as much of the file that can fit within the terminal window. PgUp/PgDown to navigate
|
more <file> print file out line by line
|
head <file> output first 10 lines of file
|
tail <file> output last 10 lines of file
|
tail -f <file> output contents of file as it grows
|
sed -i 's,foo,bar,g' <file.txt> replaces all instances of foo with bar in <file.txt>
|
Finding files
find /etc/ -name foo* find all files starting with foo in /etc/
|
find /dir/ -user bar find all files owned by bar in /dir/
|
locate <file> find all instances of <file>
|
Finding binaries
which <binary> find location of binary e.g. which sudo
|
whereis <binary> find the location, source, and manual for a binary
|
|
|
|