Command Line Access

This document is designed to provide CS 211 students with a UNIX command line environment, either locally or on a remote virtual machine called bertvm.

Running UNIX on Your Own Machine

If you have a Mac or a relatively new Windows laptop, then compared to using bertvm one of the following alternatives will likely be the most convenient option for you.

  • Mac
    The
    macOS operating system is built on a version of UNIX. The terminal window and the graphical user interface share the same underlying file system. To open up a command window:

    1. Open up Spotlight by pressing and holding the Command key and then pressing the spacebar. In the resulting search window you can type in any program or filename.

    2. Type in terminal and then press enter and then select the top item of the search results list. You can then run UNIX commands locally, or connect to bertvm as described below.

  • Windows Subsystem for Linux (WSL) on Windows machines.
    After doing the installation start it up by running the Windows
    Ubuntu program.

    1. Windows 10: How to Use Linux Terminal in Windows 10

    2. Windows 11: How to Install Windows Subsystem for Linux in Windows 11

Running UNIX on the Remote Virtual Machine bertvm

The bertvm.cs.uic.edu (abbreviated as bertvm) machine is owned by the CS department, but is accessed using standard UIC NetIDs and passwords. The bertvm virtual machine requires the use of an additional Secure Shell ( SSH ) program for secure remote login and file transfers, as described below. The remainder of this page will explain how to securely access bertvm, and how to use it to write, compile, and run a basic C program.

Acquiring a Secure Shell and Secure File Transfer Program

UIC offers a lot of free or discounted software through its WebStore, located at webstore.illinois.edu (or search for webstore site:uic.edu). One of those free products is “Secure CRT & Secure FX”. Follow these steps to obtain, install, and use this software:

  1. Go to the WebStore web site webstore.illinois.edu , select “Personal Purchases”, and login using your NetID and password.

  2. Select “Windows Products” ( regardless of your real OS ), find Secure CRT & Secure FX on the list, add the package to your cart, and proceed to the checkout.

  3. At checkout you will be able to choose your preferred download package. At this time you can choose between Windows, Mac, Red Hat, or Ubuntu operating systems, and you can also choose to download just the Secure CRT, or just the Secure FX, or preferably both items bundled together.

  4. Below the download selection is license information that will be needed to license the product after it is installed. You will need to cut-and-paste about 7 lines of information to complete the license process, not just the license key, from “Name” through “Features”.

  5. There is also a link to full installation instructions on the check out page. It is worth looking over those instructions, particularly if you have not installed a lot of software before.

  6. Launch SecureCRT, and specify bertvm.cs.uic.edu as a new session. The first time you connect to any new site using Secure CRT you will get a “New Host Key” warning about the key not being found in the existing database. This is normal for new sites. Just select “Accept and Save” and continue. You will need to provide your UIC NetID and password.

  7. Once SecureCRT is connected to bertvm, find and click the button to launch SecureFX. Secure CRT will provide a secure terminal window to bertvm, and Secure FX will provide secure file transfer between local and remote machines.
    [This section originally created by Pat Troy, Nasim Mobasheri, John Bell. Last revised 10/13 by Dale Reed ]

Built-in Secure Shell (ssh) connection on Mac/Linux

If you are using a Mac/Linux system, you can directly use the ssh service through any terminal window. Simply open your terminal and type the following:

ssh netid@bertvm.cs.uic.edu

For example if your netid is reed you would type in: ssh reed@bertvm.ccs.uic.edu
Then proceed by entering your password and you will be connected to your bertvm account. For securely transferring files, you can either use something like Filezilla or the built-in sftp command.

Creating Your First Program

Now that we have a command line prompt, we can use it to create a new directory, change into that directory, create a C program and run it.

  1. Create a new directory by typing:
    mkdir cs211
    Verify that it has been created by getting a directory listing by typing:
    ls

  2. Change into the newly-created directory by typing:
    cd cs211
    Later (but not right now) we can move back the file hierarchy to the parent folder by typing
    cd ..

  3. Create a new C program
    There are two edit options that we will discuss that should be built into your environment:
    nano and vi. Nano is much simpler to use, while vi is much more powerful but requires more practice to get used to. For now we will use nano. At the command line type in:
    nano hello.c
    This should open up an edit window with space to type in your program at the top, and options given down at the bottom. Type in the following program:
    #include <stdio.h>
    int main() {
    printf(
    "Visualize whirled peas\n");
    return 0;
    }

  4. Take a look at the options at the bottom of the screen (see below), where "^" means press the control key on your keyboard. Select the option to "Write Out" your file by pressing and holding the control key and then pressing the o key (lower case). You will be prompted for the filename to use, in this case defaulting the the filename used when the file was created.

If you want additional guidance for the above section, see also the nano tutorial at staffwww.fullcoll.edu/sedwards/nano/introtonano.html

Running Your First Program

If you are still in the nano editor, exit using ^x (Control-x). As done previously, again get a listing using ls to verify that this newly created file hello.c is there. Now we will compile and run the program we created above by typing in:
gcc hello.c
If this is your first time compiling using gcc in a newly installed environment, you may get the message that 'gcc' was not found. If that is the case, follow the prompt to install it by typing in:
sudo apt install gcc
This is an abbreviation for "super user do advanced package tool installation of the gnu C compiler". You will be prompted for your password and additional software will be downloaded and installed, which will take a couple of minutes.

Now again compile the program using gcc hello.c and then use ls to get a listing of the files found, which should show the newly created file a.out and then execute the program by typing ./a.out which should end up looking something like the following:

reed@cs-bertvm:~$ gcc hello.c

reed@cs-bertvm:~$ ls

a.out hello.c

reed@cs-bertvm:~$ ./a.out

Visualize whirled peas

reed@cs-bertvm:~$

The dot-slash at the front of the ./a.out command means "look in the current directory" and then a.out is the file to be run, which is the executable file created by the gcc compile command.