CS Server - Terminal

From Computer Science
Revision as of 15:28, 10 January 2023 by Jkinne (talk | contribs) (Assignment)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you have an account for the CS server and labs (see CS Accounts and CS Lab Computers), this page points you in the right direction for how to connect to the CS server with a terminal program.

Basically, you will open up a terminal program on your computer, and then use it to make the connection. A terminal program is a program where you type commands to the computer. Up until the 1980s, this is how most people interacted with computers, and this is still how programmers at times interact with computers.

Now, on to getting connected...

Opening a Terminal

Here we point you in the right direction to get a terminal program open, depending on what operating system you are using.

Windows

  • Click the start button.
  • Start typing "Command Prompt". When the icon for the program comes up, click on it.
  • You should see the "Command Prompt" start.

Some commands that you can type in the Windows command prompt include -

  • dir to list directory contents.
  • cd to change the directory that is being shown.
  • help to see a list of other commands.
  • ssh to connect to a remote server - see the next section below to connect to the CS server.

Copy/paste - To copy, simply select text with the mouse and then right-click. To paste, make sure the cursor is where you want to text to paste and then left-click.

Mac OS

  • Go to Finder.
  • Click on "Applications".
  • Double click on "Utilities".
  • Double click "Terminal" to open the program.

This terminal program uses the same commands as are used in Linux. A few to get you started -

  • ls to list directory contents.
  • dir to list directory contents.
  • cd to change the directory that is being shown.
  • ssh to connect to a remote server - see the next section below to connect to the CS server.

Linux

Every Linux distribution has various terminal programs built in. They may be called a "terminal", "console", or "shell". You can find one on your system by clicking on the icon that brings up programs, start typing one of those terms (terminal, console, shell) and click on the program that comes up.

The Linux terminal programs use the same commands as the Mac OS terminal.

Chromebook

Most Chromebooks do not have a terminal program built in. You can install an app, or can turn on the ability to run Linux from inside of the OS (called "Linux (Beta) on Chromebook").

Terminal apps One terminal app that we recommend is Secure Shell.

  • If you use this app, you will need to put in the settings for the CS server once you have the app installed and open.
  • For "host" you will put "cs.indstate.edu", for "port" you put 22, put in your login (e.g., cs15100, or whatever your login name is), and click "[Enter] Connect".
  • Type in your password and press enter.

Linux (Beta) on Chromebook

  • If this works then you will have Linux installed on your Chromebook and will be able to use any of the commands that you use on the CS server.
  • Not all Chromebooks allow installation of Linux (Beta).
  • Follow instructions from google.
  • Note - installation could take a very long time (e.g., an hour or more). If installation fails you may need to select Remove Linux Beta and try again.
  • Once installation is complete you open a terminal using the Terminal app.

Copy/paste - in either the Secure Shell app or the Terminal app, copy/paste as follows. To copy, simply select text with the mouse and it will be copied to the clipboard. To paste, do a triple-click (three finger click).

Connecting to the CS server

Once you have a terminal program open, you are ready to connect to the CS server. You will type the following and press enter:
ssh YOUR_LOGIN@cs.indstate.edu

If your login was cs15100, then you would type ssh cs15100@cs.indstate.edu and press enter.

Note that the above command is case-sensitive and must be exact. If you typed Ssh rather than ssh (or SSH, or sh, or sss, or ...) then it would not work. If you accidentally put an extra space somewhere (or leave one out), or skip one of the .'s, or ... then it won't work. So if you try it and it doesn't work, then carefully check what you typed against what is above.

If you typed it in correctly, then you will be prompted for your password. Type in your password, and keep typing it even if you don't see anything on the screen (it doesn't display anything as you type, as a security feature). When done typing your password, press enter. If you typed it in correctly, you will be logged in.

Note that the first time you connect to the CS server you will get a message like the following - The authenticity of host 'cs.indstate.edu (139.102.14.201)' can't be established. ECDSA key fingerprint ... Are you sure you want to continue connecting....' Type yes and enter.

Example Commands

Here's hoping you made it through all of that. If so, you are ready to run commands on the CS server. Here's a sneak peak of what fun you can have. This is a printout of running some commands and what they might do. Note that the first part ("cs50000@cs:/u1/class/cs50000>") is called the "prompt" and was not typed by the user. The commands typed by the user were the part after that (the first command typed was date).

cs50000@cs:/u1/class/cs50000> date
Tue Aug 16 22:05:19 EDT 2022
cs50000@cs:/u1/class/cs50000> cal
     August 2022    
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         
cs50000@cs:/u1/class/cs50000> hostname
cs.indstate.edu
cs50000@cs:/u1/class/cs50000> uptime
 22:04:18 up 293 days,  5:58,  4 users,  load average: 0.29, 0.20, 0.12
cs50000@cs:/u1/class/cs50000> free -h
               total        used        free      shared  buff/cache   available
Mem:           995Gi       4.4Gi       4.0Gi        35Mi       987Gi       981Gi
Swap:          4.0Gi       1.0Gi       3.0Gi
cs50000@cs:/u1/class/cs50000> ls
demo/  Desktop/  Documents/  Downloads/  Music/  Pictures/  Public/  Templates/  Videos/
cs50000@cs:/u1/class/cs50000> pwd
/u1/class/cs50000
cs50000@cs:/u1/class/cs50000> whoami
cs50000
cs50000@cs:/u1/class/cs50000> echo "hello world"
hello world

Assignment

If a course wants to give credit for setting up your personal computer to connect to the CS server, you can do the following.

  • Install one of the terminal programs above (depending on your operating system). Use your terminal program to connect to the CS server (see the two sections above).
  • Type the following command, and press enter: finger
  • Next type the following command, and press enter: whoami
  • Next type the following command, and press enter: date

By running these commands we will see that you are logged in, we should see your name (from the finger printout), and will see the time and day you are doing this.

Next, take a screenshot of your entire desktop. This should include the terminal window (so we can see the results of the commands above), and will show which operating system you are using. You will submit this screenshot.

Pass rating check Your instructor will check that the screenshot includes the following: shows the whole desktop (so they can see what OS you are using), terminal program running, printout from the commands above (to verify this is your login and was done recently).