Linux and department servers: Difference between revisions

From Stat DS Computing Wiki
→Getting Access: (ssh): changed hydra example to leviathan
No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Department Servers]]
[[Category:Remote Server Access]]


The department has two sets of servers, the Leviathans and the Hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing. One can also view the department servers a bit more as a “sandbox” or “playground” as there are very few constraints and it’s okay to not run as polished code as you might on the [[PSC]] or Azure.
{{ScalingSidebar}}


['''Request:''' Windows users (and all users) - if you see comments that are outdated / less helpful than expected please contribute.]
The department has two sets of servers, the Leviathans and the Hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing.  


== What resources exist ==
<div style="background-color: #e8f4f8; border-left: 5px solid #17a2b8; padding: 15px; margin-bottom: 20px; margin-top: 15px; overflow: hidden;">
'''Important: The Sandbox Philosophy'''<br>
Think of the department servers as a “sandbox” or “playground.” There are very few constraints here, making it a great place to learn. It is perfectly fine to run code here that isn't quite polished enough for strict cluster environments like the [[PSC]] or [[Wright GPU Cluster]].
</div>


# The department provides 11 leviathan servers (named {<code>leviathan1</code>, ..., <code>leviathan11</code>}<code>.stat.cmu.edu</code>
['''Request:''' All users - if you see comments that are outdated / less helpful than expected please contribute.]
# Each Leviathan has 16 CPU cores and 128 GB of RAM. The Leviathan CPUs are much faster than the former Hydra CPUs.
# The Hydras and Leviathans all share the same data file system. This allows you to upload a file to any of the servers and then have it on all of them.
# [[OpenMPI]] is installed
#* This allows MPI based parallelization to be used
#* Note that the hydras ARE NOT network connected, so MPI can only be used within a single hydra. It cannot communicate across multiple hydras.
#* If you need to run something in parallel across multiple nodes, you should use [[PSC]] instead.


''See [[what_resources_when| What resources when]] for guides to help decide which resource you should be using.''
== What Resources Exist ==


== Using the servers respectfully ==
# The department provides 11 CPU servers (named <code>leviathan1.stat.cmu.edu</code> through <code>leviathan11.stat.cmu.edu</code>).
Because the servers are a shared department resource it is important to use them respectfully. There are many servers and multiple cores (CPUs) per server. To be respectful of other users:
# The department provides 3 GPU servers (named <code>ghidorah1.stat.cmu.edu</code> through <code>ghidorah3.stat.cmu.edu</code>).
# The Ghidorahs and Leviathans all share the same network-attached data file system. This allows you to upload a file to any single server and instantly access it on all of them.


# '''Check the current usage''' of the server you're on before using it.
''See [[what_resources_when| What resources when]] for guides to help decide which resource you should be using.''
# Do not use '''all''' the cores on a server, and do not use '''all''' the servers at the same time, so others can get work done.
# If you have a long-running job, '''deprioritize it''' so others can run too.
 
Each of these is easy to check.
 
=== Checking current usage ===
To check which servers are currently being used and which are open, see the [https://info.stat.cmu.edu/grafana/d/beuw1q6y3dgjkc/hydra-cluster?orgId=1 Grafana dashboard for the hydras] and [https://info.stat.cmu.edu/grafana/d/asjkldfbnvajdsfh213/leviathan-cluster?orgId=1 for the Leviathans]. It lists them all and their current usage.
 
When you're logged in to one node, you can use the <code>top</code> command. <code>top</code> displays the current usage of the server’s resources with a list of jobs run. It also tells you the percentage of the cores that are being used and the amount of RAM (memory) that is available. See [https://www.howtogeek.com/668986/how-to-use-the-linux-top-command-and-understand-its-output/ howtogeek] resources on how to interpret it all (the documentation is very clean, so we encourage you to read up ther
 
=== Limiting the cores you use ===
We recommend that when using parallel processing, use fewer than the total number of cores on the server. Most parallel processing packages let you choose the number of cores to use; the hydras have 12, so pick something smaller.


=== Deprioritize when possible ===
== Getting Access (SSH) ==
<code>nice/renice</code> allows you to lower the priority of your jobs, so the operating system lets other processes run first. See [https://www.howtogeek.com/411979/how-to-set-process-priorities-with-the-nice-and-renice-commands-in-linux/ howtogeek] resources on the basics. <code>nice</code> sets the priority, and <code>renice</code> updates your priority. On the department servers, everyone starts at the same priority, and you can only '''deprioritize''' your jobs -- you can't make them higher priority than everyone else.<syntaxhighlight lang="bash">nice -20 Rscript some-big-script.R
renice -n 20 processid # get the process ID from top</syntaxhighlight>
== Introduction to connecting to the server and useful Linux commands ==


The department servers all run Linux, and require you to use a command line to interact with it (as compared to Rstudio and other GUIs).
The department servers all run Linux and require you to interact with them remotely. To execute code, you’ll need to access them through <code>ssh</code>. Modern operating systems (Mac, Linux, and Windows 10/11) have this tool built-in natively.
=== Getting Access: (<code>ssh</code>) ===


To get onto the server and type code you’ll need to access it through <code>ssh</code>.
* '''Mac / Linux:''' Open up your <code>Terminal</code>.
* '''Windows:''' Open up <code>Windows PowerShell</code> or <code>Windows Terminal</code>.


<ul>
In your terminal, type:
<li>For Macs (and Linux), open up a <code>terminal</code> and type  
<syntaxhighlight lang="bash">ssh andrew_id@leviathan1.stat.cmu.edu</syntaxhighlight>
<syntaxhighlight lang="bash">ssh andrew_id@leviathan1.stat.cmu.edu</syntaxhighlight>


you will then have to type in your password (if you don’t know it or don’t know it or have never accessed the server before - email [mailto:remarks@stat.cmu.edu remarks@stat.cmu.edu]).
You will be prompted to type in your password. (Note: as you type, no characters will appear on the screen for security reasons. Just type it and hit Enter). If you don’t know your password or have never accessed the server before, email [mailto:remarks@stat.cmu.edu remarks@stat.cmu.edu].
</li>
<li>
For Windows, there's a few options (with different pros and cons). [https://www.makeuseof.com/tag/4-easy-ways-to-use-ssh-in-windows/ Makeuseof] provides an overview and introduction to how to get started on a few approaches, including PuTTY and Windows PowerShell.  


Again, make sure to email [mailto:remarks@stat.cmu.edu remarks@stat.cmu.edu] to check that you have an account / or what your password is if you forgot.
=== Passwordless SSH (Highly Recommended) ===
</li>
To connect to the server without typing in your password every time, you need to generate an SSH key pair.  
</ul>
If you’re accessing the servers a lot, you might also look into aliases and password storing for the <code>ssh</code> commands. - Mac/Linux: [https://scotch.io/tutorials/how-to-create-an-ssh-shortcut scotch.io] - Windows: Powershell: [https://docs.microsoft.com/en-us/windows/terminal/tutorials/ssh microsoft], PuTTY: [https://www.makeuseof.com/tag/4-easy-ways-to-use-ssh-in-windows/ makeuseof]


=== Passwordless ssh ===
# Check whether you already have a key pair by looking in your <code>.ssh</code> folder (run <code>ls ~/.ssh</code> on Mac/Linux, or <code>dir ~\.ssh</code> on Windows). If you see <code>id_ed25519</code> or <code>id_rsa</code>, you can skip to step 3.
To get on the server without typing in the password, you need to first generate a SSH key pair. This creates a private key that identifies your laptop, and a public key that the servers can use to recognize your private key.
# To generate a new key pair, run: <syntaxhighlight lang="bash">ssh-keygen -t ed25519</syntaxhighlight> Hit Enter to accept the default file location. You can enter a passphrase for extra security or leave it empty for true passwordless login.
# Upload the public key to the remote server (you only need to do this once since the servers share a file system).
#* '''For Mac/Linux:''' <br><code><syntaxhighlight lang="bash">ssh-copy-id andrew_id@leviathan1.stat.cmu.edu</syntaxhighlight></code>
#* '''For Windows:''' Windows does not natively include <code>ssh-copy-id</code>. Use this PowerShell one-liner instead:<br><code><syntaxhighlight lang="powershell">Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub" | ssh andrew_id@leviathan1.stat.cmu.edu "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"</syntaxhighlight></code>
# Finally, log into the server normally and run the following to enforce strict permissions:
# <syntaxhighlight lang="bash">
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
</syntaxhighlight>


* For Linux or Mac, open up a terminal and check whether you already have a key pair: run <code>ls ~/.ssh</code> and see if you have any files with names starting <code>id_</code>. If you do, you already have a key pair, and you can skip to the <code>ssh-copy-id</code> step below.
== File Sharing & Management ==
* Next, generate a key pair (both public and private key). There are different types of keys (RSA, ECDSA, and Ed25519). The <code>-t</code> option specifies the type of key pair.
ssh-keygen -t ed25519
* A prompt for what to name the key pair and what folder to place it in should appear. The username should be the username for your local computer and <code>id_ed25519</code> is the key pair name. You can change it. The local key should be stored in the <code>~/.ssh</code> folder on your local computer.
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/username/.ssh/id_ed25519):
* Hit Enter to accept the default name and location, or enter the folder and name manually.
* A prompt for a passphrase should appear. This is for securing the local key (on local computer) and is optional. <code>Enter Passphrase (empty for no passphrase):</code>


* Make sure there is a <code>~/.ssh</code> folder on the server. If not, make a .ssh folder.
There are two primary ways to move files between your personal computer and the server.
* Next, upload the public key to remote server. This command will upload the public key to all the hydras and ghidorahs since they share a file system.
ssh-copy-id andrew_id@leviathan1.stat.cmu.edu
* To ensure the permissions of the <code>~/.ssh</code> directory are updated, log into the hydras and run:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
You should now be able to SSH into the server without being prompted for a password.


=== File sharing (<code>scp</code> +) ===
=== Command Line (<code>scp</code>) ===
The <code>scp</code> (secure copy) command works identically across Mac, Linux, and Windows PowerShell.


There is also command line code to copy files from your personal computer to the server. This is done with a SCP (secure copy) tool. There are also GUIs (graphical user interfaces) that allow you to “drag and drop” files from your computer to the server (and visa-versa). Currently, a lot of students use GUIs to deal with file sharing.
{| style="width: 100%; border-collapse: collapse; margin-bottom: 10px;"
|-
! style="width: 50%; background-color: #d4edda; color: #155724; padding: 10px; text-align: left;" | Strengths
! style="width: 50%; background-color: #f8d7da; color: #721c24; padding: 10px; text-align: left;" | Weaknesses
|- style="vertical-align: top; background-color: #f8f9fa;"
| style="padding: 15px; border-right: 2px solid white;" |
* '''Fast and Native:''' Requires no additional software installations.
* '''Scriptable:''' Can be built into bash scripts to automate backing up data.
| style="padding: 15px;" |
* '''Syntax Heavy:''' Easy to forget the exact command structure or path names.
* '''No Visual Feedback:''' Doesn't offer a traditional file-explorer view of the remote server.
|}


==== Command line <code>scp</code>====
'''From server to your computer:'''
<syntaxhighlight lang="bash">scp andrew_id@leviathan1.stat.cmu.edu:/path/to/remote/file.txt /local/directory/</syntaxhighlight>
*(To copy an entire folder, add the <code>-r</code> flag right after <code>scp</code>).*


You can file share either by using <code>scp</code>, for example
'''From your computer to the server:'''
<syntaxhighlight lang="bash">scp /local/file.txt andrew_id@leviathan1.stat.cmu.edu:/remote/directory/</syntaxhighlight>


<ol>
=== GUI "Drag-and-Drop" Tools ===
  <li> Mac/Linux: This command is very similar to <code>cp</code> (the file copier).
Many students prefer graphical interfaces to transfer files.
  <ol>
    <li>Copy from server
    <syntaxhighlight lang="bash"> scp username@from_host:path/to/file.txt /local/directory/ </syntaxhighlight>
    <syntaxhighlight lang="bash">scp -r username@from_host:path/to/folder/ local/directory/</syntaxhighlight>
    </li>
    <li>Copy to server
    &nbsp;
<syntaxhighlight lang="bash"> scp local/file.txt username@to_host:/remote/directory/</syntaxhighlight>
<syntaxhighlight lang="bash"> scp -r local/directory/ username@to_host:/remote/directory/</syntaxhighlight>
    </li>
  </ol>
 


<code>scp</code> references: [https://haydenjames.io/linux-securely-copy-files-using-scp/ haydenjames.io]
* '''Visual Studio Code (Recommended):''' If you use the VS Code Remote-SSH extension, you can simply drag and drop files from your laptop directly into the VS Code file explorer pane.
 
* '''Mac:''' [https://cyberduck.io/ Cyberduck] remains a solid dedicated tool.
</li>
* '''Windows:''' [https://winscp.net/eng/download.php WinSCP] is a popular dedicated GUI (legacy SSH clients like PuTTY are no longer necessary).
  <li>Windows: Again, this process is a bit more complicated.
  <ol>
    <li>A PuTTY + Command Prompt provides a version that is very similar to Mac/Linux <code>scp</code> (reference: [https://success.tanaza.com/s/article/How-to-use-SCP-command-on-Windows tanaza]), and requires minor changes in the call&nbsp;&nbsp;(<code>pscp -scp</code> instead of <code>scp)</code>. </li>
    <li>A Powershell specific command is a bit more complicated / not similar to Mac/Linux <code>scp</code> (reference: [https://www.nsoftware.com/kb/articles/psserver-scp.rst nsoftware]) </li>
  </ol>
  </li>
</ol>


=== &nbsp;GUI “drag-and-drop” file sharing ===
== Basic Linux Command Line (Bash) ==
A '''lot''' of students use '''GUI''' interfaces to transfer files instead of <code>scp</code> command line. These tools allow you to “drag and drop” files from one location to another after the connection is set up.


Some examples include:
Understanding the basic Linux command line is crucial for navigating the servers. Use <code>man _command_</code> to get the manual for any command.


<ol>
{| class="wikitable" style="width: 100%; text-align: left;"
<li>Mac:
|-
  <ol><li>
! Command !! Translation !! Example Usage
  [https://cyberduck.io/ Cyberduck]
|-
  </li></ol></li>
| <code>pwd</code> || Print working directory || Shows exactly where you are in the file system.
<li>Linux:
  <ol><li>
  [https://www.openssh.com/ OpenSSH]
  </li></ol></li>
<li> Windows: lots of options - [https://www.thegeekstuff.com/2011/06/windows-sftp-scp-clients/ thegeekstuff]
  <ol>
    <li>[https://www.putty.org/ PuTTY] </li>
    <li>[https://winscp.net/eng/download.php WinSCP] </li></ol>
</li>
</ol>
=== Basic CLI (Linux command line): <code>bash</code>===
 
Understanding the basic Linux command line is important to be able to navigate when you are actually on the server. Below are some based commands to move around the file system, manipulate files, and view storage structure.
 
{| class="wikitable"
|-
|-
! command
| <code>ls _dir_</code> || List files || <code>ls -l</code> shows file permissions and sizes.
! translation
|-
|-
| <code>pwd</code>
| <code>cd _dir_</code> || Change directory || <code>cd ..</code> moves you up one folder.
| print the current working directory
|-
|-
| <code>cd _dir_</code>
| <code>rm _file_</code> || Remove / delete file || <code>rm -r _folder_</code> deletes an entire directory. '''(Irreversible!)'''
| change directory
|-
|-
| <code>rm _file_</code>
| <code>mv _file_ _dir_</code> || Move / rename file || <code>mv data.csv ./cleaned_data.csv</code>
| remove / delete file
|-
|-
| <code>mv _file_ _dir_</code>
| <code>cp _file_ _dir_</code> || Copy file || <code>cp script.R backup_script.R</code>
| move file (can change name)
|-
|-
| <code>cp _file_ _dir_</code>
| <code>chmod _perms_ _file_</code> || Change permissions || <code>chmod +x script.sh</code> makes a script executable.
| copy file
|-
|-
| <code>ls _dir_</code>
| <code>sed</code> || Stream editor || <code>sed -i 's/old/new/g' file.txt</code> replaces text inside a file automatically.
| list files in directory
|}
|}


use <code>man _command_</code> to get a listing / manual of the command.
For a deeper dive into shell scripting and Linux environments, we recommend the [http://www.jarrodmillman.com/rcsds/standard/bash.html UCB reproducible DS lecture notes] or the [https://tldp.org/LDP/Bash-Beginners-Guide/html/ Linux Documentation Project Bash Guide].
 
== Text Editors and IDEs for writing code on the servers==
 
Historically, editing code on a server required terminal-based text editors. While still useful, modern tools allow you to use a full graphical IDE on your laptop that computes natively on the server.
 
=== Visual Studio Code (Highly Recommended) ===
[https://code.visualstudio.com/ Visual Studio Code] is the industry standard for remote development.
 
# Install VS Code on your personal machine.
# Go to the Extensions tab and install '''Remote - SSH'''.
# Click the green remote indicator in the bottom-left corner, select "Connect to Host...", and type <code>andrew_id@leviathan1.stat.cmu.edu</code>.
# Once connected, you can edit scripts, run interactive terminal sessions, and drag-and-drop files exactly as if they were on your laptop.
 
=== Terminal Editors ===
If you only need to make a quick tweak to a file while already logged into the terminal:
 
{| style="width: 100%; border-collapse: collapse; margin-bottom: 10px;"
|-
! style="width: 50%; background-color: #f8f9fa; border: 1px solid #dee2e6; padding: 10px; text-align: left;" | nano
! style="width: 50%; background-color: #f8f9fa; border: 1px solid #dee2e6; padding: 10px; text-align: left;" | vim
|- style="vertical-align: top;"
| style="padding: 15px; border: 1px solid #dee2e6;" |
A very simple, beginner-friendly text editor. Commands are listed at the bottom of the screen.
* Type <code>nano _filename_</code> to open.
* Use <code>Ctrl+O</code> to save (Write Out).
* Use <code>Ctrl+X</code> to exit.
| style="padding: 15px; border: 1px solid #dee2e6;" |
A highly powerful, ubiquitous editor with a steep learning curve.
* Type <code>vim _filename_</code> to open.
* Press <code>i</code> to enter Insert Mode (to type).
* Press <code>Esc</code> then type <code>:wq</code> to save and quit.
|}
 
== Using the Servers Respectfully ==
 
Because the servers are a shared department resource, it is critical to use them considerately.
 
<div style="background-color: #fff3cd; border-left: 5px solid #ffc107; padding: 15px; margin-bottom: 20px; margin-top: 15px;">
'''The Golden Rules of Shared Servers:'''<br>
1. '''Check current usage''' before launching massive scripts.<br>
2. '''Do not use all the cores''' on a single server.<br>
3. '''Do not use all the servers''' at the exact same time.<br>
4. '''Deprioritize long jobs''' so active users aren't frozen out.
</div>
 
=== 1. Checking Current Usage ===
Check the [https://util.stat.cmu.edu/grafana/d/beuw1q6y3dgjkc/hydra-cluster?orgId=1&from=now-6h&to=now&timezone=browser Grafana dashboard for the Hydras] and the [https://util.stat.cmu.edu/grafana/d/asjkldfbnvajdsfh213/leviathan-cluster?orgId=1&from=now-6h&to=now&timezone=browser Grafana dashboard for the Leviathans] to see active usage across all nodes.
 
Once logged into a specific node, run the <code>top</code> command. This displays the percentage of cores being used, available RAM, and a list of running jobs. Press <code>q</code> to exit <code>top</code>. (See [https://www.howtogeek.com/668986/how-to-use-the-linux-top-command-and-understand-its-output/ this HowToGeek guide] for interpreting the output).
 
=== 2. Limiting Your Cores ===
When using parallel processing packages, explicitly set the number of cores to less than the server's maximum. For example, the hydras have 12 cores—hardcode your script to use 8 or fewer so the OS has room to breathe.
 
=== 3. Deprioritize When Possible (nice/renice) ===
<code>nice</code> allows you to lower the priority of your jobs, telling the OS to let other processes run first. Everyone starts at the same priority level, and you can only '''deprioritize''' your own jobs.
 
<syntaxhighlight lang="bash">
# Start a new job with lowered priority
nice -20 Rscript some-big-script.R
 
# Lower the priority of a job that is already running
renice -n 20 processid # get the process ID from the 'top' command
</syntaxhighlight>


Additional resources that capture more information on the command line and are still geared to statistical computing can be found here: [http://www.jarrodmillman.com/rcsds/standard/bash.html UCB 2015 reproducible DS lecture notes].
=== 4. Using <code>/scratch</code> for Heavy Data ===
<div style="background-color: #f8d7da; border-left: 5px solid #dc3545; padding: 15px; margin-bottom: 20px; margin-top: 15px; overflow: hidden;">
'''CRITICAL: Do not run heavy Read/Write jobs from your Home directory!'''<br>
Your home directory lives on a central network-attached storage (NAS) drive. If you read/write massive datasets directly to <code>~</code>, you will bottleneck the network and slow down operations (even basic SSH access) for '''every single user across all servers'''.
</div>


'''TODO: add information about <code>sed</code>, <code>chmod</code>, and a link to bash files.'''
Instead, use the <code>/scratch</code> folder. This folder points to a local, lightning-fast SSD specific to the server you are currently logged into.  


== Text editors ==
'''How to use <code>/scratch</code>:'''
<syntaxhighlight lang="bash">
cd /scratch
mkdir andrew_id_data # Create a folder for yourself
cd andrew_id_data
# Move your data here and run your heavy I/O scripts!
</syntaxhighlight>


There are multiple options to view code on the server side. They include:
'''Important Caveats for <code>/scratch</code>:'''
* It is specific to the node you are on (<code>leviathan1</code>'s scratch is different from <code>leviathan2</code>'s scratch).
* It is strictly for temporary runtime storage. '''Do not use it for long-term storage.'''
* Space is limited. Delete your files when your script finishes running.


*vim
== Running Jobs & Multiplexers ==
*… [to be added later]


== Running jobs ==
If you start a script over standard SSH and close your laptop, the connection breaks and your job is instantly killed.


We have included thoughts about running jobs in two places.
To run jobs that persist after you disconnect, you must use a '''terminal multiplexer''' like <code>tmux</code> or <code>screen</code>. These tools create a virtual session on the server that keeps running in the background.


#The first looks at tools that allow you to keep running jobs on the server when you close the connection to the server (turn off your laptop, etc.). These tools are call [[Terminal_multiplexers|terminal multiplexers]].&nbsp;
* Start a new session: <code>tmux new -s my_analysis</code>
#The second set of tools focus on how to run your [[R_on_the_server|R analysis]] or [[Python_on_the_server|Python analysis]] code on the server.
* Detach (leave it running in background): Press <code>Ctrl+b</code>, release, then press <code>d</code>
* Reattach later: <code>tmux attach -t my_analysis</code>


== Server specs ==
For language-specific guides on running batch analyses, see our dedicated pages for [[R_on_the_server|R analysis]] and [[Python_on_the_server|Python analysis]]. For more advanced multiplexer features, see [[terminal multiplexers]].


Generally speaking, our servers have multiple CPU cores, but no GPU cores. For deep learning tasks that need GPUs, consider using the [[GPU Cluster|GPU cluster]].
== Server Specs ==


To examine the specs yourself, use
Our servers have multiple CPU cores, but only the ghidorah servers have GPU cores. For deep learning tasks that require GPUs, consider using the [[GPU Cluster]].
<syntaxhighlight lang="bash">cat /proc/meminfo
cat /proc/cpuinfo</syntaxhighlight>


to see some information.
To check the hardware specifications of the server you are currently logged into, run:
<syntaxhighlight lang="bash">
cat /proc/cpuinfo # View processor details and core counts
cat /proc/meminfo # View RAM and memory allocation
</syntaxhighlight>

Latest revision as of 21:32, 24 August 2026


Scaling Checklist
Back to Beginner's Guide

The department has two sets of servers, the Leviathans and the Hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing.

Important: The Sandbox Philosophy
Think of the department servers as a “sandbox” or “playground.” There are very few constraints here, making it a great place to learn. It is perfectly fine to run code here that isn't quite polished enough for strict cluster environments like the PSC or Wright GPU Cluster.

[Request: All users - if you see comments that are outdated / less helpful than expected please contribute.]

What Resources Exist

  1. The department provides 11 CPU servers (named leviathan1.stat.cmu.edu through leviathan11.stat.cmu.edu).
  2. The department provides 3 GPU servers (named ghidorah1.stat.cmu.edu through ghidorah3.stat.cmu.edu).
  3. The Ghidorahs and Leviathans all share the same network-attached data file system. This allows you to upload a file to any single server and instantly access it on all of them.

See What resources when for guides to help decide which resource you should be using.

Getting Access (SSH)

The department servers all run Linux and require you to interact with them remotely. To execute code, you’ll need to access them through ssh. Modern operating systems (Mac, Linux, and Windows 10/11) have this tool built-in natively.

  • Mac / Linux: Open up your Terminal.
  • Windows: Open up Windows PowerShell or Windows Terminal.

In your terminal, type:

ssh andrew_id@leviathan1.stat.cmu.edu

You will be prompted to type in your password. (Note: as you type, no characters will appear on the screen for security reasons. Just type it and hit Enter). If you don’t know your password or have never accessed the server before, email remarks@stat.cmu.edu.

Passwordless SSH (Highly Recommended)

To connect to the server without typing in your password every time, you need to generate an SSH key pair.

  1. Check whether you already have a key pair by looking in your .ssh folder (run ls ~/.ssh on Mac/Linux, or dir ~\.ssh on Windows). If you see id_ed25519 or id_rsa, you can skip to step 3.
  2. To generate a new key pair, run:
    ssh-keygen -t ed25519
    Hit Enter to accept the default file location. You can enter a passphrase for extra security or leave it empty for true passwordless login.
  3. Upload the public key to the remote server (you only need to do this once since the servers share a file system).
    • For Mac/Linux:
      ssh-copy-id andrew_id@leviathan1.stat.cmu.edu
    • For Windows: Windows does not natively include ssh-copy-id. Use this PowerShell one-liner instead:
      Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub" | ssh andrew_id@leviathan1.stat.cmu.edu "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  4. Finally, log into the server normally and run the following to enforce strict permissions:
  5. chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys

File Sharing & Management

There are two primary ways to move files between your personal computer and the server.

Command Line (scp)

The scp (secure copy) command works identically across Mac, Linux, and Windows PowerShell.

Strengths Weaknesses
  • Fast and Native: Requires no additional software installations.
  • Scriptable: Can be built into bash scripts to automate backing up data.
  • Syntax Heavy: Easy to forget the exact command structure or path names.
  • No Visual Feedback: Doesn't offer a traditional file-explorer view of the remote server.

From server to your computer:

scp andrew_id@leviathan1.stat.cmu.edu:/path/to/remote/file.txt /local/directory/
  • (To copy an entire folder, add the -r flag right after scp).*

From your computer to the server:

scp /local/file.txt andrew_id@leviathan1.stat.cmu.edu:/remote/directory/

GUI "Drag-and-Drop" Tools

Many students prefer graphical interfaces to transfer files.

  • Visual Studio Code (Recommended): If you use the VS Code Remote-SSH extension, you can simply drag and drop files from your laptop directly into the VS Code file explorer pane.
  • Mac: Cyberduck remains a solid dedicated tool.
  • Windows: WinSCP is a popular dedicated GUI (legacy SSH clients like PuTTY are no longer necessary).

Basic Linux Command Line (Bash)

Understanding the basic Linux command line is crucial for navigating the servers. Use man _command_ to get the manual for any command.

Command Translation Example Usage
pwd Print working directory Shows exactly where you are in the file system.
ls _dir_ List files ls -l shows file permissions and sizes.
cd _dir_ Change directory cd .. moves you up one folder.
rm _file_ Remove / delete file rm -r _folder_ deletes an entire directory. (Irreversible!)
mv _file_ _dir_ Move / rename file mv data.csv ./cleaned_data.csv
cp _file_ _dir_ Copy file cp script.R backup_script.R
chmod _perms_ _file_ Change permissions chmod +x script.sh makes a script executable.
sed Stream editor sed -i 's/old/new/g' file.txt replaces text inside a file automatically.

For a deeper dive into shell scripting and Linux environments, we recommend the UCB reproducible DS lecture notes or the Linux Documentation Project Bash Guide.

Text Editors and IDEs for writing code on the servers

Historically, editing code on a server required terminal-based text editors. While still useful, modern tools allow you to use a full graphical IDE on your laptop that computes natively on the server.

Visual Studio Code (Highly Recommended)

Visual Studio Code is the industry standard for remote development.

  1. Install VS Code on your personal machine.
  2. Go to the Extensions tab and install Remote - SSH.
  3. Click the green remote indicator in the bottom-left corner, select "Connect to Host...", and type andrew_id@leviathan1.stat.cmu.edu.
  4. Once connected, you can edit scripts, run interactive terminal sessions, and drag-and-drop files exactly as if they were on your laptop.

Terminal Editors

If you only need to make a quick tweak to a file while already logged into the terminal:

nano vim

A very simple, beginner-friendly text editor. Commands are listed at the bottom of the screen.

  • Type nano _filename_ to open.
  • Use Ctrl+O to save (Write Out).
  • Use Ctrl+X to exit.

A highly powerful, ubiquitous editor with a steep learning curve.

  • Type vim _filename_ to open.
  • Press i to enter Insert Mode (to type).
  • Press Esc then type :wq to save and quit.

Using the Servers Respectfully

Because the servers are a shared department resource, it is critical to use them considerately.

The Golden Rules of Shared Servers:
1. Check current usage before launching massive scripts.
2. Do not use all the cores on a single server.
3. Do not use all the servers at the exact same time.
4. Deprioritize long jobs so active users aren't frozen out.

1. Checking Current Usage

Check the Grafana dashboard for the Hydras and the Grafana dashboard for the Leviathans to see active usage across all nodes.

Once logged into a specific node, run the top command. This displays the percentage of cores being used, available RAM, and a list of running jobs. Press q to exit top. (See this HowToGeek guide for interpreting the output).

2. Limiting Your Cores

When using parallel processing packages, explicitly set the number of cores to less than the server's maximum. For example, the hydras have 12 cores—hardcode your script to use 8 or fewer so the OS has room to breathe.

3. Deprioritize When Possible (nice/renice)

nice allows you to lower the priority of your jobs, telling the OS to let other processes run first. Everyone starts at the same priority level, and you can only deprioritize your own jobs.

# Start a new job with lowered priority
nice -20 Rscript some-big-script.R

# Lower the priority of a job that is already running
renice -n 20 processid # get the process ID from the 'top' command

4. Using /scratch for Heavy Data

CRITICAL: Do not run heavy Read/Write jobs from your Home directory!
Your home directory lives on a central network-attached storage (NAS) drive. If you read/write massive datasets directly to ~, you will bottleneck the network and slow down operations (even basic SSH access) for every single user across all servers.

Instead, use the /scratch folder. This folder points to a local, lightning-fast SSD specific to the server you are currently logged into.

How to use /scratch:

cd /scratch
mkdir andrew_id_data # Create a folder for yourself
cd andrew_id_data
# Move your data here and run your heavy I/O scripts!

Important Caveats for /scratch:

  • It is specific to the node you are on (leviathan1's scratch is different from leviathan2's scratch).
  • It is strictly for temporary runtime storage. Do not use it for long-term storage.
  • Space is limited. Delete your files when your script finishes running.

Running Jobs & Multiplexers

If you start a script over standard SSH and close your laptop, the connection breaks and your job is instantly killed.

To run jobs that persist after you disconnect, you must use a terminal multiplexer like tmux or screen. These tools create a virtual session on the server that keeps running in the background.

  • Start a new session: tmux new -s my_analysis
  • Detach (leave it running in background): Press Ctrl+b, release, then press d
  • Reattach later: tmux attach -t my_analysis

For language-specific guides on running batch analyses, see our dedicated pages for R analysis and Python analysis. For more advanced multiplexer features, see terminal multiplexers.

Server Specs

Our servers have multiple CPU cores, but only the ghidorah servers have GPU cores. For deep learning tasks that require GPUs, consider using the GPU Cluster.

To check the hardware specifications of the server you are currently logged into, run:

cat /proc/cpuinfo # View processor details and core counts
cat /proc/meminfo # View RAM and memory allocation