File attributes ----------------- name contents owner group protection (mode) date created, modified, accessed to change protection of files ----------------------------- chmod new-protection list-of-file-names e.g. I want new protection to be rw-r----- 110100000 6 4 0 chmod 640 filenames unix functions -------------- int open(char * fname, int flags {, protectionbits} ) the int is called a file descriptor (fd) int close(int fd) return value negative, there was an error positive or zero means all OK >0 usually some useful information to create anew output file int fd = open("outfile.txt", O_WRONLY | O_CREAT | O_TRUNC, 0640); OR int fd = open("outfile.txt", O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR | S_IRGRP); int rf = open("infile.txt", O_RDONLY); using stat ---------- struct stat sb; int r = stat("filename", & sb); if (r < 0) { perror("stat:"); exit(1); }