<<

SYSTEM

In Unix, everything from data can be taken or to which data can be sent, even I/O devices, is a file. For example, all devices exist in /dev/ as files. Directories are also considered to be files.

Major Directory files: 1. bin: UNIX commands and installed executable programs 2. dev: all peripheral devices 3. etc: administrative files including user account lists (passwords are encrypted) 4. home: user home directories 5. use: user home directories and user accessible programs in /usr/bin 6. sbin: super-user (administrator) commands 7. var: frequently changed files, such as email boxes

Pathnames: absolute pathname = full pathname = absolute file name = full file name Gives the location of the file in relation to the root of the e.g., /bin /dev /etc /home /usr /home/jill/mydoc/abs.txt

relative pathname . represents the current directory .. represents the parent of the current directory e.g., ./../jill/mydoc/abs.txt

Commands: 1. Listing Files (“”): list files in the current directory; ls –a: list all, including hidden files; ls –a | : display the list page by page on the screen; ls –l: produce long list containing more information for each file. e.g., ls, ls –a, ls –a | more ./../, ls –al | more ./../

2. Copy (“”), Move (“”), and Rename (“rn”) a file

3. Redirection (“>”): Output of a program is sent to a file. Example: ls –al > myfiles.txt

4. Appending (“>>”): add the output of a program to the end of a file, keeping the original contents of the file. Exmple: ls >> myfiles.txt

5. (“ln”): a pointer file pointing to another file (). Example: ln existing- file new-pointer-file (e.g., ln ./../mydoc.txt ./mydocPointer.txt)

6. Create a directory file (“ dir-name”). Example: mkdir ./mynewdir

7. Remove a directory file (“ dir-name”). Example: rmdir ./mynewdir

Reading File Information:

When you do “ls –al”, each line representing a file consists of the following data:

1. First-letter: file : “d” is a directory file and “-“ is an ordinary file

2. 9 letters: Access privileges Three letters for the owner Three for all users in the owners user group Three for all the other users

r: read access is permitted : access is permitted x: executing the file is permitted

Example: rwx r-- ---: Owner can read, write, and execute Any user in the owner’s user group can read Public has no access privileges

3. The number of links (pointer files) to this file

4. Owner user ID

5. Owner’s user group ID

6. File size in bytes

7. Last Modified Date &

8. File Name

Changing File Information:

1. userID file-name: change the ownership 2. groupID file-name: change the group of the file 3. u+w file-name: give the owner write permission chmod g+x file-name chmod a+r file-name: give the public read permission chmod u=rw file-name: and set the owner’s access privileges to “rw-“ chmod u=rwx, go=r file-name etc

Quiz 2: Try all the commands in this note. Submit a report showing the actual results of the commands displayed on the screen.