Boston Python workshop 2/Friday setup/Terminal navigation on Windows: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
<pre>dir</pre>
<pre>dir</pre>
This lists all the files in your home directory.
This lists all the files in your home directory.

<br />


<pre>cd C:\</pre>
<pre>cd C:\</pre>
This will change you into the <code>C:\</code> directory.
This will change you into the <code>C:\</code> directory.

<br />


<pre>dir</pre>
<pre>dir</pre>
This lists the contents of the <code>C:\</code> directory.
This lists the contents of the <code>C:\</code> directory.

<br />


<pre>cd Python27</pre>
<pre>cd Python27</pre>
This will change you into the <code>Python27</code> subdirectory of the <code>C:\</code> directory.
This will change you into the <code>Python27</code> subdirectory of the <code>C:\</code> directory.

<br />


<pre>dir</pre>
<pre>dir</pre>
You should see the names of all the files in <code>C:\Python27</code>, including your <code>python.exe</code> application.
You should see the names of all the files in <code>C:\Python27</code>, including your <code>python.exe</code> application.

<br />


<pre>cd ..</pre>
<pre>cd ..</pre>
<code>..</code> means "parent directory", so this command moved you up to the parent directory. You were in <code>C:\Python27</code>, so now you are in <code>C:\</code>, the root directory.
<code>..</code> means "parent directory", so this command moved you up to the parent directory. You were in <code>C:\Python27</code>, so now you are in <code>C:\</code>, the root directory.

<br />


<pre>dir</pre>
<pre>dir</pre>
This lists the contents of the root directory, confirming where you are.
This lists the contents of the root directory, confirming where you are.

<br />


* You can use Tab to auto-complete directory and file names. So from inside the root directory, if you type <code>cd Pytho</code> and hit Tab, the command prompt will auto-complete the directory name, and you can then hit enter to change into the <code>C:\Python27</code> directory.
* You can use Tab to auto-complete directory and file names. So from inside the root directory, if you type <code>cd Pytho</code> and hit Tab, the command prompt will auto-complete the directory name, and you can then hit enter to change into the <code>C:\Python27</code> directory.
Line 44: Line 58:


You've practiced using <code>dir</code> and <code>cd</code> to navigate your computer's filesystem from the command prompt.
You've practiced using <code>dir</code> and <code>cd</code> to navigate your computer's filesystem from the command prompt.

[[Boston Python workshop 2/Friday setup|&laquo; Back to the Friday setup page]]

Latest revision as of 19:23, 12 May 2011

There are two commands that we'll be using at a command prompt to navigate the filesystem on your computer:

  • dir
  • cd

dir lists the contents of a directory.
cd moves you into a new directory (it stands for "change directory").

Let's practice using these commands.

Open a command prompt:

  • On Windows Vista or Windows 7: click on the Start menu (the Windows logo in the lower left of the screen), type cmd into the Search field directly above the Start menu button, and click on "cmd" in the search results above the Search field.
  • On Windows XP: click on the Start menu (the Windows logo in the lower left of the screen), click on "Run...", type cmd into the text box, and hit enter.

Practice using dir and cd

Type each of these commands and hit enter:

dir

This lists all the files in your home directory.


cd C:\

This will change you into the C:\ directory.


dir

This lists the contents of the C:\ directory.


cd Python27

This will change you into the Python27 subdirectory of the C:\ directory.


dir

You should see the names of all the files in C:\Python27, including your python.exe application.


cd ..

.. means "parent directory", so this command moved you up to the parent directory. You were in C:\Python27, so now you are in C:\, the root directory.


dir

This lists the contents of the root directory, confirming where you are.


  • You can use Tab to auto-complete directory and file names. So from inside the root directory, if you type cd Pytho and hit Tab, the command prompt will auto-complete the directory name, and you can then hit enter to change into the C:\Python27 directory.
  • The command prompt maintains a command history. You can use the up arrow to cycle through old commands.
  • Note that the text that makes up the command prompt changes as you move around directories. The command prompt will always give the full directory path to your current directory.

Success!

You've practiced using dir and cd to navigate your computer's filesystem from the command prompt.

« Back to the Friday setup page