{"id":646,"date":"2019-09-30T10:01:25","date_gmt":"2019-09-30T09:01:25","guid":{"rendered":"https:\/\/blogs.gre.ac.uk\/cmssupport\/?page_id=646"},"modified":"2019-09-30T10:01:25","modified_gmt":"2019-09-30T09:01:25","slug":"common-unix-commands","status":"publish","type":"page","link":"https:\/\/blogs.gre.ac.uk\/cmssupport\/systems\/unix\/unix-commands\/common-unix-commands\/","title":{"rendered":"Common Unix Commands"},"content":{"rendered":"\n<p><strong>Viewing the help files in Unix<\/strong><\/p>\n\n\n\n<p>The Unix system has a very complete and concise set of manuals that accompany every application that runs on the Operating System. These can be viewed using the&nbsp;man&nbsp;command, which is short for manual.<br><br>For example, if you wanted to view the&nbsp;man&nbsp;pages for the&nbsp;ls&nbsp;command you would type:<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% man ls<\/pre>\n\n\n\n<p>Experiment with&nbsp;man&nbsp;by viewing all the&nbsp;man&nbsp;pages for the applications and commands that you are aware of.<\/p>\n\n\n\n<p><strong>Changing file permissions<\/strong><\/p>\n\n\n\n<p>chmod&nbsp;(change access permissions,&nbsp;change&nbsp;mode)<br><br>chmod&nbsp;changes the permissions of each given file according to mode, where mode describes the permissions to modify. Mode can be specified with octal numbers or with letters. Using letters is easier to understand for most people.<br><br>More information about the use of chmod can be found by visiting the following link:<br><a href=\"http:\/\/ach-support.gre.ac.uk\/unix\/chmod.html\" target=\"_blank\" rel=\"noreferrer noopener\">The chmod Command<\/a><\/p>\n\n\n\n<p><strong>Checking the size of files and directories in Unix<\/strong><\/p>\n\n\n\n<p>To check the size of files and directories in your unix home area, type the following command at the Unix shell prompt:<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% du<\/pre>\n\n\n\n<p>This will output the result in blocks of 512b increments.<br>If you would rather see the result in 1K blocks you can type:<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% du -k<\/pre>\n\n\n\n<p>If you would rather see a summary for the whole directory and not the individual files inside the directories, you can type:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% du -sk *<\/pre>\n\n\n\n<p><strong>Clearing the screen<\/strong><\/p>\n\n\n\n<p>clear&nbsp;(clear screen)<br><br>The terminal window of the previous commands can be cleared so that the output of the following commands can be clearly understood. At the prompt, type the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% clear<\/pre>\n\n\n\n<p>This will clear all text and leave you with the&nbsp;%&nbsp;prompt at the top of the window.<\/p>\n\n\n\n<p><strong>Finding out what type of system you are on<\/strong><\/p>\n\n\n\n<p>The&nbsp;uname&nbsp;command will provide useful information on system details.<br><br>uname -a&nbsp;reveals all details. Here are some example outputs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% uname -a<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">SunOS student 5.10 Generic_141445-09 i86pc i386 i86pc<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$ uname -a<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Linux stulinux 3.2.0-52-generic #78-Ubuntu SMP Fri Jul 26 16:21:44 UTC 2013 x86_64 x86_64 x86_64 GNU\/Linux<\/pre>\n\n\n\n<p>In the first example we are told that we are on a Sun Solaris (Version 5.10) system running on x86 hardware.<br><br>In the second example the command is informing us that we are operating on a Linux system running on an x86_64 hardware platform.<br><br>For more information on the uname command run:&nbsp;man uname.<\/p>\n\n\n\n<p><strong>Unix pipes<\/strong><\/p>\n\n\n\n<p>A pipeline is a convenient way to channel the output of one command into the input of another without creating an intermediate file. Let&#8217;s say we wanted to get an alphabetical listing of the current processes. From a thorough study of the previous section and the man pages for ps and sort, we already know how to do this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ps -ef &gt; processes\nsort processes<\/pre>\n\n\n\n<p>This works, but it gives us a file (namely processes) which we don&#8217;t want. The vertical bar symbol, &#8216;|&#8217; allows users to bypass this intermediate file. The above two commands can be replaced with the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ps -ef | sort<\/pre>\n\n\n\n<p>It is possible to connect a series of commands by additional pipe symbols. We could pass our previous output through the more paging program to obtain a more pleasing display of the results. This can be accomplished by typing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ps -ef | sort | more<\/pre>\n\n\n\n<p>One important point to understand is that if a command isn&#8217;t capable of reading from standard input, it cannot be placed to the right of a vertical bar symbol.<br><br>More information can be found by visiting the following link:<br><br><a href=\"http:\/\/freeengineer.org\/learnUNIXin10minutes.html#Pipes\">http:\/\/freeengineer.org\/learnUNIXin10minutes.html#Pipes<\/a><\/p>\n\n\n\n<p><strong>Summary<\/strong><\/p>\n\n\n\n<p>man command&nbsp;&#8211; view the man pages (help files)<br><br>checkquota&nbsp;&#8211; shows how much disk space you have left.<br><br>clear&nbsp;&#8211; clears the screen<br><br>uname&nbsp;&#8211; prints name of current system<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Viewing the help files in Unix The Unix system has a very complete and concise set of manuals that accompany every application that runs on the Operating System. These can be viewed using the&nbsp;man&nbsp;command, which &hellip;<\/p>\n","protected":false},"author":53,"featured_media":0,"parent":584,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-646","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/users\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/comments?post=646"}],"version-history":[{"count":0,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/646\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/584"}],"wp:attachment":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/media?parent=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}