├── 0x00-shell_basics ├── 0-current_working_directory ├── 0-iam_betty ├── 1-listit ├── 1-who_am_i ├── 10-back ├── 100-lets_move ├── 101-clean_emacs ├── 102-tree ├── 103-commas ├── 11-lists ├── 12-file_type ├── 13-symbolic_link ├── 14-copy_html ├── 2-bring_me_home ├── 2-groups ├── 3-listfiles ├── 4-listmorefiles ├── 5-listfilesdigitonly ├── 6-firstdirectory ├── 7-movethatfile ├── 8-firstdelete ├── 9-firstdirdeletion ├── README.md └── school.mgc ├── 0x01-shell_permissions ├── 0-iam_betty ├── 1-who_am_i ├── 10-mirror_permissions ├── 100-change_owner_and_group ├── 101-symbolic_link_permissions ├── 102-if_only ├── 103-Star_Wars ├── 11-directories_permissions ├── 12-directory_permissions ├── 13-change_group ├── 2-groups ├── 3-new_owner ├── 4-empty ├── 5-execute ├── 6-multiple_permissions ├── 7-everybody ├── 8-James_Bond ├── 9-John_Doe └── README.md ├── 0x02-shell_redirections ├── 0-hello_world ├── 1-confused_smiley ├── 10-no_more_js ├── 100-empty_casks ├── 101-gifs ├── 102-acrostic ├── 103-the_biggest_fan ├── 11-directories ├── 12-newest_files ├── 13-unique ├── 14-findthatword ├── 15-countthatword ├── 16-whatsnext ├── 17-hidethisword ├── 18-letteronly ├── 19-AZ ├── 2-hellofile ├── 20-hiago ├── 21-reverse ├── 22-users_and_homes ├── 3-twofiles ├── 4-lastlines ├── 5-firstlines ├── 6-third_line ├── 7-file ├── 8-cwd_state ├── 9-duplicate_last_line └── README.md ├── 0x03-shell_variables_expansions ├── 0-alias ├── 1-hello_you ├── 10-love_exponent_breath ├── 100-decimal_to_hexadecimal ├── 101-rot13 ├── 102-odd ├── 103-water_and_stir ├── 11-binary_to_decimal ├── 12-combinations ├── 13-print_float ├── 2-path ├── 3-paths ├── 4-global_variables ├── 5-local_variables ├── 6-create_local_variable ├── 7-create_global_variable ├── 8-true_knowledge ├── 9-divide_and_rule └── README.md ├── 0x04-loops_conditions_and_parsing ├── 0-RSA_public_key.pub ├── 1-for_best_school ├── 10-fizzbuzz ├── 100-read_and_cut ├── 101-tell_the_story_of_passwd ├── 102-lets_parse_apache_logs ├── 103-dig_the-data ├── 2-while_best_school ├── 3-until_best_school ├── 4-if_9_say_hi ├── 5-4_bad_luck_8_is_your_chance ├── 6-superstitious_numbers ├── 7-clock ├── 8-for_ls ├── 9-to_file_or_not_to_file └── README.md ├── 0x05-processes_and_signals ├── 0-what-is-my-pid ├── 1-list_your_processes ├── 100-process_and_pid_file ├── 101-manage_my_process ├── 102-zombie.c ├── 2-show_your_bash_pid ├── 3-show_your_bash_pid_made_easy ├── 4-to_infinity_and_beyond ├── 5-dont_stop_me_now ├── 6-stop_me_if_you_can ├── 7-highlander ├── 8-beheaded_process ├── README.md └── manage_my_process ├── 0x06-regular_expressions ├── 0-simply_match_school.rb ├── 1-repetition_token_0.rb ├── 100-textme.rb ├── 2-repetition_token_1.rb ├── 3-repetition_token_2.rb ├── 4-repetition_token_3.rb ├── 5-beginning_and_end.rb ├── 6-phone_number.rb ├── 7-OMG_WHY_ARE_YOU_SHOUTING.rb └── README.md ├── 0x07-networking_basics ├── 0-OSI_model ├── 1-types_of_network ├── 2-MAC_and_IP_address ├── 3-UDP_and_TCP ├── 4-TCP_and_UDP_ports ├── 5-is_the_host_on_the_network └── README.md ├── 0x08-networking_basics_2 ├── 0-change_your_home_IP ├── 1-show_attached_IPs ├── 100-port_listening_on_localhost └── README.md ├── 0x0A-configuration_management ├── 0-create_a_file.pp ├── 1-install_a_package.pp ├── 2-execute_a_command.pp └── README.md ├── 0x0B-ssh ├── 0-use_a_private_key ├── 1-create_ssh_key_pair ├── 100-puppet_ssh_config.pp ├── 2-ssh_config └── README.md ├── 0x0C-web_server ├── 0-transfer_file ├── 1-install_nginx_web_server ├── 2-setup_a_domain_name ├── 3-redirection ├── 4-not_found_page_404 ├── 7-puppet_install_nginx_web_server.pp └── README.md ├── 0x0D-web_stack_debugging_0 ├── 0-give_me_a_page └── README.md ├── 0x0E-web_stack_debugging_1 ├── 0-nginx_likes_port_80 ├── 1-debugging_made_short └── README.md ├── 0x0F-load_balancer ├── 0-custom_http_response_header ├── 1-install_load_balancer ├── 2-puppet_custom_http_response_header.pp └── README.md ├── 0x10-https_ssl ├── 0-world_wide_web ├── 1-haproxy_ssl_termination ├── 100-redirect_http_to_https └── README.md ├── 0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter └── 0-blog_post.txt ├── 0x12-web_stack_debugging_2 ├── 0-iamsomeoneelse ├── 1-run_nginx_as_nginx ├── 100-fix_in_7_lines_or_less └── README.md ├── 0x13-firewall ├── 0-block_all_incoming_traffic_but ├── 100-port_forwarding └── README.md ├── 0x14-mysql ├── 4-mysql_configuration_primary ├── 4-mysql_configuration_replica ├── 5-mysql_backup └── README.md ├── 0x15-api ├── 0-gather_data_from_an_API.py ├── 1-export_to_CSV.py ├── 2-export_to_JSON.py ├── 3-dictionary_of_list_of_dictionaries.py └── README.md ├── 0x16-api_advanced ├── 0-subs.py ├── 1-top_ten.py ├── 100-count.py ├── 2-recurse.py └── README.md ├── 0x18-webstack_monitoring ├── 2-setup_datadog └── README.md ├── 0x1A-application_server ├── 2-app_server-nginx_config ├── 3-app_server-nginx_config ├── 4-app_server-nginx_config ├── 4-reload_gunicorn_no_downtime ├── 5-app_server-nginx_config ├── README.md └── gunicorn.service ├── 0x1B-web_stack_debugging_4 ├── 0-the_sky_is_the_limit_not.pp ├── 1-user_limit.pp └── README.md ├── README.md └── attack_is_the_best_defense ├── 0-sniffing ├── 1-dictionary_attack ├── README.md └── user_authenticating_into_server /0x00-shell_basics/0-current_working_directory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/0-iam_betty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | su - betty 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/1-listit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/1-who_am_i: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "$USER" 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/10-back: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd - 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/100-lets_move: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mv [[:upper:]]* /tmp/u 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/101-clean_emacs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm *~ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/102-tree: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p welcome/to/school 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/103-commas: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -pamv 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/11-lists: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -al . .. /boot 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/12-file_type: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | file /tmp/iamafile 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/13-symbolic_link: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ln -s /bin/ls __ls__ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/14-copy_html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cp -nu *.html .. 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/2-bring_me_home: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/2-groups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | groups 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/3-listfiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/4-listmorefiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -al 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/5-listfilesdigitonly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -lna 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/6-firstdirectory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/7-movethatfile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mv /tmp/betty /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/8-firstdelete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm /tmp/my_first_directory/betty 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/9-firstdirdeletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/README.md: -------------------------------------------------------------------------------- 1 | system engineering devops folder 2 | -------------------------------------------------------------------------------- /0x00-shell_basics/school.mgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrightDaniel/alx-system_engineering-devops/5b5201ea9355bc5d490beff5ae8786ad02da9d02/0x00-shell_basics/school.mgc -------------------------------------------------------------------------------- /0x01-shell_permissions/0-iam_betty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | su betty 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/1-who_am_i: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | id -u -n 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/10-mirror_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod --reference=olleh hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/100-change_owner_and_group: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown -hR vincent:staff . 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/101-symbolic_link_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown -h vincent:staff _hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/102-if_only: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown --from=guillaume betty hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/103-Star_Wars: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | telnet towel.blinkenlights.nl 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/11-directories_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod -R ugo+X . 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/12-directory_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -m 751 my_dir 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/13-change_group: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chgrp school hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/2-groups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | groups 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/3-new_owner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown betty hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/4-empty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | touch hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/5-execute: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod u+x hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/6-multiple_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod u+x,g+x,o+r hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/7-everybody: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod ugo+x hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/8-James_Bond: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod 007 hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/9-John_Doe: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod 753 hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/README.md: -------------------------------------------------------------------------------- 1 | Readme details later 2 | -------------------------------------------------------------------------------- /0x02-shell_redirections/0-hello_world: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Hello, World" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/1-confused_smiley: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "\"(Ôo)'" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/10-no_more_js: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.js" -delete 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/100-empty_casks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -empty | rev | cut -d '/' -f 1 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/101-gifs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find -type f -name "*.gif" | rev | cut -d "/" -f 1 | cut -d '.' -f 2- | rev | LC_ALL=C sort -f 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/102-acrostic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c 1 | paste -s -d '' 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/103-the_biggest_fan: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n +2 | cut -f -1 | sort -k 1 | uniq -c | sort -rnk 1 | head -n 11 | rev | cut -d ' ' -f -1 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/11-directories: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type d -not -name '.' | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/12-newest_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -t1 | head -n 10 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/13-unique: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort | uniq -u 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/14-findthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/15-countthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -c -i "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/16-whatsnext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" -A 3 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/17-hidethisword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i -v "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/18-letteronly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "^[a-z]" /etc/ssh/sshd_config 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/19-AZ: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr "A" "Z" | tr "c" "e" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/2-hellofile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/20-hiago: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr -d "cC" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/21-reverse: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/22-users_and_homes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d ':' -f 1,6 /etc/passwd | sort 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/3-twofiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd /etc/hosts 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/4-lastlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/5-firstlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/6-third_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 3 iacta | tail -n +3 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/7-file: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Best School" > \\\*\\\\"'\"Best School\"\\'"\\\\\*\$\\\?\\\*\\\*\\\*\\\*\\\*\:\) 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/8-cwd_state: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la > ls_cwd_content 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/9-duplicate_last_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 1 iacta >> iacta 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/README.md: -------------------------------------------------------------------------------- 1 | Shell, I/O Redirections and filters 2 | Project done during Full Stack Software Engineering studies at Holberton School. It aims to learn about how to handle standard input and output and how to combine commands and filters with redirections in Shell. 3 | 4 | Technologies 5 | Scripts written in Bash 4.3.11(1) 6 | Tested on Ubuntu 14.04 LTS 7 | Files 8 | All of the following files are scripts: 9 | 10 | Filename Description 11 | 0-hello_world Prints "Hello, World", followed by a new line to the standard output 12 | 1-confused_smiley Displays a confused smiley "(Ôo)' 13 | 2-hellofile Displays the content of the /etc/passwdfile 14 | 3-twofiles Displays the content of /etc/passwd and /etc/hosts 15 | 4-lastlines Displays the last 10 lines of /etc/passwd 16 | 5-firstlines Displays the first 10 lines of /etc/passwd 17 | 6-third_line Displays the third line of the file iacta 18 | 7-file Creates a file named exactly \*\\'"Holberton School"\'\\*$\?\*\*\*\*\*:) containing the test Holberton School ending by a new line 19 | 8-cwd_state Writes into the file ls_cwd_content the result of the command ls -la. 20 | 9-duplicate_last_line Duplicates the last line of the file iacta 21 | 10-no_more_js Deletes all the regular files with a .js extension that are present in the current directory and all its subfolders 22 | 11-directories Counts the number of directories and sub-directories in the current directory 23 | 12-newest_files Displays the 10 newest files in the current directory 24 | 13-unique Takes a list of words as input and prints only words that appear exactly once 25 | 14-findthatword Displayes lines containing the pattern "root" from the file /etc/passwd 26 | 15-countthatword Displays the number of lines that contain the pattern "bin" in the file /etc/passwd 27 | 16-whatsnext Displays lines containing the patter "root" and 3 lines after them in the file /etc/passwd 28 | 17-hidethisword Displays all the lines in the file /etc/passwd that do not contain the pattern "bin" 29 | 18-letteronly Displays all lines of the file /etc/ssh/sshd_config starting with a letter 30 | 19-AZ Replaces all characters A and c from input to Z and e respectively 31 | 20-hiago Removes all letters c and C from input 32 | 21-reverse Reverses its input 33 | 22-users_and_homes Displays all users and their home directories, sorted by users 34 | 100-empty_casks Finds all empty files and directories in the current directory and all sub-directories 35 | 101-gifs Lists all the files with a .gif extension in the current directory and all its sub-directories 36 | 102-acrostic Decodes acrostics that use the first letter of each line 37 | 103-the_biggest_fan Parses web servers in TSV format as input and displays the 11 hosts or IP addresses which did the most requests 38 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/0-alias: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | alias ls="rm *" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/1-hello_you: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo hello $USER 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/10-love_exponent_breath: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(( BREATH**LOVE )) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/100-decimal_to_hexadecimal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf '%x\n' $DECIMAL 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/101-rot13: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr 'A-Ma-mN-Zn-z' 'N-Zn-zA-Ma-m' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/102-odd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | paste - - | cut -f1 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/103-water_and_stir: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf '%o\n' $(( 5#$( echo $WATER | tr water 01234) + 5#$( echo $STIR | tr stir. 01234 ) )) | tr 01234567 bestchol 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/11-binary_to_decimal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(( 2#$BINARY )) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/12-combinations: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo {a..z}{a..z} | tr ' ' '\n' | grep -v "oo" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/13-print_float: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf '%.2f\n' $NUM 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/2-path: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export PATH=$PATH:/action 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/3-paths: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $PATH | tr -s ':' '\n' | wc -l 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/4-global_variables: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printenv 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/5-local_variables: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/6-create_local_variable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BEST="School" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/7-create_global_variable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export BEST="School" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/8-true_knowledge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(( 128 + $TRUEKNOWLEDGE )) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/9-divide_and_rule: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(( $POWER / $DIVIDE )) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/README.md: -------------------------------------------------------------------------------- 1 | 0. Create a script that creates an alias. 2 | 1. Create a script that prints hello user, where user is the current Linux user. 3 | 2. Add /action to the PATH. /action should be the last directory the shell looks into when looking for a program. 4 | 3. Create a script that counts the number of directories in the PATH. 5 | 4. Create a script that lists environment variables. 6 | 5. Create a script that lists all local variables and environment variables, and functions. 7 | 6. Create a script that creates a new local variable. 8 | Name: BEST 9 | Value: School 10 | 7. Create a script that creates a new global variable. 11 | Name: BEST 12 | Value: School 13 | 8. Write a script that prints the result of the addition of 128 with the value stored in the environment variable TRUEKNOWLEDGE, followed by a new line. 14 | 9. Write a script that prints the result of POWER divided by DIVIDE, followed by a new line. 15 | POWER and DIVIDE are environment variables 16 | 10. Write a script that displays the result of BREATH to the power LOVE 17 | BREATH and LOVE are environment variables 18 | The script should display the result, followed by a new line 19 | 11. Write a script that converts a number from base 2 to base 10. 20 | The number in base 2 is stored in the environment variable BINARY 21 | The script should display the number in base 10, followed by a new line 22 | 12. Create a script that prints all possible combinations of two letters, except oo. 23 | Letters are lower cases, from a to z 24 | One combination per line 25 | The output should be alpha ordered, starting with aa 26 | Do not print oo 27 | Your script file should contain maximum 64 characters 28 | 13. Write a script that prints a number with two decimal places, followed by a new line. 29 | The number will be stored in the environment variable NUM. 30 | 14. 31 | 15. 32 | 16. 33 | 17. 34 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/0-RSA_public_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCzaVKjoapF2cUAVzmo2WSjTxNapBFx/odVC4kUJ1gjlNyVCY5Qievf9CLJY53Loh1Ds3u549xKm1g+390Z7TAPXiiwFnwMHVTi2/FqD/pRL21frSrWgh2M72sgANLtxuS2QWhckxOoUO5vKOd1xrwXTWbXZka7JbpvKStUl1pWkXyo8kESnx8fQnIft26mUzBdam5kgCcC/rBUaTccB7bQ4XDJ+rHRKzyyUXclLz2dRjFzOCDxjw6Khvi55jmJlFnLS7DvaCYg5J2Op6lgqXUFcJTzvGCUYpH5EKmIZtWKhSpRMafMke8bwOQB7MZaI+K8l0Xu2G0nish4FHGM6pTQ4Ii4v33dgCTbK9+E1Bse6LRj6bWf1e2LM3jcERcv9A5D1ni+ElT+QOPlrG/PCCVwuHOrb1y0cVamhJZbY0ZKaybXloK6Uvjs/G5nUeiJSqXUFGN9urP0+xtABX6bS+NjK1X1Hq2RwAIpURTm3AkxvUnur5O7Xkt6S9oybhT/+V8= $@Boundary 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/1-for_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Holberton School" 10 times 3 | for _ in {1..10} ; do 4 | echo "Best School" 5 | done 6 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/10-fizzbuzz: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays FizzBuzz when the number is a multiple of 3 and 5 fizz for 3 buzz 5 3 | for ((n=1;n<=100;n++)) 4 | do 5 | if ((n % 15 == 0)) 6 | then 7 | echo "FizzBuzz" 8 | elif ((n % 3 == 0)) 9 | then 10 | echo "Fizz" 11 | elif ((n % 5 == 0)) 12 | then 13 | echo "Buzz" 14 | else 15 | echo "$n" 16 | fi 17 | done 18 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/100-read_and_cut: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays the content of the file /etc/passwd. 3 | # Your script should only display: 4 | # username 5 | # user id 6 | # Home directory path for the user 7 | while read -r line; do 8 | echo "$line" | cut -d ':' -f 1,3,6 9 | done /var/run/myscript.pid 16 | 17 | while true 18 | do 19 | echo "To infinity and beyond" 20 | sleep 2 21 | trap 'echo "Y U no love me?!"' SIGINT 22 | trap 'echo "I hate the kill command" && terminator' SIGTERM 23 | trap 'terminator' SIGQUIT 24 | done 25 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/101-manage_my_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Manages 'manage_my_process' 3 | 4 | if [ "${1}" == "start" ] 5 | then 6 | ./manage_my_process & 7 | touch /var/run/my_process.pid 8 | echo "$!" > /var/run/my_process.pid 9 | echo "manage_my_process started" 10 | elif [ "${1}" == "stop" ] 11 | then 12 | echo "manage_my_process stopped" 13 | kill "$(cat /var/run/my_process.pid)" 14 | rm /var/run/my_process.pid 15 | elif [ "${1}" == "restart" ] 16 | then 17 | kill "$(cat /var/run/my_process.pid)" 18 | rm /var/run/my_process.pid 19 | ./manage_my_process & 20 | touch /var/run/my_process.pid 21 | echo "$!" > /var/run/my_process.pid 22 | echo "manage_my_process restarted" 23 | else 24 | echo "Usage: manage_my_process {start|stop|restart}" 25 | fi 26 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/102-zombie.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /** 8 | * infinite_while - Run an infinite while loop. 9 | * 10 | * Return: Always 0. 11 | */ 12 | int infinite_while(void) 13 | { 14 | while (1) 15 | { 16 | sleep(1); 17 | } 18 | return (0); 19 | } 20 | 21 | /** 22 | * main - Creates five zombie processes. 23 | * 24 | * Return: Always 0. 25 | */ 26 | int main(void) 27 | { 28 | pid_t pid; 29 | char count = 0; 30 | 31 | while (count < 5) 32 | { 33 | pid = fork(); 34 | if (pid > 0) 35 | { 36 | printf("Zombie process created, PID: %d\n", pid); 37 | sleep(1); 38 | count++; 39 | } 40 | else 41 | exit(0); 42 | } 43 | 44 | infinite_while(); 45 | 46 | return (EXIT_SUCCESS); 47 | } 48 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/2-show_your_bash_pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays lines containing the bash word 3 | # shellcheck disable=SC2009 4 | 5 | ps -aux | grep bash 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/3-show_your_bash_pid_made_easy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays the PID, along with the process name, of 3 | # processes whose name contain the word bash 4 | 5 | pgrep bash -l 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/4-to_infinity_and_beyond: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays To infinity and beyond indefinitely. 3 | 4 | while true 5 | do 6 | echo "To infinity and beyond" 7 | sleep 2 8 | done 9 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/5-dont_stop_me_now: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # stopped our 4-to_infinity_and_beyond process 3 | # using ctrl+c in the previous task 4 | 5 | kill "$(pgrep -f 4-to_infinity_and_beyond)" 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/6-stop_me_if_you_can: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Bash script that stops 4-to_infinity_and_beyond process. 3 | 4 | pkill -f 4-to_infinity_and_beyond 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/7-highlander: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays To infinity and beyond indefinitely 3 | # With a sleep 2 in between each iteration 4 | # I am invincible!!! when receiving a SIGTERM signal 5 | 6 | while true 7 | do 8 | echo "To infinity and beyond" 9 | sleep 2 10 | trap 'echo "I am invincible!!!"' SIGTERM 11 | done 12 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/8-beheaded_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # kill "7-highlander" process 3 | 4 | pkill -f -SIGKILL 7-highlander 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/README.md: -------------------------------------------------------------------------------- 1 | 0x05-processes_and_signals 2 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/manage_my_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Indefinitely writes I am alive! to the file /tmp/my_process 3 | 4 | while true 5 | do 6 | sudo bash -c 'echo "I am alive!" >> /tmp/my_process' 7 | sleep 2 8 | done 9 | -------------------------------------------------------------------------------- /0x06-regular_expressions/0-simply_match_school.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/School/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/1-repetition_token_0.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt{2,5}n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/100-textme.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/\[from:(.*?)\] \[to:(.*?)\] \[flags:(.*?)\]/).join(",") 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/2-repetition_token_1.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hb?tn/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/3-repetition_token_2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt+n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/4-repetition_token_3.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt*n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/5-beginning_and_end.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^h.n$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/6-phone_number.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^[0-9]{10}$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/7-OMG_WHY_ARE_YOU_SHOUTING.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/[A-Z]+/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/README.md: -------------------------------------------------------------------------------- 1 | 0x06-regular_expressions 2 | -------------------------------------------------------------------------------- /0x07-networking_basics/0-OSI_model: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/1-types_of_network: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/2-MAC_and_IP_address: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/3-UDP_and_TCP: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/4-TCP_and_UDP_ports: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # a Bash script that displays listening ports: 3 | #+ That only shows listening sockets 4 | #+ That shows the PID and name of the program to which each socket belongs 5 | 6 | sudo netstat -lp 7 | -------------------------------------------------------------------------------- /0x07-networking_basics/5-is_the_host_on_the_network: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # a Bash script that pings an IP address passed as an argument. Requirements: 3 | #+ Accepts a string as an argument 4 | #+ Displays 'Usage: 5-is_the_host_on_the_network {IP_ADDRESS}' if no argument passed 5 | #+ Pings the IP 5 times 6 | 7 | if [ "$#" -eq 0 ]; then 8 | echo 'Usage: 5-is_the_host_on_the_network {IP_ADDRESS}' 9 | else 10 | ping -c 5 "$1" 11 | fi 12 | -------------------------------------------------------------------------------- /0x07-networking_basics/README.md: -------------------------------------------------------------------------------- 1 | # 0x07. Networking basics #0 2 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/0-change_your_home_IP: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Change localhost to 127.0.0.2 3 | # Change facebook.com to 8.8.8.8 4 | 5 | cp /etc/hosts ~/hosts.new 6 | sed -i 's/127.*$/127.0.0.2 localhost\n8.8.8.8 facebook.com/' ~/hosts.new 7 | cp -f ~/hosts.new /etc/hosts 8 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/1-show_attached_IPs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays all active IPv4 IPs on the machine it is executed on 3 | 4 | ifconfig | grep -Eo "inet (addr:)?([0-9]*\.){3}[0-9]*" | cut -b 11- 5 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/100-port_listening_on_localhost: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # listens on port 98 on localhost 3 | 4 | nc -l 98 5 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/README.md: -------------------------------------------------------------------------------- 1 | 0x08. Networking basics #1 2 | -------------------------------------------------------------------------------- /0x0A-configuration_management/0-create_a_file.pp: -------------------------------------------------------------------------------- 1 | # Create file in /tmp 2 | 3 | file { '/tmp/school' : 4 | path => '/tmp/school', 5 | mode => '0744', 6 | owner => 'www-data', 7 | group => 'www-data', 8 | content => 'I love Puppet', 9 | } 10 | -------------------------------------------------------------------------------- /0x0A-configuration_management/1-install_a_package.pp: -------------------------------------------------------------------------------- 1 | # install flask from pip3 2 | package { 'flask' : 3 | ensure => '2.1.0', 4 | provider => 'pip3', 5 | } 6 | -------------------------------------------------------------------------------- /0x0A-configuration_management/2-execute_a_command.pp: -------------------------------------------------------------------------------- 1 | # create a process named killmenow 2 | 3 | exec { 'pkill killmenow' : 4 | path => '/bin/', 5 | command => 'pkill killmenow', 6 | } 7 | -------------------------------------------------------------------------------- /0x0A-configuration_management/README.md: -------------------------------------------------------------------------------- 1 | # 0x0A. Configuration management 2 | -------------------------------------------------------------------------------- /0x0B-ssh/0-use_a_private_key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Connect to your server 3 | ssh -i ~/.ssh/school ubuntu@54.160.125.234 4 | -------------------------------------------------------------------------------- /0x0B-ssh/1-create_ssh_key_pair: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Creates an RSA key pair with the passphrase betty 3 | ssh-keygen -f school -b 4096 -N betty 4 | -------------------------------------------------------------------------------- /0x0B-ssh/100-puppet_ssh_config.pp: -------------------------------------------------------------------------------- 1 | # make changes to config file using Puppet 2 | 3 | include stdlib 4 | 5 | file_line { 'Refuse to authenticate using a password': 6 | ensure => present, 7 | path => '/etc/ssh/ssh_config', 8 | line => 'PasswordAuthentication no', 9 | } 10 | 11 | file_line { 'Use private key': 12 | ensure => present, 13 | path => '/etc/ssh/ssh_config', 14 | line => 'IdentityFile ~/.ssh/school' 15 | } 16 | -------------------------------------------------------------------------------- /0x0B-ssh/2-ssh_config: -------------------------------------------------------------------------------- 1 | # ssh_config 2 | 3 | Host * 4 | PasswordAuthentication no 5 | IdentityFile ~/.ssh/school 6 | SendEnv LANG LC_* 7 | HashKnownHosts yes 8 | GSSAPIAuthentication yes 9 | HostName 100.26.10.86 10 | User ubuntu 11 | -------------------------------------------------------------------------------- /0x0B-ssh/README.md: -------------------------------------------------------------------------------- 1 | # 0x0B. SSH 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 45 | 46 | 47 | 48 |
NameUsernameIPState
59637-web-01ubuntu52.23.212.37running 21 |
22 | 27 | 43 |
44 |
49 | -------------------------------------------------------------------------------- /0x0C-web_server/0-transfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This is a bash script that transfers a file from a client to a server using scp 3 | 4 | if [ "$#" -lt 3 ]; then 5 | echo "Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY" 6 | elif [ "$#" -lt 4 ]; then 7 | scp -o StrictHostKeyChecking=no "$1" "$3@$2":~/ 8 | else 9 | scp -i "$4" -o StrictHostKeyChecking=no "$1" "$3@$2":~/ 10 | fi 11 | -------------------------------------------------------------------------------- /0x0C-web_server/1-install_nginx_web_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Install nginx on your web-01 server 3 | # Nginx should be listening on port 80 4 | # When querying Nginx at its root / with a GET request (requesting a page) 5 | # using curl, it must return a page that contains the string Holberton School 6 | 7 | apt-get -y update 8 | apt-get -y install nginx 9 | ufw allow 'Nginx HTTP' 10 | echo 'Hello World!' > /var/www/html/index.html 11 | service nginx start 12 | -------------------------------------------------------------------------------- /0x0C-web_server/2-setup_a_domain_name: -------------------------------------------------------------------------------- 1 | brightdaniel.tech 2 | -------------------------------------------------------------------------------- /0x0C-web_server/3-redirection: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure your Nginx server so that /redirect_me is redirecting to another page. 3 | # The redirection is configured as a "301 Moved Permanently" 4 | 5 | apt-get update 6 | apt-get install -y nginx 7 | 8 | mkdir /etc/nginx/html 9 | touch /etc/nginx/html/index.html 10 | echo "Hello Word!" > /etc/nginx/html/index.html 11 | printf %s "server { 12 | listen 80; 13 | listen [::]:80 default_server; 14 | root /etc/nginx/html; 15 | index index.html index.htm; 16 | location /redirect_me { 17 | return 301 https://www.youtube.com/watch?v=QH2-TGUlwu4; 18 | } 19 | }" > /etc/nginx/sites-available/default 20 | 21 | service nginx restart 22 | -------------------------------------------------------------------------------- /0x0C-web_server/4-not_found_page_404: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure your Nginx server to have a custom 404 page 3 | 4 | apt-get update 5 | apt-get install -y nginx 6 | 7 | mkdir /etc/nginx/html 8 | touch /etc/nginx/html/index.html 9 | echo "Hello World!" > /etc/nginx/html/index.html 10 | touch /etc/nginx/html/404.html 11 | echo "Ceci n'est pas une page" > /etc/nginx/html/404.html 12 | 13 | printf %s "server { 14 | listen 80; 15 | listen [::]:80 default_server; 16 | root /etc/nginx/html; 17 | index index.html index.htm; 18 | 19 | location /redirect_me { 20 | return 301 https://www.youtube.com/watch?v=QH2-TGUlwu4; 21 | } 22 | 23 | error_page 404 /404.html; 24 | location /404 { 25 | root /etc/nginx/html; 26 | internal; 27 | } 28 | }" > /etc/nginx/sites-available/default 29 | 30 | service nginx restart 31 | -------------------------------------------------------------------------------- /0x0C-web_server/7-puppet_install_nginx_web_server.pp: -------------------------------------------------------------------------------- 1 | # Install Nginx web server (w/ Puppet) 2 | package { 'nginx': 3 | ensure => installed, 4 | } 5 | 6 | file_line { 'aaaaa': 7 | ensure => 'present', 8 | path => '/etc/nginx/sites-available/default', 9 | after => 'listen 80 default_server;', 10 | line => 'rewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;', 11 | } 12 | 13 | file { '/var/www/html/index.html': 14 | content => 'Hello World!', 15 | } 16 | 17 | service { 'nginx': 18 | ensure => running, 19 | require => Package['nginx'], 20 | } 21 | -------------------------------------------------------------------------------- /0x0C-web_server/README.md: -------------------------------------------------------------------------------- 1 | 0x0C-web_server 2 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Run Apache on the 265-0 Docker container. 3 | echo "ServerName localhost" >> /etc/apache2.conf 4 | service apache2 start 5 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/README.md: -------------------------------------------------------------------------------- 1 | 0x0D. Web stack debugging #0 2 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/0-nginx_likes_port_80: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # what’s keeping your Ubuntu container’s Nginx installation from listening on port 8? 3 | # configures nginx to run and listen to port 80 4 | 5 | rm /etc/nginx/sites-enabled/default 6 | ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default 7 | service nginx restart 8 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/1-debugging_made_short: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Changes port in Nginx 3 | sed -i 's/8080/80/g' /etc/nginx/sites-enabled/default 4 | sudo service nginx restart 5 | kill -9 "$(cat /var/run/nginx.pid)" 6 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/README.md: -------------------------------------------------------------------------------- 1 | # 0x0E. Web stack debugging 2 | 3 | ### [0. Nginx likes port 80](./0-nginx_likes_port_80) 4 | * Using your debugging skills, find out what’s keeping your Ubuntu container’s Nginx installation from listening on port 80. Feel free to install whatever tool you need, start and destroy as many containers as you need to debug the issue. Then, write a Bash script with the minimum number of commands to automate your fix. 5 | 6 | 7 | ### [1. Make it sweet and short](./1-debugging_made_short) 8 | * Using what you did for task #0, make your fix short and sweet. 9 | 10 | --- 11 | 12 | ## Author 13 | * **Bright Daniel** - (https://github.com/brightdaniel) 14 | -------------------------------------------------------------------------------- /0x0F-load_balancer/0-custom_http_response_header: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure Nginx so that its HTTP response contains a custom header 3 | # HTTP response contains a custom header (on web-01 and web-02) 4 | var=$(hostname) 5 | new_string="error_page 404 \/custom_404.html;\n location \/redirect_me {\n return 301 \$scheme:\/\/www.google.com;" 6 | new_string2="server {\n\tadd_header X-Served-By $var;" 7 | 8 | apt-get update -y 9 | apt-get install nginx -y 10 | echo "Hello World!" > /usr/share/nginx/html/index.html 11 | mkdir -p /var/www/html 12 | echo "Ceci n'est pas une page" > /var/www/html/custom_404.html 13 | sudo sed -i -E "s/^[^#]+location \/ \{/$new_string/" /etc/nginx/sites-available/default 14 | sudo sed -i -E "s/^server \{/$new_string2/" /etc/nginx/sites-available/default 15 | sudo service nginx start 16 | -------------------------------------------------------------------------------- /0x0F-load_balancer/1-install_load_balancer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Installs and configures HAproxy in a load balancer server 3 | 4 | apt-get install -y software-properties-common 5 | add-apt-repository -y ppa:vbernat/haproxy-1.8 6 | apt-get update 7 | apt-get install -y haproxy=1.8.\* 8 | 9 | echo "ENABLED=1" >> /etc/default/haproxy 10 | mv /etc/haproxy/haproxy.cfg{,.original} 11 | touch /etc/haproxy/haproxy.cfg 12 | 13 | printf %s "global 14 | log 127.0.0.1 local0 notice 15 | maxconn 2000 16 | user haproxy 17 | group haproxy 18 | defaults 19 | log global 20 | mode http 21 | option httplog 22 | option dontlognull 23 | retries 3 24 | option redispatch 25 | timeout connect 5000 26 | timeout client 10000 27 | timeout server 10000 28 | listen hbnb 29 | bind 0.0.0.0:80 30 | mode http 31 | stats enable 32 | stats uri /haproxy?stats 33 | balance roundrobin 34 | option httpclose 35 | option forwardfor 36 | server 59637-web-01 54.160.85.72:80 check 37 | server 59637-web-02 35.175.132.106:80 check 38 | " >> /etc/haproxy/haproxy.cfg 39 | 40 | service haproxy start 41 | -------------------------------------------------------------------------------- /0x0F-load_balancer/2-puppet_custom_http_response_header.pp: -------------------------------------------------------------------------------- 1 | # Installs a Nginx server with custom HTTP header 2 | 3 | exec {'update': 4 | provider => shell, 5 | command => 'sudo apt-get -y update', 6 | before => Exec['install Nginx'], 7 | } 8 | 9 | exec {'install Nginx': 10 | provider => shell, 11 | command => 'sudo apt-get -y install nginx', 12 | before => Exec['add_header'], 13 | } 14 | 15 | exec { 'add_header': 16 | provider => shell, 17 | environment => ["HOST=${hostname}"], 18 | command => 'sudo sed -i "s/include \/etc\/nginx\/sites-enabled\/\*;/include \/etc\/nginx\/sites-enabled\/\*;\n\tadd_header X-Served-By \"$HOST\";/" /etc/nginx/nginx.conf', 19 | before => Exec['restart Nginx'], 20 | } 21 | 22 | exec { 'restart Nginx': 23 | provider => shell, 24 | command => 'sudo service nginx restart', 25 | } 26 | -------------------------------------------------------------------------------- /0x0F-load_balancer/README.md: -------------------------------------------------------------------------------- 1 | Here I continued to build up the configuration of the web server 2 | issued in project 0x0B. I was issued two additional servers, one to replicate 3 | the Nginx configuration of my original server, and another to set up an HAproxy 4 | load balancer on to manage both web servers. 5 | 6 | Here are the implementation specifications 7 | 8 | ## Tasks :page_with_curl: 9 | 10 | * **0. Double the number of webservers** 11 | * [0-custom_http_response_header](./0-custom_http_response_header): Bash 12 | script that installs and configures Nginx on a server with a custom HTTP 13 | response header. 14 | * The name of the HTTP header is `X-Served-By`. 15 | * The value of the HTTP header is the hostname of the server. 16 | 17 | * **1. Install your load balancer** 18 | * [1-install_load_balancer](./1-install_load_balancer): Bash script that 19 | installs and configures HAproxy version 1.5 on a server. 20 | * Enables management via the init script. 21 | * Requests are distributed using a round-robin algorithm. 22 | 23 | * **2-puppet custom http response header** 24 | * [2-puppet_custom_http_response_header.pp](./2-puppet_custom_http_response_header.pp): Bash script that 25 | Just as in task #0, we’d like you to automate the task of creating a custom HTTP header response, but with Puppet. 26 | * The name of the custom HTTP header must be X-Served-By 27 | * The value of the custom HTTP header must be the hostname of the server Nginx is running on 28 | -------------------------------------------------------------------------------- /0x10-https_ssl/0-world_wide_web: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script that will display information about subdomains 3 | 4 | DNS_info () { 5 | ANSWER=$(dig $2 | grep -A1 'ANSWER SECTION:' | awk 'NR==2 {print $0}') 6 | echo "The subdomain $1 is a $(echo $ANSWER | awk '{print $4}') record and points to $(echo $ANSWER | awk '{print $5}')" 7 | } 8 | 9 | if [[ $# == 1 ]]; then 10 | subdomains=('www' 'lb-01' 'web-01' 'web-02') 11 | for i in "${subdomains[@]}"; do 12 | CONCAT="$i.$1" 13 | DNS_info $i $CONCAT 14 | done 15 | else 16 | CONCAT="$2.$1" 17 | DNS_info $2 $CONCAT 18 | fi 19 | -------------------------------------------------------------------------------- /0x10-https_ssl/1-haproxy_ssl_termination: -------------------------------------------------------------------------------- 1 | defaults 2 | mode http 3 | timeout client 15s 4 | timeout connect 10s 5 | timeout server 15s 6 | timeout http-request 10s 7 | 8 | frontend iamitsfoss-frontend 9 | bind *:80 10 | bind *:443 ssl crt /etc/haproxy/certs/iamitsfoss.tech.pem 11 | default_backend iamitsfoss-backend 12 | 13 | backend iamitsfoss-backend 14 | http-request redirect scheme https if !{ ssl_fc } 15 | balance roundrobin 16 | server 130022-web-01 54.146.84.110:80 check 17 | server 130022-web-02 100.26.156.138:80 check 18 | -------------------------------------------------------------------------------- /0x10-https_ssl/100-redirect_http_to_https: -------------------------------------------------------------------------------- 1 | defaults 2 | mode http 3 | timeout client 15s 4 | timeout connect 10s 5 | timeout server 15s 6 | timeout http-request 10s 7 | 8 | frontend iamitsfoss-frontend 9 | bind *:80 10 | bind *:443 ssl crt /etc/haproxy/certs/iamitsfoss.tech.pem 11 | http-request redirect scheme https if !{ ssl_fc } 12 | default_backend iamitsfoss-backend 13 | 14 | backend iamitsfoss-backend 15 | http-request redirect scheme https if !{ ssl_fc } 16 | balance roundrobin 17 | server 130022-web-01 54.146.84.110:80 check 18 | server 130022-web-02 100.26.156.138:80 check 19 | -------------------------------------------------------------------------------- /0x10-https_ssl/README.md: -------------------------------------------------------------------------------- 1 | 0x10-https_ssl 2 | Devops. Here We Go 3 | -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/0-blog_post.txt: -------------------------------------------------------------------------------- 1 | To answer this question in a simple and detailed manner, lets take a look at this word called server, which we would use alot in this article 2 | 3 | What’s a Server? 4 | A server is a computer program or device that provides a service to another computer program and its user, also known as the client. This architecture is called the client–server model. 5 | 6 | The client-server model 7 | The client is typically the ‘thing’ requesting information . Typically clients are the web user’s internet-connected devices, such our computer, laptop or phone connected to Wi-Fi or mobile network — and web-accessing software available on those devices or browser like Google Chrome, Firefox, Safari. In our example, the client is in fact the browser and the device we are using to type in www.google.com 8 | 9 | Server is the ‘thing’ sending or serving information to the client. They store webpages, sites, or apps. In our example, it would be the google server. 10 | 11 | When a client device wants to access a webpage, it requests a copy of the webpage from the server which is then downloaded onto the client to be displayed in the user’s web browser. 12 | 13 | The Phonebook of the Internet 14 | When we type the website name or address — or more technically called a URL, https://www.google.com into our browser and press Enter, the first thing the browser does is to break down the URL in pieces — and for that we need Domain Name System (DNS) servers! But first… 15 | 16 | What’s a URL? 17 | URL stands for Uniform Resource Locator and is used to access a website. There are several parts in a URL: the protocol, hostname, port and path-and-file-name and more. For this blog post, we will look at the protocol and hostname. In the case of https://www.google.com: https is the protocol (more on that later) and www.google.com is the hostname, which can be a domain like in this case or also an IP address. 18 | 19 | DNS 20 | Think of the Domain Name System (DNS) like the phonebook of the internet! DNS servers are application servers that convert domain names, easily understood by humans, into machine-readable IP addresses. Each device connected to the internet has a unique IP address which other machines use to find the device. 21 | 22 | This process called DNS resolution or DNS lookup has 4 steps (and servers) involved in loading a webpage: 23 | 24 | DNS recursor is is the first stop. It’s a server designed to receive queries from clients through applications such as web browsers. If this server already has the IP address stored in cache it will simply return it back. Otherwise it’ll be responsible for making additional requests, by sending a query to the root DNS server. 25 | The root server or root nameserver doesn’t have information about the hostname but it has information where to find it so it will refer the requests to the appropriate TLD server. 26 | The TLD ( Top Level Domain) is the next step in the search for a specific IP address, and it hosts the last portion of a hostname. In google.com, the TLD server is “com”. The request is then sent to the authoritative nameserver. 27 | The Authoritative nameserver is the last stop in the nameserver query. If this server has access to the requested record, it will return the IP address for the requested hostname back to the DNS recursor that made the initial request — otherwise it will send an error saying the record couldn’t be found. 28 | 29 | Internet Protocol Suite 30 | Finally the browser knows where to find www.google.com and it’s now time to make a connection, to access the website requested. Browsers use internet protocols to build such connections. 31 | 32 | Internet Protocol Suite aka TCP/IP (TCP stand for Transmission Control Protocol) is the most common protocol used for many types of HTTP requests. It’s a set of rules governing the format of data sent via the internet or local network, such as sending e-mails, streaming videos, or connecting to a website. 33 | 34 | Traffic and Security Control 35 | Once the TCP connection is established, it is time to begin transferring data! But not so fast, first we need some traffic control — meet the load balancer… 36 | 37 | A load balancer, like HAProxy, is a server that helps handle more web traffic and avoid downtime. The load balancer receives traffic from the internet and then distribute it among multiple servers as to not overload any particular server with too many requests. Load balancers are essential for websites with a lot of traffic such google.com! But can anyone get in? That's the job of a firewall… 38 | 39 | The firewall, a software or hardware device that blocks unauthorised access to or from private networks. It acts as a barrier between secured internal network and most vulnerable network, e.g. the internet. The decision to whether to allow the traffic or not is based on a custom set of security rules, such as restrictions on the IP address of the request, the number and frequency of the requests made, or the type of content being requested. A load balancer acts as firewall. However you can install seperate firewalls for extra security and protection and to avoid SPOF (single point of failure). 40 | 41 | SSL 42 | Security is key in nowadays digital world so we have an extra security measure taken using Secure Socket Layer (SSL). 43 | 44 | SSL is a protocol for servers and web browsers that makes sure that data passed between the two are private. This is done using a SSL certificate, a small data files that cryptographically establish an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browser remain private. 45 | 46 | SSL is particularly useful when exchanging credit card information or other private sensitive information as it makes it impossible to decipher them if someone was listening in. 47 | 48 | How do you know if a website is using a SSL certificate? Easy, just look at the url and if you see that padlock and https:// instead of instead of http, then your privacy is safe. But what’s http/https? 49 | 50 | HTTP/HTTPS 51 | What is it? 52 | HTTP stands for HyperText Transfer Protocol and is perhaps the most popular application protocol used by the World Wide Web. It’s used by we browser and web server to communicate. It is a stateless, text-base protocol. 53 | 54 | It works like this: an HTTP client or web browser sends a request message to an HTTP server or web server. The server, in turn, returns a response message. Note that HTTP is a pull protocol, the client pulls information from the server rather than the server pushes information to the client. 55 | 56 | HTTPS works the same as HTTP , it’s only more secure. The additional letter, S, stands for security, and, as mentioned earlier, it means it’s using a SSL certificate. 57 | 58 | HTTP requests and response status code 59 | HTTP requests can have a range of different methods. 60 | 61 | GET is used to get data from a web server. 62 | POST is used to send data from a web server. 63 | PUT is used to update data from a web server 64 | DELETE is used to delete data from a web server 65 | An HTTP request will always return a response, at least with the status code indicating if the request has been successful or not. Some of the most popular status codes are: 66 | 67 | Informational responses (100–199) 68 | Successful responses (200–299) 69 | Redirection messages (300–399) 70 | Client error responses (400–499) 71 | Server error responses (500–599) 72 | Web and Application Servers 73 | A web server is computer software and underlying hardware that accepts requests via HTTP/HTTPS and serves static content, like simple HTML pages, images or plain text files, in other words content that doesn’t change. It’s the web server job to find content corresponding to the website address requested, and to serve it as an HTTP/HTTPS response. Examples of web servers are Nginx or Apache. 74 | 75 | However most of sites don’t only have static content. Quite the opposite most web apps depend on dynamic content, content that changes. That means, for example, it’s possible to interact with the website, save information into it, log in with a user name and a password and so on. For this, we need the application server! 76 | 77 | An application server is a software program responsible for operating applications, communicate with database server, manage user information, and more. It works with the web servers and is able to serve a dynamic application using the static content from the web server. 78 | 79 | Database 80 | Another crucial component in the client-server computing environment is the database server, which consists of hardware and software that run a database. A database is a collection of data, and the database server is the program that interacts with the database and retrieve, add, modify data in it. The two main ones are relational databases, and non-relational databases. PostgreSQL, MySQL, SQLite, MariaDB are some the most popular relational databases. 81 | 82 | Conclusion 83 | All of this steps, sending and recieving data and responses happens in a very short time, even before we notice. But anytime we type www.google.com, all this steps must happen. I hope this article helps you get a better understanding of the processes involved when we type www.google.com. 84 | 85 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/0-iamsomeoneelse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs the `whoami` command under the given user 3 | su "$1" -s /bin/bash -c 'whoami' 4 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/1-run_nginx_as_nginx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes the issue with the server 3 | chmod 644 /etc/nginx/nginx.conf 4 | sed -Ei 's/\s*#?\s*user .*/user nginx;/' /etc/nginx/nginx.conf 5 | sed -Ei 's/(listen (\[::\]:)?80) /\180 /' /etc/nginx/sites-enabled/default 6 | pkill apache2 7 | su nginx -s /bin/bash -c 'service nginx restart' 8 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/100-fix_in_7_lines_or_less: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes the issue with the server 3 | chmod 644 /etc/nginx/nginx.conf 4 | sed -Ei 's/\s*#?\s*user .*/user nginx;/' /etc/nginx/nginx.conf 5 | sed -Ei 's/(listen (\[::\]:)?80) /\180 /' /etc/nginx/sites-enabled/default 6 | pkill apache2 7 | su nginx -s /bin/bash -c 'service nginx restart' 8 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/README.md: -------------------------------------------------------------------------------- 1 | # Web Stack Debugging 2 | 3 | This project contains tasks for learning about how to debug web stacks. 4 | 5 | ## Tasks To Complete 6 | 7 | + [x] 0. Run software as another user
_**[0-iamsomeoneelse](0-iamsomeoneelse)**_ contains a Bash script that meets the following requirements. 8 | + Info: 9 | + The user `root` is, on Linux, the "superuser". It can do anything it wants, that's a good and bad thing. A good practice is that one should never be logged in the `root` user, as if you fat finger a command and for example run `rm -rf /`, there is no comeback. That's why it is preferable to run as a privileged user, meaning that the user also has the ability to perform tasks that the `root` user can do, just need to use a specific command that you need to discover. 10 | + For the containers that you are given in this project as well as the checker, everything is run under the `root` user, which has the ability to run anything as another user. 11 | + Requirements: 12 | + Write a Bash script that accepts one argument. 13 | + The script should run the `whoami` command under the user passed as an argument. 14 | 15 | + [x] 1. Run Nginx as Nginx
_**[1-fix_in_7_lines_or_less](1-fix_in_7_lines_or_less)**_ contains a Bash script that configures a container to fit the following requirements. 16 | + Info: 17 | + The `root` user is a superuser that can do anything on a Unix machine, the top administrator. Security wise, you must do everything that you can to prevent an attacker from logging in as `root`. With this in mind, it's a good practice not to run your web servers as `root` (which is the default for most configurations) and instead run the process as the less privileged nginx user instead. This way, if a hacker does find a security issue that allows them to break-in to your server, the impact is limited by the permissions of the nginx user. 18 | + Requirements: 19 | + `nginx` must be running as `nginx` user. 20 | + `nginx` must be listening on all active IPs on port `8080`. 21 | + You cannot use `apt-get remove`. 22 | 23 | + [x] 2. 7 lines or less
_**[100-fix_in_7_lines_or_less](100-fix_in_7_lines_or_less)**_ contains a Bash script uses what was done for task #1 but is short and sweet. 24 | + Requirements: 25 | + Your Bash script must be 7 lines long or less. 26 | + There must be a new line at the end of the file. 27 | + You respect Bash script requirements. 28 | + You cannot use `;`. 29 | + You cannot use `&&`. 30 | + You cannot use `wget`. 31 | + You cannot execute your previous answer file (Do not include the name of the previous script in this one). 32 | -------------------------------------------------------------------------------- /0x13-firewall/0-block_all_incoming_traffic_but: -------------------------------------------------------------------------------- 1 | sudo apt-get install ufw -y 2 | sudo ufw default deny incoming 3 | sudo ufw default allow outgoing 4 | sudo ufw allow 22/tcp 5 | sudo ufw allow 443/tcp 6 | sudo ufw allow 80/tcp 7 | sudo ufw enable -y 8 | sudo ufw status 9 | -------------------------------------------------------------------------------- /0x13-firewall/100-port_forwarding: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/ufw/before.rules 3 | # 4 | # rules.before 5 | # 6 | # Rules that should be run before the ufw command line added rules. Custom 7 | # rules should be added to one of these chains: 8 | # ufw-before-input 9 | # ufw-before-output 10 | # ufw-before-forward 11 | # 12 | 13 | # Don't delete these required lines, otherwise there will be errors 14 | *filter 15 | :ufw-before-input - [0:0] 16 | :ufw-before-output - [0:0] 17 | :ufw-before-forward - [0:0] 18 | :ufw-not-local - [0:0] 19 | # End required lines 20 | 21 | # Allow port forwarding from port 8080/TCP to port 80/TCP 22 | *nat 23 | :PREROUTING ACCEPT [0:0] 24 | -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 25 | COMMIT 26 | 27 | 28 | # allow all on loopback 29 | -A ufw-before-input -i lo -j ACCEPT 30 | -A ufw-before-output -o lo -j ACCEPT 31 | 32 | # quickly process packets for which we already have a connection 33 | -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 34 | -A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 35 | -A ufw-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 36 | 37 | # drop INVALID packets (logs these in loglevel medium and higher) 38 | -A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny 39 | -A ufw-before-input -m conntrack --ctstate INVALID -j DROP 40 | 41 | # ok icmp codes for INPUT 42 | -A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT 43 | -A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT 44 | -A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT 45 | -A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT 46 | 47 | # ok icmp code for FORWARD 48 | -A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT 49 | -A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT 50 | -A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT 51 | -A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT 52 | 53 | # allow dhcp client to work 54 | -A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT 55 | 56 | # 57 | # ufw-not-local 58 | # 59 | -A ufw-before-input -j ufw-not-local 60 | 61 | # if LOCAL, RETURN 62 | -A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN 63 | 64 | # if MULTICAST, RETURN 65 | -A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN 66 | 67 | # if BROADCAST, RETURN 68 | -A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN 69 | 70 | # all other non-local packets are dropped 71 | -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny 72 | -A ufw-not-local -j DROP 73 | 74 | # allow MULTICAST mDNS for service discovery (be sure the MULTICAST line above 75 | # is uncommented) 76 | -A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT 77 | 78 | # allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above 79 | # is uncommented) 80 | -A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT 81 | 82 | # don't delete the 'COMMIT' line or these rules won't be processed 83 | COMMIT 84 | -------------------------------------------------------------------------------- /0x13-firewall/README.md: -------------------------------------------------------------------------------- 1 | readme 2 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_primary: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License, version 2.0, 5 | # as published by the Free Software Foundation. 6 | # 7 | # This program is also distributed with certain software (including 8 | # but not limited to OpenSSL) that is licensed under separate terms, 9 | # as designated in a particular file or component or in included license 10 | # documentation. The authors of MySQL hereby grant you an additional 11 | # permission to link the program and your derivative works with the 12 | # separately licensed software that they have included with MySQL. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License, version 2.0, for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | 23 | # 24 | # The MySQL Server configuration file. 25 | # 26 | # For explanations see 27 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 28 | 29 | [mysqld] 30 | pid-file = /var/run/mysqld/mysqld.pid 31 | socket = /var/run/mysqld/mysqld.sock 32 | datadir = /var/lib/mysql 33 | log-error = /var/log/mysql/error.log 34 | 35 | 36 | # By default we only accept connections from localhost 37 | #--disabled inorder to enable mysql replication 38 | #bind-address = 127.0.0.1 39 | 40 | # Disabling symbolic-links is recommended to prevent assorted security risks 41 | symbolic-links=0 42 | 43 | # setting server id 44 | server-id = 1 45 | 46 | # setting the base name & location of mysql bunary log file 47 | log_bin = /var/log/mysql/mysql-bin.log 48 | 49 | # name of database to replicate 50 | binlog_do_db = tyrell_corp 51 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_replica: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2021, Oracle and/or its affiliates. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License, version 2.0, 5 | # as published by the Free Software Foundation. 6 | # 7 | # This program is also distributed with certain software (including 8 | # but not limited to OpenSSL) that is licensed under separate terms, 9 | # as designated in a particular file or component or in included license 10 | # documentation. The authors of MySQL hereby grant you an additional 11 | # permission to link the program and your derivative works with the 12 | # separately licensed software that they have included with MySQL. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License, version 2.0, for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | 23 | # 24 | # The MySQL Server configuration file. 25 | # 26 | # For explanations see 27 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 28 | 29 | [mysqld] 30 | pid-file = /var/run/mysqld/mysqld.pid 31 | socket = /var/run/mysqld/mysqld.sock 32 | datadir = /var/lib/mysql 33 | log-error = /var/log/mysql/error.log 34 | 35 | # By default we only accept connections from localhost 36 | bind-address = 127.0.0.1 37 | server-id = 2 38 | log_bin = /var/log/mysql/mysql-bin.log 39 | replica_do_db = tyrell_corp 40 | relay-log = /var/log/mysql/mysql-relay-bin.log 41 | 42 | # Disabling symbolic-links is recommended to prevent assorted security risks 43 | symbolic-links=0 44 | -------------------------------------------------------------------------------- /0x14-mysql/5-mysql_backup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Generates a compressed archive of a MySQL dump. 3 | mysqldump -uroot -p"$1" --all-databases > backup.sql 4 | tar -cvzf "$(date +%d-%m-%Y)".tar.gz backup.sql 5 | -------------------------------------------------------------------------------- /0x14-mysql/README.md: -------------------------------------------------------------------------------- 1 | 0x14-mysql 2 | -------------------------------------------------------------------------------- /0x15-api/0-gather_data_from_an_API.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Returns to-do list information for a given employee ID.""" 3 | import requests 4 | import sys 5 | 6 | if __name__ == "__main__": 7 | url = "https://jsonplaceholder.typicode.com/" 8 | user = requests.get(url + "users/{}".format(sys.argv[1])).json() 9 | todos = requests.get(url + "todos", params={"userId": sys.argv[1]}).json() 10 | 11 | completed = [t.get("title") for t in todos if t.get("completed") is True] 12 | print("Employee {} is done with tasks({}/{}):".format( 13 | user.get("name"), len(completed), len(todos))) 14 | [print("\t {}".format(c)) for c in completed] 15 | -------------------------------------------------------------------------------- /0x15-api/1-export_to_CSV.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to CSV format.""" 3 | import csv 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.csv".format(user_id), "w", newline="") as csvfile: 15 | writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) 16 | [writer.writerow( 17 | [user_id, username, t.get("completed"), t.get("title")] 18 | ) for t in todos] 19 | -------------------------------------------------------------------------------- /0x15-api/2-export_to_JSON.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to JSON format.""" 3 | import json 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.json".format(user_id), "w") as jsonfile: 15 | json.dump({user_id: [{ 16 | "task": t.get("title"), 17 | "completed": t.get("completed"), 18 | "username": username 19 | } for t in todos]}, jsonfile) 20 | -------------------------------------------------------------------------------- /0x15-api/3-dictionary_of_list_of_dictionaries.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information of all employees to JSON format.""" 3 | import json 4 | import requests 5 | 6 | if __name__ == "__main__": 7 | url = "https://jsonplaceholder.typicode.com/" 8 | users = requests.get(url + "users").json() 9 | 10 | with open("todo_all_employees.json", "w") as jsonfile: 11 | json.dump({ 12 | u.get("id"): [{ 13 | "task": t.get("title"), 14 | "completed": t.get("completed"), 15 | "username": u.get("username") 16 | } for t in requests.get(url + "todos", 17 | params={"userId": u.get("id")}).json()] 18 | for u in users}, jsonfile) 19 | -------------------------------------------------------------------------------- /0x15-api/README.md: -------------------------------------------------------------------------------- 1 | # 0x15. API 2 | 3 | # API 4 | 5 | This project was further practice in working with API's. I collected data from the 6 | [JSONPlaceholder REST API](https://jsonplaceholder.typicode.com/), and learned how 7 | to export it to either CSV or JSON format. 8 | 9 | ## Tasks :page_with_curl: 10 | 11 | * **0. Gather data from an API** 12 | * [0-gather_data_from_an_API.py](./0-gather_data_from_an_API.py): Python script 13 | that returns information on the to-do list progress of a given employee ID. 14 | * Usage: `python3 0-gather_data_from_an_API.py `. 15 | * Output: `Employee is done with tasks(<# completed tasks>/):` 16 | 17 | * **1. Export to CSV** 18 | * [1-export_to_CSV.py](./1-export_to_CSV.py): Python script exports to-do list 19 | information of a given employee ID to CSV format. 20 | * Usage: `python3 1-export_to_CSV.py ` 21 | * File name: `.csv`. 22 | * Format: `"","","",""`. 23 | 24 | * **2. Export to JSON** 25 | * [2-export_to_JSON.py](./2-export_to_JSON.py): Python script that exports 26 | to-do list information of a given employee ID to JSON format. 27 | * Usage: `python3 2-export_to_JSON.py ` 28 | * File name: `.json` 29 | * Format: `{ "": [ {"task": "", "completed": , "username": ""}}, ... ]}` 30 | 31 | * **3. Dictionary of list of dictionaries** 32 | * [3-dictionary_of_list_of_dictionaries.py](./3-dictionary_of_list_of_dictionaries.py): 33 | Python script that exports to-do list information for all employees to JSON format. 34 | * Usage: `python3 3-dictionary_of_list_of_dictionaries.py` 35 | * File name: `todo_all_employees.json` 36 | * Format: `{ "": [ {"username": "", "task": "", "completed": }, {"username": "", "task": "", "completed": }, ... ], "": [ {"username": "", "task": "", "completed": }, {"username": "", "task": "", "completed": }, ... ]}` 37 | -------------------------------------------------------------------------------- /0x16-api_advanced/0-subs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Function that queries the Reddit API and returns the number of subscribers 4 | (not active users, total subscribers) for a given subreddit. 5 | If an invalid subreddit is given, the function should return 0 6 | """ 7 | 8 | import requests 9 | 10 | 11 | def number_of_subscribers(subreddit): 12 | """ 13 | Function that queries the Reddit API 14 | - If not a valid subreddit, return 0. 15 | """ 16 | req = requests.get( 17 | "https://www.reddit.com/r/{}/about.json".format(subreddit), 18 | headers={"User-Agent": "Custom"}, 19 | ) 20 | 21 | if req.status_code == 200: 22 | return req.json().get("data").get("subscribers") 23 | else: 24 | return 0 25 | -------------------------------------------------------------------------------- /0x16-api_advanced/1-top_ten.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Function that queries the Reddit API and prints the titles 4 | of the first 10 hot posts listed for a given subreddit. 5 | """ 6 | 7 | import requests 8 | 9 | 10 | def top_ten(subreddit): 11 | """ 12 | Function that queries the Reddit API 13 | - If not a valid subreddit, print None. 14 | """ 15 | req = requests.get( 16 | "https://www.reddit.com/r/{}/hot.json".format(subreddit), 17 | headers={"User-Agent": "Custom"}, 18 | params={"limit": 10}, 19 | ) 20 | 21 | if req.status_code == 200: 22 | for get_data in req.json().get("data").get("children"): 23 | dat = get_data.get("data") 24 | title = dat.get("title") 25 | print(title) 26 | else: 27 | print(None) 28 | -------------------------------------------------------------------------------- /0x16-api_advanced/100-count.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Function to count words in all hot posts of a given Reddit subreddit. 4 | """ 5 | import requests 6 | 7 | 8 | def count_words(subreddit, word_list, after=None, counts={}): 9 | """ 10 | Recursive function that queries the Reddit API, parses the title of all 11 | hot articles, and prints a sorted count of given keywords 12 | """ 13 | if not word_list or word_list == [] or not subreddit: 14 | return 15 | 16 | url = f"https://www.reddit.com/r/{subreddit}/hot.json" 17 | headers = {"User-Agent": "Mozilla/5.0"} 18 | 19 | params = {"limit": 100} 20 | if after: 21 | params["after"] = after 22 | 23 | response = requests.get(url, 24 | headers=headers, 25 | params=params, 26 | allow_redirects=False) 27 | 28 | if response.status_code != 200: 29 | return 30 | 31 | data = response.json() 32 | children = data["data"]["children"] 33 | 34 | for post in children: 35 | title = post["data"]["title"].lower() 36 | for word in word_list: 37 | if word.lower() in title: 38 | counts[word] = counts.get(word, 0) + title.count(word.lower()) 39 | 40 | after = data["data"]["after"] 41 | if after: 42 | count_words(subreddit, word_list, after, counts) 43 | else: 44 | sorted_counts = sorted(counts.items(), 45 | key=lambda x: (-x[1], x[0].lower())) 46 | for word, count in sorted_counts: 47 | print(f"{word.lower()}: {count}") 48 | -------------------------------------------------------------------------------- /0x16-api_advanced/2-recurse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Recursive function that queries the Reddit API and returns 4 | a list containing the titles of all hot articles for a given subreddit. 5 | If no results are found for the given subreddit, 6 | the function should return None. 7 | """ 8 | 9 | import requests 10 | 11 | 12 | def recurse(subreddit, hot_list=[], after=""): 13 | """ 14 | Queries the Reddit API and returns 15 | a list containing the titles of all hot articles for a given subreddit. 16 | 17 | - If not a valid subreddit, return None. 18 | """ 19 | req = requests.get( 20 | "https://www.reddit.com/r/{}/hot.json".format(subreddit), 21 | headers={"User-Agent": "Custom"}, 22 | params={"after": after}, 23 | ) 24 | 25 | if req.status_code == 200: 26 | for get_data in req.json().get("data").get("children"): 27 | dat = get_data.get("data") 28 | title = dat.get("title") 29 | hot_list.append(title) 30 | after = req.json().get("data").get("after") 31 | 32 | if after is None: 33 | return hot_list 34 | else: 35 | return recurse(subreddit, hot_list, after) 36 | else: 37 | return None 38 | -------------------------------------------------------------------------------- /0x16-api_advanced/README.md: -------------------------------------------------------------------------------- 1 | Ox16 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/2-setup_datadog: -------------------------------------------------------------------------------- 1 | 56da5102-057c-11ee-a48a-da7ad0900005-3d7b2e9ec7703ccb45c1b8e353d60318 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/README.md: -------------------------------------------------------------------------------- 1 | # 0x18-webstack_monitoring 2 | 3 | This repository contains the solutions to the tasks related to webstack monitoring using Datadog. The three tasks included in this repository are: 4 | 5 | ## [Task 0: Sign up for Datadog and install datadog-agent](./0-setup_datadog) 6 | 7 | In this task, we will sign up for Datadog, create an account, and install the datadog-agent on our machine. We will then use the agent to monitor various metrics related to our web server. 8 | 9 | ## [Task 1: Monitor some metrics](./1-monitor_system) 10 | 11 | In this task, we will focus on monitoring some system-level metrics. We will use the Datadog dashboard to create graphs and alerts for CPU usage, memory usage, and disk space utilization. 12 | 13 | ## [Task 2: Setup Datadog](./2-setup_datadog) 14 | 15 | In this task, we will set up Datadog for our web server. We will install the necessary packages, configure the Datadog agent, and create custom metrics and monitors for our web application. 16 | 17 | To get started with this repository, please refer to the individual tasks and follow the instructions provided. Happy monitoring! 18 | 19 | #### Learn More 20 | 21 | Learn more about [Datadog](https://www.datadoghq.com/) - A monitoring and analytics platform for cloud-scale infrastructure and applications. 22 | -------------------------------------------------------------------------------- /0x1A-application_server/2-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Configures Nginx to serve the route /airbnb-onepage/ from AirBnB_clone_v2. 2 | 3 | server { 4 | # Listen on port 80 5 | listen 80 default_server; 6 | listen [::]:80 default_server ipv6only=on; 7 | 8 | # Use IP of server as domain name 9 | server_name 104.196.168.90; 10 | 11 | # Customize HTTP response header 12 | add_header X-Served-By 375-web-01; 13 | 14 | # Serve /airbnb-onepage/ route from AirBnB_clone_v2 15 | location = /airbnb-onepage/ { 16 | proxy_pass http://127.0.0.1:5000/airbnb-onepage/; 17 | } 18 | 19 | # 404 error page 20 | error_page 404 /404.html; 21 | location /404 { 22 | root /var/www/html; 23 | internal; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /0x1A-application_server/3-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Configures Nginx to serve the /number_odd_or_even/ route on AirBnB_clone_v2. 2 | 3 | server { 4 | # Listen on port 80 5 | listen 80 default_server; 6 | listen [::]:80 default_server ipv6only=on; 7 | 8 | # Use server IP as domain name 9 | server_name 104.196.168.90; 10 | 11 | # Customize HTTP response header 12 | add_header X-Served-By 375-web-01; 13 | 14 | # Serve /airbnb-onepage/ route on AirBnB_clone_v2 15 | location = /airbnb-onepage/ { 16 | proxy_pass http://127.0.0.1:5000/airbnb-onepage/; 17 | } 18 | 19 | # Serve /number_odd_or_even/ route on AirBnB_clone_v2 20 | location ~ /airbnb-dynamic/number_odd_or_even/(\d+)$ { 21 | proxy_pass http://127.0.0.1:5001/number_odd_or_even/$1; 22 | } 23 | 24 | # 404 error page 25 | error_page 404 /404.html; 26 | location /404 { 27 | root /var/www/html; 28 | internal; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /0x1A-application_server/4-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Configures Nginx to serve the AirBnB_clone_v3 API. 2 | 3 | server { 4 | # Listen on port 80 5 | listen 80 default_server; 6 | listen [::]:80 default_server ipv6only=on; 7 | 8 | # Use server IP as domain name 9 | server_name 104.196.168.90; 10 | 11 | # Customize HTTP response header 12 | add_header X-Served-By 375-web-01; 13 | 14 | # Serve /airbnb-onepage/ route on AirBnB_clone_v3 15 | location = /airbnb-onepage/ { 16 | proxy_pass http://127.0.0.1:5000/airbnb-onepage/; 17 | } 18 | 19 | # Serve /number_odd_or_even/ route on AirBnB_clone_v3 20 | location ~ /airbnb-dynamic/number_odd_or_even/(\d+)$ { 21 | proxy_pass http://127.0.0.1:5001/number_odd_or_even/$1; 22 | } 23 | 24 | # Serve API on AirBnB_clone_v3 25 | location /api { 26 | proxy_pass http://127.0.0.1:5002/api; 27 | } 28 | 29 | # 404 error page 30 | error_page 404 /404.html; 31 | location /404 { 32 | root /var/www/html; 33 | internal; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /0x1A-application_server/4-reload_gunicorn_no_downtime: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Gracefully reloads Gunicorn. 3 | # Get the PID of the Gunicorn process 4 | PID=$(pgrep gunicorn) 5 | 6 | # Reload Gunicorn gracefully 7 | kill -s HUP $PID 8 | -------------------------------------------------------------------------------- /0x1A-application_server/5-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Configures Nginx to serve the complete AirBnB_clone_v4 application. 2 | 3 | server { 4 | # Listen on port 80. 5 | listen 80 default_server; 6 | listen [::]:80 default_server ipv6only=on; 7 | 8 | # Use server IP as domain name 9 | server_name 104.196.168.90; 10 | 11 | # Customize HTTP response header 12 | add_header X-Served-By 375-web-01; 13 | 14 | # Serve /airbnb-onepage/ route on AirBnB_clone_v2 15 | location = /airbnb-onepage/ { 16 | proxy_pass http://127.0.0.1:5000/airbnb-onepage/; 17 | } 18 | 19 | # Serve /number_odd_or_even/ route on AirBnB_clone_v2 20 | location ~ /airbnb-dynamic/number_odd_or_even/(\d+)$ { 21 | proxy_pass http://127.0.0.1:5001/number_odd_or_even/$1; 22 | } 23 | 24 | # Serve AirBnB_clone_v3 API 25 | location /api { 26 | proxy_pass http://127.0.0.1:5002/api; 27 | } 28 | 29 | # Configure /2-hbnb route of AirBnB_clone_v4 as root location 30 | location / { 31 | proxy_pass http://127.0.0.1:5003/2-hbnb; 32 | } 33 | 34 | # Serve static content for AirBnB_clone_v4 35 | location /static { 36 | proxy_pass http://127.0.0.1:5003; 37 | } 38 | 39 | # 404 error page 40 | error_page 404 /404.html; 41 | location /404 { 42 | root /var/www/html; 43 | internal; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /0x1A-application_server/README.md: -------------------------------------------------------------------------------- 1 | 0x1A-application_server 2 | -------------------------------------------------------------------------------- /0x1A-application_server/gunicorn.service: -------------------------------------------------------------------------------- 1 | description "Gunicorn application server running AirBnB_clone_v4" 2 | 3 | start on runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | setuid ubuntu 8 | setgid www-data 9 | 10 | chdir /home/ubuntu/AirBnB_clone_v4 11 | exec gunicorn --workers 3 --bind 0.0.0.0:5003 web_dynamic.2-hbnb:app >> /tmp/airbnb-access.log 2> /tmp/airbnb-error.logirbnb-access.log 12 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/0-the_sky_is_the_limit_not.pp: -------------------------------------------------------------------------------- 1 | # Fixes an nginx site that can't handle multiple concurrent requests 2 | exec { 'fix--for-nginx': 3 | command => "bash -c \"sed -iE 's/^ULIMIT=.*/ULIMIT=\\\"-n 8192\\\"/' \ 4 | /etc/default/nginx; service nginx restart\"", 5 | path => '/usr/bin:/usr/sbin:/bin' 6 | } 7 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/1-user_limit.pp: -------------------------------------------------------------------------------- 1 | # Changes the limitations on the holberton user 2 | exec { 'change-os-configuration-for-holberton-user': 3 | command => "bash -c \"sed -iE 's/^holberton hard nofile \ 4 | 5/holberton hard nofile 88888/' /etc/security/limits.conf; \ 5 | sed -iE 's/^holberton soft nofile \ 6 | 4/holberton soft nofile 88888/' /etc/security/limits.conf\"", 7 | path => '/usr/bin:/usr/sbin:/bin' 8 | } 9 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/README.md: -------------------------------------------------------------------------------- 1 | WEB STACK DEBUGGING 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | system engineering devops 2 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/0-sniffing: -------------------------------------------------------------------------------- 1 | mypassword9898! 2 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/1-dictionary_attack: -------------------------------------------------------------------------------- 1 | password123 2 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/README.md: -------------------------------------------------------------------------------- 1 | ## 2 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/user_authenticating_into_server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrightDaniel/alx-system_engineering-devops/5b5201ea9355bc5d490beff5ae8786ad02da9d02/attack_is_the_best_defense/user_authenticating_into_server --------------------------------------------------------------------------------