FAQs : Frequently Asked Questions
Steven J. Zeil
This is a collection of questions (and answers!) that have arisen repeatedly in some of my past classes.
1 I can’t log in to…
1.1 I can’t log in to… Canvas
You’ll need to take that up with the ITS Help Desk.
1.2 I can’t log in to… the CS VPN
-
Make sure that you are using the correct VPN client.
- The VPN is not something that you connect to using a web browser!
- If the VPN client suggests that you need to enter a license or invitation code, you have downloaded and installed the wrong software. Uninstall it and then get the right software.
-
Make sure that you are connecting to the right VPN.
Some ITS-supplied documentation discusses connecting to the ODU VPN used only by ODU staff.
The portal for the CS VPN is
128.82.11.11
. -
Are you able to log in to other CS resources that are not behind the VPN such as this page?
- If so, then you know that your login name and password are working and can skip to step 6.
- Make sure that you are using the correct login name. All CS student login names consist of “
cs_
” followed by your ODU MIDAS ID. For example, if your MIDAS ID isjdoe001
, your CS login name iscs_jdoe001
. - Make sure that you are using the correct password. If you have forgotten your password, you can reset it.
- Check your cell phone to see if you have pending requests to identify yourself from the two-factor authentication system.
- If none of that helps, contact
root@cs.odu.edu
. Let them know that you have checked the above steps. Also be sure to tell them what operating system you are running on your PC. (Don’t just say “Windows”. They need to know whether it’s Windows 10 or Windows 11.)
1.3 I can’t log in to… the CS Linux servers
- Make sure that you are using an appropriate SSH client. You cannot connect to the Linux servers using a web browser!
- You must connect to the CS VPN before connecting to the Linux servers.
- Are you getting a message warning about possible Spoofing? If so, see this discussion.
- Are you getting a message saying that the authenticity ofthe host can’t be established? If so, see this discussion.
- Are you getting a message saying that
linux.cs.odu.edu
does not exist or is not on the network? Then you are not connected to the VPN. - Make sure that you are using the correct login name. All CS student login names consist of “
cs_
” followed by your ODU MIDAS ID. For example, if your MIDAS ID isjdoe001
, your CS login name iscs_jdoe001
. - Make sure that you are using the correct password. If you have forgotten your password, you can reset it.
- If none of that helps, contact
root@cs.odu.edu
. Let them know that you have checked the above steps.
1.4 I can’t log in to… an assignment submit page (https://www.cs.odu.edu/~zeil/submit/...
)
- Are you able to log in to other CS resources such as the CS VPN?
- If so, then you know that your login name and password are working and can skip to step 4.
- Make sure that you are using the correct login name. All CS student login names consist of “
cs_
” followed by your ODU MIDAS ID. For example, if your MIDAS ID isjdoe001
, your CS login name iscs_jdoe001
. - Make sure that you are using the correct password. If you have forgotten your password, you can reset it.
- If you are absolutely sure that your login name and password are correct, contact
root@cs.odu.edu
. Let them know that which of the systems in step 1 you were and were not able to connect with.
1.5 I can’t log in to… a password-protected course page hosted at (https://www.cs.odu.edu/...
)
- Make sure that you are trying to access the correct course, and not a website for a different semester or a section taught by someone else.
- If your course website has an Outline or landing page, look there and check the semester and instructor name listed at the top.
- Make sure that you are using the correct login name. All CS student login names consist of “
cs_
” followed by your ODU MIDAS ID. For example, if your MIDAS ID isjdoe001
, your CS login name iscs_jdoe001
. - Are you able to log in to this page?
-
If so, your login name and password are working fine, but you might not be on the access list for the course website. Contact the course instructor. Be sure to include the exact URL of the page that you are trying to access.
-
- Are you able to log in to other CS resources such as the CS VPN or the CS Virtual PC lab?
- If so, then you know that your login name and password are working and can skip to step 5.
- Make sure that you are using the correct password. If you have forgotten your password, you can reset it.
- If you are absolutely sure that your login name and password are correct, contact
root@cs.odu.edu
. Let them know that which of the systems in steps 3 and 4 you were and were not able to connect with and the URL of the page that you are unable to reach.
2 Problems Connecting to CS Linux servers
2.1 “This site can’t be reached”
You need to use an appropriate SSH client.
You cannot connect to the Linux servers using a web browser!
2.2 “unable to connect, host does not exist”
You need to run the VPN before making your SSH connection.
2.3 “The authenticity of host … can’t be established.”
This is a normal and expected message whenever you connect to a new machine for the first time.
Just answer “yes” the to question about whether to continue connecting.
2.4 “POSSIBLE DNS SPOOFING DETECTED” or “REMOTE HOST IDENTIFICATION HAS CHANGED”
This message arises whenever the “hardware” that responds to connections to a particular machine name (e.g., linux.cs.odu.edu
) has changed. Your SSH client remembers the hardware IDs of your past connections and objects when the hardware appears to have changed.
This check was added to SSH a long time ago and made sense at the time as protection against “DNS spoofing” (a.k.a.“man-in-the-middle”) attacks where someone on the network would insert their machine as a kind of wire-tap between you and your intended destination in order to spy out your login name and password.
It’s now pretty much just an annoyance because
- DNS spoofing is almost impossible if you are connecting via the VPN.
- In the modern world of cloud computing, the servers that respond to your connection attempts probably aren’t hardware at all, but “virtual machines” simulating the hardware, and those virtual machines may change at any time, far more frequently than anyone would ever purchase new hardware.
So what do you do?
-
Depending on your SSH client’s settings, it may have connected you anyway after issuing the warning. In that case, you can ignore the warning.
-
If it does not connect you, it will go on to tell you “Offending EDCSA key in filename:_lineNumber_”. This will be the file on your PC where the hardware IDs of past SSH connections are kept. For example, if you were connecting from a Windows 10 PC and your Windows login name is “
aStudent
”, you might seeOffending ECDSA key in C:\\Users\\aStudent/.ssh/known_hosts:1
telling you that the file is in
C:\Users\aStudent\.ssh\known_hosts
and the particular ID is in line 1 of that file.You can
- Edit that file (with Notepad or any other text editor) and delete that line, or
- Delete the file entirely. If the only machines that you do SSH connections to are CS Dept machines, this is probably the easier approach.
** Missing file: FAQ/faq/generalProgramming.mdi **
3 Compilers and IDEs
3.1 What is an IDE?
IDE stands for Integrated Development Environment. An IDE provides a convenient way to access and work with compilers and debuggers.
Many people confuse IDEs with compilers. They may talk about using the “Code::Blocks” compiler, for example. But compilers and debuggers are command-line tools – they don’t pop up windows with menus, toolbars, and convenient editors. All that convenient interface stuff is the province of an IDE.
A typical IDE provides
- editors for writing source code,
- a way to launch the compiler on a particular source code file,
- a “build manager” that can run the compiler on all of the source code files that make up an entire project, and
- a way to run a compiled program inside the editor, with convenient displays of where execution has paused and what the values of the variables are at that moment in time.
Some IDEs go much further, with support for external build managers, unit testing, code transformation or refactoring, issue tracking and task management, etc.
IDEs commonly in use in ODU CS classes include:
- Code::Blocks, a beginner’s IDE for C/C++ programming
- Eclipse: a multi-language IDE with more professional features
- VSCode: a lighter-weight multi-language IDE, with support for remote development (running the IDE on your local PC while compiling and running your code on a remote machine).
Althouch “VSCode” is short for “Visual Studio Code”, do not confuse this with Microsoft’s proprietary “Visual Studio”. VSCode is a portable IDE (with an an open-source base) that works equally with Microsoft and non-Microsoft compilers.)
- emacs: really an editor, but with good support for the basic functions expected of an IDE.
- vim: another editor with IDE-like capabilities, with the notable exception of any support for running a debugger.
- xcode: the official IDE for Apple MacOs PCs
All of the above except xcode can be run on Windows, Linux, and MacOs PCs.
Some IDEs are tied to specific programming languages and, sometimes, specific compilers. Others will work with multiple programming languages and with whatever compilers and debuggers you have already installed on your PC.
3.2 How can I install a compiler and IDE on my own PC?
See Installing a C++/Java IDE on Your Own PC
3.3 How do I supply command line parameters when executing my programs?
Often you will be writing programs that take “command line parameters” as part of their inputs.
Of course, if you are executing a program from the command line, you just type the parameter values on the command line (hence the name!), e.g.,
./myProgram ../testData/myTestData.txt 23
But what if you are launching your program from an IDE?
You need to set up a “run configuration” in your IDE telling it what program to launch and what parameters you want to supply. For details, see
- Run configurations in Eclipse
- Run configurations in VSCode
3.4 How do I get my program to read from a file instead of from the keyboard?
At the command line, this is called input redirection and is done by appending
< location_of_input_file
to the end of the command launching the program. You can read more about this in CS252, and it works the exact same way in a Windows command-line session.
What if you are launching your program from an IDE?
3.4.1 Eclipse
After you have successfully compiled your code, click on your executable binary in the Project Explorer). Then, from the Run
menu, select Run
configurations...
You’ll see a list of different project types, one of which should be “... Application
”.
-
Underneath that, you might already have a configuration for this program (Clicking on a configuration will show you what project and what executable file it is associated with.
-
If not, select “
... Application
”, then at the cop of the columm click on "_New launch configuration`".
On the “Common
” tab, under “Standard input and output”, click to select the “Input” box, then use one of the three buttons on the line below to selectthe file of input data you want supplied as the standard input.
Click Run
to save these arguments and launch your program.
3.5 Why do compilers’ error messages often give the wrong line number, or even the wrong file?
A compiler can only report where it detected a problem. Where you actually committed a mistake may be someplace entirely different.
Let’s look at a simple example:
3.5.1 Example 1
Assume that the compiler has read part, but not all, of your program. The part that has just been read contains a syntax error. For the sake of example, let’s say you wrote:
x = y + 2 * x // missing semi-colon
Now, when the compiler has read only the first line, it can’t tell that anything is wrong. That’s because it is still possible, as far as the compiler knows, that the next line of source code will start with a “;” or some other valid expression. So the compiler will never complain about this line.
If the compiler reads another line, and discovers that you had written:
x = y + 2 * x // missing semi-colon
++i;
The compiler knows that you did something wrong. But it still won’t conclude that there’s a missing semi-colon. For all it knows, the “real” mistake might be that you meant to type “+” instead of “++”.
3.5.2 Example 2
Now, things can be much worse. Suppose that inside a file Foo.java
you write
public class Foo {
⋮
public Foo() {...}
public int fox() { ... } // oops! Meant to say "foo", not "fox"
}
and inside another file, bar.java
, you write
Foo x = new Foo();
int k = x.foo();
Where will the error be reported? Probably on the statement assigning to k
in bar.java
. Why? Because the compiler only knows that Foo
does not have a member function named “foo”. It does not know if you should have declared “foo” instead of “fox”, or if you meant to have two member functions named “foo” and “fox” but forgot one, or if you misspelled the function name as “foo” instead of “fox” when you tried to call the function.
All that the compiler can do is report where it detected that something was wrong. That does not mean that is where the actual mistake was made.
So, with most error messages, you know only that the real mistake occurred on the line reported or earlier, possibly even in an earlier processed file.
4 Java Programming
4.1 How do I determine the starting class of a Java program?
A starting class for a program must contain a function of the form
static int main (String[] args) {
⋮
}
This is quite similar to the main() function used in C++, though because Java does not allow stand-alone functions, the main() function in Java must be a class member. If a project is supposed to provide more than one program, then there may be many different starting classes within the project. A good way to list them quickly (on a Unix/Linux system) is
find yourProjectDirectory -name '*.java' | xargs grep main
4.2 error: the declared package “…” does not match the expected
package “…”
The source code files of Java programs must be arranged in a way that reflects the package and class style of their contents.
If you have a Java class
MyClass
, it must be stored in a file namedMyClass.java
.If your Java class is inside a package
myPackage
, then the Java source code must be stored inside a directory namedmyPackage
.
For example, on one of my projects, I have a class edu.odu.cs.AlgAE.Client.Layout.Anchors
. That means that the source code for this class starts with:
package edu.odu.cs.AlgAE.Client.Layout;
⋮
public class Anchors {
⋮
and I would find the file containing that source code file in edu/odu/cs/AlgAE/Client/Layout/Anchors.java
. (If you are on Windows, the same rule applies, but you use \ instead of / in the path.)
So, when you get the “package does not match” error, the possible causes are:
- You have misspelled or omitted the
package
name in the.java
file. - You have misspelled the class name in the
.java
file. - You have misspelled a directory or file name, or otherwise put the file in a place that does not match the package and class named in the source code.
- You are compiling from the wrong place.
That last possibility is often the one that trips people up, so let’s talk about it.
4.2.1 Compiling from the Command Line
Suppose you have a class named MyPackage.SubPackage.MyClass
. That should be in a file MyPackage/SubPackage/MyClass.java
.
The command to compile this is
javac
compiler-options MyPackage/SubPackage/MyClass.java
So it makes sense that this will only work if you are cd’d into the directory where MyPackage/
resides. If you list the contents of your current directory (e.g., with a Linux ls
or Windows dir
command) and don’t see MyPackage
, then you are probably in the wrong place.
For example, if the absolute path to your source code were /home/yourName/projects/project1/MyPackage/SubPackage/MyClass.java
, then you would want to
cd /home/yourName/projects/project1
before trying to compile your code.
4.2.2 Compiling from Eclipse
Part of the project settings for any Java project is a list of one or more “Source” directories. The Source directories are the places where Eclipse believes that you are keeping your packages of source code. These need to follow the same rule about packages and directories.
For example, if the absolute path to your source code were /home/yourName/projects/project1/MyPackage/SubPackage/MyClass.java
, then you should have /home/yourName/projects/project1
as one of (possibly the only one of) your Source directories.
To view and change your project’s source directories, go to the Eclipse Project
menu and select Properties
-> Build Path
, or right-click on any file or directory of the project in the Package Explorer and select Build Path
-> Configure Build Path...
Look at the Source tab to see your Source directories and make changes as necessary.
4.3 How do I import a new library into my code?
4.3.1 This has nothing to do with import
statements!
If, by that question, you meant “What import statements do I write at the beginning of my Java code?”, you are thinking about it incorrectly.
Java import
statements are not like C++ #include
statements. They don’t load new libraries into your code. Java doesn’t have an equivalent to the C++ #include
statement. It doesn’t need one, because Java has its rules that say each public class must be in a Java file of the same name, and each Java package must be in a directory of the same name. C++ #include
statements tell the compiler where to find other code. Java’s rules about files and directory names means that the compiler already knows where to find other code, just as soon as you give the full name of class that you want.
Java import
statements are like C++ using
statements. They allow you to refer to things by abbreviated names.
Neither Java import
statements nor C++ using
statements are ever really necessary. You can always refer to things by their fully-qualified names, giving all the packages (Java) or namespaces (C++) that uniquely identify the symbol:
C++
#include <iostream>
⋮
std::cout << "Hello" << std::endl;
Java
java.io.File input = new java.io.File("input.dat");
Or, you could authorize shortcuts for the specific symbols that you are using:
C++
#include <iostream>
⋮
using std::cout;
using std::endl;
⋮
cout << "Hello" << endl;
Java
import java.io.File;
⋮
File input = new File("input.dat");
Or you can authorize shortcuts for all of the names in a namespace/package:
C++
#include <iostream>
⋮
using namespace std;
⋮
cout << "Hello" << endl;
Java
import java.io.*;
⋮
File input = new File("input.dat");
import
and using
statements really aren’t necessary. They are just awfully convenient.
4.3.2 OK, so how do I include a new library in Java?
That’s handled by the compiler settings (specifically the CLASSPATH
), which is usually set by your IDE.
4.4 How do I get my program to read from a file instead of from the keyboard?
At the command line, this is called input redirection and is done by appending
< location_of_input_file
to the end of the command launching the program. You can read more about this in CS252, and it works the exact same way in a Windows command-line session.
What if you are launching your program from an IDE?
4.4.1 Eclipse
After you have successfully compiled your code, right-click on the Java class that contains your main
function. Then, from the Run
menu, select Run configurations...
You’ll see a list of different project types, one of which should be “Java Application
”.
-
Underneath that, you might already have a configuration for this program (Clicking on a configuration will show you what project and what Java class it is associated with.
-
If not, select “
Java Application
”, then at the top of the columm click on "_New launch configuration`".
On the “Common
” tab, under “Standard input and output”, click to select the “Input” box, then use one of the three buttons on the line below to select the file of input data you want supplied as the standard input.
Click Run
to save these arguments and launch your program.
4.5 Error Message: Unsupported class file major version …
If you are doing local development and getting error messages about “Unsupported class file major version …” or other messages that appear to complain about Java versions, check your versions:
java --version
javac --version
You should get the same version number for both commands, and it should be 17.x or 21.x
-
If the versions are different, you probably have multiple JDK’s and JRE’s installed. Uninstall everything but the jdk17 (or jdk21).
-
If the versions match but are not 17.x or 21.x, you should probably switch to 17. Java 17 and 21 are the two most recent LTS (Long term Support) versions available.
- Java 21 was released in Sept 2023, and if you have that, it’s probably OK. (I like to wait 6 months to a year after an LTS release to give the authors of Java support tools and libraries time to catch up.)
5 Java IDE Issues
5.1 I created a Java project with the wrong settings. How do I re-do it?
A lot depends on just how much is wrong. Minor problems can be fixed by right-clicking on the project name, selecting “Build path”, then “Configure Build Path” and adjusting your settings from there.
For major issues, it is often easier to to ask Eclipse to re-examine your project and deduce your settings, though you may still need to make minor tweaks to the build path afterwards.
To do this:
-
In Eclipse, delete your project. Do not check the box to delete the project contents. You just want Eclipse to stop tracking the project.
-
In your operating system, go to the project directory and locate and delete the
.project
and.classpath
files. These are where Eclipse stored your old project settings.Take note that these file names start with ‘.’, which means that in Linux and MacOS these files are “hidden” by default. You can spot them by adding the “-a” to your “ls” commands.
-
Back in Eclipse, create or import your project again.
5.2 How do I install a Java compiler & IDE on my PC?
Refer to Installing a C++/Java IDE on Your Own PC. Simply skip over the parts about installing C++ if you want a Java-only solution.
5.3 How do I set compiler flags and options?
From the command line. of course, you just type the option into the command.
5.3.1 Eclipse: changing the settings for one project
If you are using Eclipse, use the Project
menu, select Properties
. Go to Java Compiler
. You can make changes here or in any of the sub-pages you reach by expanding the Java Compiler
tree.
You will probably need to check the box “Enable project specific settings” on any page where you actually want to change the settings.
5.3.2 Eclipse: changing the default settings for all Java projects
From the Window
menu, select Preferences
, then Java
, then Compiler
. From here , and on the sub-pages you reach by expanding the Compiler
tree, you can change settigns that will become the default for all Java projects in this Eclipse workspace.
5.4 How do I supply command line parameters when executing my programs?
Often you will be writing programs that take “command line parameters” as part of their inputs.
Of course, if you are executing a program from the command line, you just type the parameter values on the command line (hence the name!), e.g.,
Java MyPackage.MyProgram ../testData/myTestData.txt 23
But what if you are launching your program from an IDE?
5.4.1 Eclipse
-
After you have successfully compiled your code, right-click on the Java class that contains your
main
function. Then, from theRun
menu, selectRun configurations...
You’ll see a list of different project types, one of which should be “
Java Application
”.-
Underneath that, you might already have a configuration for this program (Clicking on a configuration will show you what project and what Java class it is associated with.
-
If not, select “
Java Application
”, then at the top of the columm click on "_New launch configuration`".
-
-
On the “
Arguments
” tab, enter your command line parameters into the “Program Arguments
” box. -
Click
Run
to save these arguments and launch your program.
5.4.2 VSCode
Running the Debugger
Running in the debugger, with or without command line parameters, requires some preparation.
-
Be sure that you have set up the debugger in your project directory by following these directions.
-
You will now have a file
.vscode/launch.json
that will allow you to launch your program in a debugger by pressingF5
or using the menu entry.Open that file in the editor and look for the line
"args": [],
(If you don’t have one, create it, just underneath the
mainClass
entry.)Inside the brackets, you can add your desired command line parameters as a comma-separated list of quoted strings. For example,
"args": ["hello", "42"],
Save your changes.
5.5 I think my IDE project settings are incorrect. How do I reset them?
This is very common if you change the arrangement of your code or switch or reconfigure build managers after having created a project in your IDE.
5.5.1 Eclipse
In some cases, you can fix the problems by right-clicking on the project name and selecting “Properties”.
But it can be easier to force Eclipse to re-evaluate your project settings and let it see what you have done. To do this:
-
Right-click on the project name in Eclipse and delete the project. (Do not tell Eclipse to delete the source code - just delete the project, removing it from Eclipse.)
-
In your machine’s operating system, search the project for files named
.project
and.classpath
and remove them. Remember that in Linux and in MacOs, all files with names starting with “.
” are hidden. You will need to use “ls -a
” to see them. -
Back in Eclipse, import the Java project at that same directory. Eclipse will scan your directory structure and deduce most of the important project settings.
5.5.2 VSCode
-
In many cases, closing the folder and re-opening it will cause VSCode to re-evaluate your project settings.
-
In the left (Explorer) column, look for the “JavaProjects” section and expand it.
Click the
...
menu, and select “Clean the Workspace”.
6 Git and SSH key issues
6.1 ssh complains about an “UNPROTECTED PRIVATE KEY FILE!”
Your private key file should be readable (and writable) by you alone.
-
If you are using ssh from Windows WSL
- Keep the private key in the WSL area: preferably in
~/.ssh
- Use the
chmod
command to change its permissions to600
- Keep the private key in the WSL area: preferably in
-
If your private key is on a Linux/MacOS machine, or in Windows CygWin
-
Use the
chmod
command to change its permissions to600
-
-
If your private key is in ordinary Windows
- Use the Windows File Explorer to display the directory containing the key.
- Right-click on the key file and select
Properties
. - Go to the
Security
tab. ClickEdit
to change the permissions. - Make sure that you (ie., your Windows login name) have full access ot the file (all Allow boxes checked, even if they are greyed out).
Deny
permission to all other User names (leaveSYSTEM
alone). If your own Windows login is an Administrator account (common on most personal PCs), you should allow the permissions forAdministrators
.- Hit OK until you are out of the Properties.
6.2 Git prompts me for a password when I try to clone, push, or pull.
These three actions (clone, push, & pull) are the ones that communicate directly with GitHub. Other actions (e.g., add, commit) work on your local copy of the repository only.
You need to provide an SSH key to log into GitHub for those three actions. If you are prompted for a password, it’s a sign that your SSH key was not seen or was rejected.
Refer to the next question for troubleshooting tips.
6.3 Git tells me “Permission denied (publickey).”
Either
- You are trying to clone a private repository belonging to someone else, or
- GitHub is not able to log in with your SSH key.
6.3.1 Troubleshooting
The most likely reasons for this are
- You have not properly registered the public half of your key with GitHub, or the key that you updated was garbled or incomplete.
- You aren’t running an SSH agent on your own PC.
- You have not added the private half of your key to the agent.
- If developing remotely, you did not use the “
ssh -A
” option to connect to the remote Linux machine, or you are in X2Go, which does not support that option.- If you are doing remote development with VSCode, you may have forgotten the ForwardAgent parameter in your connection setup.
To see which of these might be relevant:
-
Try to access the GitHub page for the repository that you are trying to clone. If you get a 404 error, the repository is private and your account is not among those who have been granted access.
-
On your local PC, give the command
ssh-add -l
-
If it complains that it can’t contact a server, then your problem is #2 above. Refer to Starting an Agent….
-
If it does not complain, but does not list your GitHub SSH key (or any key at all), then your problem is #3 above. refer to Adding Keys to the Agent.
-
If it lists your keys, then move on to the next step.
-
-
If you are doing remote development, in your SSH session to the remote Linux machine, give the same command
ssh-add -l
(If you are doing remote development with VSCode, do this inside the VSCode terminal.)
- If it complains that it can’t contact a server or fails to list your key, then the problem is #4 above. Refer to Cloning an Existing Project.
If that command on the remote machine does list your key, then your problem is likely #1 above. Refer to Logging in to GitHub.
-
Look at the output of that last
ssh-add -l
command. Each key is described using an SHA-256 code, e.g.521 SHA256:PnWdYEB3QxlZxwJzaVozOj+femwq42JDvrkt6PlH+YE MyKey (ECDSA)
Now go to GitHub, click on the icon or picture in the upper right corner, select
Settings
, and then selectSSH and GPG keys
. In the list of keys, look for a key with the same SHA256 code.- If you don’t see any keys at all, or if you don’t see an SHA256 code matching the ones from your
ssh-add -l
command, then you either have not uploaded the public half of your key to GitHub, or the uploaded key was garbled somehow. - Delete the old key(s) from GitHub if necessary.
- Then try re-uploading the public half of your key.
If you are on Windows, try to avoid including the end-of-line terminator characters when you copy-and-paste the key into the text box on GitHub.
- If you don’t see any keys at all, or if you don’t see an SHA256 code matching the ones from your
6.3.2 More Unusual Problems
-
If you have multiple GitHub accounts and your agent contains keys associated with these multiple accounts, GitHub will try to use the first account with a key that it recognizes. This might not be the account you want to use for this repository. Remove the keys for other GitHub accounts from your key agent with the command
ssh-add -d path-to-a-key
(replacing the highlighted phrase appropriately) and try again using just the key for the account you want to use.
-
If you are on Windows running OpenSSH, there is a bug in some versions that can cause this.
-
You can try updating your Windows OpenSSH. This page will direct you to the latest (beta) versions of OpenSSH. These are binary install packages (
.msi
files) and the page tells you how to run them.-
You will need to know whether your PC is 32 or 64 bit and whether your CPU is x86 (Win32) or x64 (Win64) or ARM. (Enter Settings, click on System, then About, and look at the System type.)
-
-
You can use an alternative to the native Windows OpenSSH. Install CygWin or the Microsoft WSL, which give you a Unix layer within Windows, and to run their SSH. Then follow the Linux/CygWin instructions in CS252 for logging in via SSH and for using SSH keys and key agents.
-
6.3.3 A Final Workaround
If none of this resolves the problem, it is possible to work with ssh keys stored on the remote machine.
6.4 I cannot use a key agent on my local PC with a remote git
If you are absolutely unable to get a key agent working on your local PC that transfers to a remote machine, or if you find yourself sometimes working from a library or work machine on which the necessary SSH key support is missing, you can run git
on a remote machine using a private key stored there.
This has two disadvantages:
- It is somewhat less secure, because you need to keep a private key on a machine that you do not control physical access to.
- You will need to type your SSH key passphrase each time you do a
git clone
,git push
, orgit pull
operation.
So consider this a means of last resort.
- Transfer the private half of your GitHub SSH key to the remote Linux machine, storing it in your
~/.ssh/
directory. - Make sure that only you can read that key file:
chmod 600 ~/.ssh/name-of-your-key-file
(replacing the highlighted portion with your own file name).
-
Look in your home directory with
ls -a ~
You should have a file named
.bashrc
or.zshrc
. This file contains commands that are run when you log in to your account. -
Edit that file, adding the following line at the end:
alias github="GIT_SSH_COMMAND='ssh -i /home/yourLoginName/.ssh/name-of-your-key-file -o IdentitiesOnly=yes'"
(again, replacing the highlighted portions with your own names). Pay close attention to the single and double quotes in that command.
-
Log out of the remote Linux machine and then log back in again.
You should now be able to issue git commands to clone, push, or pull by preceding the command with “github”, e.g.,
github git push
Most
git
commands other than clone, push and pull do not access the remote repository on GitHub and therefore do not need the “github” prefix.
6.5 What kinds of things should I commit with git
?
We only track source files in git – things that we as programmers supply and edit.
We do not track generated files, the things that we produce by running compilers or other non-interactive programs on the source files.
The vast majority of source files are text files, which git
handles very well. On occasion, we may have source files that are binary (e.g., a graphic or picture that will be part of a website or a background image in our user interface).
Most generated files are binary, e.g., .o
.class
, .zip
or .jar
files. git
really does not handle those as well as text file, though it does well enough with small numbers of binary files.
The main rule, however, is that if you edit it with an interactive program (e.g., a text or code editor or, for graphics, a drawing tool), then you should track it with git.
If you generate a file with a non-interactive command (e.g., a compiler or most shell commands), then do not track it with git
.
git
, however, won’t know which of your files are source files and which are generated. It will suggest (when you run git status
) that you stage and commit everything.
You can tell git
to stop nagging you about certain files and reduce the risks that you will make a mistake by supplying a .gitignore
file. This is a text file that contains a list of files that you don’t want git
to look at. An example would be
bin/
**/build/
**/*.class
**/*.jar
**/*.o
**/*.jar
The first line indicates that anything in the bin/
directory (relative to the directory containing this .gitignore
file) should not be suggested for staging.
The second line uses **/
which matches any number of directories and indicates that anything in any build/
directory should be ignored. The remaining lines use the same pattern to suggest that common binary files should be ignored no matter what directory they are found in.
These rules apply to the directory in which the .gitignore
file resides, and to any subdirectories of that directory.
6.6 How do I replace my current file with a version from the past?
- Use the
git log
command or a similar feature in your IDE to get a list of the commit IDs from your old commits. - Examine the old versions to see which one you want.
There are several ways to do this.
- The command
git checkout commit-id
will move your entire project back in time to the older version. (When typing commit IDs, you only need to give enough to uniquely identify that commit. Usually 5 or 6 characters will do.)
This leaves you in an odd state. You can’t make changes in this state because that commit is already a part of the historical record. Do
git checkout main
to return to the “present”.- The command
git diff commit-id
will list all changes between your current files and the ones in that older commit.
The variation
git diff commit-id -- paths-to-files
will limit that report to the files that you indicate.- Both GitHub and, probably, your IDE will have functions to display the changes made in specific commits and to specific files.
- The command
-
Check out the desired older version.
-
The command
git checkout commit-id -- paths-to-files
will bring the indicated files “forward in time” from a past commit.
-
Remember,
git checkout commit-id
moves you back in time.git checkout commit-id -- paths-to-files
moves files forward in time from the past.
If you search this topic on the Internet, you are likely to encounter lots of references to git reset
.
Avoid using
git reset
to rewrite any changes you have already pushed.
git reset
“rewrites history”, which in many ways violates the essential spirit of git
, the ability to maintain an accurate historical record of changes to your files. More importantly, it can “break” the clones of anyone collaborating with you, including, in this course, your instructor’s.
6.7 I committed a binary or generated file by mistake. How do I convince git to stop tracking it?
We all make this mistake from time to time. We should only use git
to track source files, not the generated files that are produced by compiling or processing those sources. But, particularly when using IDEs, we are often prompted by default to commit generated files.
Adding a new entry to the .gitignore
file won’t help, because .gitignore
only applies to files that are not already being tracked in git
.
To remove a file from a directory and tell git
that you don’t want it to track changes to that file, use the command
git rm path-to-file --cache
or, for an entire directory:
git rm -r path-to-directory --cache
Then add that path to your .gitignore
file so that you aren’t prompted to commit that file again.
7 Mathematics and Notation
7.1 \( \forall \) ? \( \exists \) ?
Some of the notation used in logical expressions:
- \( \forall \)
- “for all”
- \( \exists \)
- “there exists”
- \( \ni | \)
- “such that”
- \( \Rightarrow \)
- “implies” (Alternatively, you can read \(A \Rightarrow B \) as “if
A
, thenB
”)
So, for example, the formula
\[ \exists c_1, n_0 \; | \; n > n_0 \Rightarrow t(n) \leq c_1 * \left(c \, f(n)\right) \]
reads as “there exists some values for \( c_{1} \) and \( n_{0} \) such that, whenever \(n > n_0\), then \(t_n\) is less than or equal to \(c_1*c*f(n)\).”
7.2 Basic Probability (probably just what you wanted)
A probability is a number between $0$ and $1$ that expresses the chances of something happening. For example, in rolling an ordinary 6-sided die, the probability of getting a ‘5’ is $1/6$. The probability of getting an even number is $3/6$ or $0.5$. The probability of getting a ‘9’ is $0.0$ — it can’t possibly happen with a single roll of an ordinary die. The probability of getting some number between 1 and 6 is 1.0.1
Some key ideas about probabilities:
-
Every probability lies between $0$ and $1$.
- $0$ means it never happens.
- $1$ means it always happens.
-
If you know all the possible events and add up the probabilities, the sum must be $1.0$.[^independence]
For example, on a single roll of a six-sided die, the probability of seeing a “1” is $1/6$, the probability of seeing a “2” is $1/6$, and so on for all six possible outcomes.
So we have six total events, each with a probability of $1/6$, which adds up to $1.0$.2
-
If there are only two possible outcomes to a test, and the probability of the first outcome is $p$, then the probability of the other is $1-p$. (This follows from the fact that the two probabilities have to add up to $1$.)
-
If the probability of seeing an event in one try is $p$, and we make $k$ independent tries,
- the probability of seeing that event every time is $p^k$.
- The probability of never seeing that event in any of the $k$ tries is $(1-p)^k$ .
- The probability of seeing that event at least once is $1-(1-p)^k$.
-
Suppose that we are looking at a set of possible numeric values for some quantity $X$, and the we know the values of $X$ will be drawn from a set
\[ {x_1, x_2, … x_n}. \]
Suppose that the probability of seeing $x_1$ is $p_1$ , the probability of seeing $x_2$ is $p_2$ , and so on. Then the average or expected value of $X$ is
\[ X_{\mbox{average}} = \sum_{i=1}^n p_i x_i\]
(Notice that if all the values are equally likely, then $p_i = (1/n)$ and this formula simplifies to
\[ X_{\text{average}} = \sum_{i=1}^n (1/n) x_i = \frac{\sum_{i=1}^n x_i}{n}\]
which is the “normal” formula for taking an average of $n$ things.)
-
Suppose that we are waiting on an event that has a probability $p$ of occurring on any one try. On average, we can expect to wait $1/p$ tries before seeing that event.
For example, if we are throwing a six-sided die and waiting to see a ‘4’, we know that ‘4’ has a $1/6$ probability of coming up on a single throw. So we should expect to wait, on average, $\frac{1}{(1/6)} = 6$ throws before seeing a ‘4’.
7.3 Yucch! Nobody told me I needed to know about logarithms.
Suppose that $a^b = c$ . Then we say that b is the logarithm to the base $a$ of $c$, written as $\log_a c$ . In other words, $\log_a c$ is the power that $a$ must be raised to, in order to produce $c$.
Most uses of logarithms outside of Computer Science focus on $log_{10}$ , often abbreviated as $\log$ , and on $log_e$ (where $e$ is the irrational number $2.71828\ldots$), often abbreviated as $\ln$ .
In Computer Science, however, most uses of logarithms arise from considering a situation where we start with $N$ objects, divide that set of objects in half, divide that half in half, divide that fourth in half, and so on:
\[ N, N/2, N/4, \ldots , 2, 1\]
The question is: how many divisions in half can we perform until we get down to a single object? The answer to this question comes from considering the sequence of numbers in reverse:
\[ 1, 2, 4, \ldots , N/2, N\]
and realizing that at each step, we are moving to a progressively higher power of 2: $2^0, 2^1, 2^2, \ldots , N/2, N$ . How many such doublings can we do before reaching $N$ ? This question is the same as asking “to what power can we raise 2 until we reach $N$?”. And the answer, by definition, is $\log_2 N$.
Logarithms to the base 2 are so common in Computer Science that we use the abbreviation $\log$ to stand for $\log_{2}$ , unlike the rest of the scientific world where that stands for $log_{10}$ .
But when we are doing a big-O analysis, the base of the logarithm does not matter, because of the conversion formula between logarithms of different bases:
\[\log_a x = \frac{\log_b x}{\log_b a}\]
So if we have, for example, $\log_{10} N$ , we can convert this to a base $2$ logarithm
\[ \log_2 N = \frac{\log_{10} N}{\log_{10} 2}\]
But $log_{10} 2$ is a constant, and we can drop constant multipliers within $O( … )$ . So $O(\log_{10} N) = O(\log_{2} N)$ . We can generalize this argument to cover any two bases, and so we just write $O(log N)$ without even worrying about the base.
Some useful formulae:
\[ \log_a x = \frac{\log_b x}{\log_b a}\]
\[\log (x*y) = \log x + \log y\]
\[\log (x^y) = y \log x\]
7.4 Simplifying Summations
Some useful formulae:
\[ \sum_{i=0}^{n} 2^i = 2^{n+1} - 1 \]
\[ \sum_{i=0}^{n} a^i = \frac{a^{n+1} - 1}{a-1} \]
\[ \sum_{i=0}^{n} i = \frac{n(n+1)}{2} \]
\[ \sum_{i=0}^{n} i^2 = \frac{n(n+1)(2n+1)}{6} \]
\[ \sum_{i=0}^{n} (1/i) = O(\log n) \]
\[ \sum_{i=0}^{\infty} \frac{1}{2^i} = 2 \]
\[ \sum_{i=0}^{\infty} \frac{i}{2^i} = 3 \]
1: Well, I suppose the die could come to rest on an edge, or a black hole could suddenly open up and swallow the die, so make that probability $0.9999\ldots$.
2: OK, that’s a bit of an over-simplification. Technically, the events that we’re talking about have to be “independent” of one another. That’s why we add up the probability of the die coming up $1, 2, … , 6$ but do not also add in the probability of the die coming up with an even number. The “coming up even” event is not independent of the event “coming up ‘2’”: when a die comes up ‘2’ it is also coming up even.)
8 Miscellaneous
8.1 How do I download a file from a link on a web page?
Left-clicking on the link will often show you the file in the browser, but not provide an easy way to download the file itself.
Instead, right-click on the link and in the pop-up menu, look for something along the lines of “Save link as” (exact phrase depends on what browser you are using). Selecting that should allow you to download the file.
8.2 I can’t save makefiles (or other files with no extension or unusual extensions) without adding an extension.
This is a Windows-specific problem. Windows used to be stupid about file extensions (the ‘.’ followed by 1-3 letters at the end of a file name), requiring all non-folder files to have one. Although Windows itself has gotten better about this, a lot of Windows software (including popular browsers) remains stupid.
The workaround is simple:
- Go ahead and add a
.txt
or other extension to the file name when you save it. - Then immediately rename the saved file back to its intended name.
8.3 Will we be able to see solutions to quiz/exam questions? Why is my quiz/exam score so low? etc.
Most quizzes and exams will contain questions cannot be (reliably) graded automatically. Therefore you will have to wait for the instructor to grade your submission before you have a final score.
- Typically, this will be a week or so after the due date.
- In the meantime, Blackboard may show you partial scores based upon the multiple-choice questions that it could grade on its own, or upon the questions that I have graded so far.
Anything still ungraded will be counted as zero.
Do not send me email complaining about your grade or asking about the solutions until Blackboard shows that your quiz/exam has actually been graded.
-
You will know that your quiz/exam has been graded when the score shown in the Quiz/Exam Grades area (a.k.a. My Grades in Blackboard) turns into a link.
-
Once that happens, you will be able to use that link to see your answers, my answers, your score, and possibly other notes from me.