Introduction To Unix Operating System File System, Security and Links
Introduction To Unix Operating System File System, Security and Links
#hen a new file is created on a Unix-like system, its permissions are determined from the umask of the process that created it.
Permissions
There are three specific permissions on Unix-like systems that apply to each class$ The read permission, which grants the a%ility to read a file. #hen set for a directory, this permission grants the a%ility to read the names of files in the directory (%ut not to find out any further information a%out them such as contents, file type, si&e, ownership, permissions, etc." The write permission, which grants the a%ility to modify a file. #hen set for a directory, this permission grants the a%ility to modify entries in the directory. This includes creating files, deleting files, and renaming files. The execute permission, which grants the a%ility to execute a file. This permission must %e set for executa%le %inaries (for example, a compiled c'' program" or shell scripts (for example, a Perl program" in order to allow the operating system to run them. #hen set for a directory, this permission grants the a%ility to tra(erse its tree in order to access files or su%directories, %ut not see files inside the directory (unless read is set". The effect of setting the permissions on a directory (rather than a file" is )one of the most fre*uently misunderstood file permission issues) (+atch ,--.". #hen a permission is not set, the rights it would grant are denied. Unlike A !-%ased systems, permissions on a Unix-like system are not inherited. /iles created within a directory will not necessarily ha(e the same permissions as that directory. The permissions to %e assigned are determined using umasks.0123
Example 1.1
2. 4 mkdir 56courses6unix%asic6lesson. 7ake directory named lesson. under the directory 6courses6unix%asic6 that was created on lesson,. ,. .. 4 cd 6etc 8o to directory etc directly under root. 4 cp group passwd shadow 56courses6unix%asic6lesson.
1.3 umask The umask shell command changes the umask of the shell process, and all processes su%se*uently started from the shell then inherit the new umask. The effect is lost when these processes terminate, e.g. when the user logs out. To set an umask permanently, the appropriate umask command can %e added to a login script. 7odern Unix systems allow umasks to %e specified in two ways$ A default permission, also called a 9ym%olic Umask. D.g. uBrwx,gBrwx,oB An octal num%er that controls which permissions will %e masked (not set" for any newly created file, e.g. -->.
Example 1.2
2. chmod a'w la%file. Using sym%olic mode, add write permissions for la%.file. ,. la -l la%file. .. chmod >=- la%file. Using octal mode, change the permissions on the la%.file rwxrw---;. la -l la%file. <. cat E a%cd ls -la crl-F reate a new file called a%cd. #rite at first empty line and then next line write a text ls Gla =. .6a%cd Try to execute the script. Hou canIt execute that. >. reate a new file called memo into your home directory. #rite your name. ?. chmod g'w memoJ chmod g'w 5 to
Example 2.1
2. nano original 7ake a file named original in your home directory. Hou can write some lines of texts f.ex your name , phonenum%er and address. ,. ln -s original orisoft reate a soft link orisoft. .. ln original orihard reate a hard link named orihard to original. ;. ls -i =>2;,2<, orisoft <. ls -lh total .,L -rw------- , kirsirat users -rw------- , kirsirat users lrwxrwxrwx 2 kirsirat users original .< Ao( .< Ao( ? Ao( ? 2@$2; original ? 2@$2; orihard ? 2@$22 orisoft -E =>2;,2;@ original =>2;,2;@ orihard
=. Add a few lines of text to the file called original f. ex your friendIs name and address. heck if you can see the additional lines of text also within the link files.
3.2 cat
cat - concatenate and print files
3.3 less
Less is a program similar to more, %ut which allows %ackward mo(ement in the file as well as forward mo(ement. Also, less does not ha(e to read the entire input file %efore starting, so with large input files it starts up faster than text editors like vi .
3.4 more
In computing, more is a command to (iew (%ut not modify" the contents of a text file one screen at a time (terminal pager". Mptions are typically entered %efore the file name, %ut can also %e entered in the en(ironment (aria%le 47MCD. Mptions entered in the actual command line will o(erride those entered in the 47MCD en(ironment (aria%le.
3.5 diff
9hows differences %etween two files.
3.6 wc
ounts lines (-l", words (-w" and characters (-c" from a file. Fefault is to list all.
E ample 3.1
2. cat E myfile this is something I Kust felt I needed
4.2 #ippin"
/iles can %e compressed to smaller si&e in %ytes. ommand g&ip can %e used for compression, gun&ip for extracting compressed files.
4 g&ip package.tar packs the tar%all to a new name package.tar.g& 4 gun&ip package.tar.g& for re(ersed action (package.tar"
'
5. &eferences
[1] http://en. ikipedia.!r"/ iki/Filesystem#permissi!ns $1%.1%.1%&