Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #80 and almost complete #81

Open
wants to merge 18 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions _episodes/03-file-transfer.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

---
title: "Transferring Files"
teaching: 10
exercises: 0
questions:
- "How to use wget, curl and lftp to transfer file?"
- "How to use wget, curl, and lftp to transfer files?"
objectives:
- "FIXME"
- "To know different ways to interact with remote files"
keypoints:
- "FIXME"
- "`wget` is the default tool, available in most Linux, to download file."
- "`curl` is another tools to download file which support larger protocols."
- "`lftp` is sosphisticated file transfer program with more capability including torrent support."
---

There are other ways to interact with remote files other than git.
Expand Down Expand Up @@ -94,7 +95,7 @@ where:

`-m` is for mirroring with time stamping, infinite recursion depth, and preservation of FTP directory settings
`-k` converts links to make them suitable for local viewing
`-q` supresses the output to the screen
`-q` suppresses the output to the screen

The above command can also save the clone the contents of one domain to another
if we are using ssh or sshfs to access a webserver.
Expand Down
95 changes: 75 additions & 20 deletions _episodes/04-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ For example, if a file had the following set of permissions:

it would mean that:

* the file's owner can read and write it, but not run it;
* other people in the file's group can read it, but not modify it or run it; and
* everybody else can do nothing with it at all.
* the file's owner can read and write it, but not run it;
* other people in the file's group can read it, but not modify it or run it; and
* everybody else can do nothing with it at all.

Let's look at this model in action.
If we `cd` into the `labs` directory and run `ls -F`,
Expand All @@ -98,13 +98,16 @@ i.e.,
that it's (probably) something the computer can run.

~~~
$ cd labs
$ ls -F
cd labs
ls -F
~~~

{: .bash}

~~~
safety.txt setup* waiver.txt
~~~

{: .output}

> ## Necessary But Not Sufficient
Expand All @@ -124,14 +127,17 @@ safety.txt setup* waiver.txt
Now let's run the command `ls -l`:

~~~
$ ls -l
ls -l
~~~

{: .bash}

~~~
-rw-rw-r-- 1 vlad bio 1158 2010-07-11 08:22 safety.txt
-rwxr-xr-x 1 vlad bio 31988 2010-07-23 20:04 setup
-rw-rw-r-- 1 vlad bio 2312 2010-07-11 08:23 waiver.txt
~~~

{: .output}

The `-l` flag tells `ls` to give us a long-form listing.
Expand Down Expand Up @@ -173,13 +179,15 @@ Here's a long-form listing showing the permissions on the final grades
in the course Vlad is teaching:

~~~
$ ls -l final.grd
ls -l final.grd
~~~

{: .bash}

~~~
-rwxrwxrwx 1 vlad bio 4215 2010-08-29 22:30 final.grd
~~~

{: .output}

Whoops: everyone in the world can read it—and what's worse,
Expand All @@ -190,8 +198,9 @@ which would almost certainly not work.)
The command to change the owner's permissions to `rw-` is:

~~~
$ chmod u=rw final.grd
chmod u=rw final.grd
~~~

{: .bash}

The 'u' signals that we're changing the privileges
Expand All @@ -201,69 +210,78 @@ A quick `ls -l` shows us that it worked,
because the owner's permissions are now set to read and write:

~~~
$ ls -l final.grd
ls -l final.grd
~~~

{: .bash}

~~~
-rw-rwxrwx 1 vlad bio 4215 2010-08-30 08:19 final.grd
~~~

{: .output}

Let's run `chmod` again to give the group read-only permission:

~~~
$ chmod g=r final.grd
$ ls -l final.grd
chmod g=r final.grd
ls -l final.grd
~~~

{: .bash}

~~~
-rw-r--rw- 1 vlad bio 4215 2010-08-30 08:19 final.grd
~~~

{: .output}

And finally,
let's give "all" (everyone on the system who isn't the file's owner or in its group) no permissions at all:
let's give "others" (everyone on the system who isn't the file's owner or in its group) no permissions at all:

~~~
$ chmod a= final.grd
$ ls -l final.grd
chmod o= final.grd
ls -l final.grd
~~~

{: .bash}

~~~
-rw-r----- 1 vlad bio 4215 2010-08-30 08:20 final.grd
~~~

{: .output}

Here,
the 'a' signals that we're changing permissions for "all",
the 'o' signals that we're changing permissions for "others",
and since there's nothing on the right of the "=",
"all"'s new permissions are empty.
"others"'s new permissions are empty.

We can search by permissions, too.
Here, for example, we can use `-type f -perm -u=x` to find files
that the user can execute:

~~~
$ find . -type f -perm -u=x
find . -type f -perm -u=x
~~~

{: .bash}

~~~
./tools/format
./tools/stats
~~~

{: .output}

Before we go any further,
let's run `ls -a -l`
to get a long-form listing that includes directory entries that are normally hidden:

~~~
$ ls -a -l
ls -a -l
~~~

{: .bash}

~~~
Expand All @@ -273,6 +291,7 @@ drwxr-xr-x 1 vlad bio 8192 2010-08-27 23:11 ..
-rwxr-xr-x 1 vlad bio 31988 2010-07-23 20:04 setup
-rw-rw-r-- 1 vlad bio 2312 2010-07-11 08:23 waiver.txt
~~~

{: .output}

The permissions for `.` and `..` (this directory and its parent) start with a 'd'.
Expand Down Expand Up @@ -303,6 +322,40 @@ She's allowed to go through `pluto`, but not to look at what's there.
This trick gives people a way to make some of their directories visible to the world as a whole
without opening up everything else.

## Shebang

Shebang is the #! syntax used in scripts to indicate an interpreter for execution under UNIX/Linux operating systems. For shell, we can use two different approaches,

~~~{.bash}
#!/bin/bash
~~~

or,

~~~{.bash}
#!/usr/bin/env bash
~~~

at the top of the script. The second approach is more portable and recommended.
For instance, check the `file_info.sh` script in the `code` directory.
First, after creating or downloading the script, we need to make it executable using `chmod` command.

~~~{.bash}
chmod u+x file_info.sh
~~~

The `u+x` option is used to permit the "**u**ser to e**x**ecute" the script.
Then we can run the script using the following command:

~~~{.bash}
./file_info.sh example.txt
~~~

Shebang is necessary if we want to run the code without explicitly telling Unix what the interpreter is.
We still run the code without shebang, i.e., by telling the interpreter to run the code,
e.g., `bash file_info.sh example.txt`. If we run the code directly but no shebang
is given, or the permission is not given, the code will not run ("Permission denied" error).

## What about Windows?

Those are the basics of permissions on Unix.
Expand All @@ -322,15 +375,17 @@ Some modern variants of Unix support ACLs as well as the older read-write-execut
but hardly anyone uses them.

> ## Challenge
>
> If `ls -l myfile.php` returns the following details:
>
> ~~~
> -rwxr-xr-- 1 caro zoo 2312 2014-10-25 18:30 myfile.php
> ~~~
>
> {: .output}
>
>
> Which of the following statements is true?
>
>
> 1. caro (the owner) can read, write, and execute myfile.php
> 2. caro (the owner) cannot write to myfile.php
> 3. members of caro (a group) can read, write, and execute myfile.php
Expand Down
17 changes: 0 additions & 17 deletions _episodes/05-directory-structure.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Job control
title: Job Control
teaching: 5
exercises: 0
questions:
Expand Down
2 changes: 1 addition & 1 deletion _episodes/07-aliases.md → _episodes/06-aliases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Aliases and bash customization
title: Aliases and Bash Customization
teaching: 10 minutes
exercises: 0
questions:
Expand Down
Loading