paleoCAMP logo

0.1 Basic Unix Commands#

Tutorials at the 2026 paleoCAMP | June 15–June 29, 2026

Jiang Zhu
jiangzhu@ucar.edu
Climate & Global Dynamics Laboratory
NSF National Center for Atmospheric Research


Learning Objectives#

By the end of this notebook, you will be able to:

  • Navigate between directories with cd and check your location with pwd

  • Inspect files and folders with ls

  • Copy, move, and remove files with cp, mv, and rm

  • Search file contents with grep and use * as a wildcard

  • Clone a repository from GitHub with git clone

Time to learn: 10 minutes


Quick reference#

Click a command to jump to its details. (You can also open the Table of Contents sidebar in Jupyter for the same navigation.)

Command

What it does

cd

change directory

ls

list files and directories

pwd

print working directory

cp

copy files or directories

mv

move or rename

rm

remove — careful, irreversible

grep

search text by pattern

*

wildcard

git clone

get code from a GitHub repository

cd#

Description: cd is used to navigate from one directory to another.

Examples:

  • cd paleocamp - changes the current directory to the paleocamp directory

  • cd ~ - brings you to your home directory


ls#

Description: ls lists the files and directories in the current directory, or in a directory you specify.

Examples:

  • ls - lists files and directories in the current directory

  • ls -l - shows more detail such as permissions, file size, and modification time

  • ls -ltr - sorts by modification time, with the most recently modified files near the bottom; handy when a model run crashes and you want to find the newest log file


pwd#

Description: pwd displays the name of the current working directory — the directory you are currently in.

Example:

  • pwd - displays the current working directory, e.g. /Users/jiangzhu/paleocamp


cp#

Description: cp copies files or directories from a source location to a destination.

Examples:

  • cp file1 file2 - copies the contents of file1 to file2

  • cp -r directory1 directory2 - copies directory1 to directory2. The -r flag means “recursively”


mv#

Description: mv moves or renames files and directories. It can also move files from one directory to another.

Examples:

  • mv file1 file2 - renames file1 to file2

  • mv file1 directory1 - moves file1 into the directory directory1


rm#

Description: rm deletes files or directories. Be cautious — the operation is often irreversible.

Examples:

  • rm file - deletes a file named file

  • rm -rf directory - removes directory and all of its contents. -f means “force it” with no prompts

Warning There is no trash bin in most Unix workflows. After rm, files are usually gone. Double-check the path before running commands such as rm -r or rm -rf.


grep#

Description: grep searches for lines containing a specified pattern within one or more text files. Useful for text searching and pattern matching.

Examples:

  • grep hello file.txt - finds the string hello in file.txt and prints every line containing it

  • grep -r hello directory - searches recursively through all files in directory

  • grep -ir hello directory - same, but ignores case (uppercase/lowercase)


wildcards#

Description: * represents any combination of characters in Unix.

Examples:

  • grep hello *.txt - searches for the string hello, but only in files that end in .txt


git clone#

Description: git clone clones a repository into a newly created directory.

Example:

  • git clone https://github.com/jiang-zhu/paleocamp2026 - clones the paleocamp2026 repository (including the notebooks) into a newly created folder, paleocamp2026, in the working directory


Keep going: Unix Tutorial from UCAR’s COMET Program#

UCAR’s COMET Program offers a free, self-paced Introduction to Unix course. From it you can learn:

  • the basics of Unix file structures,

  • how to navigate in a Unix environment, and

  • how to create, store and search for files.

Time to complete: about 15–30 minutes if you have some Unix experience, or 30–60 minutes if you’re new to it.

ℹ️ Free registration required. Sign up on the MetEd dashboard to access the course, take the quiz, and download a completion certificate.