003 - Files Permissions and Git
003 - Files Permissions and Git
1
Objectives covered
Objective Summary Book
2.5 File permissions 15
3.1 Common scripting utilities 4
3.3 Git operations 27
3.4 Advanced Git operations 27
4
LAB: Files and directories
37
Command hints
sudo Switch User and DO
mkdir MaKe DIRectory
nano Friendly editor
vi Less-than-friendly editor
cp CoPy
rm ReMove
man MANual (documentation)
38
Assignment
• Create two new directory trees:
– "~/staff/files" and "~/dummies/files"
• Use "nano" or "vi" to put some text into:
– ~/staff/files/staff-demo.txt
– ~/dummies/files/dummy-demo.txt
• Move:
– ~/staff/ to /home/staff/
– ~/dummies to /home/dummies
39
Spoilers
$ cd ~
$ mkdir -p staff/files dummies/files
$ vi staff/files/staff-demo.txt
$ vi dummies/files/dummies-demo.txt
$ sudo mv staff /home/
$ sudo mv dummies /home/
40
LAB: File permissions
60
Command hints
chmod CHange MODe
chown CHange OWNer
chgrp CHange GRouP
61
Assignment
• /home/staff and contents should have group "staff".
– New files should automatically get group "staff".
– Files should only be deletable by their creator.
– Group "staff" should have full rights on all contents.
62
Spoilers
$ sudo chgrp -R staff /home/staff
$ sudo chown -R opsuser /home/staff
63
Spoilers
$ sudo chgrp -R dummies /home/dummies
$ sudo chown -R dummy1 /home/dummies
64
LAB: Git
99
What's the point again?
• Companies want teams to cooperate.
– They will work on the same code.
– When code is ready for release,
– The central copy will be pushed to production.
100
Your own, "remote" repo
• We now have two VMs.
– And we can SSH from Fedora to the other.
101
Setting up the server
• On the Ubuntu VM, make user account "git".
– With homedir "/home/git".
– And a password you won’t mind typing.
102
Making a repo
• On the Ubuntu VM, login as user "git".
– Configure their name and email (slide 70).
104
Making a change
• On the Fedora VM, "cd" into the Git repo.
• Make a new file and commit the change.
• Then "git push" the update.
105
Comparing
• Compare the contents of:
– The cloned git repo on your Fedora box.
– The bare repo on the Ubuntu VM.
– "git log" on the two repository locations.
106
Co-working
• On the Fedora VM, login as user “dummy”.
• "cd" into your Documents folder.
• Clone the repository from the new VM:
$ git clone ssh://git@ubuntu:/home/git/firstrepo
107
Co-working
• Do you see the file(s) you just pushed?
• Now make another file, as dummy.
• Commit and push it.
108
Spoilers - on Ubuntu
• With your own account …
$ su - git
109
Spoilers - on Ubuntu
• You are now the “git user”…
110
Spoilers - on Fedora
• With your own account.
$ cd ~/Documents
$ cd firstrepo
111
Spoilers - on Fedora
• With your own account.
$ su - dummy
112
Spoilers - on Fedora
• Now you are user "dummy".
113
Spoilers - on Fedora
• You are still user "dummy".
$ exit
114
Spoilers - on Fedora
• You are now using your own account again.
$ cd ~/Documents/firstrepo
$ git pull
$ ls -al
$ cat dummy.txt
115
Closing
117
Homework
• Reading:
– Chapter 4
– Chapter 25
119
Homework
• Go do:
– Download the free book "Pro Git".
– Complete the "Git" lab.
– Make a directory "~/Scripts" for your account.
• Make it a Git repository.
• We will use this for our scripts next week.
120
Reference materials
122
Resources
• Linux file paths
• FHS on Wikipedia
• Identifying file types in Linux
• Graphical vi cheatsheet
• Vim Adventures! (game to practice hotkeys)
• Nano cheatsheet
123
Resources
• Git internals
• Free book: Pro Git
• Intro to Git for security professionals
• Bare vs non-bare repositories
• Stop making shell aliases for SSH!
124