Linux programming environment for COMS 3136

The CLOC server

All registered students will receive an account on CLOC, which is a Linux server instance running on Google Cloud Platform. CLOC runs Ubuntu Linux, 64-bit version. All homework assignments in this class will be submitted and graded on CLOC.

If you are not familiar with Linux programming environment, you need to become familiar with it ASAP. There are many books and online tutorials you can use. For example, here is the top link that came up when I googled for “linux tutorial for beginners”: http://www.ee.surrey.ac.uk/Teaching/Unix/

Logging in to CLOC

On Mac OS X, launch the Terminal app, and type the following at the command prompt:

ssh -X YOUR_UNI@cloc.cs.columbia.edu

On Windows, I recommend MobaXterm.

Picking your editor

The official way to code in this course is to use a text editor and command line tools. There are two popular text editors in the UNIX environment: Emacs and Vim. They split power users and programmers in UNIX world into two camps (that constantly make fun of each other). The choice between them largely boils down to personal taste. I recommend you pick one of those as your editor and start using it, learning tips and tricks as you go. You can start with the built-in tutorials: run vimtutor at the command prompt for Vim, and click on “Emacs Tutorial” under Help menu for Emacs. Emacs and Vim have been ported to virtually every platform, so you can install and use them on your PC or Mac as well.

Another possibility is Nano (also called Pico). Nano is very easy to use, especially for beginners, but it is rather limited in functionality. It is only recommended for those who are new to UNIX and feel there are just too many things to learn before you get to do anything. Even so, I recommend that you switch to either Emacs or Vim as early as possible.

Setting up your shell environment

The application with which you interact in a terminal window – the program that prints the command prompt and carries out the commands that you type – is called a “shell”. There are many different shell programs. Your CLOC account is configured to use the Bash shell by default. Try typing echo $SHELL. You’re good if you see /bin/bash.

There is something you need to add to the .bashrc file in your home directory to setup your shell environment for this class. Type cd to go to your home directory, and then open the .bashrc file in your editor. For example, type the following to open the .bashrc file using the Nano editor:

cd
nano .bashrc

Then, add the following line to the end of your .bashrc file:

export EDITOR=your_editor

You should of course replace “your_editor” with either vim, emacs, or nano, depending on what editor you actually use.

Log out of CLOC (by typing “exit” at the command prompt) and log in again. Type echo $EDITOR to see if your modification to .bashrc has taken effect. If it hasn’t, try adding the following lines to .bash_profile file in your home directory:

if [ -f ~/.bashrc ]; then 
    source ~/.bashrc 
fi

Basic UNIX commands

Here are some UNIX commands that you should get comfortable with. You can use the man command to display the manual page for any given command. (Typing ‘q’ will exit out of man command.)

man, cat, less, rm, cp, ls, ll (an alias for ls -alF), pwd, cd, mkdir,
alias, locate, gcc, make, touch

Here are some more that you will find handy:

clear, history, date, mv, grep, diff, find, tar

Last updated: 2022–09–09