Learn your tools!

Lots of upperclassmen will tease you if dont know how to navigate your tools. This is not to say they wont help you learn them though!
So here I have tried to compile some tools I have found helpful.


SSH Key Generation
Below I have included the steps to generate ssh keys so you dont need to log in every time as well as images with me doing it myself

First we must generate a public/private key pair. If you want to know more about this you will need to look more into RSA encryption. For this the command is: ssh-keygen. But without the period, maybe it seems silly but I have been the college student mistyping commands because I thought the period was part of it. Now this command is going to ask you where to store it so make sure you know where your home directory is and store it in /home/.ssh/stu.cs.jmu.edu and no need to give it a password.

Here is what it looked like when I did it but with my info

Before we add the key into our authorized key file let's add some information to our ssh config. Place the following information but with your e-id

                            Host *
                            ServerAliveInterval 30
                            ServerAliveCountMax 120
                            AddKeysToAgent yes
                            IdentitiesOnly yes

                            Host stu
                                HostName stu.cs.jmu.edu
                                IdentityFile ~/.ssh/stu.cs.jmu.edu
                                User e-id
                            Host w3
                                User e-id
                                IdentityFile ~/.ssh/w3.cs.jmu.edu
                                ProxyJump stu
                        

Now let's ssh into stu to edit our authorized keys!

In order to edit this run the following command: vim ~/.ssh/authorized_keys
Then paste the contents of the contents of your public key e.g. the stuff we just generated e.g. paste the contents of /home/.ssh/stu.cs.jmu.edu.pub
If you dont quite know where to get this you can type : cat /home/.ssh/stu.cs.jmu.edu.pub and then copy and paste

Github
Lots of people dont know how to use Github. You basically need 4 commands and it could save you so much headache. I have peronally overwritten numerous PAs and version control has saved my grades

So lets say that you have created a git repository or maybe your teacher created on for you for some assignment.
The first step is to clone the repository so you can add your code to it from your machine. To do this you need to go the the github page and you should see a clone or download button in the top right. Copy the link to it. Now back in the command line type "git clone link" where link is the appropriate place. Note that this will create the repository wherever you are so make sure you are located in the directory you want.

If you dont have a repository created yet but instead need to initialize on you would type "git init".

Now what is the process of adding code to the repository:

  • git status tells you the current status of your local repo
  • git add * this means adds all my files you can add just specific files by saying "git add hi.py" This specifies which files are going to be added to the repository
  • git commit -m "a message descriping your changes" Now this command will commit your changes to your local repository but doesnt make changes to the remote repository
  • git push this will push your changes to the remote repository

Now these are the commands you will need for your own repository. If this is a repository with multiple team members you will need one more. Lets say your teammate made changes to your group's code and now you need the most up to date code. you would say "git pull". Everytime you are about to push code to a shared repository you need to call this command. This could lead to merge conflicts meaning there were changes that were made while you were working on the same code. You would need to fix this conflicts and then push your code.
There are a plenty of commands that are out there but these are the mains ones that you would be using. The only other one I have touched is "git checkout" and this is to "checkout" a branch but I will leave it up to you to learn what that means.
One of I have just recently learned about is "git diff". You can use this in multiple different ways. One way is you have made some changes git diff will tell you where these changes are and whether they are addition or subtractions. Happy coding!

SCP
Next I am going to talk about a way to transfer files from stu to your local machine without using something like WinSCP

Unfortunately, I do not know much about this command but look forward to the opportunity to learn more about it.
For now I will provide what I do know. So there are two different file transfer commands scp and ftp. You always want to use scp because it is secure. So to transfer a file from stu to your machine you would type in the terminal "scp e-id@stu.cs.jmu.edu:path-to-file place-you-want-it" The last part of the path to file will be the /fileName.extension. It is very important that you dont add a space before your path-to-file. Also you can say "." to mean place it where I am currently located. If you want an entire folder instead of a file it is the same command with a -r meaning recursive (I believe) so you would say "scp -r e-id@stu.cs.jmu.edu: path-to-file place-you-want-it" Now stu is just a host. So you can scp from other hosts but this is all the information I can provide you with

Keyboard Shortcuts
Here I am going to list a few keyboard shortcuts I have found useful. I only know a couple, but if it helps one person thats all that matters.
  • cmd v or ctrl v v will paste whatever is currently on your clipboard
  • cmd c or ctrl c will copy the current highlighted text
  • cmd x or ctrl x will cut the current hightlight text
  • cmd a or ctrl a will select all
  • you can hold shift and use your arrow keys to hightlight some text
  • cmd tab or alt tab will change your current window
  • ctrl t will change your current tab
  • cmd t or ctrl t will open a new tab/window in your browser
  • cmd w or ctrl w will close your current tab or window
  • cmd shift t or ctrl shift t will open your last closed tab or window in the browser
VIM
So VIM is a basically a terminal text editor. Once you get good at it you can get really fast and only knowing a couple things can get you there

I do not know too many VIM commands but I do love knowing it. For example, when you ssh into stu you cant use text editors that are downloaded on your local machine such as gedit. But.... VIM is there and so that is really convenient because then I can edit files in current time. You could scp the file but then if you want changes on stu you'd have to find some way to get those changes onto stu. Below are the commands I know and in front of Dr. Lam's office he has a sheet with plenty more.

  • In order to edit the file you need to hit "i" to be in insert mode
  • If you hit "o" then it will put you in insert mode on a new line
  • To get out of a mode you can hit "esc"
  • Other modes include visual mode, to enter hit "v", this allows you to select text
  • If text is selected you can hit "y" to copy the highlighted information. y stands for yank
  • dd deletes your current line, you can hit the up arrow to delete the line(s) above it
  • In order to save your changes you must write to the file so you would hit ":w"
  • To exit vim you would hit ":q" you can write and quit by saying ":wq"
  • Undo is pretty intuitive with ":u"
  • "$" will put you at the end of your current line
  • "0" will bring you to the beginning of your current line
  • if you hit "4gg" that will take you to line 4 of your file

By default, tabs are tabs not spaces and you dont see line numbers if you arent on your own machine or account you can say ":set tabstop=4" and that will say a tab is equal to four spaces and ":set nu" will include number lines. Now these will only be temporary configurations so you can add them to your .vimrc in order to permanently make these changes.

tmux
So tmux is a terminal-multiplexer. This means that it allows multiple terminal sessions to be accessed simultaneously in a single window. Now I know, I kid you not, 4 commands and I still utilize this

To open tmux you just type "tmux" in a terminal

  • ctrl b % will split your terminal in half vertically
  • ctrl b " will split your terminal in half horizontally
  • Hitting ctrl b and then using your arrow keys will move which "terminal" you are located in
  • exit will close the terminal you are in. Note: to close 2 terminals you will need to type exit 3 times. Twice for the windows and then once for tmux itself
Terminal Commands
For a while you work in a lot of IDEs but as you progress it becomes easier and easier to navigate through the terminal. So here a couple commands that I believe are useful to know
  • cd directory stands for change directory and will move you to the directory you specify e.g. cd Desktop/Cs354 means go to my desktop and then my CS354 folder
  • ls stands for list and will list the items in your current directory
  • ll will lists all items in your current directory including hidden files
  • pwd stands for the path of your working directory and will give you the entire path of where you are currently
  • mv this-file to-here stands for move what I specify to my specified spot e.g. mv Desktop/Cs354/hw1.py . means move my hw1.py file in the Cs354 folder located on my desktop to where I am currently working. You can also use move to rename a file by being located in the same directory as your file and giving it a new name.
  • cp this-file here means copy the file located at this path to where you specify it
  • rm this-file means remove this file

With a lot of these commands you can add a -r which means recursively for an entire folder instead of just a singular file. Also my own personal warning be careful with mv because you can overwrite your files!!