Andy Cheng presented the lecture titled “Operating Systems II: File Management” this week. In basis File Management systems allow users to store information in units called files, File systems provide a logical view for the user whilst hiding the physical view which is not interpretable by the average human.
- Ordinary Files – executable, text, source code, etc.
- Directories – contain Ordinary files and subdirectories (assist with Logical View)
- Special Files – represent devices and other advanced file types.
We did not get into the file types in detail during the lecture or the tut however the file type and their characters (which can be view using ls -l):
- – -> regular file
- d -> directory file
- b -> buffered special file (ie: disk drive)
- c -> unbuffered special file (ie: terminal)
- l -> symbolic link
- p -> pipe
- s -> socket
Absolute and Relative paths, self explanatory.
The lecture was cut short as we had to spent some time finishing the previous weeks slides so we did not really get into the chmod analysis which is responsible for permissions (I have had experience with this command as it is important on Unix based hosting for updating write permissions on config files). Basically the command is divided into User/Group/Others -> read, write and execute. A quick hand way for setting permissions is:
The octal (0-7) value is calculated by adding up the values for each digit
read = 4 ,write = 2, execute = 1,
User (rwx) = 4+2+1 = 7
Group(rx) = 4+1 = 5
World (rx) = 4+1 = 5
chmode mode = 0755
$ chmod 755 myfile – would be the command.
Pearl of the week: In all Unix operating systems all entities are treated as files (I assume this is related to the monolithic kernel design)
In the tut we got into working with the shell, a summary of some of the commands we covered below:
- Print working directory -> pwd
- Tab completes file name (or to fork where multiple possible values occur)
- chmod
My favored site with listings of shell commands is: http://ss64.com/bash/ I find it the quickest and easiest for learning and look up.
To get better at command-line interface the key is regular practice. I am currently running Ubuntu on my home pc, but rarely use the shell unless testing programs. It is a good habit to get into using it.
After doing some practice it appears that using wildcard for the ls command is not very useful for find particular files in subdirectories. For example if you wanted to find all of the .ape files in your My Music folder, ls -R *.mp3 would not work. Instead one would need to use:
find ~/My Music/ -regex ".*\(mp3\)$" //find all .mp4 files find -regex ".*\(.ape\|\.mp4\)$" //find all .ape and .mp4 in relative directory and subdirectories