University of Southampton


Linux Primer - Learning Linux

More like this

Why learn Linux?

A basic knowledge of Linux is required in order to use HPC facilities. There are many tutorials on the web, just Google around and you will find them. We recommend this Online tutorial. You may want to print and keep handy our Linux Quick Reference Sheet for those who prefer a hard copy.

Linux is derived from Unix, and many of its commands are identical with, or very similar to, older Unix commands. Since Apple’s Mac OS X is also derived from a version of Unix (BSD Unix), many of these commands are the same as on a Mac.

What Is the Command Line?

Typically one interacts with a Unix/Linux system using a Command Line Interface (CLI), also known as a Terminal, a Shell or a Command Prompt. Instead of pointing mouse and clicking on menus and buttons you need to type text commands to perform specific tasks. Since you can directly control the computer by typing, many tasks can be performed more quickly, and some tasks can be automated saving you, potentially, loads of time in the process.

Essential Linux Commands

Some of the more common commands that just about everyone uses are listed below:

  • man <command>- shows the manual page for the given <command>, press q to exit manual pages
  • pwd - “print working directory” prints the name of the current folder
  • ls - list directory lists all the files in the current folder
  • ls -l - long list lists the files along with permissions, creation dates, etc
  • ls -lSr  - list all files sorted by file size (-S) with the largest files at the bottom (-r)
  • ls -ltr  - will sort the results by file time (-t)  with the newest files at the bottom (-r)
  • mkdir <foldername> - make a new folder (folders are also known as directories)
  • cd <pathname> - change directory to the one named by <pathname>
  • cd .. - change directory to the directory directly above the current one
  • cd      - change to home directory
  • cat <filename> - prints the contents of a text file
  • cat <file1> <file2> > <file3> - joins together text files <file1> and <file2> and puts the result in <file3> (cat - is short for concatenate)
  • less <filename> - lets you scroll up and down through a text file; use Q to quit
  • cp <file1> <file2> - makes a copy of <file1> named <file2> in the current folder; previous contents of <file2> (if any) are lost
  • mv <file1> <file2> - move <file1> to <file2>; used to rename a file (previous contents of <file2> are lost)
  • mv <foldername1> <foldername2> - rename a directory
  • rm <file> - remove a file (delete it)
  • rm -r * - recursively remove all files and folders in the current folder (be VERY careful with this)
  • rm -r <foldername> - recursively remove the folder and all its contents, including subfolders and their files
  • rmdir <foldername> - remove a folder (delete it); the folder must be empty
  • nano <filename> - edit the named file
  • emacs <filename> - edit with the GNU Emacs editor; see the man page for help. Note that you must have an X-windows server installed and running on your machine before you can use the GUI editor. 
  • exit - quits the current Terminal session; CTRL-D often does the same



Attached files:

Was this article helpful?

If you have any further comments, please put them below.

Please note that feedback is anonymous - if you require a reply or assistance, please raise a ticket via ServiceLine.

Thank you for your feedback, it is much appreciated.

Tweet This Article

Back to List

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we will assume that you are happy to receive cookies on the University of Southampton website.