<?xml version="1.0" encoding="ISO-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:axle="http://www.cs.odu.edu/~zeil/axle" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns0="http://www.cs.odu.edu/~zeil/axle" mode="ignore" id="basicUnix" ns0:xlinkuri="open/basicCommands.dbk" ns0:xpath="//*[@id='basicUnix']" ns0:page="basicCommands" foo="0 " ns0:last="/cocoon/~cs252/open/basicCommands/printing.html"><head><title>Some Basic Unix Commands</title><link type="text/css" href="_axle/docbookstyle.css" rel="stylesheet"/><link type="text/css" href="_axle/cppformat.css" rel="stylesheet"/><link type="text/css" href="_axle/overrides.css" rel="stylesheet"/><script src="_axle/docbook.js"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/cmdlist.html" title="Next" rel="next"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/printing.html" title="Last" rel="last"/><script>function gotoNext() {top.location.href="/cocoon/~cs252/open/basicCommands/cmdlist.html";}
function gotoPrev() {}
function gotoUp() {}
</script><xhtml:link xmlns:xhtml="http://www.w3.org/1999/xhtml" rel="stylesheet" href="_axle/navigation.css" type="text/css"/><xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/navigation.js"/></head><body><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/cmdlist.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/printing.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/basicCommands/basicCommands.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table><br/><div class="info_article"><div class="title_article">Some Basic Unix Commands</div><div class="author_article"><span class="firstname">Steven</span> <span class="othername" role="mi">J</span> <span class="surname">Zeil</span></div><div class="affiliation">
        <span class="orgname">Old Dominion University</span>
        <span class="orgdiv">Dept. of Computer Science</span>
      </div><table width="100%"><tr><td align="left"><span class="copyright">©<span class="year">2000-2008</span> <span class="holder">Steven J. Zeil, Old Dominion University</span></span></td><td/><td align="right"><span class="date">Jan. 3, 2008</span></td></tr></table></div><div class="TOC">Contents:<div class="TOC-section0"><a href="#basicFileCmds">1 Getting Started: Navigating Your Directories</a></div><div class="TOC-section0"><a href="cmdlist.html#cmdlist">2 Some Common Unix Commands</a></div><div class="TOC-section1"><a href="session.html#session">2.1 Session Control</a></div><div class="TOC-section1"><a href="filemanip.html#filemanip">2.2 File and Directory Manipulation</a></div><div class="TOC-section1"><a href="textmanip.html#textmanip">2.3 Text File Manipuation</a></div><div class="TOC-section1"><a href="printing.html#printing">2.4 Printing Files</a></div></div>
  
  <div class="epigraph">
    <p class="para" align="center">
              (A printable version of this document is available 
              <a url="allPages.html" href="allPages.html">here</a>.)
            </p>
  </div>
  <div class="sect1" axle:nopage="1" id="basicFileCmds"><div class="info_sect1"><div class="title_sect2">1. Getting Started: Navigating Your Directories</div></div>
    

  <p class="para">If you have not yet done so, log in now so that you can work though
the following commands.</p>


<div style="clear:right;"/><table class="sidebar" border="1" width="40%"><tr><td>
<p class="para">
Throughout this course you will encounter sections labelled "Try This:". That means that I <span class="em">really</span> want you to log in, try the commands or procedures I describe, and observe and think about the results.
</p>
<p class="para">
If you don't understand the output you receive, please use the <span class="inlinemediaobject"><img src="_axle/forum.gif" fileref="_axle/forum.gif" align="top"/></span> symbol at the top of the page to post a question in the Forum.
</p>
<p class="para">Some of the <span class="quote">
      &#8220;Try This:&#8221;
    </span> exercises will build on the earlier ones, so skipping these early examples may lead to problems later on.
</p>
</td></tr></table>

<div class="informalexample"><div class="title_example">Try This:</div><p class="para">Upon logging in, your <span class="emphasis">working directory</span> should be your home
directory. The command <span class="code">pwd</span> will <span class="emphasis-bold" role="bold">p</span>rint the <span class="emphasis-bold" role="bold">w</span>orking <span class="emphasis-bold" role="bold">d</span>irectory. Give the command
<div class="screen"><span class="userinput">
   pwd
</span></div>
You should see something like
<div class="screen"><span class="computeroutput">
/home/yourname
</span></div></p><p class="para">Now, let's make a place to play in. <span class="code">mkdir</span> will make a new
directory.
Enter the command
<div class="screen"><span class="userinput">
   mkdir playing
</span></div>
to create a directory named <span class="quote">
      &#8220;playing&#8221;
    </span>.</p><p class="para">The command <span class="code">ls</span> lists the contents of the working directory.
More generally, <span class="code">ls <span class="emphasis">directoryname</span></span> will list the contents
of any directory.<a onmouseover="DBshowBriefly('fn_fref1_live')" name="fn_fref1" id="fn_fref1" class="footnotemark" href="#fn_fnote1">1</a><div class="footnote_live" id="fn_fref1_live">Well, not really <span class="emphasis">any</span> directory.
People can 
    <a href="../fileprot/">protect their own directories</a>
from the
prying eyes of others, in which case <span class="code">ls</span> will fail.</div></p><p class="para">Give the command 
<div class="screen"><span class="userinput">
   ls
</span></div>
and you should see <span class="code">playing</span> listed. In fact, it may be the only
thing listed.</p><p class="para">The command <span class="code">cd</span> is used to <span class="emphasis-bold" role="bold">c</span>hange the working <span class="emphasis-bold" role="bold">d</span>irectory. Give the command sequence
<div class="programlisting">
   pwd
   cd playing
   pwd
   cd ..
   pwd
   cd ./playing
   pwd
</div>
to see this in action.</p></div>

    <p class="para">The <span class="code">cp</span> command copies one or more files. You can give this
command as <span class="code">cp file1 file2</span> to make a copy of file <span class="code">file1</span>,
the copy being named <span class="code">file2</span>. Alternatively, you can copy one or
more files into a directory by giving the command as
<div class="screen"><span class="userinput">
cp file<span class="inlineequation"><span class="mathphrase"><sub>1</sub></span></span> file<span class="inlineequation"><span class="mathphrase"><sub>2</sub></span></span>&#8230;file<span class="inlineequation"><span class="mathphrase"><sub>n</sub></span></span> directory
</span></div></p>

<div class="informalexample"><div class="title_example">Try This:</div><p class="para">Now try the following:
<div class="programlisting">
   ls /usr/include
</div>
You should see a large number of files, including many ending in
<span class="quote">
      &#8220;.h&#8221;
    </span>. 
Copy two of
these files and check to see that the copy was successful, as follows:
<div class="programlisting">
   cp /usr/include/math.h /usr/include/stdio.h ~/playing
   ls ~/playing
</div>
</p></div>

  <div name="fn_fnote1" id="fn_fnote1" class="footnote">1. Well, not really <span class="emphasis">any</span> directory.
People can 
    <a href="../fileprot/">protect their own directories</a>
from the
prying eyes of others, in which case <span class="code">ls</span> will fail. (<a href="#fn_fref1">back</a>)
    </div></div>
  <script type="text/javascript">
checkForAnchorOnOtherPage('cmdlist','cmdlist');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('session','session');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('rlogin','session');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('filemanip','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('cdcmd','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('findcmd','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('lsa','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('lsF','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('pwdcmd','filemanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('textmanip','textmanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('catcmd','textmanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('morecmd','textmanip');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('printing','printing');
</script>
<br/><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/cmdlist.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/basicCommands/printing.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/basicCommands/basicCommands.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table></body></html>