Operating Systems II A Brief Look at Common UNIX Commands

advertisement
Operating Systems II
A Brief Look
at Common
UNIX Commands
CMSC 104, Lecture 04
1
UNIX Overview
•
•
•
•
Files
Commands
Directories
Resources
o books
o links from course homepage
CMSC 104, Lecture 04
2
UNIX Files
•
•
•
A file is a sequence of bytes
Created by text editor (emacs, pico, vi)
Created by other programs
(e.g. by redirection: ls > FILE)
•
•
Files which contain other files are called
“directories” (sometimes called folders)
in UNIX all devices are handled as files
CMSC 104, Lecture 04
3
Filenames
•
Restrictions
o no blanks, no metacharacters, max. length
o case sensitive
•
Wildcards:
*
?
[ range]
o wildcard characters are useful when manipulating files (e.g.,
listing or moving them)
o ? is used to represent any single character.
o * is used to represent 0 or more characters
CMSC 104, Lecture 04
4
Frequently Used Linux Commands
•
•
•
•
passwd, man, lpr
pwd, ls, cat, more, cd, cp, mv, rm
mkdir, rmdir
ctl-c
References:
• Linux man page
• Links from the 104 homepage
• Books and the Internet
CMSC 104, Lecture 04
5
Script Files
•
For repeated command sequences
o create with editor
o mark as executable (chmod u+x <filename>)
o like a DOS “batch” file
CMSC 104, Lecture 04
6
Directories
•
•
•
•
•
Your home directory is where you are located when
you log in (e.g., /afs/umbc.edu/users/j/d/jdoe28).
The current directory is where you are located at
any time while you are using the system.
Files within the same directory must be given unique
names.
Paths allow us to give the same name to different
files located in different directories.
Each running program has a current directory and all
filenames are implicitly assumed to start with the
name of that directory unless they begin with a slash.
CMSC 104, Lecture 04
7
Directories (cont’d)
/afs/umbc.edu/users/b/o/bob
junk
recipes
pie
apple
CMSC 104, Lecture 04
cookie
peach
choc_chip
8
Moving in the Directory Tree
•
•
•
•
•
•
. (dot) is the current working directory
. . (dot-dot) is the parent directory
UNIX command cd “change directory”
Use dot-dot to move up the tree
Use directory name to move down
Use complete directory name (path
name) to move anywhere
CMSC 104, Lecture 04
9
Subdirectories
•
•
Are used for organizing your files
For example,
o make a subdirectory for CMSC104
o make subdirectories for each project
CMSC104
project1
CMSC 104, Lecture 04
project2
...
project8
10
Download