Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 50 additions & 27 deletions Tutorials/LinuxBasics/Permissions_Part6.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,27 @@ So lets go ahead and look at the permission on the shell script. To do that run


You should see something like this...






![LsPerm_Screen](http://i.imgur.com/toiOOTm.png)

```
root@Omega-24CF:/# ls -l
-rw-r--r-- 1 root root 985 Sep 3 16:28 LogGen.sh
drwxr-xr-x 2 root root 722 Jul 8 19:36 bin
drwxr-xr-x 5 root root 920 Aug 18 18:07 dev
drwxrwxr-x 1 root root 0 Jul 8 19:33 etc
drwxr-xr-x 11 root root 807 Jul 8 19:26 lib
-rw-r--r-- 1 root root 170 Sep 3 16:50 log.txt
drwxr-xr-x 2 root root 3 Jul 8 19:30 mnt
drwxr-xr-x 5 root root 0 Jan 1 1970 overlay
dr-xr-xr-x 51 root root 0 Jan 1 1970 proc
drwxrwxr-x 16 root root 235 Jul 8 19:36 rom
drwxr-xr-x 1 root root 0 Sep 3 14:08 root
drwxr-xr-x 2 root root 742 Jul 8 19:36 sbin
dr-xr-xr-x 11 root root 0 Jan 1 1970 sys
drwxrwxrwt 16 root root 480 Sep 3 17:04 tmp
drwxr-xr-x 1 root root 0 Aug 5 20:13 usr
lrwxrwxrwx 1 root root 4 Jul 8 19:36 var -> /tmp
drwxr-xr-x 9 root root 171 Jul 8 19:36 www
root@Omega-24CF:/#
```


For now all we are concerned with is the column containing the stuff that looks like this drwxr-xr-x . If you are interested in a more detailed description of what all the descriptions mean refer to this [article](https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions).
Expand Down Expand Up @@ -80,12 +93,11 @@ Since we are the root user we can give ourselves full permission to the file. So



To give ourselves full permission enter this command:


To give ourselves (root) full permission 755 would be ok. If we want to include users in the (root group) 775 would be the right permission. As we want to keep our system as secure as possible, we never should use 777 as full permission. This would mean everyone (group other) who has acces to the system, can run/execute a script wich could be fatal.

<pre><code>chmod 777 LogGen.sh</code></pre>

<pre><code>chmod 755 LogGen.sh</code></pre> just for User root
<pre><code>chmod 775 LogGen.sh</code></pre> for root and group root (in our example).


To check if the permission has changed enter:
Expand All @@ -97,27 +109,38 @@ To check if the permission has changed enter:


You should see something like this below.
```bash
root@Omega-24CF:/# ls -l
-rw-r--r-- 1 root root 985 Sep 3 16:28 LogGen.sh
drwxr-xr-x 2 root root 722 Jul 8 19:36 bin
drwxr-xr-x 5 root root 920 Aug 18 18:07 dev
drwxrwxr-x 1 root root 0 Jul 8 19:33 etc
drwxr-xr-x 11 root root 807 Jul 8 19:26 lib
-rw-r--r-- 1 root root 136 Sep 3 16:29 log.txt
drwxr-xr-x 2 root root 3 Jul 8 19:30 mnt
drwxr-xr-x 5 root root 0 Jan 1 1970 overlay

```






![LsPermChanged_Screen](http://i.imgur.com/DvQMeeP.png)



We have sucessfully given ourselves full permission.
We have sucessfully given ourselves (root) full permission.



So let's try to to run the LogGen.sh file without sh.

<pre><code> ./LogGen </code></pre>





![PermGranted_Screen](http://i.imgur.com/7ud9EHX.png)
```
root@Omega-24CF:/# ./LogGen.sh
-ash: ./LogGen.sh: Permission denied
root@Omega-24CF:/# chmod 755 LogGen.sh
root@Omega-24CF:/# ./LogGen.sh
Please Enter Your Name >Daisy
Donald Sat Sep 3 16:28:53 GMT 2016
Tick Sat Sep 3 16:29:01 GMT 2016
Trick Sat Sep 3 16:29:10 GMT 2016
Track Sat Sep 3 16:29:23 GMT 2016
Daisy Sat Sep 3 16:50:34 GMT 2016
root@Omega-24CF:/#

```