2 Operating systems
2.1 Working on Windows
2.1.1 Command line basics
If this is you first time using the command prompt you might be interested by this section. The command prompt (often referred to as terminal in Linux world) is your interface to interact with the operating system and many available tools. To learn any useful scientific computing skills it is useful to get a grasp of its use because it is there that we will launch most applications. The illustrations below assume you are working under Windows, but the introductory commands are common to most operating systems.
Now let’s launch a terminal. If you are working under VS Code you can use the shortcut to display the terminal Ctrl+J; the bottom of your window should display something as
PS D:\Kompanion>
The start of this line displays you path in the system; depending on your configuration that could not be the case and you can ask the OS to give you that with pwd (print working directory)
PS D:\Kompanion> pwd
Path
----
D:\Kompanion
If you are invited to move to directory src you may which to use command change directory, or cd in the system’s language
PS D:\Kompanion> cd .\bin\
PS D:\Kompanion\bin>
Now that you reached your destination, you might be interested at inspecting the contents of this directory, i.e. listing its contents; that is done with ls as follows
PS D:\Kompanion\bin> ls
Directory: D:\Kompanion\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1/31/2025 11:11 AM apps
d----- 2/3/2025 9:19 AM data
d----- 1/30/2025 2:34 PM downloads
d----- 2/3/2025 11:50 AM pkgs
d----- 1/31/2025 9:33 AM scripts
d----- 1/30/2025 9:58 AM tests
-a---- 1/31/2025 9:33 AM 2697 activate.bat
-a---- 1/30/2025 9:58 AM 161 code.bat
-a---- 1/30/2025 9:58 AM 132 kode.bat
-a---- 1/30/2025 9:58 AM 131 kpip.bat
Oops! It was not the directory you wanted to go to! No problems, you can navigate one-level-upwards using the special symbol .. (two dots) and change directory again
PS D:\Kompanion\bin> cd ..\docs\
PS D:\Kompanion\docs>
This is the minimum you need to know: navigate, know your address, inspect contents.
2.1.2 Creating a portable launcher
A simple way to create a portable launcher requiring to source extra variables is by writing a simple batch script exporting or calling another script with the definitions:
@echo off
@REM Add variables to be sourced here such as
@REM set PATH="/path/to/some/dir";%PATH%
@REM ... or call another shared script doing so.
@REM call %~dp0\env
MyCode.exe
Because a batch script will keep a console window open, create a VB file with the following
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c MyCode.bat"
oShell.Run strArgs, 0, false
In the example we assume the program is called MyCode.exe and the batch script has been named in an analogous way MyCode.bat.
2.1.3 Mount a network drive in WSL
Here we assume we will mount drive Z: at /mnt/z:
# Create the mount point (if required):
sudo mkdir /mnt/z
# Mount the network drive in WSL:
sudo mount -t drvfs Z: /mnt/zActually the same procedure can be used to access a SMB drive from within WSL temporarily with:
sudo mount -t drvfs '\\path\to\smb' /mnt/<mount-point>/For automatic remount, consider adding the following to your /etc/fstab
//path/to/smb /mnt/<mount-point>/ drvfs auto,rw,nosuid,exec,uid=1000,gid=1000 0 02.1.4 Following the writing to a file
This is equivalent to Linux tail -f <file-path>:
Get-Content -Path "<file-path>" -Wait2.1.5 Finding a process handle
This is useful when Windows won’t let you move a file or folder because it is already open somewhere. First, download and extract Handle; from PowerShell run the following:
./handle.exe -u -nobanner "C:\Path\To\File.txt"Notice that your file might have started another process and some research might be required.
2.1.6 Identifying a proxy PEM
# List all root certs:
Get-ChildItem -Path Cert:\LocalMachine\Root
# Export a specific one:
$cert = Get-ChildItem -Path Cert:\LocalMachine\Root | Where-Object {
$_.Subject -like "*<company-name-generally>*"
}
Export-Certificate -Cert $cert -FilePath "proxy.pem"2.2 Working on Linux
2.2.1 Fresh Ubuntu
This document provides the basic steps to setup a working Ubuntu system for scientific computing. It includes the general setup and customization steps. For more on #linux, please check the dedicated section.
First of all, become a password-less sudoer, run sudo visudo by adding the following lines to the end of the file (by replacing walter by your own user name):
walter ALL=(ALL:ALL) ALL
Defaults:walter !authenticate
Then update the system:
sudo apt update && sudo apt upgrade -y && sudo apt autoremoveInstall a temperature monitor cause scientific computing can burn:
sudo apt install lm-sensors xfce4-sensors-plugin2.2.1.1 Mount a NTFS drive
Add permanent mount points to external (NTFS) drives; use this section with care because this evolves between different versions of the packages. Tested and validated under Xubuntu 24.04.
# Install the required packages:
sudo apt install ntfs-3g
# Identify the disk to be mounted:
sudo parted -l
# Identify the UUID of the disk:
ls -alt /dev/disk/by-uuid/
# Test if mounting works:
sudo mount -t ntfs3 /dev/<drive> /home/<mountpoint>/
# Open fstab for edition:
sudo vim /etc/fstab
# Add a single line with the following:
# /dev/disk/by-uuid/<UUID> /home/<mountpoint>/ ntfs defaults,uid=1000,gid=1000,umask=0022 0 0
# Check fstab for errors:
sudo findmnt --verify
# Maybe
sudo systemctl daemon-reload2.2.1.2 Version control
Install git (and gh if using GitHub) and configure credentials:
sudo apt install git gh2.2.1.3 Scientific computing
Minimum set for editing, retrieving data, and containerizing:
sudo apt install btop neovim curl terminator podman- Minimum set for using system’s built-in Python useful:
sudo apt install python3-pip python3-venv- Install Octave programming language:
sudo apt install octave- Install Julia programming language:
curl -fsSL https://install.julialang.org | sh- Install Rust programming language:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- Install the whole of TeXLive and pandoc:
sudo apt install texlive-full pandoc- For containers (
podman,apptainer), consider checking the dedicated section.
2.2.1.4 Personal configuration
- Add a secondary panel on the bottom with a few launchers for office work.
- Modify file explorer default view mode to show detailed lists.
- Edit
~/.config/users-dirs.dirsto remove (some) of the default home directories.
XDG_DESKTOP_DIR="$HOME/"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/.Templates"
XDG_PUBLICSHARE_DIR="$HOME/"
XDG_DOCUMENTS_DIR="$HOME/"
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"
- Download
.debpackages of Edge, Chrome, Obsidian and Zettlr. - Once Edge and/or Chrome is available,
sudo apt remove snapd. - Productivity tools I use in graphical environments:
sudo apt install texstudio jabref- Add user applications folder to
.bashrc:
function extra_sources() {
source "$HOME/.cargo/env"
}
function extra_paths() {
export PATH=$HOME/.local/bin:$PATH
if [ -d ~/Applications ]; then
for extrapath in ~/Applications/*; do
export PATH="$extrapath:$PATH"
done
fi
unset extrapath
}
extra_sources
extra_paths- Other
.bashrccustomization:
function build_image() {
podman build -t $1 -f $2 .
}
function run_container() {
podman run -it $1 /bin/bash
}
function openfoam12() {
FOAM_NAME=$HOME/Applications/openfoam12-rockylinux9
apptainer run --cleanenv --env-file ${FOAM}.env ${FOAM}.sif
}2.2.2 Limiting CPU frequency
Management of CPU frequency can be done through cpufrequtils; sometimes it will only work if cores are set individually (with flag -c to specify the zero-based core number).
# Check before:
cpufreq-info
# Modify bounds:
cpufreq-set -c <i> -u 2.5GHz
...
# Check after:
cpufreq-info2.2.3 Gnome 3
Several recent Linux distributions use Gnome 3 as the default desktop manager. A few innovations introduced by this environment are not really interesting and falling back to classical modes is useful:
2.2.4 Installing an AppImage
An AppImage application is a bundle intended to be portable across many distributions. Its main inconvenient is that you manually need to give execution permissions and launch it from command line every time.
The following snippet is aimed to automating an AppImage installation under Gnome 3. Simply replace the fields marked by <something> with the required names and run the script (requires admin rights).
#!/usr/bin/env bash
set -euo pipefail
NAME="<application-name>"
ICON="<application-icon>"
SOURCE_ICO="${ICON}.png"
SOURCE_APP="<application-image-name>.AppImage"
TARGET_DIR="/opt/${NAME}"
PIXMAPS="/usr/share/pixmaps"
APPLICATIONS="${HOME}/.local/share/applications"
sudo mkdir --parents ${TARGET_DIR}
sudo cp ${SOURCE_APP} ${TARGET_DIR}
sudo chmod u+x ${TARGET_DIR}/${SOURCE_APP}
sudo cp ${SOURCE_ICO} ${TARGET_DIR}
sudo ln -s ${TARGET_DIR}/${SOURCE_ICO} ${PIXMAPS}
echo "[Desktop Entry]
Type=Application
Name=${NAME}
Exec=${TARGET_DIR}/${SOURCE_APP}
Icon=${ICON}
Terminal=false" > ${APPLICATIONS}/${NAME}.desktop
update-desktop-database ~/.local/share/applications
echo "install ok"2.2.5 FTPS server configuration
sudo dnf install -y vsftpdsudo vim /etc/vsftpd/vsftpd.confssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NOsudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/certs/vsftpd.pem \
-out /etc/ssl/certs/vsftpd.pemrsa_cert_file=/etc/ssl/certs/vsftpd.pem
rsa_private_key_file=/etc/ssl/certs/vsftpd.pemchroot_local_user=YES
allow_writeable_chroot=YESsudo systemctl enable vsftpd
sudo systemctl restart vsftpd
sudo systemctl status vsftpdsudo firewall-cmd --permanent --add-service=ftp
sudo firewall-cmd --permanent --add-port=990/tcp
sudo firewall-cmd --reload