DM560, Introduction to Programming in C++

Short Note on Linux System

This short note aims at introducing you to the computer system of the ComputerLab at IMADA, where the laboratory sessions will take place.

IMADA ComputerLab

The computers at IMADA run a version of the Linux operating system called “Ubuntu” with “Gnome” as the default desktop manager. It is operated similarly to other Linux distributions, to Mac OS X, and in many ways also to Windows.

After logging on the first time with your SDU credentials (use the prefix sdu\ before your username,

create a folder in your home directory called DM560:

mkdir ~/DM560

The command mkdir crates the directory.

You can change into the folder by using cd DM560 from your home directory. If you are unsure whether you are in your home directory, just type pwd to find out where you are and cd to change to your home directory. It might be useful to create some subfolders for individual weeks, projects etc.

List of useful commands from the shell:

  • ls lists the content of the current directory
  • cd A change directory to A. The symbol ~ is an alias for the home directory. That is, the command: cd ~ will always bring you back to your home directory.
  • cp A B copy file A to B
  • mv A B move file A to B
  • rm A remove permanently the file A
  • rm -r A remove permanently the directory A
  • touch <filname> to create a new empty file
  • Further commands

A very important thing is to understand the permission system about your files and directories (see Tutorial Five linked below). You can test whether you set the correct permissions by trying to access the files of each others. Your files are placed in the directory: */home/imada//*.

One can use chmod go-rwx <directory> to set a directory and all its content to be accessible only by its owner.

It is your own respnsability that others cannot read your data. By default your data are established as NOT readable by everyone. But it is good to check the permissions to your files.

The hidden file .bashrc in your home directory can be used to set more restrictive permissions when creating a file. This can be done by adding umask 600 at the end of the file. This makes such that files are as default set with rights 600 (that is, you can read and write but the group and others cannot do anything).

Never forget to log out using the menu on the top right! Your data will remain saved in your IMADA home directory and will be there when you log in again. Do not shutdown the computer! If you have to leave the computer fast, you can block the screen with: Ctrl + Alt + L

Linux for beginners

If you want to learn about Linux, you can use this tutorial:

  • Tutorial One
  • Tutorial Two
  • Tutorial Four
  • Tutorial Five

Play around with the things you learn from the tutorial.

Tips & tricks

Firefox (og nogle andre programmer) kan som udgangspunkt kun være startet på én maskine af gangen pr. bruger. Dvs. hvis Firefox startes på en maskine, og man forlader maskinen uden at logge ud, så vil man få en fejl hvis man logger ind på anden maskine og starter Firefox. Firefox vil fortælle dig at “din profil allerede er i brug”. Det løses nemmest og mest korrekt ved at finde den oprindelige maskine Firefox er startet på, og så logge ud fra den. Hvis denne maskine ikke kan findes, kan problemet løses ved at slette filen ~/.mozilla/firefox/<profilmappe>/.parentlock. <profilmappe> er forskelligt fra bruger til bruger, men mappen hedder typisk et par tilfældige bogstaver/tal efterfulgt af .default. Filen .parentlock er skjult (filnavne der starter med et punktum er skjulte per definition i Linux - slå visning af skjulte filer til i din filbrowser for at se den).