File Management
Name | Purpose | Example | Explanation |
ls | Lists files in the current directory | ls | |
pwd | Prints the current working directory | pwd | |
cd | Changes the current directory | cd foo/ | changes to the directory “foo” |
file | Describes the contents of a file | file foo | prints a message about what type of file “foo” is |
cp | Copies files | cp a b | creates a copy of file ‘a’ called ‘b’ |
cp | Copies directories | cp -r foo bar | Copies the directory foo to the directory bar, copies all files and directories inside it too. |
mv | Moves files | mv a ./foo/ | moves file ‘a’ into the directory “foo” |
mv | Renames files | mv a b | moves the file ‘a’ to be called ‘b’ |
rm | Removes (deletes) files | rm foo | deletes the file called “foo” |
rm | Removes (deletes) directories | rm -r foo/ | deletes the directory called “foo” |
less | Views the contents of files | less foo | opens the file “foo” in
less. Use space for next page, b for back a page, q to quit. |
mkdir | Makes new directories | mkdir foo | creates a new directory inside the current one called “foo” |
quota | Tells you how much disk quota you are using and how much you have left | quota -v |
Tar Archives
Name | Purpose | Example | Explanation |
tar | Bundles many files together into one file called a “tarfile” | tar -cf files.tar foo bar baz | Creates a tarfile called “files.tar” that contains the files “foo”, “bar” and “baz”. |
tar | Extracts files from a tarfile | tar -xf files.tar | Extracts all the files from “files.tar” into the current directory. |
gzip | Compresses files to save space | gzip foo | Zip’s the contents of the file “foo”, removing the original file and replacing it with a file called “foo.gz”. |
gunzip | Uncompresses files | gzunzip foo.gz | Unzips the file “foo.gz”, renaming the uncompressed version “foo” and removing the original zipped file. |
tar | Stores many files into a tarfile and compresses them | tar -czf files.tar.gz foo bar baz | Creates a tarfile called “files.tar.gz” and stores the files “foo”, “bar” and “baz” in it. It also passes the tarfile through gzip automatically. |
tar | Extracts compressed tarfiles | tar -xzf files.tar.gz | Uncompresses “files.tar.gz” to “files.tar” then extracts all the files from it into the current directory. |
Getting Help
Name | Purpose | Example | Explanation |
man | Displays manuals for programs | man ls | shows the manual for the “ls” command |
info | Displays info-pages for programs, an alternative manual system | info ls | shows the info page |
apropos | Searches for a command by keyword | apropos keyword | Displays a list of documentation relating to “keyword” for example “networking” or “files”. |
whatis | Gives a summary of a program | whatis ls | Gives a description of what the “ls” program is for. |
User Accounts
Name | Purpose | Example | Explanation |
who | Tells you who’s logged into the system | who | |
who am i | Tells you about yourself | who am i | |
finger | Prints out information about user accounts | finger -l username | prints out information about the user called “username”. |
groups | Lists what groups a user belongs to | groups username | Prints out the group names that the user “username” belongs to. |
whois | Searches for Users by surname | whois smith | prints out the usernames and real-names of all users who’s surname is “smith” |
last | Shows the last N logins | last |
Documents
Name | Purpose | Example | Explanation |
wc | Counts words in a document | wc foo | outputs three numbers relating to file “foo”, number of lines, number of words and number of characters. |
ispell | Spell checks a document | ispell foo | spell checks the document called “foo”, creates a backup file called “foo.bak” first. |
head | Displays the first few lines of a file | head foo | Prints out the first 10 lines of the file called “foo”. |
tail | Displays the last few lines of a file | tail foo | Prints out the last 10 lines of the file “foo”. |
Processes
Name | Purpose | Example | Explanation |
ps | lists all the processes running for that login | ps | |
ps | lists all processes running for all logins of a user | ps -U username | displays all the processes of user “username”, this can be your own username. |
kill | stops a process from running | kill 17829 | Kills the process with the PID “17829”. Process Identification Numbers are found with “ps”. |
top | Lists the largest processes running | top -n 10 | Prints out the top 10 processes and a lot of information about the system. |