Unix Basic Tutorial

Summary

This module covered the origins of Unix, the architecture of Unix-based systems, and allowed users to perform the following in an online simulator:

  • navigate within directories
  • list files and directories
  • copy, move and remove files and directories
  • search for files and directories with commands and wildcards

The table below, also available as a printable take-away, lists all of the common information and commands that were covered in the module.

Command

Description

Usage or Example

Paths

/

root directory if first character, or sub-directory if any other character

cd / Changes directory to the filesystem root

.

current directory

ls . Lists the contents of the current directory

..

directory one level up from current directory

cd .. Changes to one level above current directory

Navigation & Content Listing

pwd

print working directory

pwd

ls

list working directory contents

ls option

ls -l

list working directory contents with a long-format listing

ls -l

cd

change directory

cd directory

File Management

cp

Copy file1 from directory1 to directory2 optionally renaming the file in the process.

cp file1 file2 or

cp directory1 directory2

mv

Move file1 from directory1 to directory2, optionally renaming the file in the process.

mv file1 file2 or

mv directory1 directory2

rm

Remove a file from a directory

rm -option filename or

rm -option directoryname

rmdir

remove a directory

rmdir directoryname

Search Commands

find

Find files recursively by their file name and list them.

find -name search_string

grep

Find files by their contents and display the line from each file that contains that search string.

grep search_string file

Wildcards

*

any non-zero number of characters, digits, punctuation marks, or whitespaces

ls *.jpg

ls file*

ls *in*

?

any single character, digit, punctuation mark, or whitespace

ls photo?.jpg

find ???.c

[...]

A user-defined range of characters, digits, punctuation, or whitespace that takes up one space

ls file[0-9].jpg

ls [a-z]ile.txt

ls file[_, ,.]name.txt