← CSE107 lab materials

Lab 1 · Ubuntu command reference

Examples assume you are inside your own new lab directory. Replace example names thoughtfully. Commands and filenames are case-sensitive.

CommandPurposeExample
pwdShow current directorypwd
lsList directory entriesls jupiter
cdChange current directorycd ..
mkdirCreate a directorymkdir mars
mkdir -pCreate missing parent directories toomkdir -p jupiter/io
catDisplay text-file contentscat mars/mars.txt
mvMove or renamemv jupiter/europa/io.txt jupiter/io/
cpCopycp mars/mars.txt mars/mars-copy.txt
findList matching paths recursivelyfind . -type f

Create or replace a text file:

printf 'Mars\nA planet\n' > mars/mars.txt

Append one line:

printf 'Checked in Lab 1\n' >> mars/mars.txt

> replaces the destination's existing contents. >> adds to the end. Quoting keeps the text together; \n in the printf format produces a new line.

/ is the filesystem root. ~ expands to your home directory. . is the current directory and .. its parent. A filename extension such as .txt is part of the name.