Linux Tips: Files, Users & Permissions

Fabio Emilio Costa

http://plus.google.com/+FabioEmilioCosta
http://twitter.com/Hu...
Some History
●

Linux == Unix-Like

●

Quacks like duck, walks like duck, but no duck

●

Unix was created on 1960s

●

Mu...
Permissions
●

Read (4) – cat, cp ...

●

Write (2) – gedit, vi, emacs, rm..

●

eXecute (1) – run as programs (scripts)

...
Users
●

Permissions are given on a file based on:
–
–

Group: people who are from the same group the owner;

–
●

User: w...
Reading permissions on ls -l
File type
● - – common file
● d – directory
●
b – block device (disks)
●
c – character device...
Users & Groups
●

All permissions are based on users

●

Normally indicated by either a name and/or a number

●

On applia...
Manipulating permissions
●

Changing Permissions: chmod (Change Mode);

●

Changing the Owner of a file: chown (Change Own...
Changing permissions with chmod
●

By numbers: sum the permissions numbers. Each number
represents one into User, Group, O...
The root
●

Special user

●

Can do ANYTHING with a system...

●

… including break it

●

Has a special ID of 0

●

Many ...
"With great power comes great
responsibility"
(PARKER, Ben)
Want to see Linux being broken?

Running rm -rf / on Linux

http://www.youtube.com/watch?v=D4fzInly
Don't try this at home...
Scripts
●

On Windows, files are opened based on extension;

●

.exe, .com, .bat – programs/scripts;

●

On Unix, needs eX...
THIS IS CS50
Upcoming SlideShare
Loading in …5
×

CS50x Permissions, Files, Users

289 views
198 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
289
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CS50x Permissions, Files, Users

  1. 1. Linux Tips: Files, Users & Permissions Fabio Emilio Costa http://plus.google.com/+FabioEmilioCosta http://twitter.com/HufflepuffBR http://www.facebook.com/fabiocosta0305 http://www.reddit.com/u/HufflepuffBR
  2. 2. Some History ● Linux == Unix-Like ● Quacks like duck, walks like duck, but no duck ● Unix was created on 1960s ● Multi-user ● How avoid users to access forbidden files ● Permissions ● Groups ● Everything is treated as a file on Unix (directories, devices)
  3. 3. Permissions ● Read (4) – cat, cp ... ● Write (2) – gedit, vi, emacs, rm.. ● eXecute (1) – run as programs (scripts) ● Numbers were normally used ● On directories: – Read: ls... – Write: touch, rm... – Execute: cd...
  4. 4. Users ● Permissions are given on a file based on: – – Group: people who are from the same group the owner; – ● User: who created the file (normally); Others: nuff said... ls -l shows all the normal permissions
  5. 5. Reading permissions on ls -l File type ● - – common file ● d – directory ● b – block device (disks) ● c – character devices (terms) ● l – symbolic link Owner's permissions Group's permissions Other's permissions ● read ● write ● execute ● - – unset permission -rw-------
  6. 6. Users & Groups ● All permissions are based on users ● Normally indicated by either a name and/or a number ● On appliance, jharvard is user 1000 ● Can be seen on /etc/passwd file ● Users normally are parts of groups ● Groups can be used for accounting, security, administration; ● A user can be part of one or more groups; ● jharvard is part of wheel group (can use sudo) ● Can be seen on /etc/group file
  7. 7. Manipulating permissions ● Changing Permissions: chmod (Change Mode); ● Changing the Owner of a file: chown (Change Owner); ● Changing the Group of a file: chgrp (Change Group); ● Just root can chown and chgrp; – ● On older Linux and Unix, owner could chown and chgrp, but that was a security risk (SetUID); Only root and owner can chmod;
  8. 8. Changing permissions with chmod ● By numbers: sum the permissions numbers. Each number represents one into User, Group, Others (UGO) – ● Character indication: placing the needed permissions for a kind after a = symbol; – ● chmod u=rw,go=w bar Set/Unset: using the + symbol to set a permission and a – symbol to unset a permission (easier method); – ● chmod 644 foo chmod a+r,u+w baz Special group: All
  9. 9. The root ● Special user ● Can do ANYTHING with a system... ● … including break it ● Has a special ID of 0 ● Many commands can be done just by root... ● … or users that can use sudo, from wheel group … ● … and jharvard is from wheel group
  10. 10. "With great power comes great responsibility" (PARKER, Ben)
  11. 11. Want to see Linux being broken? Running rm -rf / on Linux http://www.youtube.com/watch?v=D4fzInly Don't try this at home!!!!!
  12. 12. Scripts ● On Windows, files are opened based on extension; ● .exe, .com, .bat – programs/scripts; ● On Unix, needs eXecution permission to run as a script; ● Any file with eXecution permission will be executed (if possible);
  13. 13. THIS IS CS50

×