Sie sind auf Seite 1von 7

LINUX Assignment EX-3

Describe three different ways of setting the permissions on a file or directory to rrr. Create a file and see if this works. Answer: total 3 ways 1) mode chmod u+r g+r o+r file.txt 2) reference

chmod reference
3) octal

oldfile.txt newfile.txt

chmod !!! newfile.txt or chmod !!! "home 1.


#eam up with a partner. Copy "bin"sh to your home directory. #ype $chmod +s sh$. Check the permissions on sh in the directory listing. %ow ask your partner to change into your home directory and run the program ."sh. Ask them to run the id command. &hat's happened( )our partner can type exit to return to their shell. Answer: *+, screen shot: Copy "bin"sh to your home directory. #ype $chmod +s sh$. Check the permissions on sh in the directory listing and made permission to accessible to all users. -ee below.

*/, screen shot : entering into another user and do changes in home directory of main

user and run the program ."sh. And then id. And then exit. %ow go back to main user.

/. &hat would happen if the system administrator created a sh file in this way(
&hy is it sometimes necessary for a system administrator to use this feature using programs other than sh( 0ain user Answer: By t is feat!res system administrator gi"es #ermission !se to t eir s ell and so t at ot er !ser can o#erate t at s ell and write a scri#t t ere wit o!t ta$ing #ermission%

3. Delete sh from your home directory *or at least to do a chmod s sh,.

-creenhsot 3:

1. 0odify the permissions on your home directory to make it completely pri2ate. Check that your partner can't access your directory. %ow put the permissions back to how they were. Answer: c mod &'' ( ome(te)as t en log in to anot e !ser * $ ere% + is !ser can,t access ome directory of t e main !ser% 1.13/

4. #ype umask 555 and then create a file called world.txt containing the words
$hello world$. 6ook at the permissions on the file. &hat's happened( %ow type umask 5// and create a file called world/.txt. &hen might this feature be useful( -creen shot

Answer : when main use want to change permission to all file created under that command.

7. Create a file called $hello.txt$ in your home directory using the command cat u
8hello.txt. Ask your partner to change into your home directory and run tail f hello.txt. %ow type se2eral lines into hello.txt. &hat appears on your partner's screen( It c anges wit relati"e to c anges in main !ser%so* as main !ser ty#es somt ing at e same time #artner !ser s ows t at%

!. 9se find to display the names of all files in the "home subdirectory tree. Can you
do this without displaying errors for files you can't read( -es Using find ( ome . gre# -" error 8. 9se find to display the names of all files in the system that are bigger than +0:. find -si/e 011 9. 9se find and file to display all files in the "home subdirectory tree. as well as a guess at what sort of a file they are. Do this in two different ways. Answer: 2ind ( ome . 3args file

+5. 9se grep to isolate the line in "etc"passwd that contains your login details.
Answer:

++. 9se find and grep and sort to display a sorted list of all files in the "home
subdirectory tree that contain the word hello somewhere inside them. Answer:

+/. 9se locate to find all filenames that contain the word emacs. Can you combine
this with grep to a2oid displaying all filenames containing the word lib( Answer:

13. Create a file containing some lines that you think would match the regular expression: *;<5=>?+.4@<aAAA >+B,Cnone and some lines that you think would not match. 9se egrep to see if your intuition is correct.

Answer: egre# 45'-6781*9:5a-/ A-;7 . none4

ello%t3t

+1. Archi2e the contents of your home directory *including any subdirectories,
using tar and cpio. Compress the tar archi2e with compress. and the cpio archi2e with gAip. %ow extract their contents. Answer: tar -c"wf file%tar ( ome find #lay -ty#e f . c#io -o . g/i# -c < c#io%c#io%g/

15. Dn 6inux systems. the file "de2"urandom is a constantly generated random stream of characters. Can you use this file with od to printout a random decimal number( od -d (de"(!random 16. #ype mount *with no parameters, and try to interpret the output. Answer:

Das könnte Ihnen auch gefallen