
0.1 Basic Unix Commands#
Tutorials at the 2025 paleoCAMP | June 16–June 30, 2025
Jiang Zhu
jiangzhu@ucar.edu
Climate & Global Dynamics Laboratory
NSF National Center for Atmospheric Research
Learning Objectives#
A quick demonstration of a few basic Unix Commands
Time to learn: 10 minutes
cd (Change Directory)#
Description: cd is used to navigate from a directory to another directory.
Examples:
cd paleocamp- Changes the current directory topaleocampdirectorycd ~- Brings you to yourhomedirectory as well
ls (List):#
Description: ls` lists the files and directories in the current directory or a specified directory, along with file permissions, sizes, and timestamps.
Examples:
ls- Lists the files and directories in the current directory.ls -l- Provides more information such as the permissions settings, the file size, the time of creation etc.ls -ltr- Lists the files in reverse order of the time they were created. This can be useful when your model run crashes and you want to see which log file was most recently created.
pwd (Print Working Directory):#
Description: pwd displays the name of the current working directory, which is the directory in which you are currently located.
Example:
pwd- Displays the location of the current working directory, such as/Users/jiangzhu/paleocamp.
cp (Copy):#
Description: cp copies files or directories from a source location to a destination location.
Examples:
cp file1 file2- Copies the contents of file1 to file2cp -r directory1 directory2- Copies the contents of directory1 to directory2. The flag-rhere meansrecursively
rm (Remove):#
Description: rm deletes files or directories. Be cautious, as the operation is irreversible.
Examples:
rm file- Deletes a file named filerm -rf directory- Removes a directory named directory and all of its contents. “-f” means “force it” without prompts, and this operation is irreversible and could be dangerous.
mv (Move):#
Description: mv moves or renames files and directories. It can also be used to move files from one directory to another.
Examples:
mv file1 file2- Renames file1 to file2mv file1 directory1- Moves file1 into the directory directory1
grep (Global Regular Expression Print):#
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- Searches for the string hello in the file.txt file and displays all lines containing that stringgrep -r hello directory- Searches for a string recursively within all files that are in the directorydirectorygrep -ir hello directory- Searches ignoring case matching (uppercase/lowercase)
wildcards (*):#
Description: * can be used as a wildcard in Unix, i.e., to represent any combination of characters.
grep hello *.txt- Searches for the stringhellobut only in files that end in.txt
git clone (get code from GitHub respository)#
Description: git clone clones a repository into a newly created directory
Example:
git clone https://github.com/jiang-zhu/paleocamp2025clones the paleocamp2025 respository (including notebooks) into a newly created folder,paleocamp2025in the working directory.
Unix Tutorial from UCAR’s COMET Program#
From the Tutorial, you can learn
the basics of Unix file structures
how to navigate in a Unix environment
how to create, store and search for files.
The expected length is 15-30 minutes for users with some Unix experience, and 30-60 minutes for novices.