{"id":3857,"date":"2019-09-02T11:25:07","date_gmt":"2019-09-02T10:25:07","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=3857"},"modified":"2026-02-24T11:34:06","modified_gmt":"2026-02-24T11:34:06","slug":"linux-commands","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/getting-started\/linux-commands\/","title":{"rendered":"Linux Commands"},"content":{"rendered":"<p>The CSF runs the Linux operating system. Interaction with the system is done by typing commands into a <em>terminal<\/em> program. This can be a little daunting at first. The table below contains the basic Linux commands you will likely use on the CSF.<\/p>\n<p>It is worth remembering that when you login to the CSF, the folder you will be first <em>in<\/em> is your <em>home directory<\/em> (Windows users can think of this as similar to &#8220;My Documents&#8221;.) The home directory is private to you and where you should keep important files (it is backed-up storage).<\/p>\n<p>The other useful thing is that the Linux term <em>directory<\/em> is what Windows users call a <em>folder<\/em> when talking about storage.<\/p>\n<p>Commands specific to the batch system (not a default part of Linux) are covered in <a href=\"\/csf3\/batch\/q-commands\/\">other sections<\/a> of our documentation. Other useful Linux commands may also be mentioned elsewhere.<\/p>\n<p>While logged into the CSF, you can read the manual for each command by running <code>man <em>command<\/em><\/code> on the login node (for example <code>man ls<\/code>.) This displays the command&#8217;s &#8220;man&#8221; page &#8211; a manual usually describing what the command will do, what command-line flags it accepts and what any error messages mean.<\/p>\n<table class=\"striped\">\n<tr>\n<th style width=26%>Commands<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>\n<code>cd dir1<\/code><br \/>\n<code>cd ~\/dir1\/dir2<\/code><br \/>\n<code>cd ~\/scratch<\/code><br \/>\n<code>cd ..<\/code><br \/>\n<code>cd<\/code>\n<\/td>\n<td>\nChange directory (go into <code>dir1<\/code> which is located inside the current dir).<br \/>\nGo into <code>dir2<\/code> in <code>dir1<\/code> in home (<code>~<\/code> is shorthand for <emphasis>home<\/emphasis>)<br \/>\nGo into your <em>scratch<\/em> directory (CSF-specific)<br \/>\nGo up to parent directory (e.g., from <code>~\/dir1\/dir2<\/code> to <code>~\/dir1<\/code>)<br \/>\nGo back to your <em>home<\/em> directory from where ever you currently are (useful if you become lost)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>pwd<\/code>\n<\/td>\n<td>\nLost? Print Working Directory (display your current location &#8211; the folder you are currently working in)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>ls<\/code><br \/>\n<code>ls -lh<\/code><br \/>\n<code>ls -lh file1 dirA<\/code><br \/>\n<code>ls -lh dirA\/*.dat<\/code><\/p>\n<\/td>\n<td>\nList content (names of files and directories) of current directory<br \/>\nList in long form (dates, file sizes, names) current directory<br \/>\nList in long form (dates, file sizes, names) specified files, directories \u2026<br \/>\nList in long form all files ending in <code>.dat<\/code> in directory <code>dirA<\/code><br \/>\n(note that the <code>-l<\/code> in these commands is a lower-case letter L (not a number one)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>cp fileA fileB<\/code><br \/>\n<code>cp fileA dirA<\/code><br \/>\n<code>cp fileA ~\/scratch<\/code>\n<\/td>\n<td>\nCopy (duplicate) a file (copy <code>fileA<\/code> to a new file <code>fileB<\/code>)<br \/>\nCopy (duplicate) a file into the directory named <code>dirA<\/code><br \/>\nCopy (duplicate) a file into your <em>scratch<\/em> directory (CSF-specific)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>mv fileC fileD<\/code><br \/>\n<code>mv fileE dirA<\/code><br \/>\n<code>mv fileF dirA\/fileG<\/code>\n<\/td>\n<td>\nRename a file (from <code>fileC<\/code> to <code>fileD<\/code>). Works for directories too.<br \/>\nMove <code>fileE<\/code> into sub-directory <code>dirA<\/code> (<code>dirA<\/code> must exist)<br \/>\nMove <code>fileF<\/code> AND rename it all in one go (<code>dirA<\/code> must exist)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>rm fileH<\/code><br \/>\n<code>rm dirA\/fileB<\/code>\n<\/td>\n<td>\nDelete (remove) a file (caution!!)<br \/>\nDelete (remove) a file named <code>fileB<\/code> from <code>dirA<\/code>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>mkdir dirA<\/code><br \/>\n<code>mkdir -p dirA\/dirB\/dirC<\/code>\n<\/td>\n<td>\nCreate (make) a new folder named <code>dirA<\/code> in current location (don&#8217;t use spaces in folder names!)<br \/>\nCreate (make) a tree of folders starting at current location\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>rmdir dirA<\/code>\n<\/td>\n<td>\nDelete (remove) an <em>empty<\/em> directory.\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code><span class=\"err\">rm -rf dir1<\/span><\/code>\n<\/td>\n<td>\nDelete a directory and <strong>all<\/strong> files and other directories in there, down the entire tree (<span class=\"err\">caution!!!!!<\/span>)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>gzip bigfile<\/code><br \/>\n&nbsp;<br \/>\n<code>gunzip bigfile.gz<\/code>\n<\/td>\n<td>\nCompress a file (becomes <code>bigfile.gz<\/code>) to make better use of diskspace. Text files usually compress well.<br \/>\nUncompress previously compressed file (becomes <code>bigfile<\/code>).\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>less file1<\/code><br \/>\n<code>zless file2.gz<\/code>\n<\/td>\n<td>\nDisplay the content of <code>file1<\/code> (text file) a page at a time on screen.<br \/>\nIf you&#8217;ve compressed <code>file2<\/code> with <code>gzip<\/code>, no need to uncompress first.<br \/>\nBoth commands accept the following keystrokes to navigate:<br \/>\nPress <code>space<\/code> to page down through a long file<br \/>\nPress <code>return<\/code> to scroll down a line at a time<br \/>\nPress <code>b<\/code> to scroll back up a page<br \/>\nPress <code>G<\/code> to go to end of file<br \/>\nPress <code>q<\/code> to quit\/exit\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>cat file1<\/code><br \/>\n<code>zcat file2.gz<\/code>\n<\/td>\n<td>\nDump entire file to screen (a quick way to look at text files).<br \/>\nIf you&#8217;ve compress <code>file2<\/code> with <code>gzip<\/code>, no need to uncompress first.\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>gedit file1\n<\/td>\n<td>\nEdit <code>file1<\/code> using a simple graphical text editor (similar to notepad on Windows). Make sure you have <a href=\"\/csf3\/getting-started\/connecting\/gui-apps\/\">logged in enabling the ability to open graphical programs<\/a><br \/>\non the CSF so that they display a window on your computer.\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>file filenameA<\/code>\n<\/td>\n<td>\nTry to tell us what type of data is in <code>filenameA<\/code>. Useful to determine the output of some program where you are not sure what type of output it has generated. For example:<br \/>\n<code>file output.dat<\/code><br \/>\nMight be <code>ASCII text<\/code> (so we can look at it with <code>less<\/code> or <code>gedit<\/code>)<br \/>\nor might be <code>data<\/code> (you'll need some other program to read it)\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>du -sh .<\/code>\n<\/td>\n<td>\nHow much disk space is current directory (all files and subdirs) using?\n<\/td>\n<\/tr>\n<tr>\n<td>\n<code>df -h .<\/code>\n<\/td>\n<td>\nHow much free space is there in the current area?\n<\/td>\n<\/tr>\n<\/table>\n<h2>Further Information<\/h2>\n<p>If you would like to learn more we recommend the following training materials<\/p>\n<ul>\n<li>Research IT occasionally run an Introduction to the Unix Shell course, see <a href=\"https:\/\/www.staffnet.manchester.ac.uk\/staff-learning-and-development\/learning-pathways\/professional-and-technical-development\/it-skills\/research-computing\/research-courses\/\">the courses page for info and a link to booking and materials.<\/a><\/li>\n<li><a href=\"https:\/\/www.chm.bris.ac.uk\/unix\/\">Beginners guide to UNIX\/Linux<\/a> (University of Bristol)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The CSF runs the Linux operating system. Interaction with the system is done by typing commands into a terminal program. This can be a little daunting at first. The table below contains the basic Linux commands you will likely use on the CSF. It is worth remembering that when you login to the CSF, the folder you will be first in is your home directory (Windows users can think of this as similar to &#8220;My.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/getting-started\/linux-commands\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":12,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3857","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/3857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=3857"}],"version-history":[{"count":21,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/3857\/revisions"}],"predecessor-version":[{"id":11943,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/3857\/revisions\/11943"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/12"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=3857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}