Previous Up Next

15  Quick Reference

File Management

NamePurposeExampleExplanation
lsLists files in the current directoryls 
pwdPrints the current working directorypwd 
cdChanges the current directorycd foo/changes to the directory “foo”
fileDescribes the contents of a filefile fooprints a message about what type of file “foo” is
cpCopies filescp a bcreates a copy of file ‘a’ called ‘b’
cpCopies directoriescp -r foo barCopies the directory foo to the directory bar, copies all files and directories inside it too.
mvMoves filesmv a ./foo/moves file ‘a’ into the directory “foo”
mvRenames filesmv a bmoves the file ‘a’ to be called ‘b’
rmRemoves (deletes) filesrm foodeletes the file called “foo”
rmRemoves (deletes) directoriesrm -r foo/deletes the directory called “foo”
lessViews the contents of filesless fooopens the file “foo” in less. Use space for next page, b for back a page, q to quit.
mkdirMakes new directoriesmkdir foocreates a new directory inside the current one called “foo”
quotaTells you how much disk quota you are using and how much you have leftquota -v 

Tar Archives

NamePurposeExampleExplanation
tarBundles many files together into one file called a “tarfile”tar -cf files.tar foo bar bazCreates a tarfile called “files.tar” that contains the files “foo”, “bar” and “baz”.
tarExtracts files from a tarfiletar -xf files.tarExtracts all the files from “files.tar” into the current directory.
gzipCompresses files to save spacegzip fooZip’s the contents of the file “foo”, removing the original file and replacing it with a file called “foo.gz”.
gunzipUncompresses filesgzunzip foo.gzUnzips the file “foo.gz”, renaming the uncompressed version “foo” and removing the original zipped file.
tarStores many files into a tarfile and compresses themtar -czf files.tar.gz foo bar bazCreates a tarfile called “files.tar.gz” and stores the files “foo”, “bar” and “baz” in it. It also passes the tarfile through gzip automatically.
tarExtracts compressed tarfilestar -xzf files.tar.gzUncompresses “files.tar.gz” to “files.tar” then extracts all the files from it into the current directory.

Getting Help

NamePurposeExampleExplanation
manDisplays manuals for programsman lsshows the manual for the “ls” command
infoDisplays info-pages for programs, an alternative manual systeminfo lsshows the info page
aproposSearches for a command by keywordapropos keywordDisplays a list of documentation relating to “keyword” for example “networking” or “files”.
whatisGives a summary of a programwhatis lsGives a description of what the “ls” program is for.

User Accounts

NamePurposeExampleExplanation
whoTells you who’s logged into the systemwho 
who am iTells you about yourselfwho am i 
fingerPrints out information about user accountsfinger -l usernameprints out information about the user called “username”.
groupsLists what groups a user belongs togroups usernamePrints out the group names that the user “username” belongs to.
whoisSearches for Users by surnamewhois smithprints out the usernames and real-names of all users who’s surname is “smith”
lastShows the last N loginslast 

Documents

NamePurposeExampleExplanation
wcCounts words in a documentwc foooutputs three numbers relating to file “foo”, number of lines, number of words and number of characters.
ispellSpell checks a documentispell foospell checks the document called “foo”, creates a backup file called “foo.bak” first.
headDisplays the first few lines of a filehead fooPrints out the first 10 lines of the file called “foo”.
tailDisplays the last few lines of a filetail fooPrints out the last 10 lines of the file “foo”.

Processes

NamePurposeExampleExplanation
pslists all the processes running for that loginps 
pslists all processes running for all logins of a userps -U usernamedisplays all the processes of user “username”, this can be your own username.
killstops a process from runningkill 17829Kills the process with the PID “17829”. Process Identification Numbers are found with “ps”.
topLists the largest processes runningtop -n 10Prints out the top 10 processes and a lot of information about the system.

Previous Up Next