Connecting to a School Machine
Difficulty: EasyWithout going into the details of the school network architecture, it is important to know that the single entry point is the server called portier.polytech-lille.fr. To connect, simply type in a terminal:
ssh your_login@portier.polytech-lille.fr -p2222
The -p2222 option corresponds to the port used which is not the default ssh port and must therefore be specified.
Once on this server, you have access to your documents but not all programs are necessarily installed (such as clang). In this case, the best option is to connect to a lab machine such as phinaertXY, reuzeXY, lydericXY, gedeonXY, gayantXY (where XY is a number from 01 to 16) to have access to all useful programs.
ssh gayant01
here, it is not necessary to specify your login because you are using the same one as on
portier, and since thesshport is the default one (22), it does not need to be specified.
Inside the Polytech Lille network, the server portier.polytech-lille.fr is also called arsenic or serveur-etu.polytech-lille.fr.
- Connect via
sshtoarsenic. - Verify that you are on
arsenicvia the commanduname -n - Check the other users connected to
arsenicvia the commandworwho - From arsenic, connect to a lab machine outside your room. Use
uname -nandwhoagain to verify that the previous commands are correct.
Copying Files From / To the Outside
Difficulty: EasyOn the Polytech Lille network, your files are accessible on any machine or server, so it is not necessary to copy your files from machine to machine. However, from/to the outside, it may sometimes be necessary to copy files. For this, use the command scp, whose syntax is as follows (run man scp for help):
scp source destination
which can be specified for the following use cases:
- Copying a file
projet.c(located for example on the desktop) from a Polytech Lille machine to your local machine (the trailing.represents the current directory)
scp -P2222 your_login@portier.polytech-lille.fr:~/Desktop/projet.c .
- Copying the same file from your machine to Polytech Lille
scp -P2222 projet.c your_login@portier.polytech-lille.fr:~/Desktop/
- Copying a directory
projet(located for example in the Documents directory) from a Polytech Lille machine to your local machine (the trailing.represents the current directory)
scp -P2222 -r your_login@portier.polytech-lille.fr:~/Documents/projet .
- Copying the same directory from your machine to Polytech Lille
scp -P2222 -r projet.c your_login@portier.polytech-lille.fr:~/Documents/
- If you have a laptop (or a smartphone with the
termiusapp for example), try to transfer files from/to the Polytech Lille machines.
Using the GIT Version Control System
Difficulty: Easy
Preamble
GIT is a version control system that has become one of the standards for sharing digital resources. It has a large number of features and requires some learning to master. Here we will cover the most basic features that will allow you to easily share/save your files.
- Create a directory
sauvegarde(the name does not matter) that will contain all the files you want to save. - To structure your
GITrepository, create a subdirectoryprogrammationin yoursauvegardedirectory. - Create a directory
ed_infoin yourprogrammationdirectory - Verify that you have the correct hierarchy with the
treecommand:
.
|-- Desktop
|-- ...
|-- public_html
`-- sauvegarde
`-- programmation
`-- ed_info
Basic GIT Configuration
- Type the following commands (replacing your name and surname with the correct values):
git config --global user.name "your name"
git config --global user.email firstname.lastname@polytech-lille.net
git config --global core.editor vim
git config --global push.default simple
git config --global color.decorate full
git config --global merge.conflictstyle diff3
- If you followed the previous question correctly, you should get by typing
git config -l:
user.name=your name
user.email=firstname.lastname@polytech-lille.net
core.editor=vim
push.default=simple
color.decorate=full
merge.conflictstyle=diff3
Using GIT
- Take the file
hello.cfrom the first ED Info:
#include <stdio.h>
int main ()
{
printf ("Hello World !\n");
return 0;
}
Place this file in the directory sauvegarde/programmation/ed_info.
- In the
sauvegardedirectory, typegit init - Type
git status, verify that the message correctly indicates that theprogrammationdirectory is not tracked.
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
programmation/
nothing added to commit but untracked files present (use "git add" to track)
- Type
git add programmation/ed_info/hello.c - Type
git status, verify that the message correctly indicates that the filehello.cis a new file.
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: programmation/ed_info/hello.c
- Type the command
git commit -m "(feat) ed_info first commit". Your file is now saved in theGITrepository. - In the file
hello.c, replace the line containingprintfwithprintf ("Hello SE3!\n"); - Type
git status, verify that the message correctly indicates that the filehello.cis modified:
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: programmation/ed_info/hello.c
no changes added to commit (use "git add" and/or "git commit -a")
- Type
git add sauvegarde/programmation/hello.cto indicate that you want to save these changes, thengit commit -m "(fix) ed_info update printf"to validate the changes. - Type
git log --onelineto see the history of changes in your repository.
2306f11 (HEAD -> master) (fix) ed_info update printf
763b933 (feat) ed_info first commit
- Type
git checkout abcdefgwhereabcdefgis the identifier before the first commit you made (in my case it is763b933). - Type
cat auvegarde/programmation/hello.cand notice that you are displaying the first version of theCfile. - Type
git checkout abcdefgwhereabcdefgis the identifier before the last commit you made (in my case it is2306f11). - Type
cat auvegarde/programmation/hello.cand notice that you are displaying the latest version of theCfile. You therefore see that with thegit checkoutcommand you can display the content of any saved version… not just the most recent one.
Adding a Server
Difficulty: RxFor now, everything you have done is only accessible on the Polytech machines. The goal is to make it accessible from anywhere. We will therefore put your repository on a GIT server. There are several you can use such as:
- https://archives.plil.fr Polytech Lille
GITserver - https://gitlab.univ-lille.fr/ university
GITserver - https://gitlab.com global server where as a Polytech student you have a premium account.
- https://github.com global server where as a Polytech student you have a premium account.
- Create an account on one of these servers with your Polytech Lille email address (for example gitlab.com)
- Create a new empty project
- Then type in the terminal:
git remote add origin https://gitlab.com/your_login/your_project.git
there are two types of secure connections (https or ssh)… for security reasons, ssh outside of polytech is not possible
where you will have replaced your_login and your_project with the correct values.
- Then type
git push origin master. - Verify on
gitlab.comthat your project has been successfully transferred to the server.
Cloning a Repository
Difficulty: RxTo verify that your repository is accessible everywhere, you can clone it. To do this:
- At the root of your account, create a directory
sauv_temp - Go to this directory
- Type
git clone https://gitlab.com/your_login/your_project.git - Notice that you have a copy of the repository and all saved versions.
- Modify the file
hello.c - Add / Commit / Push the file to the server
- Go to your
sauvegardedirectory - Type the command
git pull - Notice that you have just retrieved the modified version
How to Work Between Two Computers
Once the repository is created on one machine (A) and cloned on another machine (B), the workflow is simple:
- Before modifying a file, do
git pullto retrieve the latest changes (if any) - Modify/add/delete your files…
- Add them for validation with
git add - Validate with (
git commit -m "relevant message") - Push the changes to the server with
git push
Benefits of a Version Control System
Beyond synchronizing work across multiple computers, GIT allows sharing repositories (with your lab partner, an instructor…), easily reverting to a specific version of your documents (so there is no fear of saving a bad version or losing content)… Moreover, the gitlab and github environments add a set of very interesting features:
- project management: task management, assignment to members, deliverable definition, documentation…
- automation: automatic compilation, automatic tests, binary creation…
You will see these features in the next semester :)