UC Irvine,
Information and Computer Science Department
Winter 2000
ICS 54:
Brief Notes on Chapter 7: Working with Files and Directories
Handling files and directories
- ls : lists their content and characteristics.
There are many options.
Read the friendly
man(ual) in traditional or web
form.
- cp [ -i ] : copy one file to another
- mv [ -i ] : move/rename a file
- rm [ -i ] : delete a file
- ln [ -s ] : create [symbolic] link to a file
- mkdir : create a new directory
- rmdir : delete a directory
Protecting Files: Access control
Simplified version
- Each file belongs to an owner and a group
- Each file has protections specified for each of three classes of users:
- u: the User who owns the file
- g: members of a Group with access to the file
- o: Others (anyone other than the owner)
root (the "super user") has full access
- Three possible permissions:
- r: read
- w: write
- x: execute
- Use ls -l to examine protection of a file
- Use chmod to set protection of a file
- chmod u-w filename -- User owning cannot Write
- chmod g+rx filename -- Group can Read and eXecute
- chmod o=r filename -- Others can Read
- chmod 751 filename -- u=rwx, g=rx, o=x
- umask determines (default) permissions of
newly created files
umask
tells the current value
umask 027
yields -rw-r-----
,
drwxr-x---
umask 026
yields -rw-r-----
,
drwxr-s--x
File Permissions
% ls -liga
total 28
611243 drwxr-x--- 5 unixguru fish 512 Apr 1 12:41 .
80715 drwxr-r-x 4 unixguru fish 512 Apr 1 12:27 ..
611302 -r-------- 1 unixguru fish 1674 Apr 1 12:31 400
611297 -rw------- 1 unixguru frogs 2034 Apr 1 12:31 600
611290 -rw-r----- 1 unixguru fish 970 Apr 1 12:28 640
611273 -rw-r--r-- 2 unixguru fish 2604 Apr 1 12:28 644
611273 -rw-r--r-- 2 unixguru fish 2604 Apr 1 12:28 644L
611292 -rwxr-x--x 1 unixguru swimmers 6267 Apr 1 12:29 751
625316 drwx------ 3 unixguru swimmers 512 Apr 1 12:37 d700
634698 drwxr-x--- 2 unixguru frogs 512 Apr 1 12:39 d750
620629 drwxr-x--x 4 unixguru frogs 512 Apr 1 12:35 d751
Exploring Files
- ls [ -aAbcCdfFgilLmnopqrRstux1 ] filename
- file filename -- what kind of file is this?
- find where2look -name filename -print
- wc filename -- Word Count
- cat filename -- the friendly man says,
"cat - concatenate files and print on the standard output"
cat filename | wc
- Look at longer files with pg, more, and less.
Comments are welcome.
Current as of 11 January 2000
HTML
4.01 Checked.