A catch-all of practical pointers for working on the lab servers and the LRZ cluster. Most items are one-liners that have saved time at some point. See Basic Linux Commands for the absolute basics, and LRZ Cloud Computing for cluster-specific details.
Long-running jobs
- Interactive sessions — never run a multi-hour command in a plain SSH session; if the connection drops, the job dies. Wrap it in
tmux(orscreen). See tmux for the basics. - Batch jobs — on LRZ, use SLURM (
sbatch) and array jobs for multi-subject pipelines. The canonical pattern is in 2.3 fmriPrep with Docker (search for--array=). On lab workstations, atmuxsession is usually enough.
Neurocommand in the Linux Cluster
Install a container
bash containers.sh fmriprepThis prompts for the version you want. Example offer:
| fmriprep | 24.1.0 | 20241003 | functional imaging,workflows | Run:
--------------------------------------------------------------------
./local/fetch_containers.sh fmriprep 24.1.0 20241003
Pin versions deliberately and record them in Software Versions so analyses stay reproducible.
Build your own Apptainer / Singularity image
Prefer build over pull — it is more reliable on slow or interrupted networks:
# Workstation (Apptainer)
apptainer build $CONTAINER_DIR/fitlins-<VER>.sif docker://poldracklab/fitlins:<VER>
# LRZ cluster (Singularity — same flags)
singularity build $CONTAINER_DIR/fitlins-<VER>.sif docker://poldracklab/fitlins:<VER>Always pass --cleanenv when you run or exec the resulting .sif; otherwise host env vars (locale, PYTHONPATH, etc.) leak in and cause confusing failures.
Apptainer tips
- Cache location. Pulled and built layers live in
~/.apptainer/cache(or~/.singularity/cache). On LRZ,$HOMEis small — override withexport APPTAINER_CACHEDIR=$DSS_DIR/apptainer-cachebefore building. - Clean the cache when it grows:
apptainer cache listthenapptainer cache clean. - Bind mounts. Use
-B host:container[:ro]:apptainer run --cleanenv \ -B $BIDS_DIR:/data:ro \ -B $DERIVS_DIR:/out \ -B $FS_LICENSE:/opt/freesurfer/license.txt \ $CONTAINER_DIR/fmriprep-<VER>.sif /data /out participant - Why
--cleanenv. Containers should be reproducible.--cleanenvstrips host environment variables so the container sees only what you explicitly export viaAPPTAINERENV_*(orSINGULARITYENV_*on LRZ).
Disk hygiene
Cluster quotas are real. Audit before deleting.
du -sh */ | sort -hr | head -20 # top-20 largest direct subdirs
ncdu . # interactive disk usage browser
df -h /dss /scratch ~ # see quota / free space per filesystemWarning
Never run
rm -rfagainst a/dss/path without first doing a dry run. A safe pattern:find . -name '<pattern>' -printfirst, then re-run with-deleteonce you have confirmed the list.
Permissions and ACLs for shared lab folders
chgrp -R <lab-group> /dss/<project>/shared # set group ownership
chmod -R g+rwX,o-rwx /dss/<project>/shared # group can read/write; others none
chmod g+s /dss/<project>/shared # new files inherit the groupThe capital X in g+rwX adds execute only to directories — exactly what you want for a mixed file tree.
Symlinks for shared datasets
Avoid copying large BIDS datasets into every user’s home. Link instead:
ln -s /dss/<project>/bids ~/bids
ln -s /dss/<project>/derivatives ~/derivativesScripts that read $HOME/bids then work for everyone without bloating quotas.
TemplateFlow cache (share across users)
Many tools (fMRIPrep, MRIQC, FitLins) pull templates from TemplateFlow on first run. Point everyone at the same cache so it is fetched once:
export TEMPLATEFLOW_HOME=/dss/<project>/shared/templateflow
# Inside containers (workstation)
export APPTAINERENV_TEMPLATEFLOW_HOME=$TEMPLATEFLOW_HOME
# Inside containers (LRZ / Singularity)
export SINGULARITYENV_TEMPLATEFLOW_HOME=$TEMPLATEFLOW_HOMEFreeSurfer license
fMRIPrep and several other tools require a FreeSurfer license.txt. Lab convention:
export FS_LICENSE=$HOME/license.txt
# bind into the container
apptainer run --cleanenv -B $FS_LICENSE:/opt/freesurfer/license.txt ...Warning
Never commit
license.txtto git. Add it to.gitignorein any analysis repo and keep the file mode at0600.
Common gotchas
- Windows line endings in scripts you edited on a laptop cause cryptic
bad interpretererrors. Fix withdos2unix script.sh. - SSH key permissions.
~/.ssh/id_*must bechmod 600; otherwisesshrefuses to use the key. - Locale issues in older containers (
perl: warning: Setting locale failed). The cheap workaround isexport LC_ALL=C(orAPPTAINERENV_LC_ALL=C) before the run. - Confound selection — see 5.2 Confound Selection when copy-pasting columns between fMRIPrep versions; column names occasionally change.
Where to ask for help
- Lab Slack
#fmri-helpchannel — first stop for “is this normal?” questions. - Tool-specific bugs go to GitHub issues on the relevant project (fMRIPrep, MRIQC, FitLins, …). Include the exact version from Software Versions.
- LRZ servicedesk for cluster-side problems (quota, broken modules, partition queues).