Basic Linux commands

Our server storm.cis.fordham.edu is a Fedora Linux machine. We will edit, store, and run our C++ programs on this server. Here’s how to use your account there.

Your Fordham ID

Every member of Fordham University already has a Fordham ID; it’s the first part of your Fordham email address.
For example, if your Fordham email address is jsmith@fordham.edu, then your Forham ID is jsmith (for “John Smith”).

Two passwords

You will also need two passwords.

Launch the “secure shell” ssh and change your permanent secret password

To log into your account on storm.cis.fordham.edu,

In both cases, a window will appear. See if you can enlarge the window’s font to make the writing easier to read. In this window (assuming your Fordham ID is jsmith), give the following lowercase ssh command, with a space after the ssh. The first time you use ssh, type your temporary secret password. As you type it, the characters of this password will not be echoed onto the screen: you’ll be flying blind. The computer will ask you to type your temporary secret password again so that you can replace it with a new password of your own choosing.

ssh jsmith@storm.cis.fordham.edu
Are you sure you want to continue connecting? yes
jsmith@storm.cis.fordham.edu's password: Type your temporary secret password.  You won't see what you're typing.

You are required to change your password immediately (administrator enforced).
WARNING: Your password has expired.
You must change your password now and log in again!

Current password: type your temporary secret password again
New password: type your permanent secret password
Retype new password: type your permanent secret password again

passwd: password updated successfully
Connection to storm.cis.fordham.edu closed.

Log into our server storm.cis.fordham.edu

Now start again from the beginning with another
ssh jsmith@storm.cis.fordham.edu
This time, type in your permanent secret password.
You know you have logged in when the server givees you a green prompt ending with a dollar sign:

ssh jsmith@storm.cis.fordham.edu
jsmith@storm.cis.fordham.edu's password: type your permanent secret password

jsmith@storm:~$

Run some programs

Run the lowercase date, cal, and hostname programs in response to the green prompt just to verify that you’re connected to storm.cis.fordham.edu, and to build your confidence.
If you don’t say where the output of these commands should go, the output will appear on the screen by default.

jsmith@storm:~$ date
Thu Aug 27 06:19:51 PM EDT 2026

jsmith@storm:~$ cal
     August 2026
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

jsmith@storm:~$ cal 7 1955          (Your instructor was born on a Tuesday.)
      July 1955
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

jsmith@storm:~$ hostname
storm.cis.fordham.edu

What directory are you in now?
i.e., what is your current directory?

The documents you type into the computer (for example, your C++ programs) are called files.
The part of the computer that holds the files is divided into sections called directories.
There are thousands of directories, organized into a family tree.
At any given time, you are located in one of these directories.
The directory in which you are located now is called your current directory.
To see the name of your current directory, run the lowercase pwd (“print working directory”) program.
When you log in, you will find that you are located in your own home directory.
(In other words, you will find that your current directory is your home directory.)
The name of your home directory is your Fordham ID, which we are assuming is jsmith.
pwd also shows you the complete lineage (i.e., ancestry) of your current directory.

jsmith@storm:~$ pwd
/home/students/jsmith

If you don’t already have the dashed directories, we will create them later in the course with the mkdir program.

Your browser does not support the HTML CANVAS tag.

Travel up the tree of directories with the cd command,
and leap back to your home directory

The cd command (“change directory”) will let you travel to a different directory.
The two dots .. stand for the name of the directory that is one level above your current directory.
Type a space before the two dots, with no space between them.

jsmith@storm:~$ cd ..               (Go one level up from your home directory.)
jsmith@storm:/home/students$ pwd    (Make sure you did go one level up.)
/home/students

jsmith@storm:/home/students$ cd ..  (Go another level up.)
jsmith@storm:/home$ pwd
/home

jsmith@storm:/home$  cd ..
jsmith@storm:/$ pwd
/                        (Now you're in the "root directory".  Can't go any higher.)

jsmith@storm:/$ cd ..    (Try to go higher.  You can't.)
jsmith@storm:/$ pwd
/                        (You're still in the root directory.)

jsmith@storm:/$ cd       (Go straight back to your home directory.)
jsmith@storm:~$ pwd      (Make sure you returned there.)
/home/students/jsmith

jsmith@storm:~$ cd .     (Does nothing: one dot means your current directory.)

Explore another branch of the tree of directories:
go up, go down, list

jsmith@storm:~$ cd                  (Go back to your home directory.)
jsmith@storm:~$ pwd                 (Make sure you're back in your home directory.)
/home/students/jsmith

jsmith@storm:~$ cd ..               (Go one level up from your home directory.)
jsmith@storm:/home/students$ pwd    (Find out where you went.)
/home/students

jsmith@storm:/home/students$ cd ..  (Go another level up.)
jsmith@storm:/home$ pwd             (Find out where you went.)
/home

jsmith@storm:/home$ ls              (See what's in the /home directory: lowercase LS means "list")
staff  students  sysadmin

jsmith@storm:/home$ ls -l           (Get a long listing: lowercase LS space minus lowercase L)
total 104
drwxr-xr-x.   44 root root      4096 Nov 12 13:09 staff
drwxrwxr-x. 1044 root students 86016 Nov 24 22:04 students
drwx------.   14 root root      4096 Aug 12  2019 sysadmin

jsmith@storm:/home$ cd staff        (Go down into the staff directory.)
jsmith@storm:/home/staff$ pwd
/home/staff

jsmith@storm:/home/staff$ ls
jsmith@storm:/home/staff$ ls -l
jsmith@storm:/home/staff$ ls -l | more     (Dole it out one screenful at a time.  Space bar or q.)

jsmith@storm:/home/staff$ cd ~mmeretzky    (Tilde: go to mmeretzky's home directory.)
jsmith@storm:/home/staff/mmeretzky$ pwd
/home/staff/mmeretzky
jsmith@storm:/home/staff/mmeretzky$ ls -l | more

jsmith@storm:/home/staff/meretzky$ cd public_html     (Underscore, not dash.  Ends with lowercase L.)
jsmith@storm:/home/staff/mmeretzky/public_html$ pwd
/home/staff/mmeretzky/public_html
jsmith@storm:/home/staff/mmeretzky/public_html$ ls -l | more

jsmith@storm:/home/staff/meretzky$ cd     (Go straight back to your home directory.)
jsmith@storm:~$ pwd     (Make sure you returned there.)
/home/students/jsmith

jsmith@storm:~$ ls -l | more

Two distant directories you can go to

jsmith@storm:~$ cd /usr/bin              (the "user binary" directory)

jsmith@storm:/usr/bin$ pwd               (Make sure you arrived there.)
/usr/bin

jsmith@storm:/usr/bin$ ls -l | more      (Space minus lowercase L for more information about each one)
                  (Files start with dash; subdirectories start with lowercase d)

jsmith@storm:/usr/bin$ ls -l c++         (List only one file.  This is our C++ compiler.)
-rwxr-xr-x 4 root root 1333360 May 20  2025 c++
jsmith@storm:~$ cd /usr/include/c++/15
jsmith@storm:/usr/include/c++/15$ pwd               (Make sure you arrived there.)
/usr/include/c++/15

jsmith@storm:/usr/include/c++/15$ ls -l iostream
-rw-r--r-- 1 root root 3125 May 20  2025 iostream

jsmith@storm:/usr/include/c++/15$ ls -l cstdlib
-rw-r--r-- 1 root root 7064 May 20  2025 cstdlib
jsmith@storm:/usr/include/c++/15$ cd      (Go back to your home directory.)
jsmith@storm:~$ pwd                       (Make sure you got there.)
/home/students/jsmith

Your home directory, and your public_html directory below it

The files in your public_html directory are publicly visible. See

I’m no longer bothering to show the green prompt:

cd                (Go back to your home directory.)
pwd               (Make sure you got there.)
/home/students/jsmith

ls -l | more      (See what you already have there.)

cd public_html    (Go one level down to your public_html directory.)
pwd               (Make sure you got there.)
/home/students/jsmith/public_html

ls -l | more      (See what (if anything) you already have there.)

cd                (Go back up to your home directory.)
pwd               (Make sure you got there.)
/home/students/jsmith

Four housekeeping programs:
rename, copy, move, remove a file

Let’s create an empty file named junk in your home directory. When you move a copy of this file down to your public_html subdirectory, can you see it in

cd                (Go back to your home directory.)
pwd               (Make sure you got there.)
/home/students/jsmith
ls -l | more      (See what (if anything) you already have there.)

touch junk        (Create an empty file named junk.)
ls -l | more      (See if you actually created this file.  Is its size 0?)

mv junk junk2     (Change the name of the file from junk to junk2.)
ls -l | more      (Did we actually rename the file?)

cp junk2 junk3    (Create a copy of junk2 named junk3.)
ls -l | more      (Did we actually create a copy of the file?)

mv junk3 public_html  (Move junk3 down to your public_html subdirectory.)
cd public_html    (Go down there and make sure you moved the file there.)
pwd
ls -l | more      (Can you also see junk3 in the class website?)

rm junk3          (Remove the file that we moved down into your public_html.)
ls -l | more      (Is junk3 actually gone?)

cd                (Go back up to your home directory.)
pwd
rm junk junk2          (Remove these files, too.)
ls -l | more      (Are junk and junk2 actually gone?)

Download a file from the class website

Let’s download the text file xanadu.txt from the class website. The link to this file is
https://markmeretzky.com/fordham/1600/src/xanadu.txt
Before downloading the file, go to a directory in which you have permission to deposit a new file.
For example, you have permission to deposit a new file into your own home directory.
wget means “get from the web”.

cd
pwd
/home/students/jsmith

wget https://markmeretzky.com/fordham/1600/src/xanadu.txt
HTTP response 200 OK

ls -l xanadu.txt     (Did we really download the file? How many bytes is it?)
-rw-r--r-- 1 mmeretzky staff 2040 Aug 29  2024 xanadu.txt

A minimal set of eight vi commands

Practice editing your file xanadu.txt with vi, the “visual” text editor.
When in doubt while using vi, press the ESCape key in the upper left corner of your keyboard and you should get a reassuring beep.
There are several O’Reilly books about vi.

cd
pwd
/home/students/jsmith

ls -l xanadu.txt    (See how many bytes are in the file xanadu.txt.)
vi xanadu.txt       (Start editing the file.)
  1. Move the vi cursor up, down, left, and right with the four arrow keys;     4G

  2. Delete individual character(s) with lowercase x     xxxx     4x

  3. Delete entire line(s) with lowercase dd     4dd

  4. Insert character(s) with lowercase i (before the cursor) or lowercase a (after the cursor).
    Then type as much as you want, maybe even more than one line.
    Stop inserting with the ESCape key in the upper left corner of your keyboard.

  5. Insert entire line(s) with lowercase o (below the cursor) or uppercase O (above the cursor).
    Then type as much as you want.
    Stop inserting with the ESCape key.

  6. Copy entire line(s) into the “unnamed buffer” with lowercase yy     4yy
    Then go somewhere else in the file and paste in the copied lines with lowercase p (below) or uppercase P (above) the cursor.

  7. Write the file to disk with lowercase :w followed by RETURN or ENTER.
    But first, press ESCape to make sure you’re not in the middle of an insertion.

  8. Quit vi with lowercase :q followed by RETURN or ENTER.
    But first, press ESCape to make sure you’re not in the middle of an insertion.

After quitting from vi, the green prompt should reappear and you should still be in the same directory.
See if the file you were editing is still in that directory.
Did you change its size (its number of bytes) while you were editing it?

ls -l xanadu.txt

Create two little files with vi

Go to your home directory and create two files named .plan and .project.
Their names must begin with a dot.
Put whatever you want into these files (by starting with the i command to insert, command #4 above), but the .project file can be only a single line.
Then finger yourself and others.

cd
pwd
/home/students/jsmith

vi .plan
ls -l     (when you're done with vi)
ls -la    (The "Los Angeles" option will show you *all* your files.)

finger               (Finger everyone who is logged in now.)
finger jsmith        (Finger yourself.)
finger mmeretzky     (Finger me.)

Download a C++ program from the class website

Let’s download the C++ program dime1.C from the class website.
(The .C must be uppercase for the language C++; a lowercase .c would indicate the language C.)
Point your web browser at this file and copy its link
https://markmeretzky.com/fordham/1600/src/dime/dime1.C

cd         (Go home, because you have permission to put a new file there.)
pwd
/home/students/jsmith

ls -l      (Make sure you don't already have a file named dime1.C)

wget https://markmeretzky.com/fordham/1600/src/dime/dime1.C
ls -l dime1.C   (Make sure the file was downloaded.)

Compile and execute a C++ program on storm.cis.fordham.edu

Assuming you already have the above file dime1.C in your home directory.

cd
pwd
/home/students/jsmith

ls -l dime1.C
c++ dime1.C       (c++ should create a new file named a.out)
ls -l a.out       (Did c++ create a file named a.out?)

./a.out           (Execute the a.out file and see its output.)
echo $?           (See the exit status number produced by the a.out file.)

mv dime1.C public_html   (If you want to let everyone see your dime1.C file.)
cd public_html           (Make sure you moved the file.)
pwd
ls -l dime1.C

Create a little C++ program

Download the file boilerplate.C into your home directory on storm.cis.fordham.edu, and change the file’s name to helloworld.C.

cd
pwd
/home/students/jsmith

wget https://markmeretzky.com/fordham/1600/src/output/boilerplate.C
ls -l boilerplate.C             (Make sure we downloaded the file.)
boilerplate.C

mv boilerplate.C helloworld.C   (Rename the file.)
ls -l helloworld.C              (Make sure we renamed the file.)
helloworld.C

cat helloworld.C                (See what's in the file.)

Use vi to change the contents of the file to the following:

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	cout << "Hello, world!\n";
	return EXIT_SUCCESS;
}

Can you compile this file with c++ and execute the resulting a.out file?

Log out from storm.cis.fordham.edu

By now, you are probably fatigued or overwhelmed.

  1. Give the exit command to log out from storm.cis.fordham.edu.

  2. Then give another exit command to close your CMD window (on a Windows PC) or your Terminal.app window (on an Apple Macintosh).
exit
exit