├── 0-give_me_a_page ├── 0x00-shell_basics ├── 0-current_working_directory ├── 1-listit ├── 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 ├── 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 └── groups ├── 0x02-shell_redirections ├── .101-gifs.swp ├── .echo.swp ├── 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-dile ├── 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 ├── apache-access.log └── hh ├── 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 ├── 67-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 └── killmenow ├── 0x0B-ssh ├── 0-use_a_private_key ├── 1-create_ssh_key_pair ├── 100-puppet_ssh_config.pp ├── 2-ssh_config ├── README.md └── web-01 ├── 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 ├── fabfile.py └── web-01 ├── 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 ├── web-01 └── web-02 ├── 0x10-https_ssl ├── 0-world_wide_web ├── 1-haproxy_ssl_termination ├── 100-redirect_http_to_https └── README.md ├── 0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter ├── 0-blog_post ├── 1-what_happen_when_diagram ├── 2-contribution-to_what-happens-when_github_answer ├── README.md └── google.com on your browser ├── 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 ├── lb-01 ├── web-01 └── web-02 ├── 0x15-api ├── 0-gather_data_from_an_API.py ├── 1-export_to_CSV.py ├── 2-export_to_JSON.py ├── 2.csv ├── 2.json ├── 3-dictionary_of_list_of_dictionaries.py └── README.md ├── 0x16-api_advanced ├── 0-main.py ├── 0-subs.py ├── 1-top_ten.py ├── 100-count.py ├── 2-recurse.py ├── README.md ├── __pycache__ │ └── 0-subs.cpython-35.pyc └── tests │ ├── 0-main.py │ ├── 1-main.py │ ├── 100-main.py │ ├── 2-main.py │ └── README.md ├── 0x17-web_stack_debugging_3 ├── 0-strace_is_your_friend.pp └── README.md ├── 0x18-webstack_monitoring ├── 0-setup_datadog ├── 2-setup_datadog └── README.md ├── 0x19-postmortem ├── My_first_postmortem └── README.md ├── 0x1A-application_server ├── 2-app_server-nginx_config ├── 3-app_server-nginx_config ├── 4-app_server-nginx_config ├── 5-app_server-nginx_config └── README.md ├── 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 ├── command_line_for_the_win ├── 0-first_9_tasks.jpg ├── 0-first_9_tasks.png ├── 1-next_9_tasks.jpg ├── 1-next_9_tasks.png ├── 2-next_9_tasks.jpg ├── 2-next_9_tasks.png └── README.md └── dev-ops.png /0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # run apache on designated container 3 | 4 | echo "ServerName localhost" >> /etc/apache2.conf 5 | service apache2 start 6 | -------------------------------------------------------------------------------- /0x00-shell_basics/0-current_working_directory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/1-listit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls 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 -amvp 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 -un *.html ../ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/2-bring_me_home: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd ~ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/3-listfiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/4-listmorefiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/5-listfilesdigitonly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -lan 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 | script that print path name of the current working directory 2 | -------------------------------------------------------------------------------- /0x00-shell_basics/school.mgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/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 -un 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 | shell permissions 2 | -------------------------------------------------------------------------------- /0x01-shell_permissions/groups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | groups 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/.101-gifs.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/0x02-shell_redirections/.101-gifs.swp -------------------------------------------------------------------------------- /0x02-shell_redirections/.echo.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/0x02-shell_redirections/.echo.swp -------------------------------------------------------------------------------- /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" -printf "%f\n" | rev | cut -d '.' -f2- | 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 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 -i "bin" /etc/passwd | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/16-whatsnext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -iA 3 "root" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/17-hidethisword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -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 ":" -f1,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 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/5-firstlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/6-third_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -3 iacta | tail -1 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/7-dile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/0x02-shell_redirections/7-dile -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 0x03. Shell, init files, variables and expansions 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/0-RSA_public_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCi9HEI4OFqjHuDK13aUfDarOmcsaY5QwcW/wSKVgWcnaWiZAE1GmWEoJbfF9iMFPe7EmCNMMomQqZdOGjN14siLlHfjMjtcQpncWoU2Cvr6XU5tc5ZH0LX6H0QKt5hbw6bn7b5bSEH0URKteGuR76++69xyvJoldsZBCPxdJnhduUCRaTD9uWcHoKhAgW8MFKj6ckjvVZFJs4zSMWDqZhxeE70xojX+q/mu1nilKs/LGzoXzTgtT4jS/87TTcL9Jb+C7gCM2FVEtVbkE2iO2e5b/RES0gGOm63JXv0b+0XmU2c/UGxNTtQcl6DPpPTCwf5iwltKe0Hl2G6Om4GTdN3Hwi/GcMhvdM4gQ45Y+B/Ki5sEq4+biQ/nb25+neW4QThHqL5+f+sDzFDE8c7dgiP0kXyCpTPN28eI1G2nUHwaiL4OQ+Dm3bbubWTLB+F5rrYxBocM3qHmwwLXTLWC/NMPJ2HwbflArD+/5ntMKyGNVkumUiCL9HyQ5Vi/t/dYz8= root@4109f561e02d 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/1-for_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "Best School" 10 times using a for loop. 3 | 4 | for (( i=0; i<10; i++ )) 5 | do 6 | echo "Best School" 7 | done 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/10-fizzbuzz: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 100 in list format. 3 | # Displays "FizzBuzz" when the number is a multiple of 3 and 5. 4 | # Displays "Fizz" when the number is a multiple of 3. 5 | # Displays "Buzz" when the number is a multiple of 5. 6 | # Otherwise, displays the number. 7 | 8 | for num in {1..100} 9 | do 10 | if (( num % 3 == 0 && num % 5 == 0 )) 11 | then 12 | echo "FizzBuzz" 13 | elif (( num % 3 == 0 )) 14 | then 15 | echo "Fizz" 16 | elif (( num % 5 == 0 )) 17 | then 18 | echo "Buzz" 19 | else 20 | echo "$num" 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/100-read_and_cut: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the contents of the file `/etc/passwd`. 3 | # Only displays the username, user id, and user home directory path. 4 | 5 | while read -r passwd; do 6 | echo "$passwd" | cut -d ':' -f1,3,6 7 | done < "/etc/passwd" 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/101-tell_the_story_of_passwd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tells a story based on the contents of the `/etc/passwd` file. 3 | 4 | while IFS=':' read -r username password uid gid info home shell; do 5 | echo "The user $username is part of the $gid gang,"\ 6 | "lives in $home and rides $shell."\ 7 | "$uid's place is protected by the passcode $password,"\ 8 | "more info about the user here: $info" 9 | done < "/etc/passwd" 10 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/102-lets_parse_apache_logs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Parses Apache log files in list format. 3 | # Displays the IP and HTTP status code. 4 | 5 | awk '{print $1 " " $9}' apache-access.log 6 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/103-dig_the-data: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Parses Apache log files in list format. 3 | # Groups visitors by IP and HTTP status code. 4 | # Displays the number of occurrences, IP, and HTTP status 5 | #+ code of each log, in sorted order. 6 | 7 | awk '{ print $1 " " $9}' apache-access.log | sort | uniq -c | sort -rn 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/2-while_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "Best School" 10 times using a while loop. 3 | 4 | count=0 5 | 6 | while [ $count -lt 10 ] 7 | do 8 | echo "Best School" 9 | (( count++ )) 10 | done 11 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/3-until_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "Best School" 10 times using an until loop. 3 | 4 | count=0 5 | 6 | until [ $count -eq 10 ] 7 | do 8 | echo "Best School" 9 | (( count++ )) 10 | done 11 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/4-if_9_say_hi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "Best School" 10 times using a while loop. 3 | # On the 9th iteration, displays "Hi" before "Best School". 4 | 5 | count=0 6 | 7 | while [ $count -lt 10 ] 8 | do 9 | if [ $count -eq 9 ] 10 | then 11 | echo "Hi" 12 | fi 13 | echo "Best School" 14 | (( count++ )) 15 | done 16 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/5-4_bad_luck_8_is_your_chance: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Loops from 1 to 10 and displays: 3 | # "bad luck" for the 4th iteration 4 | # "good luck" for the 8th iteration 5 | # "Best School" for all other iterations 6 | 7 | count=0 8 | 9 | while [ $count -lt 10 ] 10 | do 11 | if [ $count -eq 3 ] 12 | then 13 | echo "bad luck" 14 | elif [ $count -eq 7 ] 15 | then 16 | echo "good luck" 17 | else 18 | echo "Best School" 19 | fi 20 | (( count++ )) 21 | done 22 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/6-superstitious_numbers: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 20 in addition to: 3 | # "bad luck from China" for the 4th iteration 4 | # "bad luck from Japan" for the 9th iteration 5 | # "bad luck from Italy" for the 17th loop iteration 6 | 7 | count=1 8 | 9 | while [ $count -le 20 ] 10 | do 11 | echo "$count" 12 | case $count in 13 | "4") echo "bad luck from China";; 14 | "9") echo "bad luck from Japan";; 15 | "17") echo "bad luck from Italy";; 16 | esac 17 | (( count++ )) 18 | done 19 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/7-clock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the time for 12 horus and 59 minutes. 3 | # Displays hours from 0 to 12 4 | # Displays minutes from 1 to 59 5 | 6 | hour=0 7 | 8 | while [ $hour -le 12 ] 9 | do 10 | echo "Hour: $hour" 11 | minute=1 12 | while [ $minute -le 59 ] 13 | do 14 | echo "$minute" 15 | (( minute++ )) 16 | done 17 | (( hour++ )) 18 | done 19 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/8-for_ls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the contents of the current directory in list format. 3 | # Only displays the part of the name after the first dash. 4 | 5 | list=$(ls) 6 | for i in $list; do 7 | echo "$i" | cut -d '-' -f2 8 | done 9 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/9-to_file_or_not_to_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays information about the `school` file. 3 | 4 | if [ -e "school" ] 5 | then 6 | echo "school file exists" 7 | if [ -s "school" ] 8 | then 9 | echo "school file is not empty" 10 | else 11 | echo "school file is empty" 12 | fi 13 | 14 | if [ -f "school" ] 15 | then 16 | echo "school is a regular file" 17 | fi 18 | else 19 | echo "school file does not exist" 20 | fi 21 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/README.md: -------------------------------------------------------------------------------- 1 | h 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/hh: -------------------------------------------------------------------------------- 1 | l 2 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/0-what-is-my-pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays its own PID. 3 | 4 | echo $$ 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/1-list_your_processes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays a list of currently running processes. 3 | # Shows all processes, for all users, including those 4 | #+ which might not have a TTY. 5 | 6 | ps -auxf 7 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/100-process_and_pid_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Does the following: 3 | # Create a file /var/run/myscript.pid containing the script PID. 4 | # Displays "To infinity and beyond" indefinitely 5 | # Displays "I hate the kill command" upon receiving a SIGTERM 6 | # Displays "Y U no love me?!" upon receiving a SIGINT 7 | # Deletes the file /var/run/myscript.pid and terminates upon 8 | #+ receiving a SIGQUIT or SIGTERM. 9 | 10 | terminator() { 11 | rm /var/run/myscript.pid 12 | exit 13 | } 14 | 15 | echo "$$" > /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 the script manage_my_process. 3 | # When passed the argument `start`: 4 | # 1. Starts manage_my_process 5 | # 2. Creates a file containings its PID in /var/run/my_process.pid 6 | # 3. Displays "manage_my_process started" 7 | # When passed the argument `stop`: 8 | # 1. Stops manage_my_process 9 | # 2. Deletes the file /var/run/my_process.pid 10 | # 3. Displays "manage_my_process stopped" 11 | # When passed the argument `restart`: 12 | # 1. Stops manage_my_process 13 | # 2. Deletes the file /var/run/my_process.pid 14 | # 3. Starts manage_my_process 15 | # 4. Creates a file containing its PID in /var/run/my_process.pid 16 | # 5. Displays "manage_my_process restarted" 17 | # If any other or no arguments are passed, displays 18 | #+ "Usage: manage_my_process {start|stop|restart}" 19 | 20 | if [ "${1}" == "start" ] 21 | then 22 | ./manage_my_process & 23 | touch /var/run/my_process.pid 24 | echo "$!" > /var/run/my_process.pid 25 | echo "manage_my_process started" 26 | elif [ "${1}" == "stop" ] 27 | then 28 | echo "manage_my_process stopped" 29 | kill "$(cat /var/run/my_process.pid)" 30 | rm /var/run/my_process.pid 31 | elif [ "${1}" == "restart" ] 32 | then 33 | kill "$(cat /var/run/my_process.pid)" 34 | rm /var/run/my_process.pid 35 | ./manage_my_process & 36 | touch /var/run/my_process.pid 37 | echo "$!" > /var/run/my_process.pid 38 | echo "manage_my_process restarted" 39 | else 40 | echo "Usage: manage_my_process {start|stop|restart}" 41 | fi 42 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/102-zombie.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: 102-zombie.c 3 | * Auth: Brennan D Baraban 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * infinite_while - Run an infinite while loop. 14 | * 15 | * Return: Always 0. 16 | */ 17 | int infinite_while(void) 18 | { 19 | while (1) 20 | { 21 | sleep(1); 22 | } 23 | return (0); 24 | } 25 | 26 | /** 27 | * main - Creates five zombie processes. 28 | * 29 | * Return: Always 0. 30 | */ 31 | int main(void) 32 | { 33 | pid_t pid; 34 | char count = 0; 35 | 36 | while (count < 5) 37 | { 38 | pid = fork(); 39 | if (pid > 0) 40 | { 41 | printf("Zombie process created, PID: %d\n", pid); 42 | sleep(1); 43 | count++; 44 | } 45 | else 46 | exit(0); 47 | } 48 | 49 | infinite_while(); 50 | 51 | return (EXIT_SUCCESS); 52 | } 53 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/2-show_your_bash_pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays a list of currently running processes containing the bash keyword. 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 contains 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 with 3 | #+ a sleep 2 in between each iteration. 4 | 5 | while true 6 | do 7 | echo "To infinity and beyond" 8 | sleep 2 9 | done 10 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/5-dont_stop_me_now: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Kills the 4-to_infinity_and_beyond process 3 | 4 | kill "$(pgrep -f 4-to_infinity_and_beyond)" 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/6-stop_me_if_you_can: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Kills the 4-to_infinity_and_beyond process. 3 | 4 | pkill -f 4-to_infinity_and_beyond 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/67-stop_me_if_you_can: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Kills the 4-to_infinity_and_beyond process. 3 | 4 | pkill -f 7-highlander 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/7-highlander: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "To infinity and beyond" indefinitely with 3 | #+ a sleep 2 in between each iteration. 4 | # Displays "I am invincible!!!" in between each iteration. 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 | # Kills the process 7-highlander. 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 | # Pauses two seconds in between each message. 4 | 5 | while true 6 | do 7 | echo "I am alive!" >> /tmp/my_process 8 | sleep 2 9 | done 10 | -------------------------------------------------------------------------------- /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?t?n/).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(/^\d{10,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 | # Displays listening ports. Includes listening sockets as well 3 | # + as the PID and name of the program to which each socket belongs. 4 | 5 | netstat -l --program 6 | -------------------------------------------------------------------------------- /0x07-networking_basics/5-is_the_host_on_the_network: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Pings an IP address received as an argument 5 times. 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "Usage: 5-is_the_host_on_the_network {IP_ADDRESS}" 7 | else 8 | ping -c 5 "$1" 9 | fi 10 | -------------------------------------------------------------------------------- /0x07-networking_basics/README.md: -------------------------------------------------------------------------------- 1 | 0x07-networking_basics 2 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/0-change_your_home_IP: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configures an Ubuntu server as follows: 3 | # - localhost reslves to 127.0.0.2 4 | # - facebook.com resolves to 8.8.8.8 5 | 6 | cp /etc/hosts ~/hosts.new 7 | echo "127.0.0.2 localhost" > ~/hosts.new 8 | echo "8.8.8.8 facebook.com" >> ~/hosts.new 9 | cp -f ~/hosts.new /etc/hosts 10 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/1-show_attached_IPs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays all acive IPv4 addresses on the machine. 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 localhost 98 5 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/README.md: -------------------------------------------------------------------------------- 1 | 0x08-networking_basics_2 2 | -------------------------------------------------------------------------------- /0x0A-configuration_management/0-create_a_file.pp: -------------------------------------------------------------------------------- 1 | # creates a file in /tmp 2 | 3 | file { '/tmp/school': 4 | content =>'I love Puppet', 5 | mode => '0744', 6 | owner => 'www-data', 7 | group => 'www-data', 8 | } 9 | -------------------------------------------------------------------------------- /0x0A-configuration_management/1-install_a_package.pp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/pup 2 | # Install an especific version of flask (2.1.0) 3 | package { 'flask': 4 | ensure => '2.1.0', 5 | provider => 'pip3', 6 | } 7 | -------------------------------------------------------------------------------- /0x0A-configuration_management/2-execute_a_command.pp: -------------------------------------------------------------------------------- 1 | # kill process killmenow 2 | 3 | exec { 'pkill': 4 | command => 'pkill killmenow', 5 | provider => 'shell', 6 | } 7 | -------------------------------------------------------------------------------- /0x0A-configuration_management/README.md: -------------------------------------------------------------------------------- 1 | # Configuration management 2 | 3 | In this project, I started working with Puppet as a configuration management 4 | tool. I practiced writing Puppet manifest files to create a file, install a 5 | package, and execute a command. 6 | 7 | ## Tasks :page_with_curl: 8 | 9 | * **0. Create a file** 10 | * [0-create_a_file.pp](./0-create_a_file.pp): Puppet manifest file that 11 | creates a file `school` in the `/tmp` directory. 12 | * File permissions: `0744`. 13 | * File group: `www-data`. 14 | * File owner: `www-data`. 15 | * File content: `I love Puppet`. 16 | 17 | * **1. Install a package** 18 | * [1-install_a_package.pp](./1-install_a_package.pp): Puppet manifest file 19 | that install `flask` from pip3. 20 | 21 | * **2. Execute a command** 22 | * [2-execute_a_command.pp](./2-execute_a_command.pp): Puppet manifest file 23 | that kills the process `killmenow`. 24 | -------------------------------------------------------------------------------- /0x0A-configuration_management/killmenow: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [[ true ]] 3 | do 4 | sleep 2 5 | done 6 | -------------------------------------------------------------------------------- /0x0B-ssh/0-use_a_private_key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Connects to server 54.237.33.119 with key in ~/.ssh/school 3 | 4 | ssh -i ~/.ssh/school ubuntu@54.237.33.119 5 | -------------------------------------------------------------------------------- /0x0B-ssh/1-create_ssh_key_pair: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Create an RSA key pair 3 | ssh-keygen -b 4096 -f school -N betty 4 | -------------------------------------------------------------------------------- /0x0B-ssh/100-puppet_ssh_config.pp: -------------------------------------------------------------------------------- 1 | # Seting up my client config file 2 | include stdlib 3 | 4 | file_line { 'Turn off passwd auth': 5 | ensure => present, 6 | path => '/etc/ssh/ssh_config', 7 | line => ' PasswordAuthentication no', 8 | replace => true, 9 | } 10 | 11 | file_line { 'Delare identity file': 12 | ensure => present, 13 | path => '/etc/ssh/ssh_config', 14 | line => ' IdentityFile ~/.ssh/school', 15 | replace => true, 16 | } 17 | -------------------------------------------------------------------------------- /0x0B-ssh/2-ssh_config: -------------------------------------------------------------------------------- 1 | # ssh config file 2 | Include /etc/ssh/ssh_config.d/*.conf 3 | Host * 4 | PasswordAuthentication no 5 | IdentifyFile ~/.ssh/school 6 | PubkeyAuthentication yes 7 | SendEnv LANG LC_* 8 | HashKnownHosts yes 9 | GSSAPIAuthentication yes 10 | -------------------------------------------------------------------------------- /0x0B-ssh/README.md: -------------------------------------------------------------------------------- 1 | # SSH 2 | 3 | In this project, I became familiar connecting to and working 4 | with servers using the SSH protocol. I worked on a server 5 | provided by ALX. 6 | 7 | ## Tasks :page_with_curl: 8 | 9 | * **0. Use a private key** 10 | * [0-use_a_private_key](./0-use_a_private_key): Bash script that uses `ssh` to connect to my 11 | Holberton-provided server. 12 | 13 | * **1. Create an SSH key pair** 14 | * [1-create_ssh_key_pair](./1-create_ssh_key_pair): Bash script that creates an RSA key pair. 15 | 16 | * **2. Client configuration file** 17 | * [2-ssh_config](./2-ssh_config): SSH configuration file configured to use the private key 18 | `~/.ssh/holberton` and to refuse authentication using a password. 19 | -------------------------------------------------------------------------------- /0x0B-ssh/web-01: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@100.26.165.147 8 | -------------------------------------------------------------------------------- /0x0C-web_server/0-transfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Transfers a file from Holberton's client to another. 3 | # Accepts four arguments: 4 | #+ The path to the file to be transferred. 5 | #+ The IP of the server to transfer the file to. 6 | #+ The username that scp connects with. 7 | #+ The path to the SSH private key that scp uses. 8 | 9 | if [ $# -lt 4 ] 10 | then 11 | echo "Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY" 12 | else 13 | scp -o StrictHostKeyChecking=no -i "$4" "$1" "$3@$2":~ 14 | fi 15 | -------------------------------------------------------------------------------- /0x0C-web_server/1-install_nginx_web_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # installs nginx and configures it on a remote server 3 | 4 | sudo apt-get update 5 | sudo apt-get install -y nginx 6 | sudo chown -R ubuntu /var/www 7 | echo "Hello World!" > /var/www/html/index.html 8 | sudo service nginx start 9 | -------------------------------------------------------------------------------- /0x0C-web_server/2-setup_a_domain_name: -------------------------------------------------------------------------------- 1 | viroo.tech 2 | -------------------------------------------------------------------------------- /0x0C-web_server/3-redirection: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure Nginx server so that /redirect_me is redirecting to another page 3 | # redirection must be a “301 Moved Permanently” 4 | # By: victor 5 | 6 | ADD301_REDIRECT="\\\trewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;" 7 | 8 | sudo apt-get update 9 | sudo apt-get install -y nginx 10 | sudo chown -R ubuntu /var/www 11 | echo "Hello World!" > /var/www/html/index.nginx-debian.html 12 | sudo sed -i "30i $ADD301_REDIRECT" /etc/nginx/sites-available/default 13 | sudo service nginx restart 14 | -------------------------------------------------------------------------------- /0x0C-web_server/4-not_found_page_404: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # sets up a new 404 error page 3 | sudo apt-get update 4 | sudo apt-get install -y nginx 5 | echo "Hello World!" > index.html 6 | sudo mv index.html /var/www/html 7 | 8 | 9 | echo "Ceci n'est pas une page" > 404.html 10 | sudo mv 404.html /var/www/html 11 | echo "server { 12 | listen 80 default_server; 13 | listen [::]:80 default_server; 14 | 15 | root /var/www/html; 16 | index index.html; 17 | location /redirect_me { 18 | return 301 https://www.youtube.com/watch?v=QH2-TGUlwu4; 19 | } 20 | error_page 404 /404.html; 21 | location = /404.html{ 22 | internal; 23 | } 24 | }" > default 25 | sudo mv -f default /etc/nginx/sites-available/default 26 | sudo service nginx restart 27 | -------------------------------------------------------------------------------- /0x0C-web_server/7-puppet_install_nginx_web_server.pp: -------------------------------------------------------------------------------- 1 | # Installs a Nginx server 2 | 3 | exec {'install': 4 | provider => shell, 5 | command => 'sudo apt-get -y update ; sudo apt-get -y install nginx ; echo "Hello World!" | sudo tee /var/www/html/index.nginx-debian.html ; sudo sed -i "s/server_name _;/server_name _;\n\trewrite ^\/redirect_me https:\/\/github.com\/Tolulope05 permanent;/" /etc/nginx/sites-available/default ; sudo service nginx start', 6 | } 7 | -------------------------------------------------------------------------------- /0x0C-web_server/README.md: -------------------------------------------------------------------------------- 1 | # Web server 2 | 3 | In this project, I learned how web servers work and began using one. I was 4 | provided a personal server by ALX. I learned how to use `scp` 5 | and Fabric to transfer files to my server. Additionally, I completed a basic 6 | configuration of the server using Nginx. 7 | 8 | The server is accessible at [bdbnb.site](http://bdbnb.site). 9 | 10 | ## Tasks :page_with_curl: 11 | 12 | * **0. Transfer a file to your server** 13 | * [0-transfer_file](./0-transfer_file): Bash script that transfers a file 14 | from Holberton's client to a server. 15 | * Accepts four arguments: 16 | * The path of the file to be transferred. 17 | * The IP of the server to transfer the file to. 18 | * The username that `scp` connects with. 19 | * The path of the SSH privtae key that `scp` uses. 20 | * `scp` transfers the file to the user home directory `~/`. 21 | 22 | * **1. Install nginx web server** 23 | * [1-install_nginx_web_server](./1-install_nginx_web_server): Bash script 24 | that configures a new Ubuntu machine with Nginx. 25 | * Nginx listens on port 80. 26 | * When querying Nginx at its root `/` with a `curl` GET request, 27 | it returns a page containing the string `Holberton School`. 28 | 29 | * **2. Setup a domain name** 30 | * [2-setup_a_domain_name](./2-setup_a_domain_name): A text file containing 31 | the domain name set up for the server through Gandi. 32 | 33 | * **3. Redirection** 34 | * [3-redirection](./3-redirection): Bash script that configures a new Ubuntu 35 | machine with Nginx. 36 | * Setup is identical to [1-install_nginx_web_server](./1-install_nginx_web_server) 37 | plus: 38 | * The location `/redirect_me` returns a `301 Moved Permanently` redirection 39 | to another page. 40 | 41 | * **4. Not found page 404** 42 | * [4-not_found_page_404](./4-not_found_page_404): Bash script that configures 43 | a new Ubuntu machine with Nginx. 44 | * Setup is identical to [1-install_nginx_web_server](./1-install_nginx_web_server) 45 | plus: 46 | * Features a custom 404 page containing the string `Ceci n'est pas une page`. 47 | 48 | * **5. Design a beautiful 404 page** 49 | * A custom-designed 404 error page for my server, accessible at 50 | [bdbnb.site/404](http://bdbnb.site/404). 51 | 52 | * **6. Deploy fast, deploy well** 53 | * [fabfile.py](./fabfile.py): A Python Fabric configuration file defining 54 | the following functions: 55 | * `pack` 56 | * Usage: `fabric pack` 57 | * Creates a tar gzipped archive of the current directory named 58 | `holbertonwebapp.tar.gz` in the local directory. 59 | * `deploy` 60 | * Usage: `fabric -H deploy` 61 | * Uploads the archive `holbertonwebapp.tar.gz` to the `/tmp` 62 | directory of the remote server. 63 | * Creates the directory `/tmp/holbertonwebapp` in the remote server. 64 | * Untars `holbertonwebapp.tar.gz` in the `/tmp/holbertonwebapp` directory 65 | of the remote server. 66 | * `clean` 67 | * Deletes the archive `holbertonwebapp.tar.gz` in the local directory. 68 | -------------------------------------------------------------------------------- /0x0C-web_server/fabfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Fabfile defining functions to pack, deploy, and clean the 3 | # current directory to a remote server. 4 | from fabric import task 5 | 6 | 7 | @task 8 | def pack(c): 9 | """Create a tar gzipped archive of the current directory.""" 10 | c.run("touch holbertonwebapp.tar.gz") 11 | c.run("tar --exclude='*.tar.gz' -cvzf holbertonwebapp.tar.gz .") 12 | 13 | 14 | @task 15 | def deploy(c): 16 | """Upload the archive to the remote server in the /tmp/ directory.""" 17 | c.user = "ubuntu" 18 | c.put("holbertonwebapp.tar.gz", "/tmp") 19 | c.run("mkdir /tmp/holbertonwebapp") 20 | c.run("tar -C /tmp/holbertonwebapp -xzvf /tmp/holbertonwebapp.tar.gz") 21 | 22 | 23 | @task 24 | def clean(c): 25 | """Deletes holbertonwebapp.tar.gz on the local machine.""" 26 | c.run("rm holbertonwebapp.tar.gz") 27 | -------------------------------------------------------------------------------- /0x0C-web_server/web-01: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@54.144.152.30 8 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # run apache on designated container 3 | 4 | echo "ServerName localhost" >> /etc/apache2.conf 5 | service apache2 start 6 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/README.md: -------------------------------------------------------------------------------- 1 | # Web stack debugging #0 2 | 3 | This was the first in a series of web stack debugging projects. In these 4 | projects, I was given broken/bugged webstacks in isolated containers, 5 | and tasked with fixing the web stack to a working state. For each 6 | task, I wrote a script automating the commands necessary to fix the 7 | web stack. 8 | 9 | ## Tasks :page_with_curl: 10 | 11 | * **0. Give me a page!** 12 | * [0-give_me_a_page](./0-give_me_a_page): Bash script that runs Apache on a 13 | web server and gets it to respond to queries to the root. 14 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/0-nginx_likes_port_80: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configures an Nginx server to listen on port 80. 3 | 4 | rm /etc/nginx/sites-enabled/default 5 | ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default 6 | service nginx restart 7 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/1-debugging_made_short: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configures an Nginx server to listen on port 80. 3 | ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default 4 | service nginx start 5 | kill "$(pgrep 'nginx' | head -1)" 6 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/README.md: -------------------------------------------------------------------------------- 1 | # Web stack debugging #1 2 | 3 | This was the second in a series of web stack debugging projects. In these 4 | projects, I was given broken/bugged webstacks in isolated containers, 5 | and tasked with fixing the web stack to a working state. For each 6 | task, I wrote a script automating the commands necessary to fix the 7 | web stack. 8 | 9 | ## Tasks :page_with_curl: 10 | 11 | * **0. Nginx likes port 80** 12 | * [0-nginx_likes_port_80](./0-nginx_likes_port_80): Bash script that 13 | configures Nginx to run and listen to port 80 on all of a server's active IPv4's. 14 | 15 | * **1. Make it sweet and short** 16 | * [1-debugging_made_short](./1-debugging_made_short): Bash script that 17 | configures Nginx to listen to port 80 without running on all of a server's 18 | active IPv4's. 19 | -------------------------------------------------------------------------------- /0x0F-load_balancer/0-custom_http_response-header: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script that configures Nginx server with a custom header 3 | apt-get -y update 4 | apt-get -y install nginx 5 | echo "Hello World!" > /var/www/html/index.nginx-debian.html 6 | echo "not found" > /usr/share/nginx/html/custom_404.html 7 | sed -i "s/server_name _;/server_name _;\n\trewrite ^\/redirect_me https:\/\/github.com\/victor0089 permanent;\n\n\terror_page 404 \/custom_404.html;\n\tlocation = \/custom_404.html {\n\t\troot \/usr\/share\/nginx\/html;\n\t\tinternal;\n\t}/" /etc/nginx/sites-available/default 8 | sed -i "s/include \/etc\/nginx\/sites-enabled\/\*;/include \/etc\/nginx\/sites-enabled\/\*;\n\tadd_header X-Served-By \"$HOSTNAME\";/" /etc/nginx/nginx.conf 9 | service nginx start 10 | -------------------------------------------------------------------------------- /0x0F-load_balancer/1-install_load_balancer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs and setup haproxy 3 | 4 | apt-get install -y software-properties-common 5 | add-apt-repository -y ppa:vbernat/haproxy-1.8 6 | apt-get -y update 7 | apt-get install -y haproxy=1.8.\* 8 | 9 | echo "ENABLED=1" > /etc/default/haproxy 10 | 11 | # Listen to web1 and web2 servers 12 | echo " 13 | listen load_balancer 14 | bind *:80 15 | mode http 16 | balance roundrobin 17 | option httpclose 18 | option forwardfor 19 | server 349269-web-01 54.144.152.30:80 check 20 | server 349269-web-02 35.174.176.12:80 check 21 | " >> /etc/haproxy/haproxy.cfg 22 | 23 | service haproxy start 24 | -------------------------------------------------------------------------------- /0x0F-load_balancer/2-puppet_custom_http_response-header.pp: -------------------------------------------------------------------------------- 1 | # Installs a Nginx server with custome 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 | } -------------------------------------------------------------------------------- /0x0F-load_balancer/README.md: -------------------------------------------------------------------------------- 1 | # Load Balancer -------------------------------------------------------------------------------- /0x0F-load_balancer/web-01: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@54.144.152.30 8 | -------------------------------------------------------------------------------- /0x0F-load_balancer/web-02: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@35.174.176.12 8 | -------------------------------------------------------------------------------- /0x10-https_ssl/0-world_wide_web: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Bash script displays DNS records: record type, IP, subdomains 3 | 4 | print_rec () 5 | { 6 | printf "The subdomain %s is a " "$2" 7 | dig "$2.$1" | grep -A1 'ANSWER SECTION:' | awk -F' ' '{ printf $4 }' 8 | printf " record and points to " 9 | dig "$2.$1" | grep -A1 'ANSWER SECTION:' | awk -F' ' '{ printf $5 }' 10 | echo "" 11 | } 12 | 13 | if [ -z "$2" ]; then 14 | for subs in "www" "lb-01" "web-01" "web-02" 15 | do 16 | print_rec "$1" "$subs" 17 | done 18 | else 19 | print_rec "$1" "$2" 20 | fi 21 | -------------------------------------------------------------------------------- /0x10-https_ssl/1-haproxy_ssl_termination: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners 6 | stats timeout 30s 7 | maxconn 2048 8 | user haproxy 9 | group haproxy 10 | tune.ssl.default-dh-param 2048 11 | daemon 12 | 13 | # Default SSL material locations 14 | ca-base /etc/ssl/certs 15 | crt-base /etc/ssl/private 16 | 17 | # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate 18 | ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 19 | ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 20 | ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets 21 | 22 | defaults 23 | log global 24 | mode http 25 | option httplog 26 | option dontlognull 27 | timeout connect 5000 28 | timeout client 50000 29 | timeout server 50000 30 | errorfile 400 /etc/haproxy/errors/400.http 31 | errorfile 403 /etc/haproxy/errors/403.http 32 | errorfile 408 /etc/haproxy/errors/408.http 33 | errorfile 500 /etc/haproxy/errors/500.http 34 | errorfile 502 /etc/haproxy/errors/502.http 35 | errorfile 503 /etc/haproxy/errors/503.http 36 | errorfile 504 /etc/haproxy/errors/504.http 37 | frontend website 38 | bind :80 39 | bind :443 ssl crt /etc/haproxy/ssl/www.viroo.tech.pem 40 | default_backend servers 41 | backend servers 42 | balance roundrobin 43 | option httpchk GET / 44 | option redispatch 45 | redirect scheme https if !{ ssl_fc } 46 | server 349269-web-01 54.144.152.30:80 check 47 | server 349269-web-02 35.174.176.12:80 check 48 | -------------------------------------------------------------------------------- /0x10-https_ssl/100-redirect_http_to_https: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin 6 | stats timeout 30s 7 | user haproxy 8 | group haproxy 9 | daemon 10 | 11 | # Setting up SSL from tutorial 12 | # https://www.digitalocean.com/community/tutorials/how-to-secure-haproxy-with-let-s-encrypt-on-ubuntu-16-04 13 | maxconn 2048 14 | tune.ssl.default-dh-param 2048 15 | 16 | # Default SSL material locations 17 | ca-base /etc/ssl/certs 18 | crt-base /etc/ssl/private 19 | 20 | # Default ciphers to use on SSL-enabled listening sockets. 21 | # For more information, see ciphers(1SSL). This list is from: 22 | # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ 23 | ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS 24 | ssl-default-bind-options no-sslv3 25 | 26 | defaults 27 | log global 28 | mode http 29 | option httplog 30 | option dontlognull 31 | timeout connect 5000 32 | timeout client 50000 33 | timeout server 50000 34 | errorfile 400 /etc/haproxy/errors/400.http 35 | errorfile 403 /etc/haproxy/errors/403.http 36 | errorfile 408 /etc/haproxy/errors/408.http 37 | errorfile 500 /etc/haproxy/errors/500.http 38 | errorfile 502 /etc/haproxy/errors/502.http 39 | errorfile 503 /etc/haproxy/errors/503.http 40 | errorfile 504 /etc/haproxy/errors/504.http 41 | # Setting up SSL from tutorial 42 | # https://www.digitalocean.com/community/tutorials/how-to-secure-haproxy-with-let-s-encrypt-on-ubuntu-14-04 43 | option forwardfor 44 | option http-server-close 45 | 46 | # Setting up SSL from tutorial 47 | 48 | frontend www-http 49 | bind *:80 50 | reqadd X-Forwarded-Proto:\ http 51 | default_backend www-backend 52 | 53 | frontend www-https 54 | bind *:443 ssl crt /etc/haproxy/certs/www.melissax.online.pem 55 | reqadd X-Forwarded-Proto:\ https 56 | acl letsencrypt-acl path_beg /.well-known/acme-challenge/ 57 | use_backend letsencrypt-backend if letsencrypt-acl 58 | default_backend www-backend 59 | 60 | backend www-backend 61 | balance roundrobin 62 | redirect scheme https code 301 if !{ ssl_fc } 63 | # server 349269-web-01 100.25.134.93:80 check 64 | # server 349269-web-02 35.175.134.83:80 check 65 | 66 | backend letsencrypt-backend 67 | server letsencrypt 127.0.0.1:54321 68 | 69 | #listen appname 0.0.0.0:80 70 | # mode http 71 | # balance roundrobin 72 | # option httpclose 73 | # option forwardfor 74 | # server 349269-web-01 100.25.134.93:80 check 75 | # server 349269-web-02 35.175.134.83:80 check 76 | -------------------------------------------------------------------------------- /0x10-https_ssl/README.md: -------------------------------------------------------------------------------- 1 | # HTTPS SSL 2 | 3 | In this project, I learned about the importance of HTTPS and how it works. I 4 | configured my HolbertonBnB web servers with `certbot` certificate and HAproxy 5 | SSL termination. 6 | 7 | ## Tasks :page_with_curl: 8 | 9 | 10 | * **0. World wide web** 11 | * [1-world_wide_web](./0-world_wide_web): Bash script that displays 12 | information about subdomains on my configured servers. 13 | * Usage: `./1-world_wide_web ` 14 | * Output: `The subdomain [SUB_DOMAIN] is a [RECORD_TYPE] record and 15 | points to [DESTINATION]` 16 | * If no `subdomain` parameter is passed, displays information about the 17 | subdomains `www`, `lb-01`, `web-01` and `web-02`, in that order. 18 | 19 | * **2. HAproxy SSL termination** 20 | * [2-haproxy_ssl_termination](./2-haproxy_ssl_termination): HAproxy 21 | configuration file that accepts encrypted SSL traffic for the subdomain 22 | `www.` on TCP port 443. 23 | 24 | * **3. No loophole in your website traffic** 25 | * [100-redirect_http_to_https](./100-redirect_http_to_https): HAproxy 26 | configuration file that automatically redirects HTTP traffic to HTTPS. 27 | -------------------------------------------------------------------------------- /0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter/0-blog_post: -------------------------------------------------------------------------------- 1 | https://medium.com/@k.coovi/googling-101-what-really-happens-when-you-visit-google-64c55d9cab35 2 | -------------------------------------------------------------------------------- /0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter/1-what_happen_when_diagram: -------------------------------------------------------------------------------- 1 | https://drive.google.com/file/d/1Uv4sqIO30iPmilAAsx90oHX1kxBTzXKl/view 2 | -------------------------------------------------------------------------------- /0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter/2-contribution-to_what-happens-when_github_answer: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter/README.md: -------------------------------------------------------------------------------- 1 | solutions to devops exercises 2 | 3 | 0. What happens when... 4 | 5 | This question is a classic and still widely used interview question for many types of software engineering position. It is used to assess a candidate’s general knowledge of how the web stack works on top of the internet. One important guideline to begin answering this question is that you should ask your interviewer whether they would like you to focus in on one specific area of the workflow. For a front-end position they may want you to talk at length about how the DOM is rendering. For an SRE position they may want you to go into the load balancing mechanism. 6 | 7 | This question is a good test of whether you understand DNS. Many software engineering candidates struggle with this concept, so if you do well on this question, you are already way ahead of the curve. If you take this project seriously and write an excellent article, it may be something that will grab the attention of future employers. 8 | 9 | Write a blog post explaining what happens when you type https://www.google.com in your browser and press Enter. 10 | 11 | Requirements, your post must cover: 12 | 13 | DNS request 14 | TCP/IP 15 | Firewall 16 | HTTPS/SSL 17 | Load-balancer 18 | Web server 19 | Application server 20 | Database 21 | Publish your blog post on Medium or LinkedIn; share the URL of your blog post in your answer file and in the field below. 22 | 23 | Please, remember that these blogs must be written in English to further your technical ability in a variety of settings. 24 | 25 | 1. Everything's better with a pretty diagram 26 | 27 | Add a schema to your blog post illustrating the flow of the request created when you type https://www.google.com in your browser and press Enter. 28 | 29 | The diagram should show: 30 | 31 | DNS resolution 32 | that the request hitting server IP on the appropriate port 33 | that the traffic is encrypted 34 | that the traffic goes through a firewall 35 | that the request is distributed via a load balancer 36 | that the web server answers the request by serving a web page 37 | that the application server generates the web page 38 | that the application server request data from the database 39 | 40 | [Gliffy](https://www.gliffy.com/) is free and what I personally use, but feel free to use what fits you best. 41 | 42 | 2. Contribute! 43 | 44 | Folks on the Internet have been trying to put together a comprehensive answer to the question. Help them by submitting a pull request. Paste the link in your answer file. 45 | 46 | https://github.com/alex/what-happens-when#the-g-key-is-pressed 47 | 48 | Requirements: 49 | 50 | The pull request must bring meaningful value (not a typo correction or style improvement) 51 | Share the pull request URL in your answer file and in the field below 52 | Please, remember that these blogs must be written in English to further your technical ability in a variety of settings. 53 | -------------------------------------------------------------------------------- /0x11.-What-happens-when-you-type-google.com-in-your-browser-and-press-Enter/google.com on your browser: -------------------------------------------------------------------------------- 1 | 7V3td6K4Gv9res7dD/UQwot+VNve7jltd864Z/fupzmoqXKLhAWs7f71mwBBSKKgEtCxM9OpBAjheX7Pa57EGzheffw3dILlM54j70bXFqE7v4F3N7oOyA9pCJwFKjXQKybuP6xRy1rX7hxFpQtjjL3YDcqNM+z7aBaX2pwwxJvyZa/YE4cxmTkeElr/dOfxMm3t6/a2/RG5iyV7ELAG6ZmVwy7OBh4tnTneFJrg/Q0chxjH6afVxxh5lDKMLul9DzvO5gMLkR/XuWE81Z6j74Pb6eZtcP94e4de/MdbIxtb/MleGM3J+2eHOIyXeIF9x7vfto5CvPbniPaqkaPtNU8YB6QRkMb/ozj+zHjnrGNMmpbxysvOkgGHn//L7k8O/qIHPZMd3n0UT959ZkfpWOkAd5Iga4rwOpyhPe/NkOOECxTvuc7MGUXgi/AKkfGQ+0LkObH7Xh6HkyFrkV+X3/oNu2SEuvaR3WBmmPhkqDHLXaTjyu7a8pR8KAxj25Rw+gCuZwN+d7w1I5LnouxZRTBEbyieLRmn17Hn+micCxZtfMV+PMYeDpMbIPn7QAcyWoTOnHbJzvnYp9iJ4hC/IdkNr67nFdpfkz+kfe5Eyxxs7yiMXSKcT84Ued9w5MYu9sm5KY5jvCpcMPTcBT0RU0iOnOxoRgaEwjIY6QtkSAU6O84oQB/pREH6tq/uBx3HiMhxQE+uPhZUn/WcTWT0QpRC7tcZHc+IHKafylfNUiozJNPBoo/9WBaxl90AyxCys8PNVkkNsqZlQT+xNhlWSyg7GFLXqknMmpoEwBNVyUnsMQWJH1FTSISB51qZJ5ulG6NJ4CQk2BAkl+nfAI6BVQZy3xSAbEuAbKkCsi1Q6u5lQhoIJt/WgUAu8uJxmSaCsuF10sqdz1P4o8j9x5nmqiag+j55H3N0Y97Rvgjio0w5CdozU6lFxZk1NcAW3ahki0y/QGX6xepEv3y4ca5eyOeCdiFHW+VCD5huyXUSKOsku0Wl1G9LKSW3DsPQ+SxckOF4p/tj8u4P1Dh8pD026vP0Bbm+0S2Pym5QgpX195p65CMq2LeZLA/JFR56TS23Rp2gWwZ6egr09OQMu5V8WtDfL84Kkc/OimpNfxoF6bnkoVHg+NLnJhr3NkpVLu09CJG0d/Kb+EkDxX0SWqfdsgu0nWf4F9WOa/r9M0CtvlFD45Y0/ZGAbfvcoPBQtdCrJODUmb0tEv14O0uNB+3O9YlH7XjSLjebTW+B8cJDvRnxtUVcS3EuUvvUcWmN8r5pKo1fhs/3l/LyVfhN2a2AShmC9hGpVXEp4bo5zdOqVt7zT3rT8CdRsvImElf0zH6PeKTkpy8H1SmRj8dlIARvn09R5F5/ZXyQ5iwa8OHNfqUPD7U2kwQDeWx1JSGVxYVUzAsusMOUcENdSCWmAX/9Ro6H8zkhYyQRoithlKGXGcXikyKngCwpoY5VZpfRL/t8UPR7q/U0El6WQmAI84YdMXBy9A2FLqEbBVDjeX9YMzLuNxEYV0e+NRP/uyPsxqcGRDHvLM9in3+ipTaeTp1IOk19QFHTT6iq/44i7L2fQRYYmpWuSl+icJVlgYHoqizjmE4xD2nH+gMfDV+LaYRmmU8Sy9iqE8NMNe/EXKnrwk8LSl0XvVUGSbxMSmEfidPNpDs3iCgp2CTrzMPreSsaCHDeuWxGVUq5vjLKiVpbpJg/H9KiloRUThS5szJhyno8N7M9YMCCqQU9Ta+wteRAoVu2wzpWREas7dRqDJuTGZPjaDp8wSmr7EiAhuKyDt1QBxizXwQMAVC3gNklzO0gJi9GY4w+FjF8RwL0VCNGrAt4TNwcSqK/1yiKWeZsGrK8GWdZ4dAw4NXYV95IaBIjASXAM5QZCWsnB4lzH2A/Ql8sLLtIwDw3Hoo1JwI3DgrIlGWUWZVXRjoDiKQzZBnlPM3cPO1k8/on2by6Vqor4wO57CQExxofs6KjzpNRTAr3madr0Vpc4A0lgV2rBVlQjOtEw3MtzKkTO4JWuaML3Jncf//j/vvV8ARYZYGxJQLT6hyOITFMbVZIb4ui/yqeU58jh5mLWpkjN3ZwtJ0kORQ96TGeo6kj86D/8/j8+9ONTp6kjSeTX8iv24S1ZJwzgc3qk1ec/rF0if6R5a6U5c9hDZc2z/F9ei4BeQirHdtpKg5P07whLz36LV2dwhRNpnPMhqYntLIysSQxgyWhr7LcIBTd3jsndnaA9dmJiCb/5Wp0fx5uMHbBeosKlEV4QKuTmlNvDZrU6oPL0OriRN4wCDwC6aQuS9cmKEwmQAWhufv0nZU7E6VGvTrX7bK6MWUpilb1uSF6+3+iaYF8XZu8MyCR6D+IIn5k9r2ce9fAoMvce2rbO0t/cFkLg7exddMfkM2vMQTxyOg8/WGIuutURO0omamqmDlmHdQ52ZqWpoUGDUHT4PwXgw9KFU8LmaK2F4B3HglpgzMDsow0lFUOqctIm7Jpe967EFuefhuSS7XR8Gn4Mpbkaba1ERW0FhasKyM+5OrLdQnxgSwsAsqMsClOaDalMrWentrdrdocVOpNWTnr1qwPtH5BodKKWQ3u1amqZ9XtmnrW3LFutCUXwKpQj7VdAE5hQ37lg2o9q9BlLBdt98HhwCogv68XgZ8A1T4G+g1i1axbeat3665aFRCrjVXe0vEGTDVWa2T0jtespdy0VgWtHOQ2KEdGAyJRXZax1a4G79RPNfiJ32MxadjHYbK9EMpsvDygEJSnWrFove1O0Vd7U6tOrbfJBzc8aI5FH7Rb1ojqwnOi2bZLpbKkD+yrtbiVsDmvvI+QrqkNG67m0qwZXLentNibnVGylfNius+2WnUU+0VNqFh15TClaVcTKpaYGzr/CRWrf3b4rWM8Lgu/+mXgVxcIfzllHpwa7r7Ow6qxRumC6jxszjfovM7DEvOZe+o8Jp7zjq6nzMPmq3K6LvOwxHzelVVd8lvOdF51aYvqXrSzRyYAdIvF+ywBAFhGoJMEgNVpXG+z5YenBmg2W9N0thPzdvMLLbeRv2XlqfXDkqHlJZrgYCSqztjXD3C6xTFfWcSbi9o4hpxA1MxPtYfjfuM4rguXzko0+OkY/UjmQlDRUefMBVrzc+FbXXO6pjliUYJqDQXrzn93q6H4/cmMoy0tp+rsk0G8Q1igfC1O7XG1sUE00CTe++QpgdLcw7M3QXi+vh2j0W/HiCLvByO1kuKwvD6vtFxZFFOFywBqTKK7q+SLkIpcyJru3NWCPNdzp+T/mecGP5yQSM2Dj+INDt9cn559cEO0cTzvh6b/AHr/g/z0AnrmZHLyJk9GTlmpHb+nRYMbWNaoU7ysJCrQ6m7d3+2yinycF4lkvn5MkkZtd7c5Jlk/E5Dr1myfPB1wlEti8rPA2n6XpOJ6VS5JjVmis5UyoTqoezHTq8lZcurKqdURzfART3ac/6bpVn2cnBn0q85kvwtnWG/iGT1tKDfK2myxESR96qakUdZm889OGoDk2XybLmmUdil5tsYNMslbVzqwlUsKBH9UcG4TlqLw/h2lnAUSp3XmRjMMBsRvpX2NgpC5q9h3YxxSwRFc8och/Stz4jXN1GzYUH6d32JOstNEuy6tZG/ZL5n6kqkLkik+2WCJIrUvmaNApGqkZb9E6kukzlekbPPsZEqMV5+3ZNK1mfwLcH/aeXp+CYCskqjVHauAZMv1a+YQX0jR+ZZieWHZF4PSMJX3G86AQ2I+lIX3V8MWwM01GZKiMFkJn0KuiFmHq+OKya9e7J4rYtx6dVyB3LdFyDYVbZkrh1WkZKSoU1YFgHVTLDVga+07XFDV7cpka4eLfvB6Kt7XP3kb4YPGqzYBL9kg/xQ81gVPZ7VvvNd5dGUJ39HZ7S0NJDvnN6NqimqmxtZK57JPQjY70llRE78s+OhF6fwGYXzu++hlweQwxPSLb7eX0zzMM54jesW/ -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/0-iamsomeoneelse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs the whoami command under the user passed as argument. 3 | sudo -u "$1" whoami 4 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/1-run_nginx_as_nginx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes a web server to run Nginx as the nginx user listening on port 8080. 3 | sed -i "s/#user www-data/user nginx/" /etc/nginx/nginx.conf 4 | sed -i "s/80/8080/g" /etc/nginx/sites-available/default 5 | chmod 644 /etc/nginx/nginx.conf 6 | pkill apache2 7 | sudo -u nginx service nginx start 8 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/100-fix_in_7_lines_or_less: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes a web server to run Nginx as the nginx user listening on port 8080. 3 | sed -i "s/#user www-data/user nginx/" /etc/nginx/nginx.conf 4 | sed -i "s/80/8080/g" /etc/nginx/sites-available/default 5 | chmod 644 /etc/nginx/nginx.conf 6 | pkill apache2 7 | sudo -u nginx service nginx start 8 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Web stack debugging #2 3 | This was the third in a series of web stack debugging projects. In these 4 | projects, I was given broken/bugged webstacks in isolated containers, 5 | and tasked with fixing the web stack to a working state. For each 6 | task, I wrote a script automating the commands necessary to fix the 7 | web stack. 8 | ## Tasks :page_with_curl: 9 | 10 | * **0. Run software as another user** 11 | * [0-iamsomeonelese](./0-iamsomeonelese): Bash script that runs the command 12 | `whoami` under the user passed as argument. 13 | * Usage: `./0-iamsomeonelese ` 14 | 15 | * **1. Run Nginx as Nginx** 16 | * [1-run_nginx_as_nginx](./1-run_nginx_as_nginx): Bash script that fixes a 17 | web server to run Nginx listening on port `8080` as the `nginx` user. 18 | 19 | * **2. 7 lines or less** 20 | * [100-fix_in_7_lines_or_less](./100-fix_in_7_lines_or_less): Bash script 21 | that fixes a web server to run Nginx listening on port `8080` as the `nginx` 22 | user. 23 | * 7 lines long. 24 | -------------------------------------------------------------------------------- /0x13-firewall/0-block_all_incoming_traffic_but: -------------------------------------------------------------------------------- 1 | sudo ufw status 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 8 | sudo ufw status 9 | sudo ufw disable 10 | -------------------------------------------------------------------------------- /0x13-firewall/100-port_forwarding: -------------------------------------------------------------------------------- 1 | # 2 | # rules.before 3 | # 4 | # Rules that should be run before the ufw command line added rules. Custom 5 | # rules should be added to one of these chains: 6 | # ufw-before-input 7 | # ufw-before-output 8 | # ufw-before-forward 9 | # 10 | 11 | *nat 12 | :PREROUTING ACCEPT [0:0] 13 | -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 14 | 15 | # Don't delete these required lines, otherwise there will be errors 16 | *filter 17 | :ufw-before-input - [0:0] 18 | :ufw-before-output - [0:0] 19 | :ufw-before-forward - [0:0] 20 | :ufw-not-local - [0:0] 21 | # End required lines 22 | 23 | 24 | # allow all on loopback 25 | -A ufw-before-input -i lo -j ACCEPT 26 | -A ufw-before-output -o lo -j ACCEPT 27 | 28 | # quickly process packets for which we already have a connection 29 | -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 30 | -A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 31 | -A ufw-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 32 | 33 | # drop INVALID packets (logs these in loglevel medium and higher) 34 | -A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny 35 | -A ufw-before-input -m conntrack --ctstate INVALID -j DROP 36 | 37 | # ok icmp codes for INPUT 38 | -A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT 39 | -A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT 40 | -A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT 41 | -A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT 42 | -A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT 43 | 44 | # ok icmp code for FORWARD 45 | -A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT 46 | -A ufw-before-forward -p icmp --icmp-type source-quench -j ACCEPT 47 | -A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT 48 | -A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT 49 | -A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT 50 | 51 | # allow dhcp client to work 52 | -A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT 53 | 54 | # 55 | # ufw-not-local 56 | # 57 | -A ufw-before-input -j ufw-not-local 58 | 59 | # if LOCAL, RETURN 60 | -A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN 61 | 62 | # if MULTICAST, RETURN 63 | -A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN 64 | 65 | # if BROADCAST, RETURN 66 | -A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN 67 | 68 | # all other non-local packets are dropped 69 | -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny 70 | -A ufw-not-local -j DROP 71 | 72 | # allow MULTICAST mDNS for service discovery (be sure the MULTICAST line above 73 | # is uncommented) 74 | -A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT 75 | 76 | # allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above 77 | # is uncommented) 78 | -A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT 79 | 80 | # don't delete the 'COMMIT' line or these rules won't be processed 81 | COMMIT 82 | 83 | -------------------------------------------------------------------------------- /0x13-firewall/README.md: -------------------------------------------------------------------------------- 1 | # Firewall 2 | In this project, I used `ufw` to configure firewalls on my issued web servers. 3 | ## Tasks :page_with_curl: 4 | 5 | * **0. Block all incoming traffic but** 6 | * [0-block_all_incoming_traffic_but](./0-block_all_incoming_traffic_but): Bash 7 | script that installs a `ufw` firewall to block all incoming traffic except for 8 | ports `22`, `443` and `80` on a web server. 9 | 10 | * **2. Port forwarding** 11 | * [100-port_forwarding](./100-port_forwarding): `ufw` configuration file that 12 | configures a firewall to redirect port `8080/TCP` to port `80/TCP`. 13 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_primary: -------------------------------------------------------------------------------- 1 | # 2 | # The MySQL Server configuration file. 3 | # 4 | 5 | [mysqld] 6 | pid-file = /var/run/mysqld/mysqld.pid 7 | socket = /var/run/mysqld/mysqld.sock 8 | datadir = /var/lib/mysql 9 | log-error = /var/log/mysql/error.log 10 | # By default we only accept connections from localhost 11 | bind-address = 0.0.0.0 12 | # Disabling symbolic-links is recommended to prevent assorted security risks 13 | symbolic-links=0 14 | # Distinguish servers in a replication setup 15 | server-id = 1 16 | # MySQL's Binary Log File 17 | log_bin = /var/log/mysql/mysql-bin.log 18 | # Database we want to replicate 19 | binlog_do_db = tyrell_corp 20 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_replica: -------------------------------------------------------------------------------- 1 | # 2 | # The MySQL Server configuration file. 3 | # 4 | 5 | [mysqld] 6 | pid-file = /var/run/mysqld/mysqld.pid 7 | socket = /var/run/mysqld/mysqld.sock 8 | datadir = /var/lib/mysql 9 | log-error = /var/log/mysql/error.log 10 | # By default we only accept connections from localhost 11 | bind-address = 127.0.0.1 12 | # Disabling symbolic-links is recommended to prevent assorted security risks 13 | symbolic-links=0 14 | # Distinguish servers in a replication setup 15 | server-id = 2 16 | # MySQL's Binary Log File 17 | log_bin = /var/log/mysql/mysql-bin.log 18 | # Database we want to replicate 19 | binlog_do_db = tyrell_corp 20 | # Defines the location of the replica's relay log 21 | relay-log = /var/log/mysql/mysql-relay-bin.log 22 | -------------------------------------------------------------------------------- /0x14-mysql/5-mysql_backup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # backup and compress my databases 3 | 4 | # variables 5 | day=$(date +"%d") 6 | month=$(date +"%m") 7 | year=$(date +"%Y") 8 | file_name="$day-$month-$year.tar.gz" 9 | 10 | mysqldump --all-databases -u root --password="$1" > backup.sql 11 | tar -czvf "$file_name" backup.sql 12 | -------------------------------------------------------------------------------- /0x14-mysql/README.md: -------------------------------------------------------------------------------- 1 | # Mysql 2 | 3 | This project involved learning how to configure database servers in a 4 | primary-replica model. I configured the two servers provided to me by 5 | ALX in a MySQL primary-replica setup with a dummy database, and wrote 6 | a Bash script to automate generation of database backups. 7 | 8 | ## Tasks :page_with_curl: 9 | * [4-mysql_configuration_primary](./4-mysql_configuration_primary): The MySQL 10 | `my.conf` configuration file used to set up my first server as a primary database 11 | server on the database `tyrell_corp`. 12 | 13 | * [4-mysql_configuration_replica](./4-mysql_configuration_replica): The MySQL 14 | `my.conf` configuration file used to set up my second server as the replica 15 | database server on the database `tyrell_corp`. 16 | 17 | * [5-mysql_backup](./5-mysql_backup): Bash script that generates a compressed 18 | `tar.gz` archive from a MySQL dump. 19 | * Usage: `./5-mysql_backup ` 20 | * Generates a dump containing all MySQL databases on the root server. 21 | * Names the resulting tar archive in the format `day-month-year.tar.gz`. 22 | -------------------------------------------------------------------------------- /0x14-mysql/lb-01: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@100.25.21.201 8 | -------------------------------------------------------------------------------- /0x14-mysql/web-01: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@54.144.152.30 8 | -------------------------------------------------------------------------------- /0x14-mysql/web-02: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # server-01 login 3 | eval $("ssh-agent") 4 | 5 | ssh-add ~/.ssh/school 6 | 7 | ssh ubuntu@35.174.176.12 8 | -------------------------------------------------------------------------------- /0x15-api/0-gather_data_from_an_API.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | A Script that, uses this REST API, for a given employee ID, returns 4 | information about his/her TODO list progress 5 | """ 6 | 7 | import json 8 | import requests 9 | from sys import argv 10 | 11 | 12 | if __name__ == "__main__": 13 | 14 | sessionReq = requests.Session() 15 | 16 | idEmp = argv[1] 17 | idURL = 'https://jsonplaceholder.typicode.com/users/{}/todos'.format(idEmp) 18 | nameURL = 'https://jsonplaceholder.typicode.com/users/{}'.format(idEmp) 19 | 20 | employee = sessionReq.get(idURL) 21 | employeeName = sessionReq.get(nameURL) 22 | 23 | json_req = employee.json() 24 | name = employeeName.json()['name'] 25 | 26 | totalTasks = 0 27 | 28 | for done_tasks in json_req: 29 | if done_tasks['completed']: 30 | totalTasks += 1 31 | 32 | print("Employee {} is done with tasks({}/{}):". 33 | format(name, totalTasks, len(json_req))) 34 | 35 | for done_tasks in json_req: 36 | if done_tasks['completed']: 37 | print("\t " + done_tasks.get('title')) 38 | -------------------------------------------------------------------------------- /0x15-api/1-export_to_CSV.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | A Script that, uses a REST API, for a given employee ID, returns 4 | information about his/her TODO list progress 5 | exporting data in the CSV format. 6 | """ 7 | 8 | import csv 9 | import json 10 | import requests 11 | from sys import argv 12 | 13 | 14 | if __name__ == "__main__": 15 | 16 | sessionReq = requests.Session() 17 | 18 | idEmp = argv[1] 19 | idURL = 'https://jsonplaceholder.typicode.com/users/{}/todos'.format(idEmp) 20 | nameURL = 'https://jsonplaceholder.typicode.com/users/{}'.format(idEmp) 21 | 22 | employee = sessionReq.get(idURL) 23 | employeeName = sessionReq.get(nameURL) 24 | 25 | json_req = employee.json() 26 | usr = employeeName.json()['username'] 27 | 28 | totalTasks = 0 29 | 30 | for done_tasks in json_req: 31 | if done_tasks['completed']: 32 | totalTasks += 1 33 | 34 | fileCSV = idEmp + '.csv' 35 | 36 | with open(fileCSV, "w", newline='') as csvfile: 37 | write = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_ALL) 38 | for i in json_req: 39 | write.writerow([idEmp, usr, i.get('completed'), i.get('title')]) 40 | -------------------------------------------------------------------------------- /0x15-api/2-export_to_JSON.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | A sript that, uses a REST API, for a given employee ID, returns 4 | information about his/her TODO list progress 5 | and exports data in the JSON format. 6 | """ 7 | 8 | import json 9 | import requests 10 | from sys import argv 11 | 12 | 13 | if __name__ == "__main__": 14 | 15 | sessionReq = requests.Session() 16 | 17 | idEmp = argv[1] 18 | idURL = 'https://jsonplaceholder.typicode.com/users/{}/todos'.format(idEmp) 19 | nameURL = 'https://jsonplaceholder.typicode.com/users/{}'.format(idEmp) 20 | 21 | employee = sessionReq.get(idURL) 22 | employeeName = sessionReq.get(nameURL) 23 | 24 | json_req = employee.json() 25 | usr = employeeName.json()['username'] 26 | 27 | totalTasks = [] 28 | updateUser = {} 29 | 30 | for all_Emp in json_req: 31 | totalTasks.append( 32 | { 33 | "task": all_Emp.get('title'), 34 | "completed": all_Emp.get('completed'), 35 | "username": usr, 36 | }) 37 | updateUser[idEmp] = totalTasks 38 | 39 | file_Json = idEmp + ".json" 40 | with open(file_Json, 'w') as f: 41 | json.dump(updateUser, f) 42 | -------------------------------------------------------------------------------- /0x15-api/2.csv: -------------------------------------------------------------------------------- 1 | "2","Antonette","False","suscipit repellat esse quibusdam voluptatem incidunt" 2 | "2","Antonette","True","distinctio vitae autem nihil ut molestias quo" 3 | "2","Antonette","False","et itaque necessitatibus maxime molestiae qui quas velit" 4 | "2","Antonette","False","adipisci non ad dicta qui amet quaerat doloribus ea" 5 | "2","Antonette","True","voluptas quo tenetur perspiciatis explicabo natus" 6 | "2","Antonette","True","aliquam aut quasi" 7 | "2","Antonette","True","veritatis pariatur delectus" 8 | "2","Antonette","False","nesciunt totam sit blanditiis sit" 9 | "2","Antonette","False","laborum aut in quam" 10 | "2","Antonette","True","nemo perspiciatis repellat ut dolor libero commodi blanditiis omnis" 11 | "2","Antonette","False","repudiandae totam in est sint facere fuga" 12 | "2","Antonette","False","earum doloribus ea doloremque quis" 13 | "2","Antonette","False","sint sit aut vero" 14 | "2","Antonette","False","porro aut necessitatibus eaque distinctio" 15 | "2","Antonette","True","repellendus veritatis molestias dicta incidunt" 16 | "2","Antonette","True","excepturi deleniti adipisci voluptatem et neque optio illum ad" 17 | "2","Antonette","False","sunt cum tempora" 18 | "2","Antonette","False","totam quia non" 19 | "2","Antonette","False","doloremque quibusdam asperiores libero corrupti illum qui omnis" 20 | "2","Antonette","True","totam atque quo nesciunt" 21 | -------------------------------------------------------------------------------- /0x15-api/2.json: -------------------------------------------------------------------------------- 1 | {"2": [{"task": "suscipit repellat esse quibusdam voluptatem incidunt", "completed": false, "username": "Antonette"}, {"task": "distinctio vitae autem nihil ut molestias quo", "completed": true, "username": "Antonette"}, {"task": "et itaque necessitatibus maxime molestiae qui quas velit", "completed": false, "username": "Antonette"}, {"task": "adipisci non ad dicta qui amet quaerat doloribus ea", "completed": false, "username": "Antonette"}, {"task": "voluptas quo tenetur perspiciatis explicabo natus", "completed": true, "username": "Antonette"}, {"task": "aliquam aut quasi", "completed": true, "username": "Antonette"}, {"task": "veritatis pariatur delectus", "completed": true, "username": "Antonette"}, {"task": "nesciunt totam sit blanditiis sit", "completed": false, "username": "Antonette"}, {"task": "laborum aut in quam", "completed": false, "username": "Antonette"}, {"task": "nemo perspiciatis repellat ut dolor libero commodi blanditiis omnis", "completed": true, "username": "Antonette"}, {"task": "repudiandae totam in est sint facere fuga", "completed": false, "username": "Antonette"}, {"task": "earum doloribus ea doloremque quis", "completed": false, "username": "Antonette"}, {"task": "sint sit aut vero", "completed": false, "username": "Antonette"}, {"task": "porro aut necessitatibus eaque distinctio", "completed": false, "username": "Antonette"}, {"task": "repellendus veritatis molestias dicta incidunt", "completed": true, "username": "Antonette"}, {"task": "excepturi deleniti adipisci voluptatem et neque optio illum ad", "completed": true, "username": "Antonette"}, {"task": "sunt cum tempora", "completed": false, "username": "Antonette"}, {"task": "totam quia non", "completed": false, "username": "Antonette"}, {"task": "doloremque quibusdam asperiores libero corrupti illum qui omnis", "completed": false, "username": "Antonette"}, {"task": "totam atque quo nesciunt", "completed": true, "username": "Antonette"}]} -------------------------------------------------------------------------------- /0x15-api/3-dictionary_of_list_of_dictionaries.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Script that, using this REST API, for a given employee ID, returns 4 | information about his/her TODO list progress 5 | and export data in the JSON format. 6 | """ 7 | 8 | import json 9 | import requests 10 | from sys import argv 11 | 12 | 13 | if __name__ == "__main__": 14 | 15 | import json 16 | import requests 17 | import sys 18 | 19 | users = requests.get("https://jsonplaceholder.typicode.com/users") 20 | users = users.json() 21 | todos = requests.get('https://jsonplaceholder.typicode.com/todos') 22 | todos = todos.json() 23 | todoAll = {} 24 | 25 | for user in users: 26 | taskList = [] 27 | for task in todos: 28 | if task.get('userId') == user.get('id'): 29 | taskDict = {"username": user.get('username'), 30 | "task": task.get('title'), 31 | "completed": task.get('completed')} 32 | taskList.append(taskDict) 33 | todoAll[user.get('id')] = taskList 34 | 35 | with open('todo_all_employees.json', mode='w') as f: 36 | json.dump(todoAll, f) 37 | -------------------------------------------------------------------------------- /0x15-api/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x16-api_advanced/0-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import sys 3 | 4 | 5 | if __name__ == '__main__': 6 | number_of_subscribers = __import__('0-subs').number_of_subscribers 7 | if len(sys.argv) < 2: 8 | print("Please pass an argument for the subreddit to search.") 9 | else: 10 | print("{:d}".format(number_of_subscribers(sys.argv[1]))) 11 | -------------------------------------------------------------------------------- /0x16-api_advanced/0-subs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ How many subs? """ 3 | import requests 4 | from requests import get 5 | from sys import argv 6 | 7 | 8 | def number_of_subscribers(subreddit): 9 | # Replace these values with your Reddit application details 10 | client_id = 'E9UcaSW-udVFniBFD8Cf6w' 11 | client_secret = 'tiSdtSn31T0MlzpPz3ZGyme7VhAuSg' 12 | head = {'User-Agent': 'victor'} 13 | # Reddit API endpoint for subreddit information 14 | url = 'https://oauth.reddit.com/r/{}/about.json'.format(subreddit) 15 | 16 | # Set up the headers with authentication 17 | auth = requests.auth.HTTPBasicAuth(client_id, client_secret) 18 | header = head 19 | 20 | # Make a GET request to the API 21 | response = requests.get(url, headers=header, auth=auth, 22 | allow_redirects=False) 23 | 24 | # Check if the request was successful (status code 200) and not redirected 25 | if response.status_code == 200 and not response.is_redirect: 26 | # Parse the JSON response and extract the number of subscribers 27 | data = response.json() 28 | subscribers_count = data['data']['subscribers'] 29 | return subscribers_count 30 | else: 31 | # Return 0 for invalid subreddit or other errors 32 | return 0 33 | -------------------------------------------------------------------------------- /0x16-api_advanced/1-top_ten.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | prints the titles of the first 10 hot posts listed for a given subreddit 5 | """ 6 | 7 | from requests import get 8 | 9 | 10 | def top_ten(subreddit): 11 | """ 12 | function that queries the Reddit API and prints the titles of the first 13 | 10 hot posts listed for a given subreddit 14 | """ 15 | 16 | if subreddit is None or not isinstance(subreddit, str): 17 | print("None") 18 | 19 | user_agent = {'User-agent': 'bhalut'} 20 | params = {'limit': 10} 21 | url = 'https://www.reddit.com/r/{}/hot/.json'.format(subreddit) 22 | 23 | response = get(url, headers=user_agent, params=params) 24 | results = response.json() 25 | 26 | try: 27 | my_data = results.get('data').get('children') 28 | 29 | for i in my_data: 30 | print(i.get('data').get('title')) 31 | 32 | except Exception: 33 | print("None") 34 | -------------------------------------------------------------------------------- /0x16-api_advanced/100-count.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ raddit api""" 3 | 4 | import json 5 | import requests 6 | 7 | 8 | def count_words(subreddit, word_list, after="", count=[]): 9 | """count all words""" 10 | 11 | if after == "": 12 | count = [0] * len(word_list) 13 | 14 | url = "https://www.reddit.com/r/{}/hot.json".format(subreddit) 15 | request = requests.get(url, 16 | params={'after': after}, 17 | allow_redirects=False, 18 | headers={'user-agent': 'bhalut'}) 19 | 20 | if request.status_code == 200: 21 | data = request.json() 22 | 23 | for topic in (data['data']['children']): 24 | for word in topic['data']['title'].split(): 25 | for i in range(len(word_list)): 26 | if word_list[i].lower() == word.lower(): 27 | count[i] += 1 28 | 29 | after = data['data']['after'] 30 | if after is None: 31 | save = [] 32 | for i in range(len(word_list)): 33 | for j in range(i + 1, len(word_list)): 34 | if word_list[i].lower() == word_list[j].lower(): 35 | save.append(j) 36 | count[i] += count[j] 37 | 38 | for i in range(len(word_list)): 39 | for j in range(i, len(word_list)): 40 | if (count[j] > count[i] or 41 | (word_list[i] > word_list[j] and 42 | count[j] == count[i])): 43 | aux = count[i] 44 | count[i] = count[j] 45 | count[j] = aux 46 | aux = word_list[i] 47 | word_list[i] = word_list[j] 48 | word_list[j] = aux 49 | 50 | for i in range(len(word_list)): 51 | if (count[i] > 0) and i not in save: 52 | print("{}: {}".format(word_list[i].lower(), count[i])) 53 | else: 54 | count_words(subreddit, word_list, after, count) 55 | -------------------------------------------------------------------------------- /0x16-api_advanced/2-recurse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Using reddit's API 4 | """ 5 | import requests 6 | after = None 7 | 8 | 9 | def recurse(subreddit, hot_list=[]): 10 | """returning top ten post titles recursively""" 11 | global after 12 | user_agent = {'User-Agent': 'api_advanced-project'} 13 | url = "https://www.reddit.com/r/{}/hot.json".format(subreddit) 14 | parameters = {'after': after} 15 | results = requests.get(url, params=parameters, headers=user_agent, 16 | allow_redirects=False) 17 | 18 | if results.status_code == 200: 19 | after_data = results.json().get("data").get("after") 20 | if after_data is not None: 21 | after = after_data 22 | recurse(subreddit, hot_list) 23 | all_titles = results.json().get("data").get("children") 24 | for title_ in all_titles: 25 | hot_list.append(title_.get("data").get("title")) 26 | return hot_list 27 | else: 28 | return (None) 29 | -------------------------------------------------------------------------------- /0x16-api_advanced/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x16-api_advanced/__pycache__/0-subs.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/0x16-api_advanced/__pycache__/0-subs.cpython-35.pyc -------------------------------------------------------------------------------- /0x16-api_advanced/tests/0-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import sys 3 | 4 | 5 | if __name__ == '__main__': 6 | number_of_subscribers = __import__('0-subs').number_of_subscribers 7 | if len(sys.argv) < 2: 8 | print("Please pass an argument for the subreddit to search.") 9 | else: 10 | print("{:d}".format(number_of_subscribers(sys.argv[1]))) 11 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/1-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import sys 3 | 4 | if __name__ == '__main__': 5 | top_ten = __import__('1-top_ten').top_ten 6 | if len(sys.argv) < 2: 7 | print("Please pass an argument for the subreddit to search.") 8 | else: 9 | top_ten(sys.argv[1]) 10 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/100-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Contains the count_words function""" 3 | import requests 4 | 5 | 6 | def count_words(subreddit, word_list, found_list=[], after=None): 7 | '''Prints counts of given words found in hot posts of a given subreddit. 8 | 9 | Args: 10 | subreddit (str): The subreddit to search. 11 | word_list (list): The list of words to search for in post titles. 12 | found_list (obj): Key/value pairs of words/counts. 13 | after (str): The parameter for the next page of the API results. 14 | ''' 15 | user_agent = {'User-agent': 'test45'} 16 | posts = requests.get('http://www.reddit.com/r/{}/hot.json?after={}' 17 | .format(subreddit, after), headers=user_agent) 18 | if after is None: 19 | word_list = [word.lower() for word in word_list] 20 | 21 | if posts.status_code == 200: 22 | posts = posts.json()['data'] 23 | aft = posts['after'] 24 | posts = posts['children'] 25 | for post in posts: 26 | title = post['data']['title'].lower() 27 | for word in title.split(' '): 28 | if word in word_list: 29 | found_list.append(word) 30 | if aft is not None: 31 | count_words(subreddit, word_list, found_list, aft) 32 | else: 33 | result = {} 34 | for word in found_list: 35 | if word.lower() in result.keys(): 36 | result[word.lower()] += 1 37 | else: 38 | result[word.lower()] = 1 39 | for key, value in sorted(result.items(), key=lambda item: item[1], 40 | reverse=True): 41 | print('{}: {}'.format(key, value)) 42 | else: 43 | return 44 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/2-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import sys 3 | 4 | if __name__ == '__main__': 5 | recurse = __import__('2-recurse').recurse 6 | if len(sys.argv) < 2: 7 | print("Please pass an argument for the subreddit to search.") 8 | else: 9 | result = recurse(sys.argv[1]) 10 | if result is not None: 11 | print(len(result)) 12 | else: 13 | print("None") 14 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/0-strace_is_your_friend.pp: -------------------------------------------------------------------------------- 1 | # automated puppet fix (to find out why Apache is returning a 500 error) 2 | 3 | exec { 'Fix wordpress site': 4 | command => 'sudo sed -i "s/.phpp/.php/" /var/www/html/wp-settings.php', 5 | provider => shell, 6 | } 7 | -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/0-setup_datadog: -------------------------------------------------------------------------------- 1 | c20fac122fe946819a6d990d1a833b2c 2 | dec0ca55-cb0a-4bdf-97cf-86b7fb7d47e7 3 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/2-setup_datadog: -------------------------------------------------------------------------------- 1 | 1705514868281 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /0x19-postmortem/My_first_postmortem: -------------------------------------------------------------------------------- 1 | https://medium.com/@besthor/my-first-postmortem-68aeab85f0ef 2 | -------------------------------------------------------------------------------- /0x19-postmortem/README.md: -------------------------------------------------------------------------------- 1 | # `Postmortem` 2 | 3 | # 4 | ![](https://i.imgflip.com/7f2140.jpg) 5 | -------------------------------------------------------------------------------- /0x1A-application_server/2-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/victor0089 permanent; 15 | 16 | error_page 404 /404.html; 17 | 18 | location = /404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location / { 29 | try_files $uri $uri/ =404; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /0x1A-application_server/3-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/besthor permanent; 15 | 16 | error_page 404 /404.html; 17 | 18 | location = /404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location / { 34 | try_files $uri $uri/ =404; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /0x1A-application_server/4-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/victor0089 permanent; 15 | 16 | error_page 404 /404.html; 17 | 18 | location = /404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location /api/ { 34 | include proxy_params; 35 | proxy_pass http://0.0.0.0:5002/api/; 36 | } 37 | 38 | location / { 39 | try_files $uri $uri/ =404; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /0x1A-application_server/5-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost 35.231.33.237; 5 | 6 | root /home/ubuntu/AirBnB_clone_v4/web_dynamic; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/besthor permanent; 15 | 16 | error_page 404 /404.html; 17 | 18 | location = /404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location /static { 34 | } 35 | 36 | location /api/ { 37 | include proxy_params; 38 | proxy_pass http://0.0.0.0:5002/api/; 39 | } 40 | 41 | location / { 42 | include proxy_params; 43 | proxy_pass http://0.0.0.0:5003/2-hbnb/; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /0x1A-application_server/README.md: -------------------------------------------------------------------------------- 1 | 2 | tmux new-session -d 'gunicorn --bind 0.0.0.0:5003 web_dynamic.2-hbnb:app' 3 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/0-the_sky_is_the_limit_not.pp: -------------------------------------------------------------------------------- 1 | # This manuscriptincreases the amount oftraffic an Nginx servercan handle 2 | 3 | # Increase the ULIMIT of the default file 4 | file { 'fix-for-nginx': 5 | ensure => 'file', 6 | path => '/etc/default/nginx', 7 | content => inline_template('<%= File.read("/etc/default/nginx").gsub(/15/, "4096") %>'), 8 | } 9 | 10 | # Restart Nginx 11 | -> exec { 'nginx-restart': 12 | command => 'nginx restart', 13 | path => '/etc/init.d/', 14 | } 15 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/1-user_limit.pp: -------------------------------------------------------------------------------- 1 | # This manuscript enablesthe user holbertonto login and open files withouterror 2 | 3 | # Increase hard file limit for user holberton 4 | exec { 'increase-hard-file-limit-for-holberton-user': 5 | command => 'sed -i "/holberton hard/s/5/50000/" /etc/security/limits.conf', 6 | path => '/usr/local/bin/:/bin/' 7 | } 8 | 9 | # Increase soft file limit for user holberton 10 | exec { 'increase-soft-file-limit-for-holberton-user': 11 | command => 'sed -i "/holberton soft/s/4/50000/" /etc/security/limits.conf', 12 | path => '/usr/local/bin/:/bin/' 13 | } 14 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DevOps Engineer 2 | # ALX SYSTEM ENGINEERING - DEVOPS 3 | 4 | ![image](https://github.com/victor0089/alx-system_engineering-devops/blob/dev-ops.png) 5 | 6 | This repository contains programs created for the _**ALX Software Engineering** Programs._ Your girl here is ready for collaborations, Currently sharpening my knowledge and skills of C and shell scripting. Hey you! Come let's do hard things. The following is a specific list of projects : 7 | 8 | | PR.NO | PROJECT | DESCRIPTION | 9 | | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | 10 | | 0x00 | [Shell, basics](./0x00-shell_basics/) | | 11 | | 0x01 | [Shell, Permissions](./0x01-shell_permissions/) | | 12 | | 0x02 | [Shell, Redirections](./0x02-shell_redirections/) | | 13 | | 0x03 | [Shell, Variable Expansions](./0x03-shell_variables_expansions/) | | 14 | | 0x04 | [Loops, conditions and parsing](./0x04-loops_conditions_and_parsing/) | | 15 | | 0x05 | [Proccesses and signals](./0x05-processes_and_signals/) | | 16 | | 0x06 | [Regular expressions](./0x06-regular_expressions/) | | 17 | | 0x07 | [Networking basics #0](./0x07-networking_basics/) | | 18 | | 0x08 | [Networking basics #1](./0x08-networking_basics_2/) | | 19 | | 0x09 | [Web infrastructure design](./0x09-web_infrastructure_design/) | | 20 | | 0x0A | [Configuration management](./0x0A-configuration_management/) | | 21 | | 0x0B | [Shell, SSH](./0x0B-ssh/) | | 22 | | 0x0C | [Web server](./0x0C-web_server/) | | 23 | | 0x0D | [Web stack debugging #0](./0x0D-web_stack_debugging_0/) | | 24 | | 0x0E | [Web stack debugging #1](./0x0E-web_stack_debugging_1/) | | 25 | | 0x0F | [Load balancer](./0x0F-load_balancer/) | | 26 | | 0x10 | [HTTPS SSL](./0x10-https_ssl/) | | 27 | | 0x11 | [What happens when you type google.com in your browser and press Enter](./0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/)| | 28 | | 0x12 | [web_stack_debugging_#2](./0x12-web_stack_debugging_2/) | 29 | | 0x13 | [firewall](./0x13-firewall/) | | 30 | | 0x14 | [mysql](./0x14-mysql/) | | 31 | | 0x15 | [api](./0x15-api/) | | 32 | | 0x16 | [api_advanced](./0x16-api_advanced/) | | | 33 | | 0x17 | [web_stack_debugging_#3](./0x17-web_stack_debugging_3/) | | 34 | | 0x18 | [webstack_monitoring](./0x18-webstack_monitoring/) | | 35 | | 0x19 | [postmortem](./0x19-postmortem/) | | 36 | | 0x1A | [application_server](./0x1A-application_server/) | | 37 | | 0x1B | [web_stack_debugging_#4](./0x1B-web_stack_debugging_4/) | | 38 | | N/A | [0-iam_betty](./0-iam_betty/) | | 39 | | N/A | [Command line for the win](./command_line_for_the_win) | 40 | | N/A | [Attack is the best defense](./attack_is_the_best_defense/)| | | 41 | 42 | 43 | ### AUTHOR: 44 |
45 | Victor 46 | 57 |
58 | 59 | --- 60 | 61 | ### Acknowledgements :pray: 62 | ___ 63 | All of the work in this project was conducted as part of the ALX-SE program's curriculum. ALX Africa is an online full-stack software engineering school that uses project-based peer learning to educate students for careers in the IT industry. Visit this website for further information. 64 | 65 | -------------------------------------------------------------------------------- /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 | # Attack is the best defense 2 | 3 | ## Description 4 | What you should learn from this project: 5 | - Network basics 6 | - Docker 7 | 8 | --- 9 | 10 | ### [0. ARP spoofing and sniffing unencrypted traffic](./0-sniffing) 11 | * 12 | 13 | 14 | ### [1. Dictionary attack](./1-dictionary_attack) 15 | * Password-based authentication systems can be easily broken by using a dictionary attack (you’ll have to find your own password dictionary). Let’s try it on an SSH account. 16 | 17 | --- 18 | 19 | ## Author 20 | * **Geoffrey Zoref** - [Gzoref](https://github.com/Gzoref) 21 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/user_authenticating_into_server: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /command_line_for_the_win/0-first_9_tasks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/0-first_9_tasks.jpg -------------------------------------------------------------------------------- /command_line_for_the_win/0-first_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/0-first_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/1-next_9_tasks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/1-next_9_tasks.jpg -------------------------------------------------------------------------------- /command_line_for_the_win/1-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/1-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/2-next_9_tasks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/2-next_9_tasks.jpg -------------------------------------------------------------------------------- /command_line_for_the_win/2-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/command_line_for_the_win/2-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/README.md: -------------------------------------------------------------------------------- 1 | adding 2 | -------------------------------------------------------------------------------- /dev-ops.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victor0089/alx-system_engineering-devops/2397ed7032fce73e2a14e77c3930cf9d2663cbed/dev-ops.png --------------------------------------------------------------------------------