Download presentation
Presentation is loading. Please wait.
1
CIS 191 Linux and Unix Skills
Lecture 1
2
Lecture Plan Introduction and Logistics. Unix/Linux Overview.
Navigating the Filesystem.
3
Introduction and Logistics
4
About Me Instructor: Solomon Maina Office Hours : Wednesdays 4:00-6:00 Location : Levine 057
5
Why Take CIS 191? Learn how to use the Unix OS using the Command Line.
Learn how to write shell scripts. Learn some important tools and skills for programming.
6
What are Scripts? A script is a small program used to automate the execution of tasks e.g. create this directory then compile this program then delete this file etc...
7
Shell Script Example The script below renames filenames of the form picturename.jpg to picturename.jpg for fn in *.jpg do mv $fn ‘echo $fn |\ sed ‘s/([0-9]+)-([0-9]+)-([0-9]+)/\3-\2-\1/’‘ done
8
Workload Lectures once a week.
Five assignments, roughly one every two weeks. Final project.
9
Resources Course website: https://www.cis.upenn.edu/~cis191/
Piazza: is191 Canvas:
10
Unix/Linux Overview
11
What is Unix? Unix is a widely influential operating system developed in the 70s. Unix was written in C instead of assembly, making it the first portable OS. Unix helped set the standard for multi-tasking, multi-user systems. Unix was proprietary!
12
GNU: GNU’s Not Unix! Richard Stallman started the GNU project in 1983.
Goal: create a free complete Unix-compatible software system (free as in the users have the freedom to run, copy, distribute, study, change and improve the software) . Largely achieved this goal by the early 1990s except for some low-level elements such as the kernel.
13
Linux Linus Torvalds wrote a kernel (with others) in 1991.
Kernel adopted by the GNU system in 1992. GNU/Linux system now just called “Linux”.
14
Linux Distros Linux comes in hundreds of flavors called “distributions” or distros. Distros generally have different design goals (security, speed, desktop use, etc). Examples are Ubuntu, Mint, Debian, Fedora, Red Hat, openSUSE etc…
15
Unix Flavours There currently exist many operating systems based on Unix, or Unix flavours e.g. Berkeley Software Distribution (BSD) GNU/Linux Mac OS X Sun’s Solaris IBM AIX, HP-UX, Silicon Graphics IRIX, etc… For CIS 191, we will focus on GNU/Linux.
16
SUS and POSIX The Single UNIX Specification (SUS) is the collective name of a family of standards for computer operating systems, compliance with which is required to qualify for using the “UNIX” trademark. The SUS emerged from a mid-1980s project to standardize operating system interfaces for software designed for variants of the Unix operating system. In 1988, these standards became POSIX, which loosely stands for Portable Operating System Interface. Some Unix flavours are POSIX-certified (e.g. Mac OS X) while others are not (e.g. Linux).
17
Shells Unix flavours allow the user to interact with the OS through command line interpreters, or shells. There are many shells: sh – Bourne shell (Unix) bash – Bourne Again shell (GNU/Linux) csh – C shell (BSD Unix) ash, dash, ksh, zsh, tcsh, fish etc… For CIS 191, we will focus on bash.
18
Command Line Basics To execute a command or use a tool, type its name into the shell and press return/enter. Commands are of the form, SomeCommand [-opt] [target] … for example turnin –c cis191 –p hw0 file.txt
19
Flags/Options Most commands take flags/options that usually com before any targets and begin with a dash. Some common options are -h, --help : Give a usage message and exit -v, --version : Show program version and exit -a, --all : Show all information or operate on all arguments -l, --list : List files or arguments without taking other action -o : Output filename -r, -R, --recursive : Operate recursively (down directory tree) -q, --quiet : Suppress stdout -v, --verbose : Output additional information to stdout or stderr -z, --compress : Apply compression Options that do not take arguments can be usually be ganged together, e.g. ls –a –l = ls -al.
20
Getting Unix/Linux Dual boot i.e. run your OS and Unix/Linux side by side but not at the same time. Install a virtual machine (recommended). Install Windows Subsystem for Linux (WSL) on Windows. Download Cygwin on Windows. For CIS 191, you *MAY* get by using Mac OS X on Mac, Cygwin on Windows, or any other Unix flavor.
21
Navigating the Filesystem
22
Navigating the Filesystem
ls [OPTION]… [FILE]… List information about the FILEs (the current directory by default) -a : do not ignore entries starting with a . (hidden files). -l : use a long listing format.
23
Navigating Directories
pwd [OPTION]… Print name of current/working directory. cd [OPTION]… [DIRECTORY] Change the working directory. mkdir [OPTION]… [DIRECTORY]… Make the DIRECTORY(ies), if they do not already exist. rmdir [OPTION]… DIRECTORY… Remove the DIRECTOR(ies), if they are empty.
24
The Directory Stack The directory stack is a list of recently-visited directories. The pushd command adds directories to the stack as it changes the current directory. The popd command removes specified directories from the stack and changes the current directory to the directory removed. The current directory is always at the “top” of the stack. The dirs command displays the contents of the directory stack.
25
The Directory Stack dirs [-clpv] [+N | -N]
Display the list of currently remembered directories. -c : Clears the directory stack by deleting all of the elements. -l : Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory. -p : Causes dirs to print the directory stack with one entry per line. -v : Causes dirs to print the directory stack with one entry per line, prefixing each entry with its index in the stack. +N : Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. -N : Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
26
., .., ~ On Unix-like operating systems, every directory contains an object represented by a single dot and another represented by two successive dots. The former refers to the directory itself and the latter refers to its parent directory (i.e., the directory that contains it). In most shells, tilde (~) expands to the value of the home directory of the current user. ~user expands to the value of the home directory of the user named user. ~+N expands to the string that would be displayed by ‘dirs +N’. ~-N expands to the string that would be displayed by ‘dirs -N’.
27
Creating and Viewing Files
touch [OPTION]… FILE… Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created. cat [OPTION]… FILE Concatenate FILE(s) to standard output With no FILE, or when FILE is -, read standard input.
28
Viewing Files more [OPTION]… FILE…
A filter for paging through text one screenful at a time. SPACE, z or RETURN to display next page, d to scroll forward. b to display previous page, but no way to scroll backward. q to quit less [OPTION]… FILE Same as more but lets you scroll backwards. Does not have to read the entire input file before starting, hence is faster with large files.
29
Viewing Files head [OPTION]… FILE…
Print the first 10 lines of each file to standard output. -n NUM: Print the first NUM lines instead of the first 10; with the leading '-', print all but the last NUM lines of each file. With no FILE, or when file is -, read standard input. tail [OPTION]… FILE Print the last 10 lines of each file to standard output.
30
Navigating the Filesystem
rm [OPTION]… [FILE]… Remove files or directories -r, -R, --recursive : removes directories and their contents recursively. -i : prompts the user whether to proceed with the entire operation if there are more than three files or -r, -R, --recursive are given.
31
Navigating the Filesystem
cp [OPTION]… SOURCE DEST Copy SOURCE to DEST. mv [OPTION]… SOURCE DEST mv [OPTION]… SOURCE DIRECTORY Rename SOURCE to DEST, or move SOURCE(s) to directory.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.