Skip to content

Instantly share code, notes, and snippets.

@nakaz
Last active August 30, 2017 05:04
Show Gist options
  • Save nakaz/c6e86e112ab2339986a252553c106924 to your computer and use it in GitHub Desktop.
Save nakaz/c6e86e112ab2339986a252553c106924 to your computer and use it in GitHub Desktop.

This exercise can be performed in Bash, CMD, or Powershell

Follow the instructions

Build a bash-exercise.sh file in your HOME directory.

Do your work in the scripts.sh file. Make sure your bash-exercise.sh is executable. You may comment out lines respective to each task to avoid overwriting/errors.

  1. Build a folders directory and inside, build 10 new directories with the incremented name of dir. We should get something like ./folders/dir1, ./folders/dir2 and so forth.
  2. Create a projects directory in ./folders/dir1 and build a README.md file in the projects dir.
  3. Write a command to append the string "Hello World" in your README.md located at: ./folders/dir1/projects/README.md.
  4. Read the contents of the README.md in ./folders/dir1/projects/.
  5. Build a notes directory in the tmp directory located in your root.
  6. Change the ownership of notes dir created to be owned by admin and the permissions drwxr--r--.
  7. Build 3 incremented markdown files in /tmp/notes/ dir as note1.md, note2.md, and note3.md.
  8. Append strings "foo", "bar", and "baz" on separate lines in each of the 3 markdown files in the notes directory of tmp root.
  9. Ensure that the three note files have the permissions of -r--r--r--.
  10. Read the contents of all three markdown files.
  11. Use the word count commmand to print out how many lines are in the nginx.log located in the logs directory. Write the value in your script.
  12. How many lines are in the syslog?
  13. In ufw.log?
  14. in auth.log?
  15. Evaluate the last 100 lines of the nginx.log file and display only lines that have a 404 HTTP status code.
  16. Append all discovered lines into a tmp.nginx.log file in your HOME directory.
  17. Evaluate the first 50 lines of auth.log and display only the lines have "Connection closed".
  18. Append all discovered lines into a tmp.auth.log file in your HOME directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment