CS计算机代考程序代写 file system data structure Files

Files
& Command Line (aka Shell)




– – –

Shells
$ gcc -Wall -g -std=gnu99 –o hello hello.c
The $ is a shell prompt.
Shells
accept commands (programs) as input finds the executable
interprets the arguments
starts executing the command
Shells also have some “built-in” commands.

Running a program
$ gcc -Wall -g -std=gnu99 –o hello hello.c
$ hello
load a program into memory and hand it off to the

OS to run the program.

• •
Files and Directories
“Everything is a file.”

• video
• keyboard • sound
• network
File interface = open, read, write, close
Unix provides a file interface for all Input/Output. regular files

– directories – devices

File System Hierarchy
Everything starts in the “root” directory whose name

is “/”
• • •
A directory is a file that contains directory entries. A directory entry maps a file name to an inode.
An inode is the data structure that contains information about a file, including which disk blocks contain the file data.

Inodes and Directory Entries

File System Hierarchy

Directories and Links

Permissions




– –
File permissions
read, write, execute – pretty much what you think
Directory permissions
read – you can run ls on the directory
write – you can create and delete files in the directory
execute – you can “pass through” the directory when searching subdirectories.



– –
chmod

chmod 755
3 numbers between 0 and 7, the octal value for that

category of user
Another approach
chmod u+rwx
chmod go-x
adds or removes permissions for those categories of users
Quiz — what is the command to set the permissions of the

file classlist to be world readable but writeable only by the file owner and members of the group.

• • • • •
Globbing
A little like regular expressions but different syntax * matches any number of any character
? matches any one character
[list of characters]
[1-5] or [a-z] or [a-xz]