IISER Mohali Logo
IISER Mohali Unofficial HPC Guide

Linux Basics

mkdir — Creating Folders

mkdir creates a new folder. Use -p to create a whole nested path in one go. Notice we do ls after each step to see what changed.

# Start — home directory is empty except notes.txt [ms21080@login1 ~]$ ls notes.txt # Create a new folder [ms21080@login1 ~]$ mkdir my_project [ms21080@login1 ~]$ ls my_project notes.txt # Create nested folders in one go with -p [ms21080@login1 ~]$ mkdir -p my_project/run1/output [ms21080@login1 ~]$ cd my_project [ms21080@login1 my_project]$ ls run1 [ms21080@login1 my_project]$ cd run1 [ms21080@login1 run1]$ ls output # Go back home [ms21080@login1 run1]$ cd [ms21080@login1 ~]$

cp — Copying Files and Folders

cp copies a file. To copy a whole folder use -r (recursive).

[ms21080@login1 ~]$ ls my_project input.dat notes.txt # Copy a file (creates a new file alongside original) [ms21080@login1 ~]$ cp input.dat input_backup.dat [ms21080@login1 ~]$ ls my_project input.dat input_backup.dat notes.txt # Copy a file into a folder [ms21080@login1 ~]$ cp input.dat my_project/run1/ [ms21080@login1 ~]$ ls my_project/run1/ input.dat output # Copy a whole folder with -r [ms21080@login1 ~]$ cp -r my_project my_project_backup [ms21080@login1 ~]$ ls my_project my_project_backup input.dat input_backup.dat notes.txt

mv — Moving and Renaming

mv is used for both moving a file to another folder and renaming it. There is no separate rename command in Linux.

[ms21080@login1 ~]$ ls my_project my_project_backup input.dat input_backup.dat # Rename a file — old name is gone, new name appears [ms21080@login1 ~]$ mv input_backup.dat input_v2.dat [ms21080@login1 ~]$ ls my_project my_project_backup input.dat input_v2.dat # Move a file into a folder [ms21080@login1 ~]$ mv input_v2.dat my_project/ [ms21080@login1 ~]$ ls my_project my_project_backup input.dat # Confirm it is now inside my_project [ms21080@login1 ~]$ ls my_project/ run1 input_v2.dat # Rename a folder the same way [ms21080@login1 ~]$ mv my_project_backup old_backup [ms21080@login1 ~]$ ls my_project old_backup input.dat

rm — Deleting Files and Folders

rm deletes a file. To delete a folder and everything inside it use rm -rf.

[ms21080@login1 ~]$ ls my_project old_backup input.dat temp.log # Delete a single file [ms21080@login1 ~]$ rm temp.log [ms21080@login1 ~]$ ls my_project old_backup input.dat # Delete a folder and everything inside it [ms21080@login1 ~]$ rm -rf old_backup [ms21080@login1 ~]$ ls my_project input.dat # old_backup is completely gone
Warning: There is no recycle bin in Linux. Once you run rm the file is gone permanently. Be very careful with rm -rf. Always double check the path before running it.

cat, less, head, tail

CommandWhat it doesBest for
cat file.txtPrints whole file at onceSmall files
less file.txtOpens scrollable viewerLarge files and logs
head file.txtFirst 10 linesQuick peek at file start
head -n 20 file.txtFirst 20 linesCustom line count
tail file.txtLast 10 linesQuick peek at file end
tail -n 50 file.txtLast 50 linesCustom line count
tail -f file.txtFollows file as it grows liveWatching a running job log
Use less for big files: Never use cat on a large file as it will flood your terminal. Use less instead. Press Space to scroll down, b to go back, q to quit.

Example Session

[ms21080@login1 ~]$ ls submit.sh job.out output.dat # Print a small script file [ms21080@login1 ~]$ cat submit.sh #!/bin/bash #PBS -N MyJob #PBS -q short #PBS -l nodes=1:ppn=4 python script.py # Check last few lines of job output [ms21080@login1 ~]$ tail -n 5 job.out Step 980/1000 | Loss: 0.0421 Step 990/1000 | Loss: 0.0398 Step 1000/1000 | Loss: 0.0374 Training complete. Saved to output.dat # Watch a log update live as the job runs # Press Ctrl+C to stop watching (job keeps running) [ms21080@login1 ~]$ tail -f job.out Step 100/1000 | Loss: 0.8231 Step 101/1000 | Loss: 0.8190 Step 102/1000 | Loss: 0.8144 ^C # Check first 5 lines of output file [ms21080@login1 ~]$ head -n 5 output.dat x y energy 0.000000 0.000000 -1042.31 0.100000 0.000000 -1041.98 0.200000 0.000000 -1041.45 0.300000 0.000000 -1040.87

grep — Searching Inside Files

Very useful for finding errors or warnings in long job output files.

# Search for the word "error" in log [ms21080@login1 ~]$ grep "error" job.out FileNotFoundError: input.dat not found # Case insensitive search [ms21080@login1 ~]$ grep -i "warning" job.out Warning: convergence not reached at step 450 WARNING: memory usage above 80% # Show line numbers of matches [ms21080@login1 ~]$ grep -n "Step" job.out 12: Step 1/1000 | Loss: 1.2341 13: Step 2/1000 | Loss: 1.1982

Using nano

nano is a simple text editor that runs inside the terminal. You will mostly use it to edit PBS scripts and config files. It is the easiest terminal editor to learn.

[ms21080@login1 ~]$ ls submit.sh notes.txt # Open an existing file [ms21080@login1 ~]$ nano submit.sh [ nano editor opens — edit your file here ] [ Ctrl+O to save, Ctrl+X to exit ] # Create a brand new file [ms21080@login1 ~]$ nano new_script.sh [ nano creates and opens the new file ] [ms21080@login1 ~]$ ls submit.sh notes.txt new_script.sh
ShortcutWhat it does
Ctrl + O then EnterSave the file
Ctrl + XExit nano
Ctrl + KCut the current line
Ctrl + UPaste the cut line
Ctrl + WSearch for text

Why This Matters

The cluster has storage quotas. If your home or scratch folder fills up, your jobs will fail because they cannot write output files. Check your usage regularly after long runs.

CommandWhat it shows
du -sh *Size of each item in current folder
du -sh .Total size of current folder
du -sh /persistent/data1/ms21080Total size of your main working directory
df -hDisk space used and free on all partitions

Example Session

[ms21080@login1 ~]$ ls md_simulation dft_run1 notes.txt submit.sh # Check size of each item in current folder [ms21080@login1 ~]$ du -sh * 1.2G md_simulation 250M dft_run1 4.0K notes.txt 4.0K submit.sh # Total size of current folder [ms21080@login1 ~]$ du -sh . 1.5G . # Move to your working directory (persistent storage) [ms21080@login1 ~]$ cd /persistent/data1/ms21080/ # Check what is inside [ms21080@login1 ms21080]$ ls AGAIN cellwise_segmentation.C Data HGCAL # Check size of each item [ms21080@login1 ms21080]$ du -sh * 2.1G Data 850M HGCAL 120M AGAIN 4.0K cellwise_segmentation.C # Total usage of your working directory [ms21080@login1 ms21080]$ du -sh . 3.1G . # Overall disk usage on cluster [ms21080@login1 ms21080]$ df -h Filesystem Size Used Avail Use% Mounted on 192.168.12.247:/globalstorage1 102T 67T 30T 70% /persistent/data1 192.168.12.246:/globalstorage2 102T 27T 70T 28% /persistent/data2 10.10.10.248:/flashstorage/home 21T 1.9T 18T 10% /home
Note: If df -h shows scratch at 95% or above, contact the admin.

Connecting to the Cluster

You connect to the cluster using SSH. The login node IP address is 172.16.3.200. You must be on the IISER Mohali network or VPN for this to work.

# Basic SSH login [ms21080@laptop ~]$ ssh ms21080@172.16.3.200 ms21080@172.16.3.200's password: Last login: Mon Jan 13 09:21:14 2025 from 172.16.1.45 [ms21080@login1 ~]$ # SSH with -Y flag (enables graphical apps like xterm, gnuplot) [ms21080@laptop ~]$ ssh -Y ms21080@172.16.3.200 [ms21080@login1 ~]$
When to use -Y: The -Y flag enables X11 forwarding. Use it only if you need to open a graphical window from the cluster on your local screen, for example running a GUI application or plotting tool. For normal terminal work you do not need it.

Recommended for Windows: MobaXterm

If you are on Windows, use MobaXterm. It gives you SSH, a file browser, and drag and drop file transfer all in one program. You do not need to type any scp commands at all.

Download it from mobaxterm.mobatek.net. The free version is enough for all HPC work.

# In MobaXterm, connect like this in the terminal tab MobaXterm$ ssh ms21080@172.16.3.200 # The left panel shows your cluster files automatically # Drag files from Windows Explorer into the panel to upload # Drag files from the panel to your desktop to download
MobaXterm also supports X11 forwarding by default. So graphical apps launched from the cluster will open on your Windows screen automatically without needing the -Y flag.

scp — Copy Files Over SSH

scp works exactly like cp but over SSH. You run it from your local computer, not from inside the cluster. The format is always scp source destination where remote paths include the server address.

# Upload a single file from laptop to your home on cluster [ms21080@laptop ~]$ scp myfile.txt ms21080@172.16.3.200:/home/ms21080/ myfile.txt 100% 512 1.2MB/s 00:00 # Confirm it arrived [ms21080@laptop ~]$ ssh ms21080@172.16.3.200 "ls /home/ms21080/" myfile.txt submit.sh notes.txt projects # Upload a whole folder to scratch (use -r for folders) [ms21080@laptop ~]$ scp -r my_inputs/ ms21080@172.16.3.200:/scratch/ms21080/ input_1.dat 100% 2048 3.1MB/s 00:00 input_2.dat 100% 2048 3.1MB/s 00:00 config.ini 100% 128 0.5MB/s 00:00 # Download a single result file from cluster to current local folder [ms21080@laptop ~]$ scp ms21080@172.16.3.200:/home/ms21080/results.dat . results.dat 100% 8192 4.2MB/s 00:00 # Download a whole folder from cluster to local folder [ms21080@laptop ~]$ scp -r ms21080@172.16.3.200:/scratch/ms21080/run1/ ./local_run1/ output_step1.dat 100% 512KB 2.1MB/s 00:00 output_step2.dat 100% 512KB 2.1MB/s 00:00 job.log 100% 128KB 1.8MB/s 00:00
The dot at the end: The . in a download command means copy it here, into my current local folder. You can replace it with any path like ~/Desktop/ or C:\Users\yourname\Downloads\.

Keyboard Shortcuts

ShortcutWhat it does
TabAutocomplete file or folder name
Tab TabShow all possible completions
Ctrl + CStop the currently running process immediately
Ctrl + ZPause the current process and send it to background
Ctrl + RSearch through command history by typing
Up ArrowGo to previous command
Down ArrowGo forward through history
Ctrl + LClear the terminal screen
Ctrl+C is very useful: If a command is stuck or running too long or you ran the wrong thing, press Ctrl+C to stop it immediately.

Command History

The terminal remembers all your previous commands. You can search and reuse them instead of typing everything again.

# See recent commands [ms21080@login1 ~]$ history 245 cd /scratch/ms21080 246 ls -lh 247 qsub submit.sh 248 qstat -u ms21080 249 tail -f job.out 250 history # Press Ctrl+R and start typing to search history (reverse-i-search)`qsub': qsub submit.sh # Press Enter to run it # Run a specific command from history by its number [ms21080@login1 ~]$ !247 Your job 10521 ("MyJob") has been submitted

A Few More Useful Commands

CommandWhat it does
whoamiPrint your username
echo $HOMEPrint your home directory path
ls *.shList only files ending in .sh
ls run*List all files starting with run
clearClear the terminal screen