By Hunter Open Source Club
This page is dedicated to information about our school's UNIX workstations, collectively referred to as ENIAC
. (NOTE: The name is kind of a misnomer, as technically ENIAC
is only the gateway machine; the rest of the computers are named {cslab1
, cslab2
, ... cslab30
}).
As Hunter students, we have the ability to remotely log in to these lab computers via ssh
(or use them in person in the computer labs on the 10th floor). This is a great opportunity to explore the command-line and learn about UNIX. It's also lot of fun :).
- Whenever a section of this guide is not self contained (i.e. we expect you to go to outside sources to learn something) you'll see this icon.
- Signifies a side note or fun fact.
When you see something in angle brackets, e.g. <username>
, interpret it as a placeholder for a value (in this case, your username). Square brackets, e.g. [username]
are similar, but the value they denote is optional.
We precede lines on the command-line with the $
symbol -- it isn't part of the actual commands being demonstrated.
ENIAC (Electronic Numerical Integrator and Computer) was the first programmable electronic, general-purpose digital computer, made in 1945.
Our school system is named after this historic computer.
UNIX is an operating system created in the early 1970s at AT&T's Bell Laboratories.
When we say UNIX on this page, we are really referring to any system from the family of operating systems descending from UNIX, such as: Linux, MacOS, FreeBSD/OpenBSD/NetBSD, and so on. Yes, there are other systems besides Windows and MacOS :P; and yes, you are a UNIX user (you do have an iPhone or Android, right?).
The information on this page applies to the common command-line interface shared by UNIX-like systems. For more information on what exactly is in common between them, read about POSIX. This article may also be insightful.
If you are interested in further discussing the history of UNIX please email us. :).
Today we have two main sorts of interfaces through which we access our computer systems -- graphical and textual. Just as windows, menus, and the mouse cursor are the graphical means by which we orchestrate our computing environments, the command-line allows us to do so through text -- language instead of motions.
Some tasks are better done graphically, others textually. You'll see :P.
You may have heard these 3 terms: command-line, shell, and terminal. What exactly is the difference between them?
'Command-line' is a generic term referring to the sort of interface where you interact with your computer by typing commands.
'Shell' refers to a kind of program that implements this command-line interface (and has UNIX-related connotations). For example: sh
, bash
, etc.
'Terminal' is a historical term. Computers were once very large, and one interacted with them via a terminal (and before that, a teletype/typewriter/TTY).
What we refer to as a 'terminal' today is really a terminal emulator -- an application that emulates the visual look of the physical terminal you see in the image above.
For a more in depth explanation, see this great article. For a more sentimental piece, see In the Beginning was the Command Line by Neal Stephenson.
You can connect to ENIAC via the ssh
protocol. To do so, you need an ssh
client. On UNIX-like systems you likely have an ssh
client installed already, but for others you can download one from the Internet (e.g. PuTTY).
Windows users: Note that WSL (Windows Subsystem for Linux) now exists; please set it up and partake in this journey with us. See Owen's guide on installing WSL. Also see Micro$oft's new open source terminal emulator.
The rest of this section assumes you're at a UNIX-like command-line. Here's what to do:
Firstname.LastnameXX
, just like your Hunter email. For example: Ken.Thompson69
. NOTE: The uppercase characters are important.ssh <username>@eniac.cs.hunter.cuny.edu
. Replace <username>
with the username you determined in step 1.
ENIAC is only the gateway machine though, and it's missing a lot of software that is present on the other cslab hosts. Before doing any work make sure to connect to a host of your choosing (cslab1
...cslab30
) by running ssh cslabN
.
For further ENIAC related concerns see this page.
Finally, you've made it :D!
The first thing you'll have to do is learn how to navigate the file system. Here are some specific things to figure out:
ls
)cd
)pwd
)touch
, text editors, etc) and folders (mkdir
)mv
)cp
)rm
, rmdir
) <-- BE CAREFULcat)
Search online for help with this.
Go on a voyage around the system and see what you can find. Try to cd /
and find your way back to your home folder. Find a folder that you cannot enter into (you'll see a permission denied error).
Other useful things to understand:
.
represents the directory you are in and ..
represents the parent directory.man
pagesHere is an illustration of a hierarchical file system to help you picture what's going on:
Once you're comfortable with this you can start experimenting with other commands. It would be wise to learn how to use a command-line text editor, which we'll discuss in a later section.
NOTE: you'll notice that your files are the same regardless of what cslab host you're logged into -- how could this be if you're logging in to a different computer each time? This is because the school computers are using NFS, a networked file system developed by Sun Microsystems.
export PATH="$PATH:~/bin"
Today we have two main sorts of interfaces through which we access our computer systems-- graphical and textual. Just as windows, menus, and the mouse cursor are the graphical means by which we orchestrate our computing environments, the shell allows us to do so through text -- language instead of motions. Everyone's desktop is different -- we all have different backgrounds and document organization schemes. But the shell and the environment it interfaces with are even more deeply personal; almost every aspect can be configured, and many things can be automated. In the Unix shell you can arbitrarily extend the language you use to talk to your system -- each program or script you create is another word in your vocabulary! Have you ever read the book Frindle by Andrew Clements? A kid discovers that individuals get to determine what words mean, so he decides to make up a new word for 'pen' -- frindle. Words, languages are made up by people, and we are people too! Yet, in 'real life' we rarely exercise the power to extend language. Using and modifying the Unix shell will be your first step in escaping the myth of determinism, the idea that things are how they are because they have to be that way. Not true -- it's all been imagined up. Reject arbitrary rules that have been imposed on us. Reclaim your childhood innocence and be human.
Have you ever wondered how to print text in bold or a different color in your terminal?
You can do all sorts of crazy stuff, including this, using ANSI escape sequences. For example, run this in your shell:
# print a bold and underlined "Hello" in red
$ printf "\033[31;1;4mHello\033[0m\n"
Cool, right? Try to change the 31
after \033[
to other numbers like 32
, see what happens. Also try to change the 4
in ;4m
to a 3
or other numbers. Another thing you can do is clear your entire terminal window including all the previous output (try scrolling up afterwards, you'll see what I mean):
$ printf '\e[2J\e[3J'
All of these escape sequences can get annoying to type (and are not necessarily portable to different terminal emulators), so there are some alternatives. The tput
utility is one. To print bold text with tput
, you can run:
$ tput bold
$ echo hello world
$ tput sgr0 # reset
See also:
UNIX is a time sharing system, we're all logged in to one big machine and sharing its resources. (The operating system is the arbiter of this process, by the way). Since we're all logged in, let's compute together!
Who exactly are we, by the way? Let's find out:
$ who
Yours.Truly47 pts/0 Feb 5 11:28
Ken.Thompson69 :0 Feb 5 03:22 (:0)
Dennis.Ritchie93 :1 Feb 2 08:35 (:1)
Brian.Kernighan72 :2 Jan 31 20:17 (:2)
Heh, looks like some of the UNIX pioneers are logged into ENIAC, nice! (Just kidding, that would be super cool doe).
Let's send a message to Ken:
$ write Ken.Thompson69
is your refrigerator running?
oh crap, how do i close this 'write' thing
uhh...
oh yeah, I can send an EOF using CTRL-D
That whole message just got sent to Ken... oh well. The way the write
program is structured, it keeps accepting input until you send it an EOF (end of file) character, which is done with CTRL-D
(the control key + the d key). Ken will see our message on his screen and can respond in a similar way. Try it with your friends!
Some other programs worth checking out:
w
- Show who is logged on and what they are doingmesg
- display (or do not display) messages from other userstop
- display Linux processeswall
- write a message to all usersps aux
- report a snapshot of the current processespinky
- lightweight fingerDo you know what operating system your cslab host is running? Do you know how much hard drive space it has? How much RAM? Do you know how many CPUs it has? Do you want to know? Here are some commands you can use to find out:
uptime
- show how long system has been runninglscpu
- display information about the CPU architecturelshw
- list hardwareuname -a
- print system informationdu -h
- estimate file space usagedf -h
- report file system disk space usagefree
- display amount of free and used memory in the systemscp
utility uses the SSH protocol to transfer filesscp swag.txt First.Last12@eniac.cs.hunter.cuny.edu:~/notes
scp -r folder/ First.Last12@eniac.cs.hunter.cuny.edu:~
scp First.Last12@eniac.cs.hunter.cuny.edu:~/notes/hw1.cpp .
Text editors are programs that do what they say on the tin (edit text). If you plan on writing programs or editing files, you'll need some sort of program to facilitate that.
It's important to note that programs are just text (source code), so you do not actually need an application meant specifically for programming in order to write programs (as long as your save your file as plain text and name it with the file extension your compiler expects, you could theoretically write programs in Micro$oft Word).
You may be wondering what the difference is between IDEs and text editors.
An IDE (integrated development environment) is an application for programmers that combines multiple components in one place -- a text editor, compiler, debugger, and so on. IDEs are usually built to be used with a specific programming language, though some support multiple. Some examples of IDEs are Eclipse, Xcode, Visual Studio, and JetBrains PyCharm.
A text editor in its simplest form is an application that lets you edit text. Some programming-oriented editors provide features that are useful for programmers, such as syntax-highlighting, auto-complete, and so on. Other editors are just there to edit text (e.g. Notepad). Text editors don't necessarily have to be graphical, they can be programs on the command-line. Some examples of text editors are Sublime Text, Atom, VS Code, Emacs, vim, Nano, and so on. (Note: at the risk of stating the obvious, text editors perform the generic function of editing text, and therefore are suitable to be used with any programming language).
Bonus: applications like Micro$oft Word and Google Docs are called 'Word Processors' -- they're like the IDEs of document preparation.
If you want to write programs remotely on ENIAC, you'll need to do so using a command-line text editor (actually this isn't strictly true -- later we will discuss something called X11 forwarding.). At first this may seem scary, but it is well worth the investment. Nano is a pretty accessible editor (originally writen for non-technical people to write emails in), so you may want to start there. Other available editors are vim and Emacs (they are very different and come from different cultural milieus; there is also an age-old holy war waging between vim and Emacs users). These editors have a steep learning curve but learning how to use one of them is well worth your time.
- Teaching you how to use an editor is outside the scope of this document, please search that up on your own.
- NOTE: if you're curious about vim, try running the
vimtutor
program on ENIAC.
There is a lot of interesting software installed on ENIAC ready for us to explore. The following is a survey of some of that software, meant to encourage you to dig in further.
A language that doesn't affect the way you think about programming, is not worth knowing. - Alan Perlis
There are actually a good bunch of programming languages (i.e. compilers/interpreters) available on ENIAC. In school we mostly learn about procedural programming and (faux) object-oriented programming, specifically with languages in the C family. Programming can look much different than that, it's of utmost important that you open your mind by exploring different paradigms of programming languages (e.g. functional programming, logic programming, etc). Also see the paper Notation as a Tool of Thought by Ken Iverson.
Here are some languages we have on our system:
gcc
)g++
)hugs
)
prolog
)
sbcl
)
java
)python2
, python3
)
--user
flag)perl
)
ruby
)scala
)node
)
gfortran
)awk
)
R
)m4
)We encourage you to take the course CSCI 460 - Advanced Programming Languages with professor Subash Shankar.
man -k pgm
(or with ppm
, pbm
)amixer
, spd-say
, speaker-test
, speech-dispatcher
, pulseaudio
/data/biocs/b/ubuntu/bionic/
ssh -X
code
, firefox
, gedit
, idle
, xeyes
, ico