CLI tools

There are many utilities available on PSMN clusters.

Bash

Compute jobs launched on clusters are most often initialized by user-written shell scripts. Beyond that, many common operations can be simplified and automated using shell scripts.

For an introduction to shell scripting, you can refer to:

tips & tricks

  • Make sure that your PATH includes /bin and /usr/bin. That is, when you need to add a new path to $PATH, define it as follows :

export PATH=/a/new/path/to/add:$PATH
  • Aliases

The following commands should be placed on your, typically, /home/$USER/.bash_aliases file.

alias l='ls -lF'      # Use long form and classify filetypes (one of */=>@|)
alias la='ls -alF'    # Show hidden files, dot-files
alias lh='ls -lFh'    # Human-readable file sizes
alias lt='ls -lFt'    # sort by time
alias ll='ls -alFth'  # all above :)

alias du1='du -h -d1 .'

alias hgrep='history | grep '  # grep from the bash history

alias pending='squeue --me --states=PENDING --sort=S,Q --format="%.10i %.12P %.8j %.8u %.6D %.4C %.20R %Q %.19S" '  # my pending jobs
alias running='squeue --me --states=RUNNING --format="%.10i %.12P %.8j %.8u %.2t %.10M %.6D %.4C %R %.19e" '  # my running jobs
  • Perform mathematical computation in shell (~/.bashrc functions):

num()
{
    echo $* | bc -l
}
  • Copy a file or directory in multiple destinations (~/.bashrc functions):

mcp()
{
    echo "${*:2}" | xargs -n 1 cp $1
}
  • Fail at first error

Add this line right after the bash shebang (#!/bin/bash). This will abort the script immediately and add robustness to your script.

set -euo pipefail
  • Trap errors

Use the following to trap error and show line number where your script failed to debut at run time or development time:

_failed() {
    echo "$0 - Script failed at line $1"
}

# Trap the ERR
trap '_failed $LINENO' ERR

ShellCheck

For all shell scripts, use shellcheck linter command to find syntax errors, and sometimes bugs. It can also be used online : https://www.shellcheck.net/

Detox

From detox man page:

The detox utility renames files to make them easier to work with. It removes spaces and other such annoyances. It’ll also translate or cleanup Latin-1 (ISO 8859-1) characters encoded in 8-bit ASCII, Unicode characters encoded in UTF-8, and CGI escaped characters in filenames.

iconv

Help converting files from one encoding to another.

Screen & Tmux

screen and tmux are terminal multiplexers. They replace the nohup command, which is banned on PSMN. They are installed on all PSMN clusters. You can use either one, or both, depending on your preferences.

We provide a reference card (pdf), and you can read the Tao of tmux

Some configuration files are also available at /applis/PSMN/debian13/skeletons/ (.screenrc, .tmux.conf)

Reptyr

reptyr is used to re-attach a process, which has been started from another terminal, from the same user, on the same host, to the active terminal.

reptyr is installed on all PSMN clusters.