Sie sind auf Seite 1von 12

EXERCISE-3

Question:1. Team up with a partner. Copy /bin/sh to your home directory. Type "chmod +s sh". Check the permissions on sh in the directory listing. Now ask your partner to change into your home directory and run the program ./sh. Ask them to run the id command. What's happened? Your partner can type exit to return to their shell. Step 1: Copying /bin/sh to home directory.

Step 2: Partner running the id command in .sh file.

Question:2. What would happen if the system administrator created a sh file in this way? Why is it sometimes necessary for a system administrator to use this feature using programs other than sh? Ans: If the system administrator created a sh file in this way then any other user can also execute that file from his/her terminal. System administrator need to use this features if there is a necessary to allow other user to execute the files.

Question:3. Delete sh from your home directory (or at least to do a chmod s sh). Type command : rm sh /home/japan Question:4. Modify the permissions on your home directory to make it completely private. Check that your partner can't access your directory. Now put the permissions back to how they were. Ans: Type command: sudo chmod 700 /home Change to other user and try to access home directory. It will not let you to do so. Now again change to administrator's account and type: sudo chmod 755 /home which is the default mode for home directory. Question:5. Type umask 000 and then create a file called world.txt containing the words "hello world". Look at the permissions on the file. What's happened? Now type umask 022 and create a file called world2.txt. When might this feature be useful?

total 284

drwxrwxr-t 2 japan drwxr-xr-x 4 japan drwxr-xr-x 2 japan drwxr-xr-x 2 japan -rw-r--r-- 1 japan -rw-rw-r-- 1 japan -rw-rw-r-- 1 japan -rwxr-xr-x 1 japan drwxr-xr-x 2 japan drwxrwxr-t 2 japan drwxr-xr-x 2 japan drwxr-xr-x 2 japan -rwxr-xr-x 1 japan drwxr-xr-x 2 japan -rw-rw-r-- 1 japan -rw-rw-r-- 1 japan drwxrwxr-t 3 japan drwxrwxr-x 2 japan -rw-rw-r-- 1 japan drwxr-xr-x 2 japan -----------------rw-rw-rw- 1 japan ----------------rw-r--r-- 1 japan

japan 4096 Jul 11 10:30 ASSIGNMENTS japan 4096 Jul 11 11:23 Desktop japan 4096 Jul 5 02:06 Documents japan 4096 Jul 8 20:29 Downloads japan 8445 Jul 5 02:01 examples.desktop japan 70 Jul 10 15:50 For search japan 9 Jul 10 14:48 For search~ japan 100284 Jul 11 10:46 home japan 4096 Jul 5 02:06 Music japan 4096 Jul 9 14:09 OTHER japan 4096 Jul 11 11:29 Pictures japan 4096 Jul 5 02:06 Public japan 100284 Jul 11 11:29 sh japan 4096 Jul 5 02:06 Templates japan 33 Jul 9 15:38 test1.sh~ japan 519 Jul 9 12:25 test.text japan 4096 Jul 11 10:26 TRAINING japan 4096 Jul 5 02:37 Ubuntu One japan 0 Jul 10 14:48 Untitled Document~ japan 4096 Jul 5 02:06 Videos japan 15 Jul 11 12:29 world.txt japan 18 Jul 11 12:31 world2.txt

Question:6. Create a file called "hello.txt" in your home directory using the command cat u >hello.txt. Ask your partner to change into your home directory and run tail f hello.txt. Now type several lines

into hello.txt. What appears on your partner's screen?

Other user can not make any change in Hello file. And whatever the administrator will write in the terminal the other user's file get updated with that details.

Question:7. Use 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? Ans:
/home /home/japan /home/japan/.bash_logout /home/japan/.pulse /home/japan/.pulse/78e63de6625a9524e980eeed00000009-runtime /home/japan/.pulse/78e63de6625a9524e980eeed00000009-device-volumes.tdb /home/japan/.pulse/78e63de6625a9524e980eeed00000009-default-source /home/japan/.pulse/78e63de6625a9524e980eeed00000009-default-sink /home/japan/.pulse/78e63de6625a9524e980eeed00000009-stream-volumes.tdb /home/japan/.pulse/78e63de6625a9524e980eeed00000009-card-database.tdb /home/japan/Templates /home/japan/Public /home/japan/Pictures /home/japan/.mission-control /home/japan/.mission-control/accounts /home/japan/.mission-control/accounts/accounts.cfg /home/japan/.dmrc /home/japan/TRAINING /home/japan/TRAINING/eiTRA_linux_introduction.pdf /home/japan/TRAINING/The_linux_command_line__by_william_e_shotts.pdf /home/japan/TRAINING/linux__introduction.pdf /home/japan/TRAINING/nbr2player.msi /home/japan/TRAINING/linux_introduction_1.PDF /home/japan/TRAINING/Linux_assignment_.pdf /home/japan/TRAINING/LInux OS-Farukh Sir-20130708 1052-1.arf /home/japan/TRAINING/Linux_Workshop /home/japan/TRAINING/Linux_Workshop/07-redirection-pipes.ogv /home/japan/TRAINING/Linux_Workshop/01-ubuntu-desktop.ogv /home/japan/TRAINING/Linux_Workshop/02-synaptic.ogv /home/japan/TRAINING/Linux_Workshop/05-linux-file-system.ogv /home/japan/TRAINING/Linux_Workshop/09-linux-environment.ogv

Question:8. Use find to display the names of all files in the system that are bigger than 1MB.

Ans:

/home/japan/TRAINING/The_linux_command_line__by_william_e_shotts.pdf /home/japan/TRAINING/nbr2player.msi /home/japan/TRAINING/LInux OS-Farukh Sir-20130708 1052-1.arf /home/japan/TRAINING/Linux_Workshop/07-redirection-pipes.ogv /home/japan/TRAINING/Linux_Workshop/01-ubuntu-desktop.ogv /home/japan/TRAINING/Linux_Workshop/02-synaptic.ogv /home/japan/TRAINING/Linux_Workshop/05-linux-file-system.ogv /home/japan/TRAINING/Linux_Workshop/09-linux-environment.ogv /home/japan/TRAINING/Linux_Workshop/06-file-attributes.ogv /home/japan/TRAINING/Linux_Workshop/04-gen-purpose-utils.ogv /home/japan/TRAINING/Linux_Workshop/03-basic-commands.ogv /home/japan/TRAINING/Linux_Workshop/10-simple_filter.ogv /home/japan/TRAINING/Linux_Workshop/08-linux-process.ogv

/home/japan/TRAINING/linux_introduction_commands2338.pdf /home/japan/.cache/wallpaper/0_5_1280_800_e57219d81fdba87e3494fb33aba6c0b9 /home/japan/.cache/software-center/software-center-agent.db/spelling.DB /home/japan/.cache/software-center/software-center-agent.db/postlist.DB /home/japan/.cache/software-center/piston-helper/softwarecenter.ubuntu.com,api,2.0,applications,en,ubuntu,precise,i386,,711dbeb6ebcd4b11 1ea70611e5b69912 /home/japan/OTHER/LAB3.pdf /home/japan/OTHER/The_Monk_Who_Sold_His_Ferrari_By_Robin_S_Sharma.pdf /home/japan/OTHER/nfsb_final.pdf /home/japan/.mozilla/firefox/wr4lrgjj.default/places.sqlite /home/japan/.mozilla/firefox/wr4lrgjj.default/Cache/_CACHE_003_ /home/japan/ASSIGNMENTS/JAPAN_ASSIGNMENT1_7-7-13.odt

Question:9. Use 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. Ans: Find Question:10. Use grep to isolate the line in /etc/passwd that contains your login details. Ans: Type command : grep japan /etc/passwd

Output :
japan:x:1000:1000:JAPAN,,,:/home/japan:/bin/bash

Question:11. Use 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.

Type command: find ~ * | grep Hello *.txt

test1.txt:Hello every one.. test1.txt:Hello...

Question:12. Use locate to find all filenames that contain the word emacs. Can you combine this with grep to avoid displaying all filenames containing the word lib?

Question:13. Create a file containing some lines that you think would match the regular expression: (^[09]{1,5}[azAz ]+$)|none and some lines that you think would not match. Use egrep to see if your intuition is correct.

12345

abcde ABCDE sdjhf fafijae

Question:14. Archive the contents of your home directory (including any subdirectories) using tar and cpio. Compress the tar archive with compress, and the cpio archive with gzip. Now extract their contents.

Question:15. On Linux systems, the file /dev/urandom is a constantly generated random stream of characters. Can you use this file with od to printout a random decimal number?

1432760 1433000 1433020 1433040 1433060 1433100 1433120 1433140 1433160 1433200 1433220 1433240 1433260 1433300 1433320 1433340 1433360 1433400 1433420 1433440 1433460 1433500 1433520 1433540 1433560 1433600 1433620 1433640

-1677940307 347305199 1814413204 2136695036 590738101 660254007 1004947435 1217527452 1038811918 1462603879 1622397989 1919983958 837330415 157116622 -694536364 316498044 789921254 1581222828 -1293095476 -629768382 1121350500 -1747015978 478672781 799434742 -1923815664 -148037421 -380428654 -1016346483

-1360246181 497757926 440535634 258499136 370676711 874161125 -2122030592 -147024101 684873535 125256614 41050967 -739052296 -1249339988 1158514166 -233066645 1272818466 -1043063901 1762671132 10066601 119407481 670609288 -1886270544 -1628276986 34160076 -1700530571 -401831025 596892530 -1487603289

-940406242 1704372121 -11002829 1924085194 -1005876701 -61441167 -629982669 1321732802 -1206315345 -1666169604 2066831248 512241972 201348838 824880214 -1769777299 -922384746 766796881 1778300536 -1940623756 1797631189 -918942215 1283228648 405815065 -963699737 1096465363 -1739912088 1997970409 -186735011

-172094382 11765433 -1304797255 -657309858 71145018 -1818078901 1327534355 -194551141 392185593 -1529032500 -1002485892 1630075873 -732345616 1371391052 1811239972 -2132788000 -1247504673 888996228 -815473472 1743865077 -1321489188 -1464608763 1533335148 970012175 954704509 -381483961 -113660686 7512773

Question:16. Type mount (with no parameters) and try to interpret the output. Ans: It will show all the mounts that are present in the system right now and also the path for them.
/dev/sda5 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) gvfs-fuse-daemon on /home/japan/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=japan)

Das könnte Ihnen auch gefallen