A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? Quick introduction Documentation ...
-
Upload
cleopatra-boyd -
Category
Documents
-
view
221 -
download
0
description
Transcript of A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? Quick introduction Documentation ...
A Brief Overview of UnixA Brief Overview of UnixBrandon Bohrer
TopicsTopicsWhat is Unix? – Quick introductionDocumentation – Where to get it, how to use
itText Editors – Know the dominant Unix text
editors, and their relative strengths and weaknesses.
Filesystem – Learn the differences between Unix filesystems and those on other operating systems
Using the Unix shell – Basic commands and shell syntax
What is Unix?What is Unix?Operating system first developed at Bell
Labs in 1969Based on design philosophy of simplicity and
modularityGave birth to a large family of operating
systems.The most common of these (and the one
used at Drexel) is GNU/LinuxFree and open-source
Accessing DocumentationAccessing Documentation man command
◦ Access online documentation for programs, functions, and more.
info command◦ More advanced documentation format, but not as widely
used. apropos command
◦ Searches man pages for a command; helpful when you don’t know the exact name
Course materials – Probably best source for basic commands Software manuals – More detailed and readable than man
pages Books - Unix in a Nutshell available from Drexel Unix standards
◦ POSIX, Single Unix Specification◦ Poor choice for everyday use, but may be helpful for
portability questions.
Text EditorsText EditorsVi (Visual Editor)
◦ Simple◦ Available almost everywhere (part of Single Unix
Specification)◦ Mode-based UI takes some getting used to
Emacs (Editor Macros)◦ Lots of features (even has a vi mode)◦ Highly extensible◦ Uses multi-key keyboard shortcuts instead of modes
Other editors:◦ vim◦ nano◦ Kate◦ And many more
Filesystem OverviewFilesystem OverviewFile paths are delimited with forward
slashes(/)All directories are descendants of a root
directory, called /Parent directory is denoted with two periods
(..)Current directory is denoted with one period
(.)Files are assigned permissions, which
determine how they can be accessed and by whom.
Filesystem - Related Filesystem - Related CommandsCommandsDirectory manipulation
◦ cd change directory◦ ls list files in directory◦ mkdir make directory◦ rmdir remove directory◦ pwd print working directory
File manipulation◦ mv move file◦ cp copy file◦ rm remove file◦ touch make file / update file
timestamp
More common commandsMore common commands Search
◦ grep search text (General Regular Expression Parser)◦ find search for file by name
Display◦ cat concatenate file to output◦ echo output a given string
Misc◦ wc word/line count◦ tail return the end of a file◦ cmp compare files, show first difference◦ diff compare files, show all differences◦ ps show running processes◦ less/more make large outputs easy to read
And many more
Important DirectoriesImportant Directories/ Root directory/home Personal files/usr User software files/bin Executables/sbin Restricted Executables/dev Devices/usr/man Manuals/usr/src Source code/lib Important libraries/tmp Temporary, deleted on boot For full list, see Filesystem Hierarchy Standard:
http://www.pathname.com/fhs/pub/fhs-2.3.html
File permissionsFile permissions Three sets of permissions
◦ Owner: Generally the file’s creator, but can be changed with chown
◦ Group: A group of users with a special set of permissions Defined in /etc/passwd and /etc/group File’s group is changed with chgrp
◦ Other: All other usersThree flags in each set
◦ Read, write, execute◦ Set with chmod
Often encoded with each set represented by an octal digit, and each permission flag stored in a single bit◦ E.g “Read and execute” encoded as 5 ( 2^2 + 2^0)◦ E.g All permissions for all users encoded as 777
Shell Pipes and Shell Pipes and MetacharactersMetacharacters Pipes help programs work together. Use | to send output from one program to input for another.
◦ Example: cat file.txt | grep “hello” prints lines of file.txt containing the string “hello”
Use > to write output to a file◦ Example: ls > file.txt writes a directory listing to file.txt
Use < to send a file to a program’s input◦ Example: cat < file.txt prints file.txt
* expands to all filenames in the current directory◦ Example: rm ./* deletes all files in current directory.◦ Use carefully:
Easy to type rm /* and destroy the filesystem. Use rm –i to avoid accidental deletions.
See course notes or sh manual for more shell syntax.
QuestionsQuestions