Hour 5

Ownership and Permissions


5.1.1) 14 are directories, 1 is executable, 6 are regular files, and 0 links. I used my home folder because /etc is too big.

% ls -aFl
total 32
drwx------ 14spantaro students 1536 May 23 03:03 ./
drwxr-xr-x 22 root students 512 Apr 24 13:36 ../
drwxr-xr-x 2 spantaro students 512 Dec 18 1999 .jetadmin/
-rw-r--r-- 1 spantaro students 90 MMay 9 17:42 .login
-rw------- 1 spantaro students 3244 MMay 23 10:15 .sh_history
-rwx------ 1 spantaro students 1373 MMay 22 23:42 README*
-rw-r--r-- 2 spantaro students 0 MMay 21 20:08 TEST
drwx------ 2 spantaro students 1024 May 9 16:50 bugTrack/
drwx------ 2 spantaro students 1024 Apr 13 11:18 cis316/
drwx------ 3 spantaro students 2048 Sep 19 2000 cis325/
drwx------ 2 spantaro students 512 Oct 4 2000 cis327/
drwx------ 2 spantaro students 1024 Apr 16 23:10 cis328/
drwx------ 2 spantaro students 512 Sep 19 2000 cis377/
drwx------ 2 spantaro students 512 May 16 17:20 cis396q/
-rw-r--r-- 1 spantaro students 0 MMay 23 03:05 file1
-rw-r--r-- 1 spantaro students 0 MMay 23 03:05 file2
-rw-r--r-- 1 spantaro students 0 MMay 23 03:03 file3
drwx------ 2 spantaro students 512 Sep 19 2000 m13com/
drwx------ 2 spantaro students 512 Sep 19 2000 m1feedback/
-rw-r--r-- 1 spantaro students 0 MMay 22 23:44 newfile
drwx------ 2 spantaro students 1536 Apr 28 2000 prokids/
drwx------ 2 spantaro students 512 Mar 30 13:06 public-web/
-rw-r--r-- 1 spantaro students 7907 MMay 22 16:59 sort.manpage.Z
-rw-r--r-- 2 spantaro students 0 MMay 21 20:08 test 



5.1.2)  Display path of current directory. The second command did not work. listed permisions of file say.hi. Changed permissions of the file and again listed its permissions. Before it was an executable file. The executable permission was removed.

internet% pwd
/home2/stud-30/spantaro


internet% env PATH
env: No such file or directory
internet% ls -l say.hi
-rwxr-xr-x 1 spantaro students 8 MMay 23 17:29 say.hi
internet% chmod -x say.hi
internet% ls -l say.hi
-rw-r--r-- 1 spantaro students 8 MMay 23 17:29 say.hi
internet% 

5.1.3)  It was not possible to run this file due to the fact that it has no executable permission anymore.

internet% say.hi
say.hi: Permission denied
internet%

5.1.4)  Command env did not work. Trying to create a file under bin also failed. Used touch to  create file called my.new.cmd and listed its permissions.

internet% env PATH
env: No such file or directory
internet% touch bin/my.new.cmd
touch: bin/my.new.cmd cannot create
internet% touch my.new.cmd
internet% ls -l my.*
-rwxr-xr-x 1 spantaro students 0 MMay 30 10:53 my.new.cmd


5.1.5) Executed the file but it did not do anything because the file is empty

internet% my.new.cmd
internet% 

5.1.6) Assured that the new file has executable permission, listed its permissions and executed it. Again, it did not do anything because the file is empty.

internet% chmod +x my.new.cmd
internet% ls -l my.new.cmd
-rwxr-xr-x 1 spantaro students 0 MMay 30 10:53 my.new.cmd
internet% my.new.cmd
internet%

5.2.1) Listed a directory using flag -d, then listed its content and the contents of its subdirectories. This was possible due to the permissions that where set to the directory.

internet% ls -ld testdir
drwxr-xr-x 3 spantaro students 512 May 28 13:58 testdir
internet% ls -l testdir
total 1
drwxr-xr-x 3 spantaro students 512 May 28 13:58 new.sample.dir
internet% ls -l testdir/new.sample.dir
total 1
drwxr-xr-x 2 spantaro students 512 May 28 12:59 anotherdir
-rw-r--r-- 1 spantaro students 0 MMay 28 13:35 siomara
internet%

5.2.2) Removed some permisions from the directory and got permission denied when trying to access it as example above. The directory needs to have both READ/EXECUTE permissions to be seen.

internet% chmod 400 testdir
internet% ls -ld testdir
dr-------- 3 spantaro students 512 May 28 13:58 testdir
internet% ls -l testdir
ls: testdir/new.sample.dir: Permission denied
total 0
internet% ls -l testdir/new.sample.dir
ls: testdir/new.sample.dir: Permission denied
internet% 

5.2.3) Removed read permisions from the directory and put only executable permission to the owner. A permission denied message appeared when trying to access the directory. However I could see the contents of one of its subdirectories. The directory needs to have both READ/EXECUTE permissions to be seen. Observe that the subdirectory has both read/execute permissions.

internet% chmod 100 testdir
internet% ls -ld testdir
d--x------ 3 spantaro students 512 May 28 13:58 testdir
internet% ls -l testdir
ls: testdir: Permission denied
internet% ls -l testdir/new.sample.dir
total 1
drwxr-xr-x 2 spantaro students 512 May 28 12:59 anotherdir
-rw-r--r-- 1 spantaro students 0 MMay 28 13:35 siomara
internet% ls -ld testdir/new.sample.dir
drwxr-xr-x 3 spantaro students 512 May 28 13:58 testdir/new.sample.dir
internet% 

5.2.4) Always use the command ls with -ld flags to assure that a directory has both, read and execute permissions.

5.2.5) The book skipped the action for this number.

5.2.6) All my directories have read/write permissions which allows me to add files to them. the group and others have no access to them once they don't have both permissions also set (read/write). Only write permission is not enough to allow people to access and add files to a directory.

internet% ls -l
total 27
-rwx------ 1 spantaro students 1373 MMay 22 23:42 README
-rw-r--r-- 1 spantaro students 0 MMay 21 20:08 TEST
drwx------ 2 spantaro students 1024 May 9 16:50 bugTrack
drwx------ 2 spantaro students 1024 Apr 13 11:18 cis316
drwx------ 3 spantaro students 2048 Sep 19 2000 cis325
drwx------ 2 spantaro students 512 Oct 4 2000 cis327
drwx------ 2 spantaro students 1024 Apr 16 23:10 cis328
drwx------ 2 spantaro students 512 Sep 19 2000 cis377
drwx------ 2 spantaro students 512 May 16 17:20 cis396q
-rw-r--r-- 1 spantaro students 0 MMay 28 13:13 file4.doc
-rw-r--r-- 1 spantaro students 10 MMay 28 13:13 file40
drwx------ 2 spantaro students 512 Sep 19 2000 m13com
drwx------ 2 spantaro students 512 Sep 19 2000 m1feedback
-rwxr-xr-x 1 spantaro students 0 MMay 30 10:53 my.new.cmd
-rw-r--r-- 1 spantaro students 90 MMay 28 13:04 new.login
-rw-r--r-- 1 spantaro students 0 MMay 22 23:44 newfile
drwx------ 2 spantaro students 1536 Apr 28 2000 prokids
drwx------ 2 spantaro students 512 Mar 30 13:06 public-web
-rw-r--r-- 1 spantaro students 8 MMay 23 17:29 say.hi
-rw-r--r-- 1 spantaro students 7907 MMay 22 16:59 sort.manpage.Z
d--x------ 3 spantaro students 512 May 28 13:58 testdir
-rw-r--r-- 1 spantaro students 0 MMay 28 23:53 testme
internet%

5.2.7) This shows a directory with many different owners and the way their directory permissions are set.

internet% ls -l /
total 577
-rw-r--r-- 1 root root 9699 FFeb 13 2000 *perl*
-rw-r--r-- 1 root root 0 NNov 3 2000 -R
drwx------ 2 root other 512 Nov 10 1999 Mail
drwxr-xr-x 2 root root 512 Jan 18 2000 TT_DB
drwxr-xr-x 4 root root 512 Nov 6 1999 apps
drwxr--r-- 2 root root 512 Mar 9 2000 apps2
-rw-r--r-- 1 root other 11 NNov 9 1999 awk
lrwxrwxrwx 1 root root 9 Nov 2 1999 bin -> ./usr/bin
drwxr-xr-x 5 root nobody 512 Apr 23 08:58 cdrom
drwxrwxr-x 20 root sys 5120 May 25 09:43 dev
drwxrwxr-x 4 root sys 512 Nov 2 1999 devices
-rw-r--r-- 1 root root 0 JJun 28 2000 emacs-20.4
drwxr-xr-x 35 root sys 3584 May 4 10:36 etc
drwxrwxr-x 3 root sys 512 Nov 2 1999 export
dr-xr-xr-x 1 root root 1 May 4 10:36 home
drwxr-xr-x 41 root root 1024 May 22 12:35 home1
drwxr-xr-x 45 root root 1024 Apr 2 14:01 home2
drwxr-xr-x 40 root root 1024 May 22 10:01 home3
drwxr-xr-x 9 root root 512 Dec 6 08:23 home4
-rw-r--r-- 1 root root 923 NNov 28 2000 int.df
drwxr-xr-x 9 root sys 512 Jan 3 07:56 kernel
lrwxrwxrwx 1 root root 9 Nov 2 1999 lib -> ./usr/lib
drwx------ 2 root root 8192 Nov 2 1999 lost+found
drwx------ 2 root other 512 Dec 13 1999 mail
drwxrwxr-x 2 root sys 512 Nov 2 1999 mnt
-rw-r--r-- 1 root other 0 NNov 29 1999 mrtg
dr-xr-xr-x 1 root root 1 May 4 10:36 net
drwx------ 2 root other 512 Nov 6 1999 nsmail
lrwxrwxrwx 1 root other 9 Nov 6 1999 nsr -> /apps/nsr
drwxrwxr-x 26 root sys 1536 Apr 23 09:20 opt
drwxr-xr-x 17 root sys 1024 Nov 2 1999 platform
dr-xr-xr-x 85 root root 126912 May 30 12:11 proc
-rw-r--r-- 1 root other 396320 MMay 22 10:06 quotas
drwxr-xr-- 3 root wheel 512 Nov 19 1999 root
drwxrwxr-x 2 root sys 512 Jan 3 07:56 sbin
-rw-r--r-- 1 root other 1046 NNov 12 1999 sshd2_config.mw
drwx------ 2 root root 512 Jun 1 2000 tftpboot
drwxrwxrwt 18 sys sys 3353 May 30 12:00 tmp
drwxrwxr-x 33 root sys 1024 Nov 3 1999 usr
drwxr-xr-x 26 root sys 512 Mar 9 2000 var
dr-xr-xr-x 6 root root 512 May 4 10:36 vol
drwxr-xr-x 5 root root 512 Dec 2 1999 web
dr-xr-xr-x 1 root root 1 May 29 18:33 xfn
internet% 

5.2.8) Could not find sys directory but I could identify other links as:

lrwxrwxrwx 1 root root 9 Nov 2 1999 bin -> ./usr/bin
lrwxrwxrwx 1 root root 9 Nov 2 1999 lib -> ./usr/lib
lrwxrwxrwx 1 root other 9 Nov 6 1999 nsr -> /apps/nsr

5.2.9) Enough information to analyze the different file permissions were listed by running the following command: ls -l /.

5.3.1) Touch created a file called test. Then its permissions were listed by command ls followed by -l flag. It shows that test is a regular file with read/write permission to the owner and only read permission to group and others.

internet% touch test
internet% ls -l test
-rw-r--r-- 1 spantaro students 0 MMay 30 12:47 test

5.3.2) Did not change much from the example above. I can see that the permissions when creating a file depends on the system and it can varies from one to another environment.

internet% chmod g-w test
internet% ls -l test
-rw-r--r-- 1 spantaro students 0 MMay 30 12:47 test
internet%

5.3.3) Added write and execute permissions for group regarding file test.

internet% chmod g+wx test
internet% ls -l test
-rw-rwxr-- 1 spantaro students 0 MMay 30 12:54 test
internet% 

5.3.4) Removed all permissions rwx from group regarding test file.

internet% chmod g-rwx test
internet% ls -l test
-rw----r-- 1 spantaro students 0 MMay 30 12:54 test
internet%

5.3.5) Noticed that adding permission to everyone automatically added to the group.

internet% chmod a+r test
internet% ls -l test
-rw-r--r-- 1 spantaro students 0 MMay 30 12:54 test
internet%

5.4.1)

5.5.1) Created a file called example and listed its permissions.

internet% touch example
internet% ls -l example
-rw-r--r-- 1 spantaro students 0 MMay 30 13:08 example
internet%

5.5.2) Modified the permission. Owner can write/read, and group and everyone can not read/write/execute.

internet% chmod 600 example
internet% ls -l example
-rw------- 1 spantaro students 0 MMay 30 13:08 example
internet% 

5.5.3) Modified the permission. Owner, group and everyone can write/read. No execute permission for none.

internet% chmod 666 example
internet% ls -l example
-rw-rw-rw- 1 spantaro students 0 MMay 30 13:08 example
internet%

5.5.4) Modified the permission. Owner can read/write and execute and , group and everyone can read and execute only.

internet% chmod 755 example
internet% ls -l example
-rwxr-xr-x 1 spantaro students 0 MMay 30 13:08 example
internet% 

5.7.1) At GGU with SunOS 5.7 ls -l already shows user and group. So ad or not -g flag doesn't make any difference.

internet% ls -l
total 27
-rwx------ 1 spantaro students 1373 MMay 22 23:42 README
-rw-r--r-- 1 spantaro students 0 MMay 21 20:08 TEST
drwx------ 2 spantaro students 1024 May 9 16:50 bugTrack
drwx------ 2 spantaro students 1024 Apr 13 11:18 cis316
drwx------ 3 spantaro students 2048 Sep 19 2000 cis325 
...

internet% ls -lg
total 27
-rwx------ 1 spantaro students 1373 MMay 22 23:42 README
-rw-r--r-- 1 spantaro students 0 MMay 21 20:08 TEST
drwx------ 2 spantaro students 1024 May 9 16:50 bugTrack
drwx------ 2 spantaro students 1024 Apr 13 11:18 cis316
drwx------ 3 spantaro students 2048 Sep 19 2000 cis325 
...

5.7.2) id shows my group. the following command shows a directory with a wide variety of owners. I can identify many files that belongs to my group.

internet% id
uid=10647(spantaro) gid=206(students)

internet% ls -lg /tmp
total 592
drwxr-xr-x 3 asteil students 180 May 30 11:35 amanda
-rw-rw-rw- 1 www www 68636 MMay 29 09:22 daemonstat.192.251.73.5.8
0
-rw------- 1 root root 289916 MMay 24 13:02 dtdbcache_:0
-rw------- 1 asetiawa students 0 MMay 23 00:35 mp.baaOV
-rw------- 1 asetiawa students 0 MMay 22 23:43 mp1raOlV
-rw------- 1 spantaro students 16591 MMay 9 17:08 mp8LaGwJ
-rw------- 1 fachen students 0 MMay 9 17:23 mpC1aaIL
-rw------- 1 twang students 0 MMay 9 17:23 mpCla4KL
-rw------- 1 phuang students 0 MMay 17 23:12 mpFSa4za
-rw------- 1 mewong staff 0 MMay 17 10:36 mpGtaiL0
-rw------- 1 pmcdevit students 3333 MMay 15 21:50 mpLvaG5z
-rw------- 1 asetiawa students 0 MMay 29 16:47 mpNGa4b5
-rw------- 1 spohar students 3333 MMay 29 14:57 mpOvaabK
-rw------- 1 mctsai students 0 MMay 9 17:25 mpPVaqZL
-rw------- 1 eitelman students 0 MMay 9 17:51 mpP_aqSN
-rw------- 1 wjchen students 0 MMay 22 18:18 mpSuaOKR
-rw------- 1 kloh students 34191 MMay 20 15:09 mpUwaqZr
-rw------- 1 mrubin instruct 0 MMay 9 17:21 mpXla4BL
-rw------- 1 apavlots students 0 MMay 15 20:18 mp_baiXy
-rw------- 1 chuang students 3333 MMay 28 22:42 mpceaGJt
-rw------- 1 wjchen students 0 MMay 29 16:42 mpdoaqf4
-rw------- 1 pbabla students 3333 MMay 14 19:21 mpgIaGsr
-rw------- 1 averma students 19804 MMay 16 10:30 mpmUaOjE
-rw------- 1 pbabla students 14 MMay 9 18:28 pgL4aGGO
-rw------- 1 pbabla students 3 MMay 11 12:15 pgTZaWn1
-rw-rw-r-- 1 root sys 5636 MMay 5 22:43 ps_data
srwxrwxrwx 1 root root 0 May 4 10:36 psb_back_socket
srwxrwxrwx 1 root root 0 May 4 10:36 psb_front_socket
-rw-r--r-- 1 root root 0 MMay 24 13:02 sdtvolcheck5629
drwxr-xr-x 2 yuchen students 117 May 29 18:07 search
-rw-r--r-- 1 root root 5 MMay 24 13:02 speckeysd.lock
drwxr-xr-x 2 aportoca students 117 May 30 09:35 test1
drwxr-xr-x 2 cjen students 117 May 23 18:28 testme
drwxr-xr-x 2 asteil students 117 May 30 11:34 testme!
drwxr--r-- 2 mkoshimo students 117 May 27 21:03 testme2
drwxr-xr-x 2 ktakahas students 117 May 28 18:50 testme3
drwxr-xr-x 2 llin students 117 May 29 23:41 testmeaa
drwxr-xr-x 2 clamm students 117 May 28 19:14 testmecl
dr-xr-xr-x 2 pmcdevit students 117 May 27 18:22 testy
internet%

1