created by Carlos Aguilera
updated on June 2017
The Lab machines are linux based and some of you have Macintosh or Windows. This tutorial will cover using windows via command line and also using Cygwin, a linux-like environment.
To get started, open up a Command Prompt (from the Start Menu under Windows System). Alternatively, you can use the Cortana search bar to find the command prompt by typing cmd. As the linux tutorial I'll refer to your interface as the console window. The console is a text-based interface where we can enter commands. These commands run programs with input that we provide, and then displays the output of that program.
Before we enter any commands, you should understand a little more about the console output. Look at the window below:
The text to the left with the >
at the end gives basic information such as the current directory or folder. In the above example, the user is Carlos
. We can tell because we are under the Users directory and in Carlos. Unfortunatley, windows does not have ssh capabilities. What we can do is install cygwin to assist us. However, below we will cover the basic windows commands.
In UNIX based systems to list the content in the current directory we type ls. In windows we type dir.
In UNIX based systems to change directories we type
Here you can see three commands in action: looking at the current location with cd, making a new directory, and changing directories.
C:\Users\Carlos>cd C:\Users\Carlos C:\Users\Carlos>mkdir CS110 C:\Users\Carlos>cd CS110 C:\Users\Carlos\CS110>
You can type dir at the new location and see the output. This will give you familiarity with the console. You can refer to the second image above to get an idea of the output for dir but it should be different because the directories are different and we have different content in our computers.
You can follow this guide or you can follow this online resource:
http://www.mcclean-cooper.com/valentino/cygwin_install/ which is where I got the photos.
Follow this link to the installation page: Install Cygwin
Be sure to download the setup-x86.exe for either the 32-bit or 64-bit depending on the version of windows you are runnning.
Once the download completes run the executable. Hit next until you reach the 'Choose a download source.'
After installing Cygwin, we can use cygwin to run unix commands such as ls the only downside is that we cannot execute programs or scripts in a unix based terminal fashion. Therefore, the tutorial will now concern itself with the Cygwin console.
You can either jump to Using Linux via Command Line or continue on this tutorial.
At the beginning of the tutorial I gave UNIX and windows comparisons. You can refer to those comparisons with this table:
Windows | UNIX | Notes |
---|---|---|
del | rm | remove a file |
rd | rmdir | removes a directory |
dir [directory name] | ls | list the contents of the directory |
cd or chdir | pwd | Tells the current directory location |
cd or chdir [directory name] | cd | change the directory |
rd /s /q | rm -rf | remove the directory recursively and forcefully |
del /f | rm | delete a file |
mkdirormd [directory name] | mkdir | make a new directory |
~
.
The $
indicates the console. We'll practice below with some
Carlos@hrn23502 ~ $ cd cs110 Carlos@hrn23502 ~/cs110 $
There are several Linux Tutorials on the web. Here are some useful resources recommended by Sophie Engle:
The best way to learn something is to just try it. It will be easier to remember if applying the concepts.