diff --git a/sh/tests/easy-perm/example.txt b/sh/tests/easy-perm/example.txt new file mode 100644 index 000000000..6c18d1135 --- /dev/null +++ b/sh/tests/easy-perm/example.txt @@ -0,0 +1,12 @@ +Q. How did the programmer die in the shower? +A. He read the shampoo bottle instructions: Lather. Rinse. Repeat. + +~~~~~~~~~~~~~~~~~~~~~~~~~ + +How many programmers does it take to change a light bulb? +None – It’s a hardware problem + +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Why do programmers always mix up Halloween and Christmas? +Because Oct 31 equals Dec 25. \ No newline at end of file diff --git a/sh/tests/easy-perm/example2.txt b/sh/tests/easy-perm/example2.txt new file mode 100755 index 000000000..efa82fb06 --- /dev/null +++ b/sh/tests/easy-perm/example2.txt @@ -0,0 +1,16 @@ +“The best TDD can do, is assure that code does what the programmer thinks it should do. That is pretty good BTW.” + +“Simply put, things always had to be in a production-ready state: if you wrote it, you darn well had to be there to get it running!” + +“If you think it’s expensive to hire a professional, wait until you hire an amateur.” + +“Programming is not a zero-sum game. Teaching something to a fellow programmer doesn’t take it away from you.” + +“A phased approach to continuous delivery is not only preferable, it’s infinitely more manageable.” + +“So, what do you do?” +“I’m lean” +“What?” +“I’m agile” +“What?” +“Fine. I make websites.” diff --git a/sh/tests/easy-perm_test.sh b/sh/tests/easy-perm_test.sh new file mode 100755 index 000000000..20b53a99e --- /dev/null +++ b/sh/tests/easy-perm_test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Unofficial Bash Strict Mode +set -euo pipefail +IFS=' +' +script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) + +challenge() { + submitted=$(ls -l "$1" && bash "$script_dirS"/student/easy-perm.sh) + expected=$(ls -l "$1" && bash "$script_dirS"/solutions/easy-perm.sh) + + diff <(echo "$submitted") <(echo "$expected") +} + +challenge easy-perm/ diff --git a/sh/tests/solutions/easy-perm.sh b/sh/tests/solutions/easy-perm.sh new file mode 100644 index 000000000..6555771f9 --- /dev/null +++ b/sh/tests/solutions/easy-perm.sh @@ -0,0 +1 @@ +chmod 644 easy-perm/example.txt && chmod 746 easy-perm/example2.txt diff --git a/subjects/devops/easy-perm/README.md b/subjects/devops/easy-perm/README.md new file mode 100644 index 000000000..9b8c787cf --- /dev/null +++ b/subjects/devops/easy-perm/README.md @@ -0,0 +1,46 @@ +## easy-perm + +### Instructions + +Create a file `easy-perm.sh`, which will change the default permissions for the `example.txt` and `example2.txt` files inside the folder `easy-perms`, to the ones bellow: + +Now + +Expected Output: + +```console +$ ls -l easy-perm +total 8 +-rwxr--rw- 1 user user 689 dez 13 16:14 example2.txt +-rw-r--r-- 1 user user 348 dez 13 16:14 example.txt +$ +``` + +### Hints + +-`chmod` The chmod, or change mode, command allows an administrator to set or modify a file’s permissions. Every UNIX/Linux file has an owner user and an owner group attached to it, and every file has permissions associated with it. The permissions are as follows: read, write, or execute. + +This is what the default permissions looks like when you create a file. + +```console +$ touch example.txt +$ ls -l example.txt +-rw-rw-r-- 1 user user 348 dez 13 15:31 example.txt +$ +``` + +This is what it looks like if you want to give permissions to read, write and execute to every group. + +```console +$ chmod 777 example.txt +$ ls -l example.txt +-rwxrwxrwx 1 user user 348 dez 13 15:31 example.txt +$ +``` + +> You have to use Man or Google to know more about commands flags, in order to solve this exercise! +> Google and Man will be your friends! + +### References + +- [Chmod](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/#modify-file-permissions-with-chmod)