bc is a command-line calculator that’s fast and has the capacity to do some fairly complex math.
Try it out on the command line:
echo '100 / 10' | bc -l
I released the code under GPL, and it’s available on github: http://github.com/hmason/tweetbc.
John Cook mentions the bot and makes some great observations in his post three surprises with bc.
This document will step through the process of accessing a Linux server, and several basic commands.
We will access the server via the SSH, or “Secure SHell”, protocol. SSH provides encrypted communication between two terminals. It is an alternative to telnet or rlogin.
First, make sure that you have an SSH client. If you are running Windows, I highly recommend downloading Putty. Click on the top Windows binary and save it to the desktop. You can run Putty.exe directly, without installing.
If you are using OS X, open a terminal and run ‘ssh’.
Type your hostname into the box. You can find your hostname by asking your ISP, but a good bet is that “www.yourdomain.com” will resolve to your server. You may need to request shell access
Click open. You’ll be presented with a warning, because you haven’t connected to that machine before. Approve the connection.
Next, you’ll see a login prompt. Enter your username. These will be assigned in class, but a good guess is your first initial and last name.
Enter your password. Both your username and password are case-sensitive.
You should see a screen like the one to the left. Congratulations! You’re logged into the system.
You’re now looking at an interactive shell prompt. The shell accepts the commands that you type and sends them to the kernel, which executes them. This is how you interact with the operating system.
The prompt currently shows your username, the name of the machine (PVDACDLN-01), and your current directory (~, see below).
By default, our system assigns users to the bash shell. There are many different shells available. In general, they all do the same thing, so most users choose a shell based on what they are most comfortable with.
Tip: By default, OS X uses bash as the shell in a terminal. All of these commands will work nearly identically in OS X.
The remainder of this document is an introduction to Linux commands and a reference.
The Linux filesystem is organized into a heirarchical series of folders, or directories. ‘/’ indicates the root directory, which contains all other files and directories.
pwd – pwd stands for “print working directory”. It echoes the current directory to the screen (this is where, in the filesystem, you currently are).
cd – cd stands for “change directory”. It changes your current working directory to a new directory. If you try to change to a directory that does not exist, you’ll get a No such file or directory error.
Tip: you can type “cd ~” at any time to return to your home directory, or, if you know someone’s username, type “cd ~username” to cd to their home directory.
ls – ls stands for “list”. It prints a list of files and directories in the current working directory to the screen. This version of ls presents directories in blue.
The ls command also accepts various arguments that change the output of the command. For example, the “-a” argument means “display hidden files”, while the “-l” argument means “use long listings”. Command-line switches can be used singly or combined.
Filenames that begin with a “.” are hidden by default. Also note the “.” (current directory) and “..” (parent directory) operators.
clear – The clear command requires no parameters. It clears the terminal and presents a prompt. It’s almost never necessary to do this, but it can be good for mental clarity.
who – The who command requires no parameters. It prints a list of all logged in users to the screen.
top – every program or command that runs on the machine is a process. The top command displays running processes in order of the CPU cycles consumed.
ps – ps stands for “process snapshot”. It prints a list of the current running processes. Use the “-e” argument to see everyone’s processes.
man – man stands for “manual”. It