Computing Cheat Sheets
By: Oameed Noakoasteen
Version:11, April. 2024
from Internet Archive
Table of Contents
Installing Linux: ‘Ubuntu’
Package Management with ‘apt’ and ‘dpkg’
Environment & Package Management with ‘Anaconda’
Other Useful Stuff
4-1- Keyboard Shortcuts
4-2- Adding to ‘PATH’ variable
4-3- Creating Symbolic Links
4-4- Installing Printers
4-5- Code Statistics
4-6- Operating System and Hardware Architecture Information
Most Used Commands of ‘bash’ Shell in Linux
‘vim’ Basic Commands
Remote Access to HPC System
7-1- Remote Connection using ‘ssh’
7-2- Loading Software Packages using ‘module’
7-3- Manage User’s Processes on Remote Machine using ‘top’
7-4- File Transfer using ‘scp’
7-5- Monitor Jobs Running on GPU
7-6- Resource Manager / Job Scheduler: ‘torque’ / ‘pbs’
7-7- Resource Manager / Job Scheduler: ‘slurm’
Version Control using ‘git’
Performance Monitoring Tools
9-1- Perf
9-2- likwid: perf-ctr and Marker API
Migrating To Windows
10-1- PowerShell
10-2- Visual Studio Code
10-3- Miniconda
10-4- Windows Subsystem for Linux (WSL)
10-5- Rclone
10-6- Maintaining and Consuming a Video/Music Library
Appendix I: make’s Built-in Rules and Variables
Appendix II: C/C++ Debugging using ‘gdb’
Appendix III: List of Packages
Installing Linux: ‘Ubuntu’
1 Download the most recent Long-Term Support (LTS) version of Ubuntu (from ubuntu.com)
To Install Linux on a Desktop Machine:
Use Rufus (from rufus.ie) on Windows or Startup Disk Creator utility on Ubuntu to create
2
a bootable flash drive from the downloaded ‘.iso’ file.
3 Use the bootable flash drive to install Ubuntu on the system.
To Install Linux as a Virtual Machine:
2 Download Virtual Box (from virtualbox.org) and install on system.
3 Using Virtual Box and the downloaded ‘.iso’ file, create new virtual machine.
Package Management with ‘apt’ and ‘dpkg’
To Install/Remove Packages
sudo1 apt install 〈𝑝𝑘𝑔1 〉 … 〈𝑝𝑘𝑔𝑛 〉
sudo dpkg -i 〈𝑑𝑒𝑏𝑖𝑎𝑛 𝑝𝑎𝑐𝑘𝑎𝑔𝑒〉
sudo apt remove 〈𝑝𝑘𝑔1 〉 … 〈𝑝𝑘𝑔𝑛 〉
To Update Packages
1 sudo apt update
2 sudo apt upgrade
Environment & Package Management with ‘Anaconda’
1 Download and install Anaconda (from anaconda.com) or Miniconda (from docs.conda.io).
2 List Environments conda env list
3 Create an Environment conda create -n 〈𝑒𝑛𝑣𝑛𝑎𝑚𝑒〉 〈𝑝𝑘𝑔1 〉 … 〈𝑝𝑘𝑔𝑛 〉
Available Package Versions conda search 〈𝑝𝑘𝑔 𝑛𝑎𝑚𝑒〉
Add Other Packages conda install 〈𝑝𝑘𝑔1 〉 … 〈𝑝𝑘𝑔𝑛 〉
List Packages in Environment conda list
Update Package to Latest Ver. conda update 〈𝑝𝑘𝑔 𝑛𝑎𝑚𝑒〉
Delete an Environment conda remove -n 〈𝑒𝑛𝑣𝑛𝑎𝑚𝑒〉 --all
4 Activate Environment conda activate 〈𝑒𝑛𝑣𝑛𝑎𝑚𝑒〉
Deactivate Environment conda deactivate
5 To Export an Environment
Export the Environment2 conda env export --name 〈𝑒𝑛𝑣〉 > 〈𝑓𝑖𝑙𝑒 𝑛𝑎𝑚𝑒〉. 𝑦𝑚𝑙
Create Environment from yaml conda env create --file 〈𝑓𝑖𝑙𝑒 𝑛𝑎𝑚𝑒〉. 𝑦𝑚𝑙
6 Clean Conda’s Cache conda clean --all
1
‘sudo’ enables administrative permissions.
2
for OS-agnostic environment export, use –-no-builds or --from-history.
1
Other Useful Stuff
4-1- Keyboard Shortcuts
Open a New Terminal Window Ctrl + Alt + t
Open a New Tab in Terminal Window Ctrl + Shift + t
To Switch Between Tabs Alt + 〈𝑡𝑎𝑏_𝑛𝑢𝑚𝑏𝑒𝑟〉
4-2- Adding to ‘PATH’ variable
To Add to Path:
1 PATH=$PATH:〈𝑑𝑖𝑟𝑐_𝑝𝑎𝑡ℎ〉
2 echo3 $PATH
To Permanently Add to Path:
1 Open the ‘.profile’ file : gedit ~/.profile
2 Add the following to the end of the file : PATH=$PATH:〈𝑑𝑖𝑟𝑐_𝑝𝑎𝑡ℎ〉
3 Save changes to the ‘.profile’ file
4 Issue the following command : source ~/.profile
4-3- Creating Symbolic Links4
ln -s 〈𝑝𝑎𝑡ℎ 𝑡𝑜 𝑡ℎ𝑒 𝑓𝑖𝑙𝑒 𝑜𝑟 𝑓𝑜𝑙𝑑𝑒𝑟 𝑡𝑜 𝑏𝑒 𝑙𝑖𝑛𝑘𝑒𝑑〉 〈𝑝𝑎𝑡ℎ 𝑜𝑓 𝑡ℎ𝑒 𝑙𝑖𝑛𝑘 𝑡𝑜 𝑏𝑒 𝑐𝑟𝑒𝑎𝑡𝑒𝑑〉
4-4- Installing Printers
1 Go To: Settings/Devices/Printers
2 Open: Additional Printer Settings
3 Add
4 Enter Device URI5
4-5- Code Statistics
1 Install ‘cloc’ package
2 Clone project repository
3 In the project directory do6,7 : git ls-files | xargs cloc
4-6- Operating System and Hardware Architecture Information
Kernel Name uname -s lscpu8
Hardware Architecture
uname -n lspci
Operating System and
Node Name
Kernel Release uname -r lstopo9
uname -v
Hardware
Kernel Version
Hardware Name uname -m free -h
CPU Type uname -p
Hardware Platform uname -i df -h
Operating System uname -o
To Get All10 uname -a
3
‘echo’ prints the following string or value.
4
Can be used instead of adding to path; e.g.: ln -s 〈𝑝𝑎𝑡ℎ 𝑡𝑜 𝑚𝑎𝑡𝑙𝑎𝑏〉 /usr/local/bin/matlab
5
e.g. lpd://printserver.ece.unm.edu/ece313-bw.
6
To exclude certain file types, include the following flag --exclude-ext=〈𝑡𝑦𝑝𝑒1 〉, 〈𝑡𝑦𝑝𝑒2 〉, …
7
On Windows PowerShell, do: $fn=git ls-files; cloc $fn
8
More complete information can be read from the file: /proc/cpuinfo
9
Requires hwloc package.
10
This will output informations in the same order as above.
2
Most Used Commands of ‘bash’ Shell in Linux11
Print Working Directory pwd
Change Directory12 cd 〈𝑑𝑒𝑠𝑡_𝑝𝑎𝑡ℎ〉
List Content in Long Listing Format13 ls -lat 〈𝑑𝑖𝑟𝑐_𝑝𝑎𝑡ℎ〉
To Get Size of Files in a Directory ls -lah
To Get Size of an Entire Directory du -sh 〈𝑑𝑖𝑟𝑐_𝑛𝑎𝑚𝑒 〉
Create Directory mkdir 〈𝑑𝑖𝑟𝑐_𝑛𝑎𝑚𝑒 〉
Copy & Paste cp -r 〈𝑠𝑟𝑐𝑒_𝑓𝑖𝑙𝑒/𝑑𝑖𝑟〉 〈𝑑𝑒𝑠𝑡_𝑓𝑖𝑙𝑒/𝑑𝑖𝑟〉
Cut & Paste / Rename mv 〈𝑠𝑟𝑐𝑒_𝑓𝑖𝑙𝑒/𝑑𝑖𝑟〉 〈𝑑𝑒𝑠𝑡_𝑓𝑖𝑙𝑒/𝑑𝑖𝑟〉
Remove rm -rf 〈𝑓𝑖𝑙𝑒/𝑑𝑖𝑟〉
Compress File/Directory using gzip14 tar -cvzf 〈𝑛𝑎𝑚𝑒. 𝑡𝑎𝑟. 𝑔𝑧〉 〈𝑠𝑟𝑐𝑒_𝑛𝑎𝑚𝑒〉
Extract File/Directory using gzip tar -xvzf 〈𝑛𝑎𝑚𝑒. 𝑡𝑎𝑟. 𝑔𝑧〉 -C 〈𝑑𝑒𝑠𝑡_𝑑𝑖𝑟〉
Compress File/Directory using pigz tar -cv --use-compress-program=pigz -f …
Extract File/Directory using pigz tar -xv --use-compress-program=pigz -f …
Continuous Monitoring15 watch -n 〈𝑑𝑢𝑟𝑎𝑡𝑖𝑜𝑛 〉 〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑 〉
To Print Content of File cat 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒 〉
Print First Few Lines of a File head -n 〈𝑛𝑢𝑚_𝑜𝑓_𝑙𝑖𝑛𝑒𝑠〉 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑓𝑖𝑙𝑒〉
Print Last Few Lines of a File tail -n 〈𝑛𝑢𝑚_𝑜𝑓_𝑙𝑖𝑛𝑒𝑠〉 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑓𝑖𝑙𝑒〉
To Search/Find Files Find 〈𝑓𝑖𝑙𝑒 𝑝𝑎𝑡ℎ 𝑝𝑎𝑡𝑡𝑒𝑟𝑛〉
Symbols Used for Constructing Relative Paths16
User’s ‘home’ Directory ‘~’
Current Directory ‘.’
One Level Up in Directory Hierarchy ‘..’
To See Environment Variables17 printenv 〈𝑣𝑎𝑟_𝑛𝑎𝑚𝑒〉
To Set a New Environment Variable export 〈𝑣𝑎𝑟_𝑛𝑎𝑚𝑒〉 = 〈𝑣𝑎𝑙𝑢𝑒〉
To Redirect Output to a File 〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑〉 > 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒〉
To Append Redirected Output to a File 〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑〉 >> 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒〉
Enable Execution of ‘.sh’ files18 chmod a+x 〈𝑛𝑎𝑚𝑒. 𝑠ℎ〉
Piping19 〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑1 〉|〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑2 〉|…|〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑𝑛 〉
View History of Commands history
To Auto-Complete Commands
1 press Ctrl + R
2 Type First Few Characters
3 To Put Result on Command Line press Esc
11
To get help for any command, do: 〈𝑐𝑜𝑚𝑚𝑎𝑛𝑑_𝑛𝑎𝑚𝑒 〉 ‘--help’
12
Command ‘cd’ without any arguments returns to user’s ‘home’ directory.
13
Command ‘ls’ without any arguments lists the content of the current directory. The flag ‘-l’ lists content of
the directory in Long Listing Format. The flag ‘-a’ will include hidden files and folders (the names of hidden
files and folders always start with a dot ‘.’ ; The same can be achieved in graphical mode using: ctrl+H). The
flag ‘-t’ sorts the listing according to the date modified. Single letter flags can be lumped together; e.g.: ls -la
or ls -lat. To get long format information about specific files, do: ls -l 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒1 〉 … 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒𝑛 〉.
14
To exclude files from the archive, add the following flag: --exclude=〈𝑝𝑎𝑡𝑡𝑒𝑟𝑛 〉. To remove files after
archiving, add the following flag: --remove-files.
15
An example of piping the output of ‘watch’: watch -n 1 ‘qstat | tail -n 10’
16
Full Path to a file can be used as its name.
17
Some Important Environment Variables are: HOME, PATH, PWD, SHELL, USER, USERNAME, LD_LIBRARY_PATH.
18
Shell Script files are given the extension ‘.sh’.
19
A pipe is a form of redirection that is used to send the output of one command/program/process to another
command/program/process for further processing.
3
‘vim’ Basic Commands
Open and Edit a Single File
To Open a file in Vim vim 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒〉
When a file is opened, user is in Normal Mode
To Edit the file press ‘i’
With this, user enters Insert Mode
To Exit Insert Mode press ‘Esc’
1 Enter Normal Mode
2 To Enter Visual Mode press ‘v’
To Copy/Cut & Paste To Copy press ‘y’
3
To Cut press ‘d’
4 To Paste After Curser press ‘p’
To Search a String press ‘/’ Then Type 〈𝑠𝑡𝑟𝑖𝑛𝑔〉
To Save Changes ‘:w’
To Save Changes and Quit In Normal Mode ‘:wq’ Also ‘:x’
To Quit ‘:q’
To Quit Without Saving Changes ‘:q!’
Open Multiple Files in Tabs
To Open Multiple Files vim -p 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒1 〉 … 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒𝑛 〉
To Go to the Next Tab ‘:tabn’
To Go to the Previous Tab ‘:tabp’
In Normal Mode
To Add Another File to Tabs ‘:tabe’ 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒〉
To Close All Tabs ‘:qa’
Open Multiple Files in Vertical Split Window
vim -O 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒1 〉 … 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒𝑛 〉
To Switch Between Splits press ‘Ctrl+w’ + ‘Ctrl+w’
4
Remote Access to HPC System
7-1- Remote Connection20 using ‘ssh’
To Connect Using Command Line SSH
ssh 〈𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒〉@〈𝑟𝑒𝑚𝑜𝑡𝑒_𝑚𝑎𝑐ℎ𝑖𝑛𝑒_𝑎𝑑𝑑𝑟𝑒𝑠𝑠〉21
Setup SSH Config File
1 Create file: gedit ~/.ssh/config
2 For each host machine, add the following entries22:
Host 〈𝑔𝑖𝑣𝑒𝑛_𝑛𝑎𝑚𝑒〉
hostname 〈ℎ𝑜𝑠𝑡_𝑓𝑢𝑙𝑙_𝑛𝑎𝑚𝑒〉
user 〈𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒〉
port 22
ForwardX11 〈𝑦𝑒𝑠/𝑛𝑜〉
LocalForward 〈𝑝𝑜𝑟𝑡_𝑛𝑢𝑚〉 localhost: 〈𝑝𝑜𝑟𝑡_𝑛𝑢𝑚〉
PreferredAuthentications publickey
IdentityFile 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑆𝑆𝐻_𝐾𝑒𝑦〉
Setup SSH Key23
1 ssh-keygen
2 ssh-copy-id 〈𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒〉@〈𝑟𝑒𝑚𝑜𝑡𝑒_𝑚𝑎𝑐ℎ𝑖𝑛𝑒_𝑎𝑑𝑑𝑟𝑒𝑠𝑠〉
To Connect Using PuTTY
Create Connection Profile
1 Session: Host Name, Port (𝑑𝑒𝑓𝑎𝑢𝑙𝑡 = 22), Connection Type (𝑑𝑒𝑓𝑎𝑢𝑙𝑡 = 𝑆𝑆𝐻)
SSH/Tunnels: Add New Forwarded Port: Source Port, Destination24
SSH/X11: Enable/Disable X11 Forwarding
2 In Session Tab, set a name for Saved Sessions and Save.
Select and Load Profile
Open
7-2- Loading Software Packages using ‘module’
To Get the List of Loaded Modules module list
To Get the List of Available Modules module avail
To Load a Module module load 〈𝑝𝑎𝑐𝑘𝑎𝑔𝑒_𝑛𝑎𝑚𝑒〉
To Remove a Module module unload 〈𝑝𝑎𝑐𝑘𝑎𝑔𝑒_𝑛𝑎𝑚𝑒〉
To Remove all Modules module purge
20
For resizing of windows to take effect do: eval $(resize)
21
e.g. [email protected] or [email protected].
22
X11, Port Forwarding, Preferred Authentication and Identity File are optional.
23
On windows ‘ssh-copy-id’ doesn’t exist; for the second step, the content of the ‘id_rsa.pub’ must be
manually copied to the host’s ‘authorized_keys’ file.
24
Typical values for Tensorflow applications: LocalForward 16006 localhost:6006
5
7-3- Manage User’s Processes on Remote Machine using ‘top’
To View Running Processes for a Specific User
top -u 〈𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒〉
To View Processes for all Users press ‘u’
To View Running Processes for all Users
top
To View Processes for a Specific User press ‘o’25 and enter USER=〈𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒〉
To Go Back to Processes for All Users press ‘=’
Most Used Commands
To Sort by PID press ‘N’
To Sort by CPU Usage press ‘P’
To Sort by Memory press ‘M’
To Sort by Running Time press ‘T’
To Reverse the Order of Sort press ‘R’
To Highlight the Sorted Column press ‘x’
To Kill a Process press ‘k’ and enter 〈𝑃𝐼𝐷〉
To Quit press ‘q’
To cycle through Memory units (Total) press ‘E’
To cycle through Memory units (users) press ‘e’
7-4- File Transfer using ‘scp’
From Local to Remote
On Local Machine Do:
scp -r 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑓𝑖𝑙𝑒_𝑜𝑛_𝑙𝑜𝑐𝑎𝑙〉 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑑𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑖𝑜𝑛_𝑜𝑛_𝑟𝑒𝑚𝑜𝑡𝑒〉
From Remote to Local
On Local Machine Do:
scp -r 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑓𝑖𝑙𝑒_𝑜𝑛_𝑟𝑒𝑚𝑜𝑡𝑒〉 〈𝑝𝑎𝑡ℎ_𝑡𝑜_𝑑𝑒𝑠𝑡𝑖𝑛𝑎𝑡𝑖𝑜𝑛_𝑜𝑛_𝑙𝑜𝑐𝑎𝑙〉
7-5- Monitor Jobs Running on GPU
1 From the login node, ‘ssh’ onto the node that is running the job
2 ‘nvidia-smi’
3 Username associated with the Job ID can be obtained using ‘top’ command
25
This defines a Filter.
6
7-6- Resource Manager / Job Scheduler: ‘torque’ / ‘pbs’
To Submit an Interactive Job
qsub -I -X26 -l nodes=1:ppn=< 𝑛𝑢𝑚. 𝑜𝑓 𝑎𝑣𝑎𝑖𝑙𝑎𝑏𝑙𝑒 𝑝𝑟𝑜𝑐𝑒𝑠𝑠𝑜𝑟𝑠 𝑝𝑒𝑟 𝑛𝑜𝑑𝑒 >
To Get the List of Available Queues
qstat -q
To Submit a Batch Job
Create a ‘.pbs’ file gedit 〈𝑛𝑎𝑚𝑒. 𝑝𝑏𝑠〉
Use the following template
#!/bin/bash
#PBS -S /bin/bash # SPECIFY THE SHELL TO BE BASH
#PBS -l nodes=1:ppn=16 # REQUEST RESOURCES
#PBS -l walltime=48:00:00 # REQUEST RESOURCES
#PBS -q singleGPU # REQUEST RESOURCES
#PBS -m bea # SET ALERT TYPES
#PBS -M 〈𝑒𝑚𝑎𝑖𝑙 𝑎𝑑𝑑𝑟𝑒𝑠𝑠〉 # SET EMAIL FOR ALERTS
#PBS -N 〈𝑗𝑜𝑏 𝑛𝑎𝑚𝑒〉 # SET JOB NAME
module load 〈𝑚𝑜𝑑𝑢𝑙𝑒 𝑛𝑎𝑚𝑒〉 # LOAD REQ. MODULES
module load anaconda # LOAD ANACONDA MODULE
source activate
# ACTIVATE ENVIRONMENT
〈𝐸𝑛𝑣 𝑁𝑎𝑚𝑒〉
CD TO DIRECTORY THE PBS
cd $PBS_O_WORKDIR #
SCRIPT WAS SUBMITTED FROM
ISSUE COMMANDS FOR RUNNING
python 〈𝑛𝑎𝑚𝑒 𝑜𝑓 𝑠𝑐𝑟𝑖𝑝𝑡〉 #
YOUR CODE
Place the ‘.pbs’ scrip in the
same directory as the code
script.
Submit job qsub 〈𝑛𝑎𝑚𝑒. 𝑝𝑏𝑠〉
To Check the Status of a Job
qstat
To Kill a Running Job
qdel 〈𝐽𝑜𝑏 𝐼𝐷〉
26
‘-X’ flag is used to enable X11. Its optional.
7
7-7- Resource Manager / Job Scheduler: ‘slurm’
To Submit an Interactive Job
srun --pty bash
To Get the List of Available Partitions
sinfo -N -l
To Submit a Batch Job
Create a ‘.sh’ file gedit 〈𝑛𝑎𝑚𝑒. 𝑠ℎ〉
Use the following template
#!/bin/bash
#SBATCH --ntasks=16 # REQUEST RESOURCES
#SBATCH --time=48:00:00 # REQUEST RESOURCES
#SBATCH --partition=singleGPU # REQUEST RESOURCES
#SBATCH --gres=gpu:1 # REQUEST RESOURCES
#SBATCH --mail-type=BEGIN,FAIL,END # SET ALERT TYPES
#SBATCH –-mail-user=〈𝑒𝑚𝑎𝑖𝑙 𝑎𝑑𝑑𝑟𝑒𝑠𝑠〉 # SET EMAIL FOR ALERTS
#SBATCH --job-name= 〈𝑗𝑜𝑏 𝑛𝑎𝑚𝑒〉 # SET JOB NAME
module load 〈𝑚𝑜𝑑𝑢𝑙𝑒 𝑛𝑎𝑚𝑒〉 # LOAD REQ. MODULES
module load anaconda
source activate 〈𝐸𝑛𝑣 𝑁𝑎𝑚𝑒〉
CD TO DIRECTORY THE
cd $SLURM_SUBMIT_DIR # SHELL SCRIPT WAS
SUBMITTED FROM
ISSUE COMMANDS FOR
python 〈𝑛𝑎𝑚𝑒 𝑜𝑓 𝑠𝑐𝑟𝑖𝑝𝑡〉 #
RUNNING YOUR CODE
Place the ‘.sh’ scrip in the
same directory as the code
script.
Submit job sbatch 〈𝑛𝑎𝑚𝑒. 𝑠ℎ〉
To Check the Status of a Job
squeue
To Kill a Running Job
scancel 〈𝐽𝑜𝑏 𝐼𝐷〉
8
Version Control using ‘git’
1 Create an Account on GitLab27 (gitlab.com)
2 Add SSH Key
Navigate to Edit Profile / SSH Keys
Add ‘New SSH Key’
3 Set Global Config on System
git config --global user.name ‘< 𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒 >’
git config --global user.email ‘< 𝑢𝑠𝑒𝑟_𝑒𝑚𝑎𝑖𝑙 >’
git config --global core.editor ‘vim’
git config --global core. autocrlf false
To Check Values of Global Configs git config --list
Global Config Settings are Stored in ~/.gitconfig
To Get Help on Global Configs git config --help
To Push Project Directory to a New Repository
1 Create a New Repository on GitLab
Set the ‘name’
Set the privacy setting (private/public)
Create repository
To Delete a Repository:
Navigate to Main Page of Repository
From the Left Panel Click Settings
Under Advanced Click Delete
2 Initialize File Tracking in Project Directory
cd < 𝑝𝑟𝑜𝑗𝑒𝑐𝑡_𝑑𝑖𝑟 >
git init
3 Add All Files to Staging Area
git add -A
To Add Single Files git add 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒1 〉 … 〈𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒𝑛 〉
To Reset Staging Area git reset
Check File Tracking / Commit Status
git status
4 Commit
git commit -m 〈𝑚𝑒𝑠𝑠𝑎𝑔𝑒〉
To Check the Log of Commits git log
5 Push to Master
git remote add origin < 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 >
git push --set-upstream origin master
To Remove Remote Origin git remote remove origin
To Work on Existing Project Repository
git clone < 𝑟𝑒𝑝𝑜_𝑎𝑑𝑑𝑟𝑒𝑠𝑠 >
To Create and Work on a New Branch
To List Existing Branches git branch -a
1 Create a New Branch git checkout -b 〈𝑏𝑟𝑎𝑛𝑐ℎ_𝑛𝑎𝑚𝑒〉
Push to a Newly Created Branch git push --set-upstream origin …
2 Switch Between Branches git checkout 〈𝑏𝑟𝑎𝑛𝑐ℎ_𝑛𝑎𝑚𝑒〉
To Transfer Files btw Branches git checkout < 𝑠𝑟𝑐_𝑏𝑟𝑎𝑛𝑐ℎ > 〈𝑓𝑖𝑙𝑒1 〉 … 〈𝑓𝑖𝑙𝑒𝑛 〉
27
Another Option is GitHub (github.com)
9
Performance Monitoring Tools
9-1- Perf
To get overall count of events:
perf stat -e < 𝑒𝑣𝑒𝑛𝑡1 > ⋯ < 𝑒𝑣𝑒𝑛𝑡𝑛 > < 𝑐𝑜𝑚𝑚𝑎𝑛𝑑 >
To understand where hardware events occur, by sampling events:
Perf record -e < 𝑒𝑣𝑒𝑛𝑡1 > ⋯ < 𝑒𝑣𝑒𝑛𝑡𝑛 > < 𝑐𝑜𝑚𝑚𝑎𝑛𝑑 >
perf report -i perf.data --header
To get the complete list of available events: perf list
cache-misses
cache-reference
Hardware Events
cycles
instructions
Software Events cpu-clock
L1-dcache-load-misses
Hardware Cache L1-dcache-loads
Events LLC-load-misses
LLC-loads
9-2- likwid: perf-ctr and Marker API
CPPFLAGS : -DLIKWID_PERFMON
LDLIB : -likwid
# include <likwid.h>
# include <likwid-marker.h>
…
LIKWID_MARKER_INIT; // Must be called from serial region
…
#pragma omp parallel
{
LIKWID_MARKER_THREADINIT; // Only required if measuring multiple threads
}
…
LIKWID_MARKER_START(“Compute”);
…
LIKWID_MARKER_STOP(“Compute”);
…
LIKWID_MARKER_CLOSE; // Must be called from serial region
likwid-perfctr -C < 𝑝𝑟𝑜𝑐𝑒𝑠𝑠𝑜𝑟𝑠 > -g < 𝑝𝑒𝑟𝑓𝑜𝑟𝑚𝑎𝑛𝑐𝑒 𝑔𝑟𝑜𝑢𝑝𝑠 > -m < 𝑐𝑜𝑚𝑚𝑎𝑛𝑑 >
To get the list of available Performance Groups: likwid-perfctr -a
CACHE Data cache miss rate
FLOPS_DS Double precision 𝑀𝐹 ⁄𝑠
DATA Load to store ratio
L2 L2 cache bandwidth in 𝑀𝐵 ⁄𝑠
L3 L3 cache bandwidth in 𝑀𝐵 ⁄𝑠
MEM Main memory cache bandwidth in 𝑀𝐵 ⁄𝑠
10
Migrating To Windows
10-1- PowerShell
Update PowerShell:
(1) Check the current version using the ‘$PSVersionTable’ environment variable.
(2) Search for the latest version of PowerShell:
winget search Microsoft.PowerShell
(3) Install PowerShell:
winget install --id Microsoft.Powershell --source winget
10-2- Visual Studio Code
Download from visualstudio.com
To customize its behavior:
(1) press ‘Ctrl+Shift+P’, search for ‘settings’ and choose ‘Open User Settings
(JSON)’
(2) To override Windows’ execution policy and enable the PowerShell terminal within
the Visual Studio Code to run ‘.ps1’ scripts, add the following:
"terminal.integrated.env.windows":{"PSExecutionPolicyPreference":"RemoteSigned"}
(3) To change the terminal’s default working directory, add the following:
"terminal.integrated.cwd": "< 𝑝𝑎𝑡ℎ 𝑡𝑜 𝑤𝑜𝑟𝑘𝑖𝑛𝑔 𝑑𝑖𝑟𝑒𝑐𝑡𝑜𝑟𝑦 >"
(4) Other Useful Customizations:
"editor.autoIndent": "none"
"editor.guides.indentation": false
"editor.minimap.enabled": false
"editor.renderControlCharacters": false
"editor.renderWhitespace": "none"
"files.eol": "\n"
"window.restoreWindows": "none"
"window.newWindowDimensions": "inherit"
"workbench.panel.opensMaximized": "always"
"workbench.startupEditor": "none"
Keyboard Shortcuts:
• New terminal panel:
Ctrl+Shift+`
• Switch between terminal panels:
Ctrl + Page Up / Page Down
11
10-3- Miniconda
After installation, open the ‘Anaconda Prompt’ and do:
(1) conda update conda
(2) conda init
Once this is done, an error message will be displayed each time a PowerShell terminal is
opened. The error message regards user’s lack of permission to run ‘profile.ps1’ file
(for more information on the error message see Microsoft’s about_Execution_Policies).
10-4- Windows Subsystem for Linux (WSL)
As an alternative to the Miniconda (and Windows version of packages), WSL lets developers
run a Linux environment.
To install:
wsl --install
To Run:
wsl --cd ~/
To Uninstall:
wsl --unregister
10-5- Rclone
(1) rclone on windows requires Windows File System Proxy (winfsp)
(2) Place a file named ‘rclone.conf’ in rclone directory.
(3) To configure rclone (set password, set cloud account):
rclone config
(4) Mount cloud account:
rclone mount "< 𝑟𝑐𝑙𝑜𝑛𝑒 𝑝𝑟𝑜𝑓𝑖𝑙𝑒 >" "< 𝑝𝑎𝑡ℎ 𝑡𝑜 𝑚𝑜𝑢𝑛𝑡 >"28 --cache-dir
"< 𝑝𝑎𝑡ℎ 𝑡𝑜 𝑐𝑎𝑐ℎ𝑒 >" --vfs-cache-mode full
(5) To unmount:
Ctrl+C
28
Must end with the name of a non-existent directory. rclone will create it and mount the drive in it.
12
10-6- Maintaining and Consuming a Video/Music Library
(1) Make sure none of the files in the directory have spaces in their names. cd into the
directory and use the following command in PowerShell to replace spaces with
underlines:
Get-ChildItem -File | Rename-Item -NewName { $_.Name -replace ' ','_'}
(2) Maintain a list of file names (relative paths) from a desired location:
$paths =(< 𝑝𝑎𝑡ℎ1 >, … , < 𝑝𝑎𝑡ℎ𝑛 > )
$playlists=(< 𝑛𝑎𝑚𝑒1 >, … , < 𝑛𝑎𝑚𝑒𝑛 >)
for($i=0; $i -lt $paths.Length; $i++)
{
$filenames = Get-ChildItem $paths[$i] -Recurse -Name -File
$fullfilenames=@()
foreach ($filename in $filenames)
{
$fullfilenames+=$paths[$i]+$filename
}
$fullfilenames=$fullfilenames | Sort-Object {Get-Random}
echo $fullfilenames > $playlists[$i]
}
(3) In PowerShell, cd to the location of the playlists, use vlc as follows:
$fn=Get-Content < 𝑝𝑙𝑎𝑦𝑙𝑖𝑠𝑡 𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒 >; vlc $fn
Or, use mpv as follows29:
mpv --playlist=< 𝑝𝑙𝑎𝑦𝑙𝑖𝑠𝑡 𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒 > --shuffle --geometry=80%x80%
--no-osc --volume=0
29
mpv's command line options can also be put in a configurations file: in mpv’s directory, create a directory named
‘portable_config’. Inside ‘portable_config’, create a file named ‘mpv.conf’. Put the options in
‘mpv.conf’.
13
Appendix I: make’s Built-in Rules and Variables
To see the complete list of make’s built-in rules and variables:
make --print-data-base
% : %.cc
$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
IMPLICIT
RULES
%.o: %.cc
$(COMPILE.cc) $(OUTPUT_OPTION) $<
(%): %
$(AR) $(ARFLAGS) $@ $<
CXX = g++
VARIABLES
AUTOMATIC
OUTPUT_OPTION = -o $@
AR = ar
ARFLAGS = rv
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
CXXFLAGS
USER DEFINED
CPPFLAGS
VARIABLES
LDFLAGS
LOADLIBES30
LDLIBS
$@ The filename representing the target.
$% The filename element of an archive member specification.
$< The filename of the first prerequisite.
$? The names of all prerequisites that are newer than the target, separated by spaces.
$^ The filenames of all the prerequisites, separated by spaces and duplicates removed.
$+ The filenames of all the prerequisites, separated by spaces and duplicates included.
$∗ The stem of the target filename.
30
Deprecated
14
Appendix II: C/C++ Debugging using ‘gdb’
1 Compile Executable With Flag ‘-g’
2 Start gdb gdb < 𝑒𝑥𝑒𝑐𝑢𝑡𝑎𝑏𝑙𝑒_𝑛𝑎𝑚𝑒 >
To Quit press ‘q’
3 Run the Executable run
To Set a Break Point break < 𝑓𝑖𝑙𝑒𝑛𝑎𝑚𝑒 > : < 𝑙𝑖𝑛𝑒_𝑛𝑢𝑚𝑏𝑒𝑟 >
To See the List of all Break Points info b
To Disable a Break Point disable < 𝑏𝑟𝑒𝑎𝑘_𝑛𝑢𝑚 >
To Enable a Break Point enable < 𝑏𝑟𝑒𝑎𝑘_𝑛𝑢𝑚 >
To Delete Break Points delete < 𝑏𝑟𝑒𝑎𝑘_𝑛𝑢𝑚1 > ⋯ < 𝑏𝑟𝑒𝑎𝑘_𝑛𝑢𝑚𝑛 >
To Delete all Break Points delete
To Execute Code Line by Line step / next
To Execute Rest of the Code continue
To See Neighboring Lines list
To See Values of Variables print < 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒_𝑛𝑎𝑚𝑒 >
15
Appendix III: List of Packages
On Windows, if portable version of software is not provided by the vendor, search portableapps.com.
Cloud Storage Management Scientific Tools
rclone Visualization
Code Statistics h5utils+imagemagic
cloc paraview
Compression visit
gzip Streaming/Recording
pigz OBS Studio
tar Version Control
Environment & Package Manager git
anaconda/miniconda Website Development
Editors & IDEs hugo
gedit
kdevelop
pycharm
vim
Visual Studio Code
GNU Toolchain
g++/gcc/make (build-essential)
gfortran
gnuplot
gsl31
Graphics
blender
Inkscape+textext
LaTex
texlive-full
miktex
texmaker
Media Players
mpv
vlc
Networking
putty
Parallel Computing
OpenACC
OpenMP
OpenMPI (openmpi-bin)
Performance Analysis
hwloc
likwid
perf32
valgrind/ kcachegrind
Readers & Viewers
okular
31
At the time of writing of this document, Install libgsl23/libgslcblas0 (Installed by default on Ubuntu).
32
Install package linux-tools-< 𝑘𝑒𝑟𝑛𝑒𝑙_𝑟𝑒𝑙𝑒𝑎𝑠𝑒 >.
16