Linux Essentials for Mathematics Students

🟒 FOUNDATIONAL LEVEL | Prerequisites: None | Time: 2-3 hours | For: Mathematics students new to command-line interfaces

Why Linux for Mathematicians?

Most mathematical software (MATLAB, Mathematica, SageMath), high-performance computing clusters, and research computing environments run on Linux systems. Understanding basic Linux commands enables you to:

  • Access and use computational clusters for large-scale mathematical computations

  • Manage mathematical datasets and simulation results efficiently

  • Collaborate with computational scientists and engineers

  • Use powerful mathematical software packages available only on Linux

The pages can be downloaded via the green button at the top right of the page. The commands are shell commands and can be executed in a terminal, however, do not copy the %%bash magic command that is used to execute the commands in the Jupyter Notebook environment.

As a mathematics student, you’ll frequently need to work with computational tools and high-performance computing systems. Linux skills are essential for accessing mathematical software, managing research data, and running computational experiments.

Linux Learning Modules

The following modules will guide you through essential Linux skills:

Basic Linux Navigation Commands

Here is a brief overview of some of the most common commands used for navigation in Linux:

cd – Change Directory

The cd command allows you to move between directories within the filesystem. It is one of the most frequently used commands when navigating the CLI.

Example:

%%bash
cd /tmp
pwd

This command will move you to the specified directory. If no path is specified, typing cd on its own will take you to your home directory.

  • Absolute Path: /tmp/documents (moves directly to the documents directory within /tmp)

  • Relative Path: ../documents (moves up one directory and into documents)

pwd – Print Working Directory

The pwd command prints the full path of your current directory. This is particularly useful when you’ve navigated through several directories and want to confirm your current location in the filesystem.

Example:

%%bash
mkdir /tmp/documents
cd /tmp/documents
touch file.txt
pwd

ls – List Directory Contents

The ls command lists all files and directories within the current directory. By default, it shows a simple list, but there are many options to customize what is displayed.

Basic usage:

%%bash
cd /tmp/documents
ls

Additional options:

  • ls -l: Displays detailed information about each file, such as permissions, owner, size, and modification date.

  • ls -a: Lists all files, including hidden files (those starting with a dot).

  • ls -lh: Displays sizes in human-readable format (KB, MB, etc.).

ls -l
%%bash
cd /tmp/documents
ls -l
ls -a
%%bash
cd /tmp/documents
ls -a

tree – Display Directory Structure

The tree command visually displays the directory structure as a tree. It’s a useful tool for understanding the layout of files and directories.

Example:

%%bash
cd /tmp/documents
tree ..

This will output a nested tree structure representing the contents of the current directory and its subdirectories.

Practical Examples

Here are some practical examples of how you might use these commands:

  • Navigating to a specific directory:

%%bash
cd /var/log
  • Confirming your location in the filesystem:

%%bash
cd /var/log
pwd
  • Listing files in the current directory in detail:

%%bash
cd /var/log
ls -l
  • Viewing the directory structure:

%%bash
cd /var/log
tree