Write permission for a directory

Assignment Help Other Subject
Reference no: EM133140278

KIT501 ICT Systems Administration Fundamentals

Goal

The main purpose of this fourth practical is to give you familiarity with UNIX file permissions.

Relative Assignment
Changing permissions using relative assignment (adding or subtracting permissions to existing permissions):

$ chmod u+x file1.txt
This adds x permission to the owner for file1.txt
$ chmod ugo+x file1.txt
This adds x permission to the owner, group owner and other users for file1.txt
$ chmod a+x file1.txt
This is an alternative for adding x permission for all users (a=ugo, a for all)
$ chmod a-x file1.txt
This removes x permission from all users for file1.txt
$ chmod a-rwx file1.txt
This removes all permissions from all users for file1.txt

Absolute Assignment
We can use absolute assignment for changing file permissions, when you want to set permissions explicitly, without worrying about of a file's current permissions. For example:

$ chmod a=r file1.txt
This sets r permission to all users, and removes w and x for all users.
$ chmod u=rwx file1.txt
This sets rwx permissions for the owner (group and other are unaffected).
$ chmod u=r,g=w,o= file1.txt
This sets r permission for the owner, w for the group and no permissions for other.

The write permission for a directory determines whether you can create or remove files in it. Whether you can modify a file depends solely on whether the file itself has write permission.
1. Directory's write permission not set, file's write permission not set:
The safest arrangement. The file cannot be deleted nor modifed
2. Directory's write permission not set, file's write permission set:
The file cannot be deleted, but it can be edited (modified).
3. Directory's write permission set, file's write permission not set: The file can be deleted, but it cannot be edited (modified).
4. Directory's write permission set, file's write permission set: The file can be deleted, and it can be edited (modified).

A "write-protected" file in UNIX cannot be written to, but it can be removed if the directory has
write permission.

2. Hands-on Exercises

A). If the kit501 directory is still under your home directory continue, otherwise you can create it now using mkdir. Then under the directory kit501 make a subdirectory called testdir.
B). Change directory into testdir. Create a text file called file.txt using joe or
nano under testdir. Enter any message as the content of the file.

Verify the content of the file
$ cat file.txt
C). Check the current file attributes of file.txt.
$ ls -l file.txt

Make sure that you understand each piece of information in the output (especially the permissions).

Remove the read permission from the owner/user of the file, and verify the effect
$ chmod u-r file.txt
$ ls -l file.txt

Then see if you can view the content of the file now
$ cat file.txt

Restore the read permission of the file and try to view its content again
$ chmod u+r file.txt
$ ls -l file.txt
$ cat file.txt

Next, remove the write permission from the owner/user of the file, and verify the effect
$ chmod u-w file.txt
$ ls -l file.txt

Then see if you can use the joe editor to modify the file content. If not, press CTRL-C to exit.

Restore the write permission for the owner.
$ chmod u+w file.txt
$ ls -l file.txt
D). Use the following commands to change the permissions of file.txt. Verify the effect of each command each time using ls -l. Make sure you understand the permissions represented by each octal number (the first one is done for you):

$ chmod 666 file.txt
$ ls -l file.txt
Owner: rw, group: rw, other users: rw

$ chmod 444 file.txt
$ ls -l file.txt

$ chmod 646 file.txt
$ ls -l file.txt

$ chmod 600 file.txt
$ ls -l file.txt


$ chmod 466 file.txt
$ ls -l file.txt

$ chmod 251 file.txt
$ ls -l file.txt

$ chmod 111 file.txt
$ ls -l file.txt

$ chmod 700 file.txt
$ ls -l file.txt

$ chmod 000 file.txt
$ ls -l file.txt

$ chmod 777 file.txt
$ ls -l file.txt
E). Remove file.txt.
F). Check the current attributes of the following file:
/etc/passwd
G). Change the permissions of this file to 777. If this is impossible, think about why.
H). Copy this file (/etc/passwd) to your directory testdir.
I). Repeat step G. Think about why you can change the permissions now.
J). Create two more text files and store them under testdir.
K). Set the permissions of all the files stored under testdir to 700 using a single and short command line.
L) Under the directory kit501 make another subdirectory named testdir2. Check the current attributes of testdir2.
$ ls -l

Make sure that you understand each piece of information in the output (especially the directory permissions).
M) Create a text file called file2.txt using joe or nano under testdir2.
N) Remove the owner's read permission of testdir2.
O) Change into testdir2, use ls to list all the files stored under it. Can you see any?
P) Use joe or nano to edit file2.txt. Use cat to verify the added content.
Q) Restore the read permission of testdir2. Use ls to list files stored under it again.
R) Remove the owner's write permission of testdir2. Change into testdir2. Try to remove file2.txt from testdir2. Can you do it?
S) Remove the write permission of file2.txt. Can you then add new content into the text file?
T) If somebody asks you to create a file which cannot be modified, and cannot be deleted, you should know how to do it now.
U) Restore the write permission of file2.txt. Restore the write permission of testdir2. But remove the owner's execute permission of testdir2. Then try to change directory into testdir2. Can you do it?
V) Restore the owner's execute permission of testdir2. Remove testdir2 together with its content.

3. Hands-on Exercises (compressing files)

To conserve disk space you may need to compress large and infrequently used files. The most notable compression programs available in UNIX are
bzip2 gzip zip

zip can group multiple files into a single file (called an archive). For example:

$ zip -r emailsdir emails

This compresses a directory tree under emails directory (including emails itself), and produces emailsdir.zip, which is a single zip file. Please note, the output file name (emailsdir) is specified by you (the user).
gzip can only do this with tar:
$ tar -cvf emailsdir.tar emails
This produces an archive file named emailsdir.tar, with NO compression. You can then use
gzip to compress it.

To restore the original directory tree under emails directory, you would use the following:
$ tar -xvf emailsdir.tar

A). Under the directory kit501 create a text file named f1.txt.
An easy way for creating a text file is to redirect the output of a command to a single file, like this:
$ man pwd > f1.txt

The above command line saves the man pages of pwd into f1.txt. What is the size of this file? (Use ls -l f1.txt)
B). Use bzip2, gzip, and zip to compress and then decompress f1.txt. Verify the effect of compression using ls -l (check file size before and after compression).

$ bzip2 f1.txt (This produces f1.txt.bz2 and removes the original file)
$ ls -l (Check the file size after compression using bzip2)
$ bunzip2 f1.txt.bz2 (Decompress to restore the original file)
$ ls -l (Verify result of decompression)

$ gzip f1.txt
$ ls -l
$ gunzip f1.txt.gz
$ ls -l

Please note that the zip command requires that you specify the output file name (result of compression). It also retains the original file after the file is compressed.

$ zip f1.txt.zip f1.txt
$ ls -l

You can remove the original file, and then use unzip to restore it:
$ rm f1.txt
$ ls
$ unzip f1.txt.zip
$ ls
$ rm f1.txt.zip
$ ls
C). Create two more text files using:
$ man ls > f2.txt
$ man man > f3.txt
D). Make a subdirectory called testdir (if it does not exist) and move the three text files into the subdirectory with a single command. Check the sizes of the three files.
E). Use zip to compress the directory tree testdir (produce testdir.zip). A
directory tree refers to the directory together with all the files stored under it. How big is

testdir.zip? Compare the size of this compressed file with the sum of the sizes of the three text files mentioned above.
F). Use gzip to compress the directory tree testdir. You have to use tar first to archive the directory tree (produce testdir.tar). The output of gzip should be testdir.tar.gz.
G). Compare the sizes of the two compressed files: testdir.zip, testdir.tar.gz. Which one is smaller? Which compression program is easier to use?
H) After you feel confident with using these compression programs, remove all the temporary files and directories (house cleaning), but keep the directory kit501 so that you can use it again in the future.

Attachment:- ICT Systems Administration Fundamentals.rar

Reference no: EM133140278

Questions Cloud

Find utility to locate files on the system : Find utility to locate files on the system by specifying a set of criteria. You were told to get rid of the many "Permissions denied" error messages
Calculate diana total cost recovery deduction : Diana does not elect immediate expensing under § 179. She elects additional first-year deprecation. Calculate Diana's total cost recovery deduction
What is the net income for the period : The ending balances of capital stock and retained earnings are P300,000 and P120,000, respectively. What is the net income for the period
How much is the capital balance of mariah at the end : Assuming there is an implied undervaluation or overvaluation of an asset, how much is the capital balance of Mariah at the end of the year
Write permission for a directory : The main purpose of this fourth practical is to give you familiarity with UNIX file permissions - when you want to set permissions explicitly, without worrying
Develop a single-step income statement : Currently she has $500.00 in accounts receivable and $1,200.00 in accounts payable. Develop a single-step income statement
How many cups of regular coffee and lattes must rio sell : The monthly fixed costs at Rio are $8,662. How many cups of regular coffee and lattes must Rio sell every month to break even
Evaluate the bitwise logical operations : Evaluate the bitwise logical operations - Convert the 8-bit 2s complement numbers to their decimal equivalent
Prepare the entries on the dates listed : Maker paid $12,000 to purchase a call option to buy 1 million FCU at a strike price of $0.255 expiring end of year. Prepare the entries on the dates listed

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd