Showing posts with label intro. Show all posts
Showing posts with label intro. Show all posts

Thursday, June 28, 2012

Intro to File Permissions

Intro to File Permissions

Ever want to know who has access to your files and what they're allowed to do to those files? Turns out there are permissions that do exactly those two things.

Let's start by listing out the folder contents in long format with ls -l (shortcut: ll)

alchemist@BogWarfs:/opt/test$ ll
total 12
-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault
-rw-r----- 1 deltys   elves     113 Jun 28 22:55 elvenVault
-rw-r----- 1 herpderp goblins   109 Jun 28 22:56 goblinVault
alchemist@BogWarfs:/opt/test$ cat dwarvenVault 
cat: dwarvenVault: Permission denied

Breakdown

Starting from right-to-left.

Filename

You can bequeath names in the common tongue.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

File name.

Modify Time

Timestamp. If you touch it, it will change. There are different timestamps too but that's a topic for another day.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

File Size

The file size here is 100 bytes. Whoopie.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

Group Name

This file belongs to the group, 'dwarves'. A file can have at most one group.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

Owner Name

This file belongs to the user, 'organdr'. A file can have at most one owner.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

Links

There is one link to the file. Topic for another day.

-rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

Permissions

This is actually a multi-part permissions ACL - Access Control List.

rw-r----- 1 organdr  dwarves   100 Jun 26 22:26 dwarvenVault

This row of dashes and letters has all sorts of meaning. Let's go through what each of the letters stand for. The meanings of these words are lost to mankind.

  • d - directory
  • r - read
  • w - write
  • x - execute

There are actually 4 groupings of permissions here.

-           Directory (in this case, off) 
 rw-        Owner Permissions (organdr)
    r--     Group Permissions (dwarves)
       ---  Global Permissions (everyone else)

From this ACL we can see that Organdr can read/write to the dwarvenVault, Dwarves can read from the Vault, and everyone else isn't allowed to do anything to dwarvenVault.

That's enough for one sitting, we'll talk about changing permissions in the next entry.

Saturday, June 23, 2012

Intro to DHCP

Adventures in Networking - DHCP

DHCP is one of the fundamentals of our current network infrastructure.  It is one of the protocols that allows devices to join your network without you having to push any buttons.  In our techno-splurge culture we bring our tablets and laptops with us everywhere and expect it to work whenever we find a WiFi network.

When I connect to a network, my laptop gets an IP address but how did it do it?  When you plug in a network device, it will start by broadcasting a DHCP discovery (DHCP-DISCOVER).  The broadcast can be heard by anybody within the same subnet.  If a DHCP server (usually the router in a home environment) hears the request, it responds with a DHCP offer (DHCP-OFFER).  The laptop then formally requests the offer (DHCP-REQ) and the server acknowledges it (DHCP-ACK).

These DHCP messages are sent as a package with many envelopes (DHCP Options) which each have a meaning... but we'll get to that later.

Scene 1:  Local DHCP Server

1:  Laptop:  (Yelling) Is there anybody tell me how I can join?  I need an IP address!

2:  Server:  (Yelling) Sure, how about 192.168.0.3?

(Server reserves 192.168.0.3 for Laptop then sends Laptop an info package with everything it needs to know.)

3:  Laptop:  (Yelling optional)  Server, can I please have 192.168.0.3?

4:  Server:  (Softly to Laptop)  Yes, you can use all the info you found in that package to join.

It turns in transaction 1, Laptop actually requests more than just an IP.  It will often request everything it needs to join the network.
  • #3:  Default Gateway (Router's address)
  • #1:  Subnet Mask (The boundaries of the subnet)
  • #15:  Domain Name (Network's name)
  • #6:  Domain Name Server (Server that knows all the names.)
It can request even more information if it needs to.  A VoIP phone might also ask where the call-manager is, a wireless access point might request the location of a wireless controller (not a Wii-mote in this case).  All of these requests get marked in an envelope (DHCP Option 55) and are sent to the DHCP server.  The DHCP server sees envelope #55 and does its best to include a reply for each item in that request list.

That ends our first adventure into DHCP.  It was a very simple transaction, but it enabled our laptop do a lot of amazing things.  We got an IP address and 4 DHCP options which enable our laptop  to look up names on the network and able to talk to other devices without broadcasting to everybody.