├── 0-simple_web_stack.png ├── 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 ├── .2-groups.swp ├── .3-new_owner.swp ├── 0-iam_betty ├── 1-who_am_i ├── 10-mirror_permissions ├── 100-change_owner_and_group ├── 101-symbolic_link_permissions ├── 102-if_only ├── 11-directories_permissions ├── 12-directory_permissions ├── 13-change_group ├── 2-groups ├── 3-new_owner ├── 4-empty ├── 5-execute ├── 6-multiple_permissions ├── 7-everybody ├── 8-James_Bond ├── 9-John_Doe └── README.md ├── 0x02-shell_redirections ├── 0-hello_world ├── 1-confused_smiley ├── 10-no_more_js ├── 100-empty_casks ├── 101-gifs ├── 102-acrostic ├── 103-the_biggest_fan ├── 11-directories ├── 12-newest_files ├── 13-unique ├── 14-findthatword ├── 15-countthatword ├── 16-whatsnext ├── 17-hidethisword ├── 18-letteronly ├── 19-AZ ├── 2-hellofile ├── 20-hiago ├── 21-reverse ├── 22-users_and_homes ├── 3-twofiles ├── 4-lastlines ├── 5-firstlines ├── 6-third_line ├── 7-file ├── 8-cwd_state ├── 9-duplicate_last_line └── README.md ├── 0x03-shell_variables_expansions ├── 0-alias ├── 1-hello_you ├── 10-love_exponent_breath ├── 100-decimal_to_hexadecimal ├── 101-rot13 ├── 102-odd ├── 103-water_and_stir ├── 11-binary_to_decimal ├── 12-combinations ├── 13-print_float ├── 2-path ├── 3-paths ├── 4-global_variables ├── 5-local_variables ├── 6-create_local_variable ├── 7-create_global_variable ├── 8-true_knowledge ├── 9-divide_and_rule └── README.md ├── 0x04-loops_conditions_and_parsing ├── 0-RSA_public_key.pub ├── 1-for_best_school ├── 10-fizzbuzz ├── 2-while_best_school ├── 3-until_best_school ├── 4-if_9_say_hi ├── 5-4_bad_luck_8_is_your_chance ├── 6-superstitious_numbers ├── 7-clock ├── 8-for_ls ├── 9-to_file_or_not_to_file └── README.md ├── 0x05-processes_and_signals ├── 0-what-is-my-pid ├── 1-list_your_processes ├── 2-show_your_bash_pid ├── 3-show_your_bash_pid_made_easy ├── 4-to_infinity_and_beyond ├── 5-dont_stop_me_now ├── 6-stop_me_if_you_can ├── 7-highlander └── 8-beheaded_process ├── 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 ├── 0x09-web_infrastructure_design ├── 0-simple_web_stack.pdf ├── 0-simple_web_stack.png ├── 1-distributed_web_infrastructure ├── 1-distributed_web_infrastructure.pdf ├── 1-distributed_web_infrastructure.png └── README.md ├── 0x0A-configuration_management ├── 0-create_a_file.pp ├── 1-install_a_package.pp ├── 2-execute_a_command.pp └── README.md ├── 0x0B-ssh ├── 0-use_a_private_key ├── 1-create_ssh_key_pair ├── 100-puppet_ssh_config.pp ├── 2-ssh_config ├── PasswordAuthentication no, ├── README.md ├── school └── school.pub ├── 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 └── some_page.html ├── 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 ├── 0-tranfer_file ├── 1-install_load_balancer ├── 2-puppet_custom_http_response_header.pp ├── README.md └── index.html ├── 0x10-https_ssl ├── 0-world_wide_web ├── 1-haproxy_ssl_termination ├── 100-redirect_http_to_https └── README.md ├── 0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter ├── 0-blog_post ├── 1-what_happen_when_diagram ├── 2-contribution-to_what-happens-when_github_answer └── README.md ├── 0x12-web_stack_debugging_2 ├── 0-iamsomeoneelse ├── 1-run_nginx_as_nginx └── README.md ├── 0x13-firewall ├── 0-block_all_incoming_traffic_but └── README.md ├── 0x14-mysql ├── 4-mysql_configuration_primary ├── 4-mysql_configuration_replica ├── 5-mysql_backup └── README.md ├── 0x15-api ├── 0-gather_data_from_an_API.py ├── 1-export_to_CSV.py ├── 2-export_to_JSON.py ├── 3-dictionary_of_list_of_dictionaries.py └── README.md ├── 0x16-api_advanced ├── 0-main.py ├── 0-subs.py ├── 1-main.py ├── 1-top_ten.py ├── 100-count.py ├── 2-main.py ├── 2-recurse.py └── README.md ├── 0x17-web_stack_debugging_3 ├── 0-strace_is_your_friend.pp └── README.md ├── 0x18-webstack_monitoring ├── README.md └── ddagent-install.log ├── 0x1A-application_server ├── 2-app_server-nginx_config ├── 3-app_server-nginx_config ├── 4-app_server-nginx_config ├── 4-reload_gunicorn_no_downtime ├── 5-app_server-nginx_config ├── README.md └── gunicorn.service ├── 0x1B-web_stack_debugging_4 ├── 0-the_sky_is_the_limit_not.pp ├── 1-user_limit.pp └── README.md └── command_line_for_the_win ├── 0-first_9_tasks.png ├── 1-next_9_tasks.png ├── 2-next_9_tasks.png └── README.md /0-simple_web_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0-simple_web_stack.png -------------------------------------------------------------------------------- /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 2>dev/null 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/101-clean_emacs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -f *~ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/102-tree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x00-shell_basics/102-tree -------------------------------------------------------------------------------- /0x00-shell_basics/103-commas: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p welcome/to/school 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/11-lists: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la /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 | rsync -auv --exclude='*/' --include='*.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 | shell basics for beginners 2 | -------------------------------------------------------------------------------- /0x00-shell_basics/school.mgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x00-shell_basics/school.mgc -------------------------------------------------------------------------------- /0x01-shell_permissions/.2-groups.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x01-shell_permissions/.2-groups.swp -------------------------------------------------------------------------------- /0x01-shell_permissions/.3-new_owner.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x01-shell_permissions/.3-new_owner.swp -------------------------------------------------------------------------------- /0x01-shell_permissions/0-iam_betty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | su betty 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/1-who_am_i: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | whoami 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 -R vincent:staff ./* 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/101-symbolic_link_permissions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x01-shell_permissions/101-symbolic_link_permissions -------------------------------------------------------------------------------- /0x01-shell_permissions/102-if_only: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x01-shell_permissions/102-if_only -------------------------------------------------------------------------------- /0x01-shell_permissions/11-directories_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod -R a+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 | id -nG $USER 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 ug+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 second project 2 | -------------------------------------------------------------------------------- /0x02-shell_redirections/0-hello_world: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Hello, World" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/1-confused_smiley: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "\"(Ôo)'" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/10-no_more_js: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.js" -delete 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/100-empty_casks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type d -empty -printf "%f\n" && find . -type f -empty -printf "%f\n" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/101-gifs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x02-shell_redirections/101-gifs -------------------------------------------------------------------------------- /0x02-shell_redirections/102-acrostic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x02-shell_redirections/102-acrostic -------------------------------------------------------------------------------- /0x02-shell_redirections/103-the_biggest_fan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x02-shell_redirections/103-the_biggest_fan -------------------------------------------------------------------------------- /0x02-shell_redirections/11-directories: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -mindepth 1 -type d | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/12-newest_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f | ls -tp | head -10 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/13-unique: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort | uniq -u 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/14-findthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd | grep 'root' 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/15-countthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd | grep 'bin' | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/16-whatsnext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -A 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 "^[[:alpha:]]" /etc/ssh/sshd_config 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/19-AZ: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr 'Ac' 'Ze' 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 | cat /etc/passwd | cut -d: -f1,6 | 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 -n 3 "iacta" | tail -n 1 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/7-file: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Best School" >'\\*\\'"Best School"\\'\\\\*$\\?\\*\\*\\*\\*\\*\:\)\' 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/8-cwd_state: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la > ls_cwd_content 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/9-duplicate_last_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 1 iacta >> iacta 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/README.md: -------------------------------------------------------------------------------- 1 | shell i/o redirection 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-Za-z' 'N-ZA-Mn-za-m' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/102-odd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | awk 'NR % 2 == 1' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/103-water_and_stir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x03-shell_variables_expansions/103-water_and_stir -------------------------------------------------------------------------------- /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 ':' '\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 | 2 | Home | Previous | Contents | Next 3 | Expansion 4 | Each time we type a command line and press the enter key, bash performs several processes upon the text before it carries out our command. We have seen a couple of cases of how a simple character sequence, for example “*”, can have a lot of meaning to the shell. The process that makes this happen is called expansion. With expansion, we type something and it is expanded into something else before the shell acts upon it. To demonstrate what we mean by this, let's take a look at the echo command. echo is a shell builtin that performs a very simple task. It prints out its text arguments on standard output: 5 | 6 | [me@linuxbox me]$ echo this is a test 7 | this is a test 8 | That's pretty straightforward. Any argument passed to echo gets displayed. Let's try another example: 9 | 10 | [me@linuxbox me]$ echo * 11 | Desktop Documents ls-output.txt Music Pictures Public Templates Videos 12 | So what just happened? Why didn't echo print “*”? As we recall from our work with wildcards, the “*” character means match any characters in a filename, but what we didn't see in our original discussion was how the shell does that. The simple answer is that the shell expands the “*” into something else (in this instance, the names of the files in the current working directory) before the echo command is executed. When the enter key is pressed, the shell automatically expands any qualifying characters on the command line before the command is carried out, so the echo command never saw the “*”, only its expanded result. Knowing this, we can see that echo behaved as expected. 13 | 14 | Pathname Expansion 15 | The mechanism by which wildcards work is called pathname expansion. If we try some of the techniques that we employed in our earlier lessons, we will see that they are really expansions. Given a home directory that looks like this: 16 | 17 | [me@linuxbox me]$ ls 18 | Desktop 19 | ls-output.txt 20 | Documents Music 21 | Pictures 22 | Public 23 | Templates 24 | Videos 25 | we could carry out the following expansions: 26 | 27 | [me@linuxbox me]$ echo D* 28 | Desktop Documents 29 | and: 30 | 31 | [me@linuxbox me]$ echo *s 32 | Documents Pictures Templates Videos 33 | or even: 34 | 35 | [me@linuxbox me]$ echo [[:upper:]]* 36 | Desktop Documents Music Pictures Public Templates Videos 37 | and looking beyond our home directory: 38 | 39 | [me@linuxbox me]$ echo /usr/*/share 40 | /usr/kerberos/share /usr/local/share 41 | Tilde Expansion 42 | As we recall from our introduction to the cd command, the tilde character (“~”) has a special meaning. When used at the beginning of a word, it expands into the name of the home directory of the named user, or if no user is named, the home directory of the current user: 43 | 44 | [me@linuxbox me]$ echo ~ 45 | /home/me 46 | If user “foo” has an account, then: 47 | 48 | [me@linuxbox me]$ echo ~foo 49 | /home/foo 50 | Arithmetic Expansion 51 | The shell allows arithmetic to be performed by expansion. This allow us to use the shell prompt as a calculator: 52 | 53 | [me@linuxbox me]$ echo $((2 + 2)) 54 | 4 55 | Arithmetic expansion uses the form: 56 | 57 | $((expression)) 58 | where expression is an arithmetic expression consisting of values and arithmetic operators. 59 | 60 | Arithmetic expansion only supports integers (whole numbers, no decimals), but can perform quite a number of different operations. 61 | 62 | Spaces are not significant in arithmetic expressions and expressions may be nested. For example, to multiply five squared by three: 63 | 64 | [me@linuxbox me]$ echo $(($((5**2)) * 3)) 65 | 75 66 | Single parentheses may be used to group multiple subexpressions. With this technique, we can rewrite the example above and get the same result using a single expansion instead of two: 67 | 68 | [me@linuxbox me]$ echo $(((5**2) * 3)) 69 | 75 70 | Here is an example using the division and remainder operators. Notice the effect of integer division: 71 | 72 | [me@linuxbox me]$ echo Five divided by two equals $((5/2)) 73 | Five divided by two equals 2 74 | [me@linuxbox me]$ echo with $((5%2)) left over. 75 | with 1 left over. 76 | Brace Expansion 77 | Perhaps the strangest expansion is called brace expansion. With it, we can create multiple text strings from a pattern containing braces. Here's an example: 78 | 79 | [me@linuxbox me]$ echo Front-{A,B,C}-Back 80 | Front-A-Back Front-B-Back Front-C-Back 81 | Patterns to be brace expanded may contain a leading portion called a preamble and a trailing portion called a postscript. The brace expression itself may contain either a comma-separated list of strings, or a range of integers or single characters. The pattern may not contain embedded whitespace. Here is an example using a range of integers: 82 | 83 | [me@linuxbox me]$ echo Number_{1..5} 84 | Number_1 Number_2 Number_3 Number_4 Number_5 85 | A range of letters in reverse order: 86 | 87 | [me@linuxbox me]$ echo {Z..A} 88 | Z Y X W V U T S R Q P O N M L K J I H G F E D C B A 89 | Brace expansions may be nested: 90 | 91 | [me@linuxbox me]$ echo a{A{1,2},B{3,4}}b 92 | aA1b aA2b aB3b aB4b 93 | So what is this good for? The most common application is to make lists of files or directories to be created. For example, if we were a photographer and had a large collection of images we wanted to organize into years and months, the first thing we might do is create a series of directories named in numeric “Year-Month” format. This way, the directory names will sort in chronological order. we could type out a complete list of directories, but that's a lot of work and it's error-prone too. Instead, we could do this: 94 | 95 | [me@linuxbox me]$ mkdir Photos 96 | [me@linuxbox me]$ cd Photos 97 | [me@linuxbox Photos]$ mkdir {2017..2019}-{01..12} 98 | [me@linuxbox Photos]$ ls 99 | 2017-01 2017-07 2018-01 2018-07 2019-01 2019-07 100 | 2017-02 2017-08 2018-02 2018-08 2019-02 2019-08 101 | 2017-03 2017-09 2018-03 2018-09 2019-03 2019-09 102 | 2017-04 2017-10 2018-04 2018-10 2019-04 2019-10 103 | 2017-05 2017-11 2018-05 2018-11 2019-05 2019-11 104 | 2017-06 2017-12 2018-06 2018-12 2019-06 2019-12 105 | Pretty slick! 106 | 107 | Parameter Expansion 108 | We're only going to touch briefly on parameter expansion in this lesson, but we'll be covering it more later. It's a feature that is more useful in shell scripts than directly on the command line. Many of its capabilities have to do with the system's ability to store small chunks of data and to give each chunk a name. Many such chunks, more properly called variables, are available for our examination. For example, the variable named “USER” contains our user name. To invoke parameter expansion and reveal the contents of USER we would do this: 109 | 110 | [me@linuxbox me]$ echo $USER 111 | me 112 | To see a list of available variables, try this: 113 | 114 | [me@linuxbox me]$ printenv | less 115 | With other types of expansion, if we mistype a pattern, the expansion will not take place and the echo command will simply display the mistyped pattern. With parameter expansion, if we misspell the name of a variable, the expansion will still take place, but will result in an empty string: 116 | 117 | [me@linuxbox me]$ echo $SUER 118 | [me@linuxbox ~]$ 119 | Command Substitution 120 | Command substitution allows us to use the output of a command as an expansion: 121 | 122 | [me@linuxbox me]$ echo $(ls) 123 | Desktop Documents ls-output.txt Music Pictures Public Templates Videos 124 | A clever one goes something like this: 125 | 126 | [me@linuxbox me]$ ls -l $(which cp) 127 | -rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp 128 | Here we passed the results of which cp as an argument to the ls command, thereby getting the listing of of the cp program without having to know its full pathname. We are not limited to just simple commands. Entire pipelines can be used (only partial output shown): 129 | 130 | [me@linuxbox me]$ file $(ls /usr/bin/* | grep bin/zip) 131 | /usr/bin/bunzip2: 132 | /usr/bin/zip: ELF 32-bit LSB executable, Intel 80386, version 1 133 | (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped 134 | /usr/bin/zipcloak: ELF 32-bit LSB executable, Intel 80386, version 1 135 | (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped 136 | /usr/bin/zipgrep: POSIX shell script text executable 137 | /usr/bin/zipinfo: ELF 32-bit LSB executable, Intel 80386, version 1 138 | (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped 139 | /usr/bin/zipnote: ELF 32-bit LSB executable, Intel 80386, version 1 140 | (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped 141 | /usr/bin/zipsplit: ELF 32-bit LSB executable, Intel 80386, version 1 142 | (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped 143 | In this example, the results of the pipeline became the argument list of the file command. There is an alternate syntax for command substitution in older shell programs which is also supported in bash. It uses back-quotes instead of the dollar sign and parentheses: 144 | 145 | [me@linuxbox me]$ ls -l `which cp` 146 | -rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp 147 | Quoting 148 | Now that we've seen how many ways the shell can perform expansions, it's time to learn how we can control it. Take for example: 149 | 150 | [me@linuxbox me]$ echo this is a test 151 | this is a test 152 | or: 153 | 154 | [me@linuxbox me]$ [me@linuxbox ~]$ echo The total is $100.00 155 | The total is 00.00 156 | In the first example, word-splitting by the shell removed extra whitespace from the echo command's list of arguments. In the second example, parameter expansion substituted an empty string for the value of “$1” because it was an undefined variable. The shell provides a mechanism called quoting to selectively suppress unwanted expansions. 157 | 158 | Double Quotes 159 | The first type of quoting we will look at is double quotes. If we place text inside double quotes, all the special characters used by the shell lose their special meaning and are treated as ordinary characters. The exceptions are “$”, “\” (backslash), and “`” (back- quote). This means that word-splitting, pathname expansion, tilde expansion, and brace expansion are suppressed, but parameter expansion, arithmetic expansion, and command substitution are still carried out. Using double quotes, we can cope with filenames containing embedded spaces. Imagine we were the unfortunate victim of a file called two words.txt. If we tried to use this on the command line, word-splitting would cause this to be treated as two separate arguments rather than the desired single argument: 160 | 161 | [me@linuxbox me]$ ls -l two words.txt 162 | ls: cannot access two: No such file or directory 163 | ls: cannot access words.txt: No such file or directory 164 | By using double quotes, we can stop the word-splitting and get the desired result; further, we can even repair the damage: 165 | 166 | [me@linuxbox me]$ ls -l "two words.txt" 167 | -rw-rw-r-- 1 me me 18 2020-02-20 13:03 two words.txt 168 | [me@linuxbox me]$ mv "two words.txt" two_words.txt 169 | There! Now we don't have to keep typing those pesky double quotes. Remember, parameter expansion, arithmetic expansion, and command substitution still take place within double quotes: 170 | 171 | [me@linuxbox me]$ echo "$USER $((2+2)) $(cal)" 172 | me 4 173 | February 2020 174 | Su Mo Tu We Th Fr Sa 175 | 1 2 176 | 3 4 5 6 7 8 9 177 | 10 11 12 13 14 15 16 178 | 17 18 19 20 21 22 23 179 | 24 25 26 27 28 29 180 | We should take a moment to look at the effect of double quotes on command substitution. First let's look a little deeper at how word splitting works. In our earlier example, we saw how word-splitting appears to remove extra spaces in our text: 181 | 182 | [me@linuxbox me]$ echo this is a test 183 | this is a test 184 | By default, word-splitting looks for the presence of spaces, tabs, and newlines (linefeed characters) and treats them as delimiters between words. This means that unquoted spaces, tabs, and newlines are not considered to be part of the text. They only serve as separators. Since they separate the words into different arguments, our example command line contains a command followed by four distinct arguments. If we add double quotes: 185 | 186 | [me@linuxbox me]$ echo "this is a test" 187 | this is a test 188 | word-splitting is suppressed and the embedded spaces are not treated as delimiters, rather they become part of the argument. Once the double quotes are added, our command line contains a command followed by a single argument. The fact that newlines are considered delimiters by the word-splitting mechanism causes an interesting, albeit subtle, effect on command substitution. Consider the following: 189 | 190 | [me@linuxbox me]$ echo $(cal) 191 | February 2020 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 192 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 193 | [me@linuxbox me]$ echo "$(cal)" 194 | February 2020 195 | Su Mo Tu We Th Fr Sa 196 | 1 2 197 | 3 4 5 6 7 8 9 198 | 10 11 12 13 14 15 16 199 | 17 18 19 20 21 22 23 200 | 24 25 26 27 28 29 201 | In the first instance, the unquoted command substitution resulted in a command line containing thirty-eight arguments. In the second, a command line with one argument that includes the embedded spaces and newlines. 202 | 203 | Single Quotes 204 | When we need to suppress all expansions, we use single quotes. Here is a comparison of unquoted, double quotes, and single quotes: 205 | 206 | [me@linuxbox me]$ echo text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER 207 | text /home/me/ls-output.txt a b foo 4 me 208 | [me@linuxbox me]$ echo "text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER" 209 | text ~/*.txt {a,b} foo 4 me 210 | [me@linuxbox me]$ echo 'text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER' 211 | text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER 212 | As we can see, with each succeeding level of quoting, more and more of the expansions are suppressed. 213 | 214 | Escaping Characters 215 | Sometimes we only want to quote a single character. To do this, we can precede a character with a backslash, which in this context is called the escape character. Often this is done inside double quotes to selectively prevent an expansion: 216 | 217 | [me@linuxbox me]$ echo "The balance for user $USER is: \$5.00" 218 | The balance for user me is: $5.00 219 | It is also common to use escaping to eliminate the special meaning of a character in a filename. For example, it is possible to use characters in filenames that normally have special meaning to the shell. These would include “$”, “!”, “&”, “ “, and others. To include a special character in a filename we can to this: 220 | 221 | [me@linuxbox me]$ mv bad\&filename good_filename 222 | To allow a backslash character to appear, escape it by typing “\\”. Note that within single quotes, the backslash loses its special meaning and is treated as an ordinary character. 223 | 224 | More Backslash Tricks 225 | If we look at the man pages for any program written by the GNU project, we will see that in addition to command line options consisting of a dash and a single letter, there are also long option names that begin with two dashes. For example, the following are equivalent: 226 | 227 | ls -r 228 | ls --reverse 229 | Why do they support both? The short form is for lazy typists on the command line and the long form is mostly for scripts though some options may only be available in long form. Sometimes it is better to use a long option when the option is obscure or we want to document more clearly what an option is. This is especially useful when writing scripts where maximum readability is desired, and besides, anytime we can save ourselves a trip to the man page is a good thing. 230 | 231 | As we might suspect, using the long form options can make a single command line very long. To combat this problem, we can use a backslash to get the shell to ignore a newline character like this: 232 | 233 | ls -l \ 234 | --reverse \ 235 | --human-readable \ 236 | --full-time 237 | Using the backslash in this way allows us to embed newlines in our command. Note that for this trick to work, the newline must be typed immediately after the backslash. If we put a space after the backslash, the space will be ignored, not the newline. Backslashes are also used to insert special characters into our text. These are called backslash escape characters. Here are the common ones: 238 | 239 | Escape Character Name Possible Uses 240 | \n newline Adding blank lines to text 241 | \t tab Inserting horizontal tabs to text 242 | \a alert Makes our terminal beep 243 | \\ backslash Inserts a backslash 244 | \f formfeed Sending this to our printer ejects the page 245 | The use of the backslash escape characters is very common. This idea first appeared in the C programming language. Today, the shell, C++, Perl, python, awk, tcl, and many other programming languages use this concept. Using the echo command with the -e option will allow us to demonstrate: 246 | 247 | [me@linuxbox me]$ echo -e "Inserting several blank lines\n\n\n" 248 | Inserting several blank lines 249 | 250 | [me@linuxbox me]$ echo -e "Words\tseparated\tby\thorizontal\ttabs." 251 | Words separated by horizontal tabs 252 | [me@linuxbox me]$ echo -e "\aMy computer went \"beep\"." 253 | My computer went "beep". 254 | [me@linuxbox me]$ echo -e "DEL C:\\WIN2K\\LEGACY_OS.EXE" 255 | DEL C:\WIN2K\LEGACY_OS.EXE 256 | Top | Previous | Contents | Next 257 | © 2000-2023, William E. Shotts, Jr. Verbatim copying and distribution of this entire article is permitted in any medium, provided this copyright notice is preserved. 258 | 259 | Linux® is a registered trademark of Linus Torvalds. 260 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/0-RSA_public_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDEkhZotsVuqf6fIKT1aO0g4swou+Sd2yP8/9zQdKOlb8n5nS9cTCp9/sLMPUQwiG31gbtccn3DM+i8ZeVpCZ8WgkHoNQSi4vFmDMMox1LnflSX5O2HllaPNJsIn/vBHlklgMGU17SdeVXKzjnEQCWKt6NiBmXXoIeoVzpBCsYGLVJqOoWNr7bvqwk05Y3L6XrOlzBajZ4zUaAHVL/Mli5UhqClqkqSstPspx8JSspNICRbLVUbXt3I9mv8ahfUK71uohkvfpuq6ZITXKD7DKNBBqmSXwuDwBA8l2eFIie24sS7tcproyCgPL6jCEXfaMQS8NJ82h3XR8UFFg+yAo96DQqeJ52EAaB6+o9PieiKRgmBP3gkw21UtspvsGiAvrs/5A1n7zdiDum39ss7rl0RFW/B0Yrdm56SKRdhSSOtITwf3x+OHC1kUYWq/49iGn10KEHnkwtoM7R8NPrjOILtqPjV/E0IkM+KatGyZ0RvJZOVmEuBOEi/odp3TzN7Ke0= sisay954@DESKTOP-LESCVLV 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/1-for_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Best School" 10 times 3 | 4 | for _ in {1..10}; do 5 | echo "Best School" 6 | done 7 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/10-fizzbuzz: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # a Bash script that displays numbers from 1 to 100. 3 | # Displays FizzBuzz when the number is a multiple of 3 and 5 4 | # Displays Fizz when the number is multiple of 3 5 | # Displays Buzz when the number is a multiple of 5 6 | # Otherwise, displays the number, In a list format 7 | 8 | for i in {1..100} 9 | do 10 | if ((i % 15 == 0)) 11 | then 12 | echo "FizzBuzz" 13 | elif ((i % 5 == 0)) 14 | then 15 | echo "Buzz" 16 | elif (( i % 3 == 0)) 17 | then 18 | echo "Fizz" 19 | else 20 | echo "$i" 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/2-while_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Best School" 10 times 3 | i=1 4 | while [ "$i" -le 10 ]; do 5 | echo "Best School" 6 | i=$((i + 1)) 7 | done 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/3-until_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Best School" 10 times 3 | 4 | counter=0 5 | 6 | until [ $counter -ge 10 ]; do 7 | echo "Best School" 8 | ((counter++)) 9 | done 10 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/4-if_9_say_hi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Best School" 10 times 3 | 4 | count=1 5 | while [ $count -le 10 ]; do 6 | if [ $count -eq 9 ]; then 7 | echo "Best School" 8 | echo "Hi" 9 | else 10 | echo "Best School" 11 | fi 12 | count=$((count + 1)) 13 | done 14 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/5-4_bad_luck_8_is_your_chance: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is displaying "Best School" 10 times 3 | 4 | count=1 5 | 6 | while [ $count -le 10 ]; do 7 | if [ $count -eq 4 ]; then 8 | echo "bad luck" 9 | elif [ $count -eq 8 ]; then 10 | echo "good luck" 11 | else 12 | echo "Best School" 13 | fi 14 | count=$((count + 1)) 15 | done 16 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/6-superstitious_numbers: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Bash script that displays numbers from 1 to 20 and: 3 | # displays 4 and then bad luck from China for the 4th loop iteration 4 | # displays 9 and then bad luck from Japan for the 9th loop iteration 5 | # displays 17 and then bad luck from Italy for the 17th loop iteration 6 | i="1" 7 | while [ $i -le 20 ] 8 | do 9 | case $i in 10 | 4) echo $i 11 | echo "bad luck from China" 12 | ;; 13 | 9) echo $i 14 | echo "bad luck from Japan" 15 | ;; 16 | 17)echo $i 17 | echo "bad luck from Italy" 18 | ;; 19 | *) 20 | echo $i 21 | esac 22 | i=$((i+1)) 23 | done 24 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/7-clock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Write a Bash script that displays the time for 12 hours and 59 minutes: 3 | 4 | i=0 5 | while [ $i -le 12 ]; do 6 | echo "Hour: $i" 7 | j=1 8 | while [ $j -le 59 ]; do 9 | echo $j 10 | j=$((j + 1)) 11 | done 12 | i=$((i + 1)) 13 | done 14 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/8-for_ls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Where only the part of the name after the first dash is displayed 3 | 4 | for file in *; do 5 | if [ -f "$file" ]; then 6 | after_dash=${file#*-} 7 | echo "$after_dash" 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/9-to_file_or_not_to_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays information about the file `school`. 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 | Shellcheck 2 | Shellcheck is a tool that will help you write proper Bash scripts. It will make recommendations on your syntax and semantics and provide advice on edge cases that you might not have thought about. Shellcheck is your friend! All your Bash scripts must pass Shellcheck without any error or you will not get any points on the task. 3 | 4 | Shellcheck is available on the school’s computers. If you want to use it on your own computer, here is how to install it. 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/0-what-is-my-pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays its own process ID. 3 | 4 | echo $$ 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/1-list_your_processes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Write a Bash script that displays a list of currently running processes. 3 | 4 | ps auxf 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/2-show_your_bash_pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # write a Bash script that displays lines containing the bash word, thus allowing you to easily get the PID of your Ba sh process. 3 | # shellcheck disable=SC2009 4 | ps auxf | grep bash 5 | -------------------------------------------------------------------------------- /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 processes 3 | # whose name contain the word bash 4 | 5 | pgrep -l bash 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/4-to_infinity_and_beyond: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Write a Bash script that displays To infinity and beyond indefinitely. 3 | 4 | while true; do 5 | echo "To infinity and beyond" 6 | sleep 2 7 | done 8 | 9 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/5-dont_stop_me_now: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # kills the infinity and beyond program using sigkill signal 3 | 4 | # Get the pid of the program 5 | id=$(pgrep "bash ./4-to_infinity_and_beyond" -f) 6 | 7 | # Terminate the infinate process 8 | if [ -n "$id" ] 9 | then 10 | kill -15 "$id" 11 | fi 12 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/6-stop_me_if_you_can: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # kills the infinity and beyond program using sigkill signal 3 | 4 | # Terminate the infinite process 5 | pkill -15 "bash ./4-to_infinity_and_beyond" -f 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/7-highlander: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # prints the message infinity and beyond for 3 | # eternity unless it is killed, not so ethernal after all :) 4 | 5 | # Handle SIGTERM 6 | trap "echo 'I am invincible!!!'" 15 7 | 8 | 9 | # print the message forever 10 | while true; 11 | do 12 | echo "To infinity and beyond"; 13 | sleep 2 14 | done 15 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/8-beheaded_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # kills the infinity and beyond program using sigkill signal 3 | 4 | # Terminate the infinate process 5 | pkill -9 "bash ./7-highlander" -f 6 | -------------------------------------------------------------------------------- /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*n$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/100-textme.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | log_entry = ARGV[0] 3 | from = log_entry.scan(/\[from:(.*?)\]/).flatten[0] 4 | to = log_entry.scan(/\[to:(.*?)\]/).flatten[0] 5 | flags = log_entry.scan(/\[flags:(.*?)\]/).flatten[0] 6 | 7 | puts "#{from},#{to},#{flags}" 8 | -------------------------------------------------------------------------------- /0x06-regular_expressions/2-repetition_token_1.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^(htn||hbtn)$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/3-repetition_token_2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^hb*t+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}$/).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 | Regular expressions (regex or regexp) are a powerful tool for pattern matching and text processing in computing. They enable the identification, extraction, manipulation, or replacement of specified patterns in text. Regular expressions are employed in programming languages, text editors, advanced search engines, and other applications for complex text processing tasks. 2 | 3 | Key Concepts of Regular Expressions: 4 | 5 | Basic Patterns: The simplest form of regular expressions. These are direct text matches. For example, the regex "cat" would match the string "cat" in any text. 6 | 7 | Metacharacters: Symbols or sequences that have special meaning in regex, such as . (matches any single character), * (matches zero or more of the preceding element), and + (matches one or more of the preceding element). 8 | 9 | Character Classes: Enclosed in square brackets [], character classes match any one of the enclosed characters. For example, [abc] matches "a", "b", or "c". 10 | 11 | Alternation: The pipe symbol | works as a logical OR. For example, "cat|dog" matches either "cat" or "dog". 12 | 13 | Quantifiers: Indicate how many instances of a character, group, or character class must be present for a match. Common quantifiers include * (0 or more), + (1 or more), ? (0 or 1), and {n} (exactly n times). 14 | 15 | Anchors: Special characters that indicate the position in the text relative to a line break or the beginning/end of a string. For example, ^ matches the start of a string, and $ matches the end. 16 | 17 | Grouping and Capturing: Parentheses () are used to define groups, which can be referenced later in the expression or in replacement patterns. This is useful for extracting information or reorganizing the text. 18 | 19 | Escape Character: The backslash \ is used to escape characters that otherwise have a special meaning in regex syntax, allowing them to be treated as literal characters. 20 | 21 | Lookahead and Lookbehind: These are zero-length assertions that match a pattern only if it is followed or preceded by another pattern. 22 | 23 | Flags/Modifiers: These alter how the regular expression is processed. Common flags include i for case-insensitive matching, m for multi-line mode, and g for global search. 24 | 25 | Regular expressions can be very concise but may also become complex and hard to read, making them a bit of a double-edged sword. They are extremely useful for validation (like email or password formats), searching and replacing in text, and parsing data from complex texts. 26 | -------------------------------------------------------------------------------- /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 | #Write a Bash script that displays listening ports: 3 | netstat --listening --program 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/5-is_the_host_on_the_network: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # ping command usage 3 | if [ "$1" ]; then 4 | ping -c 5 "$1" 5 | else 6 | echo "Usage: 5-is_the_host_on_the_network {IP_ADDRESS}" 7 | fi 8 | -------------------------------------------------------------------------------- /0x07-networking_basics/README.md: -------------------------------------------------------------------------------- 1 | Networking Basics 2 | 1. Definition of networking: 3 | Networking in the context of computers refers to the practice of connecting computers, servers, mainframes, network devices, peripherals, or other devices to share data and resources. 4 | 2. Key Components: 5 | 6 | Nodes: Any device connected to a network (computers, printers, servers, etc.). 7 | Router: Directs data packets between networks. 8 | Switch: Connects devices within a single network, managing data flow. 9 | Modem: Connects networks to the internet through various means (DSL, cable, fiber). 10 | 3. Types of Networks: 11 | 12 | Local Area Network (LAN): Covers a small geographical area like a home, office, or building. 13 | Wide Area Network (WAN): Covers larger geographical areas, potentially worldwide. 14 | Metropolitan Area Network (MAN): Spans a city or large campus. 15 | Personal Area Network (PAN): Very small network for personal use, typically within a range of a few meters. 16 | 4. Networking Protocols: 17 | 18 | Protocols are rules and standards that define how data is transmitted. Examples include TCP/IP, HTTP, FTP, and SMTP. 19 | 5. IP Addressing: 20 | 21 | Devices are assigned an IP address (Internet Protocol address) for identification and location addressing. 22 | 6. Network Topologies: 23 | 24 | The arrangement of network devices. Common topologies include star, mesh, bus, and ring. 25 | 7. Data Transfer Methods: 26 | 27 | Wired: Through cables (Ethernet, coaxial, fiber optic). 28 | Wireless: Via radio waves (Wi-Fi, Bluetooth). 29 | 8. Network Security: 30 | 31 | Measures to protect data integrity, availability, and confidentiality. Includes firewalls, encryption, and secure passwords. 32 | 9. Internet of Things (IoT): 33 | 34 | Refers to the growing network of devices connected to the internet, extending networking to everyday objects. 35 | Understanding these basics provides a foundation for delving deeper into the complex and ever-evolving world of computer networks. 36 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/0-change_your_home_IP: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Change localhost address 3 | cp /etc/hosts ~/hosts.new 4 | sed -i "s/^127[0-9.]*\slocalhost/127.0.0.2 localhost/" ~/hosts.new 5 | sed -i "$ a\8.8.8.8 facebook.com" ~/hosts.new 6 | cp -f ~/hosts.new /etc/hosts 7 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/1-show_attached_IPs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays all active IPv4 IPs on the machine it’s executed on 3 | ifconfig | awk -F "[: ]+" '/inet addr:/ { print $4 }' 4 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/100-port_listening_on_localhost: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Listens to the port 98 on localhost 3 | nc -l 98 4 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/README.md: -------------------------------------------------------------------------------- 1 | localhost is a hostname that refers to the computer or device you are currently using. It is a loopback network interface, meaning it is a network interface that a computer uses to communicate with itself. The concept is primarily used in networking and software development to test network software. 2 | 3 | Here are some key points about localhost: 4 | 5 | IP Address: localhost is typically associated with the IP address 127.0.0.1 in IPv4, and ::1 in IPv6. These addresses are reserved for loopback. Network traffic that a computer sends to these addresses is effectively sent back to itself. 6 | 7 | Testing and Development: Developers often use localhost for testing applications, especially web applications. For example, a web developer might start a web server on their local machine and access it via http://localhost to test their application. 8 | 9 | Networking: localhost is used to establish network connections without involving the local network interface hardware. It’s a convenient way to determine if the network stack of an operating system is working correctly. 10 | 11 | Security: Because localhost refers to the local machine, it is generally secure from external access. Connections made to localhost do not leave the machine nor can they be intercepted by external devices. 12 | 13 | Use in Software: Many software applications use localhost for various purposes, including proxy settings, local server hosting, and database connections. 14 | 15 | Understanding localhost is fundamental in network programming, system administration, and web development, as it is a standard part of the IP networking protocol that is used universally. 16 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/0-simple_web_stack.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x09-web_infrastructure_design/0-simple_web_stack.pdf -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/0-simple_web_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x09-web_infrastructure_design/0-simple_web_stack.png -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure: -------------------------------------------------------------------------------- 1 | Assign IP Addresses: 2 | 3 | Each server, including the database server, should have a unique IP address. For example: 4 | Server 1 (Nginx): 192.168.1.2 5 | Server 2 (Application Server): 192.168.1.3 6 | Database Server (MySQL): 192.168.1.4 7 | Ensure Network Connectivity: 8 | 9 | Make sure all servers are on the same network or are reachable from each other. 10 | Configure the Load Balancer (HAproxy): 11 | 12 | HAproxy should be set up to distribute incoming traffic to both the Nginx and Application servers. 13 | Use the IP addresses of these servers in the HAproxy configuration. 14 | Software Configuration 15 | Nginx Server Setup: 16 | 17 | Configure Nginx to handle incoming requests and possibly to reverse proxy requests to the Application Server. 18 | Set up proxy settings in Nginx to redirect to the Application Server’s IP (192.168.1.3). 19 | Application Server Configuration: 20 | 21 | Configure your application server's software to connect to the Database Server. 22 | Set the Database Server's IP address (192.168.1.4) in your application's database configuration. 23 | Database Server Configuration: 24 | 25 | Configure MySQL to accept connections from the Application Server's IP address. 26 | Modify MySQL settings (e.g., bind-address in my.cnf) and set appropriate user privileges. 27 | Security Configuration 28 | Firewalls: 29 | 30 | Implement firewalls on each server. 31 | Configure them to allow traffic specific to each server’s role (e.g., HTTP/HTTPS for Nginx, database connections for MySQL). 32 | Secure Connections: 33 | 34 | Use encrypted connections for sensitive operations, especially database interactions. 35 | Testing the Configuration 36 | Load Balancer Testing: 37 | 38 | Test by making web requests to your HAproxy IP and ensure they are correctly processed by your servers. 39 | Database Connectivity: 40 | 41 | Verify that your Application Server can successfully connect and interact with the Database Server. 42 | Overall Functionality: 43 | 44 | Ensure that each part of the infrastructure works as intended, including the load distribution by HAproxy. 45 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure.pdf: -------------------------------------------------------------------------------- 1 | Assign IP Addresses: 2 | 3 | Each server, including the database server, should have a unique IP address. For example: 4 | Server 1 (Nginx): 192.168.1.2 5 | Server 2 (Application Server): 192.168.1.3 6 | Database Server (MySQL): 192.168.1.4 7 | Ensure Network Connectivity: 8 | 9 | Make sure all servers are on the same network or are reachable from each other. 10 | Configure the Load Balancer (HAproxy): 11 | 12 | HAproxy should be set up to distribute incoming traffic to both the Nginx and Application servers. 13 | Use the IP addresses of these servers in the HAproxy configuration. 14 | Software Configuration 15 | Nginx Server Setup: 16 | 17 | Configure Nginx to handle incoming requests and possibly to reverse proxy requests to the Application Server. 18 | Set up proxy settings in Nginx to redirect to the Application Server’s IP (192.168.1.3). 19 | Application Server Configuration: 20 | 21 | Configure your application server's software to connect to the Database Server. 22 | Set the Database Server's IP address (192.168.1.4) in your application's database configuration. 23 | Database Server Configuration: 24 | 25 | Configure MySQL to accept connections from the Application Server's IP address. 26 | Modify MySQL settings (e.g., bind-address in my.cnf) and set appropriate user privileges. 27 | Security Configuration 28 | Firewalls: 29 | 30 | Implement firewalls on each server. 31 | Configure them to allow traffic specific to each server’s role (e.g., HTTP/HTTPS for Nginx, database connections for MySQL). 32 | Secure Connections: 33 | 34 | Use encrypted connections for sensitive operations, especially database interactions. 35 | Testing the Configuration 36 | Load Balancer Testing: 37 | 38 | Test by making web requests to your HAproxy IP and ensure they are correctly processed by your servers. 39 | Database Connectivity: 40 | 41 | Verify that your Application Server can successfully connect and interact with the Database Server. 42 | Overall Functionality: 43 | 44 | Ensure that each part of the infrastructure works as intended, including the load distribution by HAproxy. 45 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x09-web_infrastructure_design/1-distributed_web_infrastructure.png -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/README.md: -------------------------------------------------------------------------------- 1 | Web Infrastructure Design 2 | Web infrastructure design refers to the planning and structuring of the hardware, software, resources, and services required to deliver web-based services and applications. It's a comprehensive framework that ensures the efficient functioning, scalability, reliability, and security of web applications. 3 | 4 | Key Components: 5 | 6 | Servers: Central to web infrastructure, servers host applications, manage requests, and deliver content. They can be dedicated, virtual, or cloud-based. 7 | 8 | Web Servers: Software like Apache or Nginx that handle HTTP requests, serving static content like HTML, CSS, and images to clients. 9 | 10 | Application Servers: Handle the execution of application logic, process dynamic content, and manage interactions between users and backend databases. 11 | 12 | Database Servers: Store and manage data needed by web applications, like user information, content, and transaction data. 13 | 14 | Network Infrastructure: Includes routers, switches, and load balancers to ensure smooth data flow and traffic management. 15 | 16 | DNS and Domain Management: Translates domain names into IP addresses, directing users to the correct server. 17 | 18 | Security Components: Firewalls, SSL/TLS encryption, and other security protocols to protect data and applications. 19 | 20 | Key Considerations: 21 | 22 | Scalability: Ability to handle increased load, often achieved through clustering, load balancing, or cloud-based solutions. 23 | Reliability: Ensuring uptime and consistent performance, often through redundant systems and backup strategies. 24 | Security: Protecting against threats and vulnerabilities, ensuring data integrity and privacy. 25 | Maintenance: Regular updates, backups, and monitoring for optimal performance. 26 | Challenges: 27 | 28 | Single Point of Failure (SPOF): Identifying and mitigating any single component whose failure could bring down the entire system. 29 | Traffic Management: Dealing with varying traffic loads efficiently. 30 | Cost Management: Balancing performance needs with budget constraints. 31 | In essence, web infrastructure design is about creating a robust, flexible, and secure environment for web applications, ensuring they perform well and are accessible to users at all times. 32 | -------------------------------------------------------------------------------- /0x0A-configuration_management/0-create_a_file.pp: -------------------------------------------------------------------------------- 1 | #Create a file in /tmp 2 | 3 | file { 'school': 4 | ensure => 'present', 5 | path => '/tmp/school', 6 | mode => '0744', 7 | owner => 'www-data', 8 | group => 'www-data', 9 | content => 'I love Puppet' 10 | } -------------------------------------------------------------------------------- /0x0A-configuration_management/1-install_a_package.pp: -------------------------------------------------------------------------------- 1 | # install_flask.pp 2 | 3 | package { 'python3-pip': 4 | ensure => 'installed', 5 | } 6 | 7 | exec { 'install_flask': 8 | command => '/usr/bin/pip3 install Flask==2.1.0 Werkzeug==2.0.3', 9 | path => '/usr/bin', 10 | require => Package['python3-pip'], 11 | } 12 | -------------------------------------------------------------------------------- /0x0A-configuration_management/2-execute_a_command.pp: -------------------------------------------------------------------------------- 1 | #Kills a process named killmenow 2 | exec{'pkill -f killmenow': 3 | path => '/usr/bin/:/usr/local/bin/:/bin/' 4 | } 5 | -------------------------------------------------------------------------------- /0x0A-configuration_management/README.md: -------------------------------------------------------------------------------- 1 | Configuration Management (CM) is a discipline that ensures the consistency and integrity of a system or software product throughout its lifecycle. It involves the systematic management of configurations, including hardware, software, documentation, and any other components, to maintain a reliable and efficient system. 2 | 3 | Key Objectives: 4 | 5 | Version Control: 6 | 7 | CM involves versioning to track changes in the configuration items (CIs) over time. This allows for easy retrieval of previous versions and helps in identifying and resolving issues. 8 | Change Management: 9 | 10 | Ensures that changes to the system are controlled, documented, and implemented in a way that minimizes risk and maximizes benefits. This involves assessing the impact of changes and obtaining necessary approvals. 11 | Baseline Management: 12 | 13 | Establishing and maintaining baselines (snapshots) of the system at various points in its lifecycle. Baselines serve as reference points, facilitating reproducibility and ensuring that the system can be reconstructed in a known state. 14 | Traceability: 15 | 16 | CM provides traceability to link requirements, design, implementation, and testing artifacts. This traceability helps in understanding the impact of changes and ensures that every component aligns with the defined requirements. 17 | Auditing and Reporting: 18 | 19 | CM includes mechanisms for auditing changes and generating reports to provide visibility into the configuration status. This is crucial for compliance, quality assurance, and identifying trends or areas for improvement. 20 | Release Management: 21 | 22 | Coordinating the release of software or system updates in a controlled and efficient manner. This involves planning, scheduling, and deploying releases while minimizing disruptions to ongoing operations. 23 | Documentation Management: 24 | 25 | Managing documentation related to the configuration, including specifications, user manuals, and technical documentation. Ensures that documentation is consistent with the actual state of the system. 26 | Key Components: 27 | 28 | Configuration Items (CIs): 29 | 30 | These are the individual elements that make up the configuration, such as source code, libraries, hardware components, and documentation. 31 | Configuration Baselines: 32 | 33 | A set of configuration items that have been formally reviewed and agreed upon. Baselines provide a stable reference for future changes. 34 | Change Requests: 35 | 36 | Formal proposals for modifications to the configuration. These requests go through a defined change management process, including evaluation, approval, and implementation. 37 | Version Control System: 38 | 39 | Software tools that manage different versions of source code, documents, and other artifacts. Examples include Git, Subversion, and Mercurial. 40 | Audit Trail: 41 | 42 | A record of changes made to the configuration items, including who made the change, when it was made, and the nature of the change. 43 | Benefits of Configuration Management: 44 | 45 | Increased Stability and Reliability: 46 | 47 | CM ensures that changes are controlled and thoroughly tested, reducing the likelihood of introducing errors into the system. 48 | Efficient Collaboration: 49 | 50 | Version control and baseline management facilitate collaboration among development teams, allowing them to work on the same codebase simultaneously. 51 | Compliance and Documentation: 52 | 53 | Helps organizations meet regulatory requirements by providing accurate and up-to-date documentation of the system's configuration. 54 | Risk Mitigation: 55 | 56 | By tracking changes and maintaining baselines, CM minimizes the risk of system failures and makes it easier to identify and rectify issues. 57 | Improved Traceability: 58 | 59 | Provides a clear traceability matrix, linking requirements to design, implementation, and testing, aiding in better project management. 60 | In conclusion, Configuration Management is a critical aspect of software and system development, ensuring that changes are controlled, documented, and implemented in a systematic and organized manner, ultimately contributing to the success and reliability of a product or system. 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /0x0B-ssh/0-use_a_private_key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #A script to connect to the remote server 3 | 4 | ssh -i ~/.ssh/school ubuntu@52.204.95.133 5 | -------------------------------------------------------------------------------- /0x0B-ssh/1-create_ssh_key_pair: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Define the key file name and passphrase 3 | KEY_FILE="school" 4 | BITS=4096 5 | PASSPHRASE="betty" 6 | 7 | # Check if the key file already exists 8 | if [ -e "$KEY_FILE" ]; then 9 | echo "Error: Key file '$KEY_FILE' already exists." 10 | exit 1 11 | fi 12 | 13 | # Generate the RSA key pair with the specified requirements 14 | ssh-keygen -t rsa -b "$BITS" -f "$KEY_FILE" -N "$PASSPHRASE" 15 | 16 | echo "RSA key pair created successfully." 17 | -------------------------------------------------------------------------------- /0x0B-ssh/100-puppet_ssh_config.pp: -------------------------------------------------------------------------------- 1 | # puppet script - configure ssh authentication: 2 | 3 | file_line { 'Turn off passwd auth': 4 | path => '/etc/ssh/ssh_config', 5 | line => 'PasswordAuthentication no', 6 | } 7 | 8 | file_line { 'Declare identity file': 9 | path => '/etc/ssh/ssh_config', 10 | line => 'IdentityFile ~/.ssh/school', 11 | } 12 | 13 | service { 'ssh': 14 | ensure => running, 15 | enable => true, 16 | } 17 | -------------------------------------------------------------------------------- /0x0B-ssh/2-ssh_config: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # uses ssh to connect to your server using 3 | #the private key ~/.ssh/school with the user ubuntu 4 | 5 | Host 208899-web-01 6 | HostName 52.204.95.133 7 | User ubuntu 8 | IdentityFile ~/.ssh/school 9 | PasswordAuthentication no 10 | -------------------------------------------------------------------------------- /0x0B-ssh/PasswordAuthentication no,: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x0B-ssh/PasswordAuthentication no, -------------------------------------------------------------------------------- /0x0B-ssh/README.md: -------------------------------------------------------------------------------- 1 | hard readm 2 | -------------------------------------------------------------------------------- /0x0B-ssh/school: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCXO34CB8 3 | g67XMEfuTZMmc0AAAAEAAAAAEAAAIXAAAAB3NzaC1yc2EAAAADAQABAAACAQDZy2HLI5/P 4 | DqQi8P8kLiSV9LWLImAkR1Vm7RmNTURTPdoly/KmnT9EZWWISn4glRlpgsrh6qsNkVKdhB 5 | gyBgWq068oXTA1F39PMUg+4v3h4Xl/jJURMJQoVfX89tSGJOR1x+pLmjhZJY0N8//jtsIP 6 | WheZDLXGBey4eJPLVwaEDVSWQUhrcL5MgwX/NpyUuTnKPPrwyi6upLGOptrZwMgLRNc17w 7 | ajEmRLlaP+v6O5w3EiSX8sTEom3+fRh//lSUn33EDDxEReIERYsiMKglyfw7l7x8A7Nqy1 8 | XaNbvdIZgtfk5u8pFbTPNxTeN4mMu7VB2+tpJDBvz+WYt8xa2Z2n9uKjORO/dZL63uJJcW 9 | UXJ4INW+4bOLJEEgZpSbgGWlSEEY0/QYYoXwEJvesvWxyQtb9Lp7rdozgChXLeYVJiIsEZ 10 | kj+7x1AmiR/ANHhACE/kq2Zu3Og7XtnIoDO4kADnhUjmgBlt84UX5IgWkx+ni86ywXVBXl 11 | h94t+jRJqRylOZ69HDg6sQdhCE7CihCc36s4gr43wxkszvbbQTwR9t6zj/h2WbswflSQRS 12 | wnPc4uth5BvinJ/MickMyyAENeoriGNB2e05XqSdecO/HSv1P0IIOhkbIoIKN4eeSIwMXd 13 | tZYopYohBK1lIywbVb3Ve+I9nifB1zls5hVqz4S5L0/wAAB1D8v+tm7BMoUehn8jwr99fq 14 | qZWhRKqfasfDp0xvOXL8z3MMCduSBFd0XQnZqSYr048w93fOXzKQdfTJIn6NbuepMXTxPA 15 | ACJ39rbx/40853GvvL7Z/Qcr6yCiuKqRuhdlg6Nb+G4KVASVGHxIQ36NnCpyEuch8toL+5 16 | 9pj2lF0Bw+yRTChC7+axqjJh3CketOspUCfXLPzUzapBGG9Otdb5UPIwhw4tKL0HqmrUIK 17 | lbGVm7I/IvpyWwW5+vosusAfv7/muiNibwjwwe7W0hTsg0qOD/PYGeAs34COUgrJu0fxNc 18 | MIyanFdK1yZLITNYPqK4dNW8+kcYYbXANllhmBVwL5jY8E34PiQhMujRGlYnlcRcE197QA 19 | 1rhZWrUNApTFBpwJ8FZjXnXD2g8fPBWu2dsxKs8lACeDz2WlUjDsDJmml7Rmr7XVISLam9 20 | 6qRE8mI6whIII5BN+17gjgNirzu40o91KhigFnMwAJ8Ov1cSg+14tiP70hO2aphYTZb9TL 21 | fzupMudL7/ciigrbV4LpDiRNSTyDOIeAHQxX67Oe0ngZ4U2jmX4ghnPC8HuHlpYUF6q9tN 22 | bxtVjv0ps5M1Fcroze6QYFidjNo03SJdqjnlRafPEPKFXkXUDV5Gxtg7Try8mdFD7WZgnQ 23 | TJtIIyJuseKb9J3bkMAAJciqv9mtdRbk5z+4/WWRzUxg3j4Q77j0JXjt3K4aX9DOFqlDQk 24 | IYIaqAaFXaK5cbE2SyGHRmHYKFq5LjxD3VgBcvLoUkNQh5lIqYo6ql55DmLKfCftZ0eTV1 25 | wf+x5X0v1ft8LSShyOwzExrIXxewU7nYd8/Nq6kPw70fIA91RaGngG/qqdttwp9EOQj/93 26 | uzh44Q4V02SJOow6O4GFStE5VqLbh3NuqFhjz1CV3ceRJyqQFa2t1i+eISCmfQ2HjsAUSr 27 | lrcXO4VUgAonrv66M7BvpqLf6153xghOPclLYD49T3q6vG0dPOJOa7FpslmPEXzhB8aRO9 28 | YZYw1lsQ2306X2Wbl43Tg4WHluT4+VXIOIMFHDX5gst7pgsm5GRZoStFFsYsQ8lnAUwd5I 29 | pDnIuEJ9fwwzE6gTt2xaZzB5uLjwaTEsEnauvyxmKMiT0404wmq4f5KPRK204aT68PExYE 30 | r3+d1qlec49pDYhzXo5grVvu3s1TggZfG2svBweMyznoZR+FsYar+QLoPMB75MG8iayoKV 31 | cYjlBrzE9vXp4P4+IoiEe+lZ56gj9QVOwMhWhoL8mUvNzF2Fqp4xEcwYQbc5cGhz3OOT0H 32 | vmRgJH/tm+bQAaZXRjmbZujluBRvGCobqrn8MmbbkIGe3+XMPH0HnFjHegSkbMjNTB32ad 33 | DPoh3CsHhf/mCssD3tFdNK2u4RqjxLcdEAb29eWe4SLat10Rod+AumlCESbaPttoqsbQIp 34 | SzhYVtFFpnDOpKycnc+DrRLvYpiJNWmUlMfNWa3yTTGRpNUra1XOiTr/qp1ASFHzGTd4Ia 35 | rr2oAXc/ZTjktRkh/AlfrKYL5LPWkXs1hf4zB4VT4ayDInEAsiE3cBD+YYyGox4MAO1tuH 36 | MUMvsGKRZhtzAnplcS75P6aat15vgt4s5IorBqPA5EIzfa453ijJNbq/pXLrq9hb3EEigB 37 | iQX+eqgaZz/hDP9ph9F1SyWaZUmmi8KJSVAsrhlG1V8miV3P4e7yANr8dHTXDB40IYzcjo 38 | wbQuNNd+eW9YjX9CNN3cNKxWDUNDl+4JE87UNTgKbvOWs4I8hAX4ojibKgogSzgVIjCpvs 39 | FePMwlbyW+4xlZXXq8abaYeLfLxk5S4cOZ8MZ2FxBN8cxAwzYlAVGnFXRf5sTHSMD6UwSW 40 | RUJ1LpzYF49f/OuKLzRALqNk5Nr85T+6B+KxUxuqoMzVNeZNUiV//BT0qfd4A0HyKCyVqi 41 | IzBHKmiYOZQtdkfX64TUN9PMmPVCUw7doCUzs2CNLSGAT4E3jAFCAfUjFZprgUgeprrJPQ 42 | Uea/xjExZJs8Y+Tuk0dIKHLcWeuhWRJ/ObgAE1kmKkPt1lzo+SdBcydcHv66L6RYaXL1sW 43 | d6elbALHo4CeF9RNOJGP2v9qeC7mx2nXkpgLPHTJTm8bwfkxdCUiMJB2PJ9mp3ZrpWGH8T 44 | 590ZMxYMzefgtAbMx8CyqYwKNCclZ19+Rg6l/8D/53v+4D3FK8cnaEpwlvu/JRS4hvXkxh 45 | fbN2/RGv1WJlc5wK8nl7T41CmesIXPqOAhBHBOtCbZFlq42+JuuUDpMnjl/hemFdSCVZ0e 46 | Q9N2ZhDHZC1PkpNscQwVnqUDc2sop8TSANVREAEZnDsHf0To7XPU4ByBN+1luXW5JxXOve 47 | 3wv8et4nYQSa7+P5MBS1IpY7eUKLmbUVk5un2+GkADKMWFa/EjwKnIS6lWj6SrimuCKN1C 48 | tUV8sgbIDuBZfuENVoCN20+NzvmqcEIRpeOHGNJ3MIJlTU6Rc81qOrktIwKZ0cxBnNOUi8 49 | G0O1GmkCfM9d8/8xUwZ1HIk4k= 50 | -----END OPENSSH PRIVATE KEY----- 51 | -------------------------------------------------------------------------------- /0x0B-ssh/school.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDZy2HLI5/PDqQi8P8kLiSV9LWLImAkR1Vm7RmNTURTPdoly/KmnT9EZWWISn4glRlpgsrh6qsNkVKdhBgyBgWq068oXTA1F39PMUg+4v3h4Xl/jJURMJQoVfX89tSGJOR1x+pLmjhZJY0N8//jtsIPWheZDLXGBey4eJPLVwaEDVSWQUhrcL5MgwX/NpyUuTnKPPrwyi6upLGOptrZwMgLRNc17wajEmRLlaP+v6O5w3EiSX8sTEom3+fRh//lSUn33EDDxEReIERYsiMKglyfw7l7x8A7Nqy1XaNbvdIZgtfk5u8pFbTPNxTeN4mMu7VB2+tpJDBvz+WYt8xa2Z2n9uKjORO/dZL63uJJcWUXJ4INW+4bOLJEEgZpSbgGWlSEEY0/QYYoXwEJvesvWxyQtb9Lp7rdozgChXLeYVJiIsEZkj+7x1AmiR/ANHhACE/kq2Zu3Og7XtnIoDO4kADnhUjmgBlt84UX5IgWkx+ni86ywXVBXlh94t+jRJqRylOZ69HDg6sQdhCE7CihCc36s4gr43wxkszvbbQTwR9t6zj/h2WbswflSQRSwnPc4uth5BvinJ/MickMyyAENeoriGNB2e05XqSdecO/HSv1P0IIOhkbIoIKN4eeSIwMXdtZYopYohBK1lIywbVb3Ve+I9nifB1zls5hVqz4S5L0/w== root@ab4f4928422a 2 | -------------------------------------------------------------------------------- /0x0C-web_server/0-transfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #transfers a file from our client to a server: 3 | #Accepts 4 parameters 4 | #The path to the file to be transferred 5 | #The IP of the server we want to transfer the file to 6 | 7 | if [ "$#" -lt 4 ]; then 8 | echo "Usage: $0 PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY" 9 | exit 1 10 | fi 11 | 12 | # Assign parameters to variables 13 | file_path=$1 14 | server_ip=$2 15 | username=$3 16 | ssh_key_path=$4 17 | 18 | # Construct the SCP command 19 | scp -o StrictHostKeyChecking=no -i "$ssh_key_path" "$file_path" "$username@$server_ip":~/ 20 | 21 | # Check the exit status of the SCP command 22 | if [ "$?" -eq 0 ]; then 23 | echo "File transferred successfully." 24 | else 25 | echo "Error transferring the file." 26 | fi 27 | -------------------------------------------------------------------------------- /0x0C-web_server/1-install_nginx_web_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # bash: script install and configure Nginx web server: 3 | apt-get update 4 | 5 | # Install nginx 6 | apt-get install -y nginx 7 | 8 | # Create a basic HTML file with "Hello World!" 9 | echo "Hello World!" > /var/www/html/index.html 10 | 11 | # Configure Nginx to listen on port 80 and serve the HTML file 12 | echo "server { 13 | listen 80; 14 | server_name localhost; 15 | 16 | location / { 17 | root /var/www/html; 18 | index index.html; 19 | } 20 | }" > /etc/nginx/sites-available/default 21 | 22 | # Restart Nginx (without using systemctl) 23 | kill -s HUP $(cat /var/run/nginx.pid) 24 | 25 | # Done 26 | echo "Nginx installed and configured. You can test by running 'curl localhost'." -------------------------------------------------------------------------------- /0x0C-web_server/2-setup_a_domain_name: -------------------------------------------------------------------------------- 1 | anbesa.tech 2 | -------------------------------------------------------------------------------- /0x0C-web_server/3-redirection: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Create the necessary directories if they don't exist 4 | mkdir -p /data/ 5 | mkdir -p /data/web_static/ 6 | mkdir -p /data/web_static/releases/ 7 | mkdir -p /data/web_static/shared/ 8 | mkdir -p /data/web_static/releases/test/ 9 | 10 | # Create a fake HTML file for testing 11 | echo "Hello, world!" > /data/web_static/releases/test/index.html 12 | 13 | # Create a symbolic link 14 | ln -sf /data/web_static/releases/test/ /data/web_static/current 15 | 16 | # Set ownership and permissions 17 | chown -R ubuntu:ubuntu /data/ 18 | chmod -R 755 /data/ 19 | 20 | # Update the Nginx configuration 21 | config_file="/etc/nginx/sites-available/default" 22 | 23 | # Remove any existing configuration related to serving the static content 24 | sed -i '/location \/hbnb_static/ d' "$config_file" 25 | 26 | # Add the new configuration for serving the static content 27 | echo " 28 | location /hbnb_static { 29 | alias /data/web_static/current/; 30 | index index.html; 31 | }" >> "$config_file" 32 | 33 | # Restart Nginx 34 | service nginx restart -------------------------------------------------------------------------------- /0x0C-web_server/4-not_found_page_404: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Configure your Nginx server to have a custom 404 page that contains the string Ceci n'est pas une page. 3 | 4 | STRING="Hello World!" 5 | 6 | REDIRECT="\n\tlocation /redirect_me {\n\t\treturn 301 https://youtu.be/dQw4w9WgXcQ;\n\t}\n" 7 | FILE="/etc/nginx/sites-available/default" 8 | 9 | ERRORFILE="/usr/share/nginx/html/404error.html" 10 | FOUR="Ceci n'est pas une page" 11 | ERRORREDIRECT="\n\terror_page 404 /404error.html;\n\tlocation = /404error.html {\n\t\troot /usr/share/nginx/html;\n\t\tinternal;\n\t}\n" 12 | 13 | apt-get -y update 14 | apt-get -y install nginx 15 | ufw allow 'Nginx HTTP' 16 | sudo echo "$STRING" > /var/www/html/index.nginx-debian.html 17 | sed -i "37i\ $REDIRECT" "$FILE" 18 | 19 | echo "$FOUR" > "$ERRORFILE" 20 | sed -i "37i\ $ERRORREDIRECT" "$FILE" 21 | 22 | service nginx restart -------------------------------------------------------------------------------- /0x0C-web_server/7-puppet_install_nginx_web_server.pp: -------------------------------------------------------------------------------- 1 | #setup nginx 2 | 3 | package { 4 | 'nginx': 5 | ensure => installed, 6 | } 7 | 8 | file {'/var/www/html/index.nginx-debian.html': 9 | content => 'Hello World!', 10 | } 11 | 12 | file_line {'configure redirection': 13 | path => '/etc/nginx/sites-available/default', 14 | after => 'server_name _;', 15 | line => "\n\tlocation /redirect_me {\n\t\treturn 301 https://youtu.be/dQw4w9WgXcQ;\n\t}\n", 16 | } 17 | 18 | service {'nginx': 19 | ensure => running, 20 | } -------------------------------------------------------------------------------- /0x0C-web_server/README.md: -------------------------------------------------------------------------------- 1 | Web Server Basics 2 | Definition: 3 | A web server is a software application or hardware device that stores, processes, and delivers web content to clients over the Internet. It plays a fundamental role in enabling the accessibility of websites and web applications. 4 | 5 | Key Components: 6 | 1. HTTP (Hypertext Transfer Protocol): 7 | The foundation of communication on the World Wide Web. 8 | Facilitates the exchange of information between clients (web browsers) and servers. 9 | 2. Server Software: 10 | Examples include Apache, Nginx, Microsoft IIS, and others. 11 | Responsible for handling incoming requests, processing them, and delivering the appropriate response. 12 | 3. Document Root: 13 | The main directory on the server where web content (HTML, CSS, images, etc.) is stored. 14 | Clients access content by requesting specific files within this directory. 15 | 4. IP Address and Domain Name: 16 | Servers are identified on the Internet by their IP addresses. 17 | Domain names provide human-readable aliases for IP addresses. 18 | 5. Port: 19 | Servers listen on specific ports for incoming connections. 20 | Default HTTP port is 80; HTTPS uses port 443. 21 | 6. Protocols: 22 | HTTPS (HTTP Secure) encrypts data during transmission, enhancing security. 23 | SSL/TLS protocols are commonly used for secure communication. 24 | Server-Side Scripting and Databases: 25 | 1. Server-Side Scripting: 26 | Dynamic content generation using server-side languages (e.g., PHP, Python, Ruby). 27 | Allows customization of content based on user requests. 28 | 2. Databases: 29 | Storage and retrieval of data to support dynamic web applications. 30 | Common databases include MySQL, PostgreSQL, and MongoDB. 31 | Security Considerations: 32 | 1. Firewalls and Security Software: 33 | Protects the server from unauthorized access and malicious activities. 34 | 2. Regular Software Updates: 35 | Ensures that the server software and operating system have the latest security patches. 36 | 3. Access Controls: 37 | Restricts access to sensitive files and directories. 38 | Uses authentication mechanisms to verify user identity. 39 | Scalability: 40 | 1. Load Balancing: 41 | Distributes incoming traffic across multiple servers to optimize performance and prevent overload. 42 | 2. Caching: 43 | Stores frequently accessed content to reduce server load and improve response times. 44 | Monitoring and Logging: 45 | 1. Log Files: 46 | Record information about server activity, errors, and user interactions. 47 | Essential for troubleshooting and performance analysis. 48 | 2. Monitoring Tools: 49 | Keep track of server health, resource usage, and potential issues. 50 | Examples include Nagios, New Relic, and Prometheus. 51 | -------------------------------------------------------------------------------- /0x0C-web_server/some_page.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x0C-web_server/some_page.html -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fix Apache not serving the expected page 3 | 4 | # Start the Docker container with port mapping 5 | docker run -p 8080:80 -d -it holbertonschool/265-0 6 | 7 | # Connect to the running container 8 | docker exec -it /bin/bash 9 | 10 | # Inside the container, create a simple HTML file 11 | echo "Hello Holberton" > /var/www/html/index.html 12 | 13 | # Exit the container 14 | exit 15 | 16 | # Check the container's status 17 | docker ps 18 | 19 | # Test the Apache server 20 | curl 0:8080 21 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/README.md: -------------------------------------------------------------------------------- 1 | system engineering devops. 2 | debugging 3 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/0-nginx_likes_port_80: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #remove the enabled nginx 3 | rm /etc/nginx/sites-enabled/default 4 | ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default 5 | service nginx restart -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/1-debugging_made_short: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script that make nginx listen to 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)" -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/README.md: -------------------------------------------------------------------------------- 1 | Nginx likes port 80 2 | -------------------------------------------------------------------------------- /0x0F-load_balancer/0-custom_http_response_header: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure Nginx so that its HTTP response contains a custom header (on web-01 and web-02) 3 | # The name of the custom HTTP header must be X-Served-By 4 | # The value of the custom HTTP header must be the hostname of the server Nginx is running on 5 | sudo apt-get update 6 | sudo apt-get -y install nginx 7 | 8 | # configure firewall to allow request through port 80 9 | sudo ufw allow 'Nginx HTTP' 10 | 11 | sudo mkdir -p /var/www/html 12 | 13 | # change permissions to allow us to easily create files in this directory 14 | sudo chmod -R 755 /var/www 15 | 16 | # create the index page 17 | echo 'Hello World!' |sudo tee /var/www/html/index.html 18 | 19 | # create a webpage for error 404 20 | echo "Ceci n'est pas une page" |sudo tee /var/www/html/404.html 21 | 22 | # code to configure redirect for a single page(/redirect_me) and add header to display hostname 23 | string_for_replacement="server_name _;\n\tadd_header X-Served-By \$hostname;\n\trewrite ^\/redirect_me https:\/\/www.blog.ehoneahobed.com permanent;" 24 | sudo sed -i "s/server_name _;/$string_for_replacement/" /etc/nginx/sites-enabled/default 25 | 26 | # code to configure redirect for 404 error page 27 | string_for_replacement="listen 80 default_server;\n\terror_page 404 \/404.html;\n\tlocation = \/404.html {\n\t\troot \/var\/www\/html;\n\t\tinternal;\n\t}" 28 | sudo sed -i "s/listen 80 default_server;/$string_for_replacement/" /etc/nginx/sites-enabled/default 29 | 30 | # restart the web server after updating the setting 31 | sudo service nginx restart 32 | -------------------------------------------------------------------------------- /0x0F-load_balancer/0-tranfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #transfers a file from our client to a server: 3 | #Accepts 4 parameters 4 | #The path to the file to be transferred 5 | #The IP of the server we want to transfer the file to 6 | #The username scp connects with 7 | #The path to the SSH private key that scp uses 8 | #Display Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY if less than 3 parameters passed 9 | #scp must transfer the file to the user home directory ~/ 10 | #Strict host key checking must be disabled when using scp 11 | if [ $# -lt 4 ] 12 | then 13 | echo "Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY" 14 | else 15 | scp -o StrictHostKeyChecking=no -i "$4" "$1" "$3@$2":~ 16 | fi 17 | -------------------------------------------------------------------------------- /0x0F-load_balancer/1-install_load_balancer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs, configures, and starts the load balancer 3 | sudo apt-get update 4 | sudo apt-get -y install --no-install-recommends software-properties-common 5 | sudo add-apt-repository -y ppa:vbernat/haproxy-2.5 6 | sudo apt-get -y install haproxy 7 | 8 | # the load balancer's configuration 9 | DOMAIN_NAME='anbesa.tech' 10 | INIT_FILE='/etc/default/haproxy' 11 | CONFIG_FILE='/etc/haproxy/haproxy.cfg' 12 | HAPROXY_LB_CONFIG=\ 13 | " 14 | #--$DOMAIN_NAME-params-begin-- 15 | backend $DOMAIN_NAME-backend 16 | balance roundrobin 17 | server 208899-web-01 52.204.95.133:80 check 18 | server 208899-web-02 54.236.33.253:80 check 19 | frontend $DOMAIN_NAME-frontend 20 | bind *:80 21 | mode http 22 | default_backend $DOMAIN_NAME-backend 23 | #--$DOMAIN_NAME-params-end-- 24 | " 25 | 26 | [ -f "$INIT_FILE" ] || touch "$INIT_FILE" 27 | [ -f "$CONFIG_FILE" ] || touch "$CONFIG_FILE" 28 | 29 | CONFIG_WORDS=$(grep -Eco "$DOMAIN_NAME-backend" < $CONFIG_FILE) 30 | 31 | if [ "$(grep -Eco '^ENABLED=[01]$' < $INIT_FILE)" -gt 0 ]; then 32 | sed -i 's/^ENABLED=0$/ENABLED=1/' "$INIT_FILE" 33 | else 34 | echo 'ENABLED=1' >> $INIT_FILE 35 | fi 36 | 37 | if [ "$CONFIG_WORDS" -eq 0 ]; then 38 | echo -e "$HAPROXY_LB_CONFIG" >> $CONFIG_FILE 39 | else 40 | start_tkn="#--$DOMAIN_NAME-params-begin--" 41 | end_tkn="#--$DOMAIN_NAME-params-end--" 42 | a=$(grep -onE "$start_tkn" < "$CONFIG_FILE" | cut -d : -f1) 43 | b=$(grep -onE "$end_tkn" < "$CONFIG_FILE" | cut -d : -f1) 44 | a=$((a - 1)) 45 | b=$((b + 1)) 46 | sed -i "$a,$b"d "$CONFIG_FILE" 47 | echo -en "$HAPROXY_LB_CONFIG" >> $CONFIG_FILE 48 | fi 49 | 50 | if [ "$(pgrep -c haproxy)" -le 0 ]; then 51 | service haproxy start 52 | else 53 | service haproxy restart 54 | fi 55 | -------------------------------------------------------------------------------- /0x0F-load_balancer/2-puppet_custom_http_response_header.pp: -------------------------------------------------------------------------------- 1 | # creates a custom HTTP header response 2 | exec { 'command': 3 | command => 'apt-get -y update; 4 | apt-get -y install nginx; 5 | sudo sed -i "/listen 80 default_server;/a add_header X-Served-By $HOSTNAME;" /etc/nginx/sites-available/default; 6 | service nginx restart', 7 | provider => shell, 8 | } 9 | -------------------------------------------------------------------------------- /0x0F-load_balancer/README.md: -------------------------------------------------------------------------------- 1 | A load balancer is a networking device or software application designed to efficiently distribute incoming network traffic across multiple servers or resources. The primary purpose of a load balancer is to ensure that no single server becomes overwhelmed with traffic, optimizing resource utilization, preventing performance degradation, and enhancing the overall availability and reliability of a system. 2 | 3 | Key characteristics of load balancers include: 4 | 5 | Traffic Distribution: Load balancers distribute incoming requests or traffic among multiple servers, ensuring that each server shares the workload. This prevents any single server from becoming a bottleneck and improves the overall performance and response time. 6 | 7 | High Availability: Load balancing enhances system reliability by directing traffic to servers that are operational. If one server fails or experiences issues, the load balancer automatically redirects traffic to other healthy servers, minimizing downtime and ensuring continuous service availability. 8 | 9 | Scalability: Load balancers facilitate the scaling of applications and services by adding or removing servers based on demand. This scalability ensures that the system can handle increased traffic and adapt to changing workloads. 10 | 11 | Session Persistence: Some load balancers support session persistence, directing a user's requests to the same server throughout their session. This is particularly useful for applications that require consistent state, such as those using cookies or session data. 12 | 13 | Health Monitoring: Load balancers continuously monitor the health and status of individual servers. If a server becomes unavailable or experiences issues, the load balancer detects this and redistributes traffic to healthy servers, preventing users from accessing a failing server. 14 | 15 | Layered Load Balancing: Load balancing can occur at different layers of the OSI model, including Layer 4 (transport layer) and Layer 7 (application layer). Layer 4 load balancing considers factors like IP addresses and port numbers, while Layer 7 load balancing involves application-specific data for more advanced routing. 16 | 17 | Load balancers are crucial components in the architecture of modern applications and websites, particularly in environments with high traffic volume or complex infrastructure. They contribute to improved performance, scalability, and fault tolerance, making them essential for delivering a seamless and reliable user experience. 18 | -------------------------------------------------------------------------------- /0x0F-load_balancer/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x0F-load_balancer/index.html -------------------------------------------------------------------------------- /0x10-https_ssl/0-world_wide_web: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # write a Bash script that will display information about the subdomains 3 | 4 | dns_config () { 5 | script=$(dig "$2"."$1" | grep -A1 'ANSWER SECTION:' | tr '\t' '\n' | tail -2 | tr '\n' ' ') 6 | echo "$2 $script" | awk '{print "The subdomain " $1 " is a " $2 " record and points to " $3}' 7 | } 8 | 9 | if [ "$#" == 1 ] 10 | then 11 | dns_config "$1" "www" 12 | dns_config "$1" "lb-01" 13 | dns_config "$1" "web-01" 14 | dns_config "$1" "web-02" 15 | elif [ "$#" == 2 ] 16 | then 17 | dns_config "$1" "$2" 18 | fi 19 | -------------------------------------------------------------------------------- /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 | user haproxy 8 | group haproxy 9 | daemon 10 | 11 | # Default SSL material locations 12 | ca-base /etc/ssl/certs 13 | crt-base /etc/ssl/private 14 | 15 | # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate 16 | 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 17 | ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 18 | ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets 19 | 20 | defaults 21 | log global 22 | mode http 23 | option httplog 24 | option dontlognull 25 | timeout connect 5000 26 | timeout client 50000 27 | timeout server 50000 28 | errorfile 400 /etc/haproxy/errors/400.http 29 | errorfile 403 /etc/haproxy/errors/403.http 30 | errorfile 408 /etc/haproxy/errors/408.http 31 | errorfile 500 /etc/haproxy/errors/500.http 32 | errorfile 502 /etc/haproxy/errors/502.http 33 | errorfile 503 /etc/haproxy/errors/503.http 34 | errorfile 504 /etc/haproxy/errors/504.http 35 | frontend www-http 36 | bind *:80 37 | http-request set-header X-Forwarded-Proto http 38 | default_backend www-backend 39 | frontend www-https 40 | bind *:443 ssl crt /etc/letsencrypt/archive/www.anbesa.tech/www.anbesa.tech.pem 41 | http-request set-header X-Forwarded-Proto https 42 | acl letsencrypt-acl path_beg /.well_known/acme-challenges/ 43 | default_backend www-backend 44 | backend www-backend 45 | balance roundrobin 46 | redirect scheme https if !{ ssl_fc } 47 | server 208899-web-01 52.204.95.133:80 check 48 | server 208899-web-02 54.236.33.253:80 check 49 | -------------------------------------------------------------------------------- /0x10-https_ssl/100-redirect_http_to_https: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | maxconn 2048 4 | user haproxy 5 | group haproxy 6 | tune.ssl.default-dh-param 2048 7 | 8 | defaults 9 | log global 10 | mode http 11 | option httplog 12 | option dontlognull 13 | retries 3 14 | option redispatch 15 | timeout connect 5000 16 | timeout client 10000 17 | timeout server 10000 18 | option forwardfor 19 | option http-server-close 20 | 21 | frontend www-http 22 | bind 0.0.0.0:80 23 | reqadd X-Forwarded-Proto:\ http 24 | default_backend www-backend 25 | redirect scheme https code 301 if !{ ssl_fc } 26 | 27 | frontend www-https 28 | bind 0.0.0.0:443 ssl crt /etc/haproxy/certs/www.bdbnb.site.pem 29 | reqadd X-Forwarded-Proto:\ https 30 | acl letsencrypt-acl path_beg /.well-known/acme-challenge/ 31 | use_backend letsencrypt-backend if letsencrypt-acl 32 | default_backend www-backend 33 | 34 | backend www-backend 35 | balance roundrobin 36 | redirect scheme https if !{ ssl_fc } 37 | server 208899-web-01 52.204.95.133:80 check 38 | server 208899-web-02 54.236.33.253:80 check 39 | 40 | backend letsencrypt-backend 41 | server letsencrypt 127.0.0.1:54321 42 | -------------------------------------------------------------------------------- /0x10-https_ssl/README.md: -------------------------------------------------------------------------------- 1 | https ssl/tls 2 | -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/0-blog_post: -------------------------------------------------------------------------------- 1 | Title: The Journey of a URL: Exploring the Mechanics of Loading Google's Homepage 2 | 3 | When you type "https://www.google.com" into your browser and press Enter, it initiates a complex sequence of events behind the scenes. Let's take a closer look at the journey your request goes through, from the moment you hit Enter to the moment Google's homepage appears on your screen. 4 | 5 | 1. DNS Request: 6 | The process begins with a Domain Name System (DNS) request. Your browser needs to translate the human-readable domain name "www.google.com" into an IP address that computers can understand. It sends a request to a DNS server, which responds with the corresponding IP address for Google's servers. 7 | 2. TCP/IP: 8 | With the IP address in hand, your browser initiates a Transmission Control Protocol (TCP) connection to the server. This connection is established through the Internet Protocol (IP), allowing for the reliable exchange of data between your computer and Google's servers. 9 | 3. Firewall: 10 | Before your request reaches Google's servers, it may pass through a firewall, a security barrier that monitors and controls incoming and outgoing network traffic. The firewall ensures that only authorized traffic is allowed through, protecting the server from potential security threats. 11 | 4. HTTPS/SSL: 12 | To secure the communication between your browser and Google's servers, the Hypertext Transfer Protocol Secure (HTTPS) is employed. This is an extension of HTTP, with an added layer of security provided by the Secure Sockets Layer (SSL) or its successor, Transport Layer Security (TLS). This encryption ensures that the data exchanged between your browser and Google is secure and cannot be easily intercepted by malicious actors. Let us see how the ssl works with https in detail. 13 | i. Request Initiation: 14 | When you type "https://www.google.com" in your browser and press Enter, the browser sends an HTTP request to the server to retrieve the requested webpage. 15 | ii. SSL Handshake: 16 | Before any data is exchanged, an SSL handshake takes place. This is a process where the client and server establish a secure connection. Here's a step-by-step breakdown: 17 | a. ClientHello: Your browser initiates the handshake by sending a message called ClientHello to the server. This message includes information about the SSL/TLS versions supported by the browser, encryption algorithms, and other parameters. 18 | b. ServerHello: The server responds with a message called ServerHello, selecting the highest SSL/TLS version compatible with the client and choosing a cipher suite for encryption. The server also sends its digital certificate. 19 | c. Certificate Verification: Your browser checks the digital certificate provided by the server. This certificate contains the server's public key and is signed by a trusted Certificate Authority (CA). If the certificate is valid and trusted, the browser proceeds with the handshake. 20 | d. Key Exchange: The client and server exchange key information to establish a symmetric session key. This session key will be used for encrypting and decrypting data during the current session. 21 | e. Finished: Both the client and server send a Finished message, indicating that the handshake is complete, and the secure connection is established. 22 | iii. Data Encryption: 23 | Once the SSL handshake is successfully completed, the actual data transfer begins. The data exchanged between the client and server is encrypted using the symmetric session key established during the handshake. This encryption prevents eavesdroppers from intercepting and understanding the data. 24 | iv. Data Decryption: 25 | On the server side, Google's server uses its private key (part of the server's digital certificate) to decrypt the data received from your browser. The server then processes the decrypted information, which may include your request for a specific webpage or any other interaction. 26 | v. Response Encryption: 27 | When the server sends back the requested data (e.g., the Google homepage), it encrypts the data using the established symmetric session key. 28 | vi. Response Decryption: 29 | Your browser, upon receiving the encrypted response, uses the symmetric session key t o decrypt the data. This ensures that only your browser and the server can understand the exchanged information. 30 | In summary, HTTPS/SSL employs a combination of asymmetric and symmetric encryption to secure the communication between the client and the server. The SSL handshake establishes a secure connection, and the subsequent data exchange is encrypted and decrypted using keys, providing a robust layer of security for online transactions and information transfer. This encryption ensures the confidentiality and integrity of the data exchanged between your browser and Google's servers. 31 | 5. Load-Balancer: 32 | Large-scale websites like Google use load balancers to distribute incoming traffic across multiple servers. This helps ensure efficient utilization of resources and prevents any single server from becoming overwhelmed. The load balancer directs your request to one of Google's many servers. 33 | 6. Web Server:Upon reaching the selected server, your request is handled by a web server. This server is responsible for processing your request, fetching the necessary resources, such as HTML, CSS, and JavaScript files, and generating the content to be displayed on your browser. 34 | 7. Application Server: For dynamic content or interactive features, an application server may come into play. This server executes server-side code, interacts with databases, and generates content based on your specific request. 35 | 8. Database:If your request involves retrieving or storing data, the application server communicates with a database. In Google's case, this could include fetching search results from an immense database. 36 | 37 | In conclusion, the seemingly simple act of typing "https://www.google.com" and pressing Enter sets off a sophisticated chain of events involving DNS resolution, TCP/IP connections, security measures, load balancing, web servers, application servers, and databases. The efficiency and reliability of this process contribute to the seamless experience of accessing websites in today's digital age.. 38 | -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/1-what_happen_when_diagram: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/1-what_happen_when_diagram -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/2-contribution-to_what-happens-when_github_answer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/2-contribution-to_what-happens-when_github_answer -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/README.md: -------------------------------------------------------------------------------- 1 | Title: The Journey of a URL: Exploring the Mechanics of Loading Google's Homepage 2 | 3 | When you type "https://www.google.com" into your browser and press Enter, it initiates a complex sequence of events behind the scenes. Let's take a closer look at the journey your request goes through, from the moment you hit Enter to the moment Google's homepage appears on your screen. 4 | 5 | 1. DNS Request: 6 | The process begins with a Domain Name System (DNS) request. Your browser needs to translate the human-readable domain name "www.google.com" into an IP address that computers can understand. It sends a request to a DNS server, which responds with the corresponding IP address for Google's servers. 7 | 2. TCP/IP: 8 | With the IP address in hand, your browser initiates a Transmission Control Protocol (TCP) connection to the server. This connection is established through the Internet Protocol (IP), allowing for the reliable exchange of data between your computer and Google's servers. 9 | 3. Firewall: 10 | Before your request reaches Google's servers, it may pass through a firewall, a security barrier that monitors and controls incoming and outgoing network traffic. The firewall ensures that only authorized traffic is allowed through, protecting the server from potential security threats. 11 | 4. HTTPS/SSL: 12 | To secure the communication between your browser and Google's servers, the Hypertext Transfer Protocol Secure (HTTPS) is employed. This is an extension of HTTP, with an added layer of security provided by the Secure Sockets Layer (SSL) or its successor, Transport Layer Security (TLS). This encryption ensures that the data exchanged between your browser and Google is secure and cannot be easily intercepted by malicious actors. Let us see how the ssl works with https in detail. 13 | i. Request Initiation: 14 | When you type "https://www.google.com" in your browser and press Enter, the browser sends an HTTP request to the server to retrieve the requested webpage. 15 | ii. SSL Handshake: 16 | Before any data is exchanged, an SSL handshake takes place. This is a process where the client and server establish a secure connection. Here's a step-by-step breakdown: 17 | a. ClientHello: Your browser initiates the handshake by sending a message called ClientHello to the server. This message includes information about the SSL/TLS versions supported by the browser, encryption algorithms, and other parameters. 18 | b. ServerHello: The server responds with a message called ServerHello, selecting the highest SSL/TLS version compatible with the client and choosing a cipher suite for encryption. The server also sends its digital certificate. 19 | c. Certificate Verification: Your browser checks the digital certificate provided by the server. This certificate contains the server's public key and is signed by a trusted Certificate Authority (CA). If the certificate is valid and trusted, the browser proceeds with the handshake. 20 | d. Key Exchange: The client and server exchange key information to establish a symmetric session key. This session key will be used for encrypting and decrypting data during the current session. 21 | e. Finished: Both the client and server send a Finished message, indicating that the handshake is complete, and the secure connection is established. 22 | iii. Data Encryption: 23 | Once the SSL handshake is successfully completed, the actual data transfer begins. The data exchanged between the client and server is encrypted using the symmetric session key established during the handshake. This encryption prevents eavesdroppers from intercepting and understanding the data. 24 | iv. Data Decryption: 25 | On the server side, Google's server uses its private key (part of the server's digital certificate) to decrypt the data received from your browser. The server then processes the decrypted information, which may include your request for a specific webpage or any other interaction. 26 | v. Response Encryption: 27 | When the server sends back the requested data (e.g., the Google homepage), it encrypts the data using the established symmetric session key. 28 | vi. Response Decryption: 29 | Your browser, upon receiving the encrypted response, uses the symmetric session key t o decrypt the data. This ensures that only your browser and the server can understand the exchanged information. 30 | In summary, HTTPS/SSL employs a combination of asymmetric and symmetric encryption to secure the communication between the client and the server. The SSL handshake establishes a secure connection, and the subsequent data exchange is encrypted and decrypted using keys, providing a robust layer of security for online transactions and information transfer. This encryption ensures the confidentiality and integrity of the data exchanged between your browser and Google's servers. 31 | 5. Load-Balancer: 32 | Large-scale websites like Google use load balancers to distribute incoming traffic across multiple servers. This helps ensure efficient utilization of resources and prevents any single server from becoming overwhelmed. The load balancer directs your request to one of Google's many servers. 33 | 6. Web Server:Upon reaching the selected server, your request is handled by a web server. This server is responsible for processing your request, fetching the necessary resources, such as HTML, CSS, and JavaScript files, and generating the content to be displayed on your browser. 34 | 7. Application Server: For dynamic content or interactive features, an application server may come into play. This server executes server-side code, interacts with databases, and generates content based on your specific request. 35 | 8. Database:If your request involves retrieving or storing data, the application server communicates with a database. In Google's case, this could include fetching search results from an immense database. 36 | 37 | In conclusion, the seemingly simple act of typing "https://www.google.com" and pressing Enter sets off a sophisticated chain of events involving DNS resolution, TCP/IP connections, security measures, load balancing, web servers, application servers, and databases. The efficiency and reliability of this process contribute to the seamless experience of accessing websites in today's digital age.. 38 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/0-iamsomeoneelse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Check if username is provided as an argument 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | sudo -u "$1" whoami -------------------------------------------------------------------------------- /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 to 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 | web stack debugging 2 | -------------------------------------------------------------------------------- /0x13-firewall/0-block_all_incoming_traffic_but: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Configures a ufw firewall to block all incoming traffic 3 | #except for TCP ports 22, 443 and 80. 4 | apt-get install ufw 5 | sed -i 's/IPV6=.*/IPV6=yes/' /etc/default/ufw 6 | ufw disable 7 | ufw enable 8 | ufw default deny incoming 9 | ufw default allow outgoing 10 | ufw allow 22/tcp 11 | ufw allow 443/tcp 12 | ufw allow 80/tcp -------------------------------------------------------------------------------- /0x13-firewall/README.md: -------------------------------------------------------------------------------- 1 | A firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules. It acts as a barrier between a trusted internal network and untrusted external networks, such as the internet. The primary purpose of a firewall is to establish a security perimeter, preventing unauthorized access and protecting sensitive information from potential threats. 2 | 3 | Key characteristics and functions of a firewall include: 4 | 5 | Packet Filtering: Firewalls inspect packets of data moving through the network and make decisions based on predefined rules. These rules can specify which types of packets are allowed or denied based on factors like source and destination IP addresses, ports, and protocols. 6 | 7 | Stateful Inspection: Modern firewalls often employ stateful inspection, which keeps track of the state of active connections. This allows the firewall to make more informed decisions by considering the context of the traffic, rather than just individual packets. 8 | 9 | Proxy Services: Some firewalls act as proxies, serving as intermediaries between internal users and external services. They forward requests and responses on behalf of the users, adding an additional layer of security by hiding internal network details. 10 | 11 | Network Address Translation (NAT): Firewalls may use NAT to modify network address information in packet headers. This helps conceal the internal network structure and conserve public IP addresses. 12 | 13 | Logging and Monitoring: Firewalls often provide logging capabilities, allowing administrators to track and analyze network activity. Monitoring tools can help identify suspicious patterns or potential security incidents. 14 | 15 | Virtual Private Network (VPN) Support: Many firewalls support VPNs, enabling secure communication over the internet by encrypting data traffic between remote users or branch offices and the corporate network. 16 | 17 | Application Layer Filtering: Some firewalls can inspect and control traffic at the application layer, making decisions based on the specific applications or services being accessed. 18 | 19 | Firewalls play a crucial role in enhancing network security by enforcing access policies and mitigating the risk of unauthorized access, cyberattacks, and data breaches. Organizations often use a combination of hardware and software firewalls to create layered defenses and safeguard their networks against a diverse range of threats. 20 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_primary: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | pid-file = /var/run/mysqld/mysqld.pid 3 | socket = /var/run/mysqld/mysqld.sock 4 | datadir = /var/lib/mysql 5 | log-error = /var/log/mysql/error.log 6 | symbolic-links = 0 7 | server-id = 1 8 | log_bin = /var/log/mysql/mysql-bin.log 9 | binlog_do_db = tyrell_corp 10 | -------------------------------------------------------------------------------- /0x14-mysql/4-mysql_configuration_replica: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | pid-file = /var/run/mysqld/mysqld.pid 3 | socket = /var/run/mysqld/mysqld.sock 4 | datadir = /var/lib/mysql 5 | log-error = /var/log/mysql/error.log 6 | bind-address = 0.0.0.0 7 | symbolic-links = 0 8 | server-id = 2 9 | log_bin = /var/log/mysql/mysql-bin.log 10 | relay_log = /var/log/mysql/mysql-relay-bin 11 | binlog_do_db = tyrell_corp 12 | -------------------------------------------------------------------------------- /0x14-mysql/5-mysql_backup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x14-mysql/5-mysql_backup -------------------------------------------------------------------------------- /0x14-mysql/README.md: -------------------------------------------------------------------------------- 1 | MYSQL configuration 2 | -------------------------------------------------------------------------------- /0x15-api/0-gather_data_from_an_API.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Returns to-do list information for a given employee ID.""" 3 | 4 | import requests 5 | import sys 6 | 7 | 8 | if __name__ == "__main__": 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(sys.argv[1])).json() 11 | todos = requests.get(url + "todos", params={"userId": sys.argv[1]}).json() 12 | 13 | completed = [t.get("title") for t in todos if t.get("completed")] 14 | print("Employee {} is done with tasks({}/{}):".format( 15 | user.get("name"), len(completed), len(todos))) 16 | [print("\t {}".format(c)) for c in completed] 17 | -------------------------------------------------------------------------------- /0x15-api/1-export_to_CSV.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to CSV format.""" 3 | import csv 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.csv".format(user_id), "w", newline="") as csvfile: 15 | writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) 16 | [writer.writerow( 17 | [user_id, username, t.get("completed"), t.get("title")] 18 | ) for t in todos] 19 | -------------------------------------------------------------------------------- /0x15-api/2-export_to_JSON.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to JSON format.""" 3 | import json 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.json".format(user_id), "w") as jsonfile: 15 | json.dump( 16 | {user_id: [ 17 | { 18 | "task": t.get("title"), 19 | "completed": t.get("completed"), 20 | "username": username 21 | } for t in todos 22 | ]}, 23 | jsonfile 24 | ) 25 | -------------------------------------------------------------------------------- /0x15-api/3-dictionary_of_list_of_dictionaries.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information of all employees to JSON format.""" 3 | import json 4 | import requests 5 | 6 | if __name__ == "__main__": 7 | url = "https://jsonplaceholder.typicode.com/" 8 | users = requests.get(url + "users").json() 9 | 10 | with open("todo_all_employees.json", "w") as jsonfile: 11 | json.dump( 12 | { 13 | u.get("id"): [ 14 | { 15 | "task": t.get("title"), 16 | "completed": t.get("completed"), 17 | "username": u.get("username") 18 | } for t in requests.get(url + "todos", 19 | params={"userId": u.get("id")}).json() 20 | ] for u in users 21 | }, 22 | jsonfile, 23 | indent=2 24 | ) -------------------------------------------------------------------------------- /0x15-api/README.md: -------------------------------------------------------------------------------- 1 | """Learning Objectives 2 | At the end of this project, you are expected to be able to explain to anyone, without the help of Google: 3 | 4 | General 5 | What Bash scripting should not be used for 6 | What is an API 7 | What is a REST API 8 | What are microservices 9 | What is the CSV format 10 | What is the JSON format 11 | Pythonic Package and module name style 12 | Pythonic Class name style 13 | Pythonic Variable name style 14 | Pythonic Function name style 15 | Pythonic Constant name style 16 | Significance of CapWords or CamelCase in Python 17 | Copyright - Plagiarism 18 | You are tasked to come up with solutions for the tasks below yourself to meet with the above learning objectives. 19 | You will not be able to meet the objectives of this or any following project by copying and pasting someone else’s work. 20 | You are not allowed to publish any content of this project. 21 | Any form of plagiarism is strictly forbidden and will result in removal from the program. 22 | Requirements 23 | General 24 | Allowed editors: vi, vim, emacs 25 | All your files will be interpreted/compiled on Ubuntu 20.04 LTS using python3 (version 3.8.5) 26 | All your files should end with a new line 27 | The first line of all your files should be exactly #!/usr/bin/python3 28 | Libraries imported in your Python files must be organized in alphabetical order 29 | A README.md file, at the root of the folder of the project, is mandatory 30 | Your code should use the pycodestyle (version 2.8.*) 31 | All your files must be executable 32 | The length of your files will be tested using wc 33 | All your modules should have a documentation (python3 -c 'print(__import__("my_module").__doc__)') 34 | You must use get to access to dictionary value by key (it won’t throw an exception if the key doesn’t exist in the dictionary) 35 | Your code should not be executed when imported (by using if __name__ == "__main__":) 36 | Tasks 37 | 0. Gather data from an API 38 | mandatory 39 | Write a Python script that, using this REST API, for a given employee ID, returns information about his/her TODO list progress. 40 | 41 | Requirements: 42 | 43 | You must use urllib or requests module 44 | The script must accept an integer as a parameter, which is the employee ID 45 | The script must display on the standard output the employee TODO list progress in this exact format: 46 | First line: Employee EMPLOYEE_NAME is done with tasks(NUMBER_OF_DONE_TASKS/TOTAL_NUMBER_OF_TASKS): 47 | EMPLOYEE_NAME: name of the employee 48 | NUMBER_OF_DONE_TASKS: number of completed tasks 49 | TOTAL_NUMBER_OF_TASKS: total number of tasks, which is the sum of completed and non-completed tasks 50 | Second and N next lines display the title of completed tasks: TASK_TITLE (with 1 tabulation and 1 space before the TASK_TITLE) 51 | Example: 52 | 53 | sylvain@ubuntu$ python3 0-gather_data_from_an_API.py 2 54 | Employee Ervin Howell is done with tasks(8/20): 55 | distinctio vitae autem nihil ut molestias quo 56 | voluptas quo tenetur perspiciatis explicabo natus 57 | aliquam aut quasi 58 | veritatis pariatur delectus 59 | nemo perspiciatis repellat ut dolor libero commodi blanditiis omnis 60 | repellendus veritatis molestias dicta incidunt 61 | excepturi deleniti adipisci voluptatem et neque optio illum ad 62 | totam atque quo nesciunt 63 | sylvain@ubuntu$ python3 0-gather_data_from_an_API.py 4 64 | Employee Patricia Lebsack is done with tasks(6/20): 65 | odit optio omnis qui sunt 66 | doloremque aut dolores quidem fuga qui nulla 67 | sint amet quia totam corporis qui exercitationem commodi 68 | sequi dolorem sed 69 | eum ipsa maxime ut 70 | tempore molestias dolores rerum sequi voluptates ipsum consequatur 71 | sylvain@ubuntu$ 72 | sylvain@ubuntu$ python3 0-gather_data_from_an_API.py 4 | tr " " "S" | tr "\t" "T" 73 | EmployeeSPatriciaSLebsackSisSdoneSwithStasks(6/20): 74 | TSoditSoptioSomnisSquiSsunt 75 | TSdoloremqueSautSdoloresSquidemSfugaSquiSnulla 76 | TSsintSametSquiaStotamScorporisSquiSexercitationemScommodi 77 | TSsequiSdoloremSsed 78 | TSeumSipsaSmaximeSut 79 | TStemporeSmolestiasSdoloresSrerumSsequiSvoluptatesSipsumSconsequatur 80 | sylvain@ubuntu$ 81 | Repo: 82 | 83 | GitHub repository: alx-system_engineering-devops 84 | Directory: 0x15-api 85 | File: 0-gather_data_from_an_API.py 86 | 87 | 1. Export to CSV 88 | mandatory 89 | Using what you did in the task #0, extend your Python script to export data in the CSV format. 90 | 91 | Requirements: 92 | 93 | Records all tasks that are owned by this employee 94 | Format must be: "USER_ID","USERNAME","TASK_COMPLETED_STATUS","TASK_TITLE" 95 | File name must be: USER_ID.csv 96 | Example: 97 | 98 | sylvain@ubuntu$ python3 1-export_to_CSV.py 2 99 | sylvain@ubuntu$ cat 2.csv 100 | "2","Antonette","False","suscipit repellat esse quibusdam voluptatem incidunt" 101 | "2","Antonette","True","distinctio vitae autem nihil ut molestias quo" 102 | "2","Antonette","False","et itaque necessitatibus maxime molestiae qui quas velit" 103 | "2","Antonette","False","adipisci non ad dicta qui amet quaerat doloribus ea" 104 | "2","Antonette","True","voluptas quo tenetur perspiciatis explicabo natus" 105 | "2","Antonette","True","aliquam aut quasi" 106 | "2","Antonette","True","veritatis pariatur delectus" 107 | "2","Antonette","False","nesciunt totam sit blanditiis sit" 108 | "2","Antonette","False","laborum aut in quam" 109 | "2","Antonette","True","nemo perspiciatis repellat ut dolor libero commodi blanditiis omnis" 110 | "2","Antonette","False","repudiandae totam in est sint facere fuga" 111 | "2","Antonette","False","earum doloribus ea doloremque quis" 112 | "2","Antonette","False","sint sit aut vero" 113 | "2","Antonette","False","porro aut necessitatibus eaque distinctio" 114 | "2","Antonette","True","repellendus veritatis molestias dicta incidunt" 115 | "2","Antonette","True","excepturi deleniti adipisci voluptatem et neque optio illum ad" 116 | "2","Antonette","False","sunt cum tempora" 117 | "2","Antonette","False","totam quia non" 118 | "2","Antonette","False","doloremque quibusdam asperiores libero corrupti illum qui omnis" 119 | "2","Antonette","True","totam atque quo nesciunt" 120 | sylvain@ubuntu$ 121 | Repo: 122 | 123 | GitHub repository: alx-system_engineering-devops 124 | Directory: 0x15-api 125 | File: 1-export_to_CSV.py 126 | 127 | 2. Export to JSON 128 | mandatory 129 | Using what you did in the task #0, extend your Python script to export data in the JSON format. 130 | 131 | Requirements: 132 | 133 | Records all tasks that are owned by this employee 134 | Format must be: { "USER_ID": [{"task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS, "username": "USERNAME"}, {"task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS, "username": "USERNAME"}, ... ]} 135 | File name must be: USER_ID.json 136 | Example: 137 | 138 | sylvain@ubuntu$ python3 2-export_to_JSON.py 2 139 | sylvain@ubuntu$ cat 2.json 140 | {"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"}]}sylvain@ubuntu$ 141 | Repo: 142 | 143 | GitHub repository: alx-system_engineering-devops 144 | Directory: 0x15-api 145 | File: 2-export_to_JSON.py 146 | 147 | 3. Dictionary of list of dictionaries 148 | mandatory 149 | Using what you did in the task #0, extend your Python script to export data in the JSON format. 150 | 151 | Requirements: 152 | 153 | Records all tasks from all employees 154 | Format must be: { "USER_ID": [ {"username": "USERNAME", "task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS}, {"username": "USERNAME", "task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS}, ... ], "USER_ID": [ {"username": "USERNAME", "task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS}, {"username": "USERNAME", "task": "TASK_TITLE", "completed": TASK_COMPLETED_STATUS}, ... ]} 155 | File name must be: todo_all_employees.json 156 | Example: 157 | 158 | sylvain@ubuntu$ python3 3-dictionary_of_list_of_dictionaries.py 159 | sylvain@ubuntu$ cat todo_all_employees.json 160 | {"1": [{"username": "Bret", "task": "delectus aut autem", "completed": false}, {"username": "Bret", "task": "quis ut nam facilis et officia qui", "completed": false}, {"username": "Bret", "task": "fugiat veniam minus", "completed": false}, {"username": "Bret", "task": "et porro tempora", "completed": true}, {"username": "Bret", "task": "laboriosam mollitia et enim quasi adipisci quia provident illum", "completed": false}, {"username": "Bret", "task": "qui ullam ratione quibusdam voluptatem quia omnis", "completed": false}, {"username": "Bret", "task": "illo expedita consequatur quia in", "completed": false}, {"username": "Bret", "task": "quo adipisci enim quam ut ab", "completed": true}, {"username": "Bret", "task": "molestiae perspiciatis ipsa", "completed": false}, {"username": "Bret", "task": "illo est ratione doloremque quia maiores aut", "completed": true}, {"username": "Bret", "task": "vero rerum temporibus dolor", "completed": true}, {"username": "Bret", "task": "ipsa repellendus fugit nisi", "completed": true}, {"username": "Bret", "task": "et doloremque nulla", "completed": false}, {"username": "Bret", "task": "repellendus sunt dolores architecto voluptatum", "completed": true}, {"username": "Bret", "task": "ab voluptatum amet voluptas", "completed": true}, {"username": "Bret", "task": "accusamus eos facilis sint et aut voluptatem", "completed": true}, {"username": "Bret", "task": "quo laboriosam deleniti aut qui", "completed": true}, {"username": "Bret", "task": "dolorum est consequatur ea mollitia in culpa", "completed": false}, {"username": "Bret", "task": "molestiae ipsa aut voluptatibus pariatur dolor nihil", "completed": true}, {"username": "Bret", "task": "ullam nobis libero sapiente ad optio sint", "completed": true}], "2": [{"username": "Antonette", "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}], "3": [{"username": "Samantha", "task": "aliquid amet impedit consequatur aspernatur placeat eaque fugiat suscipit", "completed": false}, {"username": "Samantha", "task": "rerum perferendis error quia ut eveniet", "completed": false}, {"username": "Samantha", "task": "tempore ut sint quis recusandae", "completed": true}, {"username": "Samantha", "task": "cum debitis quis accusamus doloremque ipsa natus sapiente omnis", "completed": true}, {"username": "Samantha", "task": "velit soluta adipisci molestias reiciendis harum", "completed": false}, {"username": "Samantha", "task": "vel voluptatem repellat nihil placeat corporis", "completed": false}, {"username": "Samantha", "task": "nam qui rerum fugiat accusamus", "completed": false}, {"username": "Samantha", "task": "sit reprehenderit omnis quia", "completed": false}, {"username": "Samantha", "task": "ut necessitatibus aut maiores debitis officia blanditiis velit et", "completed": false}, {"username": "Samantha", "task": "cupiditate necessitatibus ullam aut quis dolor voluptate", "completed": true}, {"username": "Samantha", "task": "distinctio exercitationem ab doloribus", "completed": false}, {"username": "Samantha", "task": "nesciunt dolorum quis recusandae ad pariatur ratione", "completed": false}, {"username": "Samantha", "task": "qui labore est occaecati recusandae aliquid quam", "completed": false}, {"username": "Samantha", "task": "quis et est ut voluptate quam dolor", "completed": true}, {"username": "Samantha", "task": "voluptatum omnis minima qui occaecati provident nulla voluptatem ratione", "completed": true}, {"username": "Samantha", "task": "deleniti ea temporibus enim", "completed": true}, {"username": "Samantha", "task": "pariatur et magnam ea doloribus similique voluptatem rerum quia", "completed": false}, {"username": "Samantha", "task": "est dicta totam qui explicabo doloribus qui dignissimos", "completed": false}, {"username": "Samantha", "task": "perspiciatis velit id laborum placeat iusto et aliquam odio", "completed": false}, {"username": "Samantha", "task": "et sequi qui architecto ut adipisci", "completed": true}], "4": [{"username": "Karianne", "task": "odit optio omnis qui sunt", "completed": true}, {"username": "Karianne", "task": "et placeat et tempore aspernatur sint numquam", "completed": false}, {"username": "Karianne", "task": "doloremque aut dolores quidem fuga qui nulla", "completed": true}, {"username": "Karianne", "task": "voluptas consequatur qui ut quia magnam nemo esse", "completed": false}, {"username": "Karianne", "task": "fugiat pariatur ratione ut asperiores necessitatibus magni", "completed": false}, {"username": "Karianne", "task": "rerum eum molestias autem voluptatum sit optio", "completed": false}, {"username": "Karianne", "task": "quia voluptatibus voluptatem quos similique maiores repellat", "completed": false}, {"username": "Karianne", "task": "aut id perspiciatis voluptatem iusto", "completed": false}, {"username": "Karianne", "task": "doloribus sint dolorum ab adipisci itaque dignissimos aliquam suscipit", "completed": false}, {"username": "Karianne", "task": "ut sequi accusantium et mollitia delectus sunt", "completed": false}, {"username": "Karianne", "task": "aut velit saepe ullam", "completed": false}, {"username": "Karianne", "task": "praesentium facilis facere quis harum voluptatibus voluptatem eum", "completed": false}, {"username": "Karianne", "task": "sint amet quia totam corporis qui exercitationem commodi", "completed": true}, {"username": "Karianne", "task": "expedita tempore nobis eveniet laborum maiores", "completed": false}, {"username": "Karianne", "task": "occaecati adipisci est possimus totam", "completed": false}, {"username": "Karianne", "task": "sequi dolorem sed", "completed": true}, {"username": "Karianne", "task": "maiores aut nesciunt delectus exercitationem vel assumenda eligendi at", "completed": false}, {"username": "Karianne", "task": "reiciendis est magnam amet nemo iste recusandae impedit quaerat", "completed": false}, {"username": "Karianne", "task": "eum ipsa maxime ut", "completed": true}, {"username": "Karianne", "task": "tempore molestias dolores rerum sequi voluptates ipsum consequatur", "completed": true}], "5": [{"username": "Kamren", "task": "suscipit qui totam", "completed": true}, {"username": "Kamren", "task": "voluptates eum voluptas et dicta", "completed": false}, {"username": "Kamren", "task": "quidem at rerum quis ex aut sit quam", "completed": true}, {"username": "Kamren", "task": "sunt veritatis ut voluptate", "completed": false}, {"username": "Kamren", "task": "et quia ad iste a", "completed": true}, {"username": "Kamren", "task": "incidunt ut saepe autem", "completed": true}, {"username": "Kamren", "task": "laudantium quae eligendi consequatur quia et vero autem", "completed": true}, {"username": "Kamren", "task": "vitae aut excepturi laboriosam sint aliquam et et accusantium", "completed": false}, {"username": "Kamren", "task": "sequi ut omnis et", "completed": true}, {"username": "Kamren", "task": "molestiae nisi accusantium tenetur dolorem et", "completed": true}, {"username": "Kamren", "task": "nulla quis consequatur saepe qui id expedita", "completed": true}, {"username": "Kamren", "task": "in omnis laboriosam", "completed": true}, {"username": "Kamren", "task": "odio iure consequatur molestiae quibusdam necessitatibus quia sint", "completed": true}, {"username": "Kamren", "task": "facilis modi saepe mollitia", "completed": false}, {"username": "Kamren", "task": "vel nihil et molestiae iusto assumenda nemo quo ut", "completed": true}, {"username": "Kamren", "task": "nobis suscipit ducimus enim asperiores voluptas", "completed": false}, {"username": "Kamren", "task": "dolorum laboriosam eos qui iure aliquam", "completed": false}, {"username": "Kamren", "task": "debitis accusantium ut quo facilis nihil quis sapiente necessitatibus", "completed": true}, {"username": "Kamren", "task": "neque voluptates ratione", "completed": false}, {"username": "Kamren", "task": "excepturi a et neque qui expedita vel voluptate", "completed": false}], "6": [{"username": "Leopoldo_Corkery", "task": "explicabo enim cumque porro aperiam occaecati minima", "completed": false}, {"username": "Leopoldo_Corkery", "task": "sed ab consequatur", "completed": false}, {"username": "Leopoldo_Corkery", "task": "non sunt delectus illo nulla tenetur enim omnis", "completed": false}, {"username": "Leopoldo_Corkery", "task": "excepturi non laudantium quo", "completed": false}, {"username": "Leopoldo_Corkery", "task": "totam quia dolorem et illum repellat voluptas optio", "completed": true}, {"username": "Leopoldo_Corkery", "task": "ad illo quis voluptatem temporibus", "completed": true}, {"username": "Leopoldo_Corkery", "task": "praesentium facilis omnis laudantium fugit ad iusto nihil nesciunt", "completed": false}, {"username": "Leopoldo_Corkery", "task": "a eos eaque nihil et exercitationem incidunt delectus", "completed": true}, {"username": "Leopoldo_Corkery", "task": "autem temporibus harum quisquam in culpa", "completed": true}, {"username": "Leopoldo_Corkery", "task": "aut aut ea corporis", "completed": true}, {"username": "Leopoldo_Corkery", "task": "magni accusantium labore et id quis provident", "completed": false}, {"username": "Leopoldo_Corkery", "task": "consectetur impedit quisquam qui deserunt non rerum consequuntur eius", "completed": false}, {"username": "Leopoldo_Corkery", "task": "quia atque aliquam sunt impedit voluptatum rerum assumenda nisi", "completed": false}, {"username": "Leopoldo_Corkery", "task": "cupiditate quos possimus corporis quisquam exercitationem beatae", "completed": false}, {"username": "Leopoldo_Corkery", "task": "sed et ea eum", "completed": false}, {"username": "Leopoldo_Corkery", "task": "ipsa dolores vel facilis ut", "completed": true}, {"username": "Leopoldo_Corkery", "task": "sequi quae est et qui qui eveniet asperiores", "completed": false}, {"username": "Leopoldo_Corkery", "task": "quia modi consequatur vero fugiat", "completed": false}, {"username": "Leopoldo_Corkery", "task": "corporis ducimus ea perspiciatis iste", "completed": false}, {"username": "Leopoldo_Corkery", "task": "dolorem laboriosam vel voluptas et aliquam quasi", "completed": false}], "7": [{"username": "Elwyn.Skiles", "task": "inventore aut nihil minima laudantium hic qui omnis", "completed": true}, {"username": "Elwyn.Skiles", "task": "provident aut nobis culpa", "completed": true}, {"username": "Elwyn.Skiles", "task": "esse et quis iste est earum aut impedit", "completed": false}, {"username": "Elwyn.Skiles", "task": "qui consectetur id", "completed": false}, {"username": "Elwyn.Skiles", "task": "aut quasi autem iste tempore illum possimus", "completed": false}, {"username": "Elwyn.Skiles", "task": "ut asperiores perspiciatis veniam ipsum rerum saepe", "completed": true}, {"username": "Elwyn.Skiles", "task": "voluptatem libero consectetur rerum ut", "completed": true}, {"username": "Elwyn.Skiles", "task": "eius omnis est qui voluptatem autem", "completed": false}, {"username": "Elwyn.Skiles", "task": "rerum culpa quis harum", "completed": false}, {"username": "Elwyn.Skiles", "task": "nulla aliquid eveniet harum laborum libero alias ut unde", "completed": true}, {"username": "Elwyn.Skiles", "task": "qui ea incidunt quis", "completed": false}, {"username": "Elwyn.Skiles", "task": "qui molestiae voluptatibus velit iure harum quisquam", "completed": true}, {"username": "Elwyn.Skiles", "task": "et labore eos enim rerum consequatur sunt", "completed": true}, {"username": "Elwyn.Skiles", "task": "molestiae doloribus et laborum quod ea", "completed": false}, {"username": "Elwyn.Skiles", "task": "facere ipsa nam eum voluptates reiciendis vero qui", "completed": false}, {"username": "Elwyn.Skiles", "task": "asperiores illo tempora fuga sed ut quasi adipisci", "completed": false}, {"username": "Elwyn.Skiles", "task": "qui sit non", "completed": false}, {"username": "Elwyn.Skiles", "task": "placeat minima consequatur rem qui ut", "completed": true}, {"username": "Elwyn.Skiles", "task": "consequatur doloribus id possimus voluptas a voluptatem", "completed": false}, {"username": "Elwyn.Skiles", "task": "aut consectetur in blanditiis deserunt quia sed laboriosam", "completed": true}], "8": [{"username": "Maxime_Nienow", "task": "explicabo consectetur debitis voluptates quas quae culpa rerum non", "completed": true}, {"username": "Maxime_Nienow", "task": "maiores accusantium architecto necessitatibus reiciendis ea aut", "completed": true}, {"username": "Maxime_Nienow", "task": "eum non recusandae cupiditate animi", "completed": false}, {"username": "Maxime_Nienow", "task": "ut eum exercitationem sint", "completed": false}, {"username": "Maxime_Nienow", "task": "beatae qui ullam incidunt voluptatem non nisi aliquam", "completed": false}, {"username": "Maxime_Nienow", "task": "molestiae suscipit ratione nihil odio libero impedit vero totam", "completed": true}, {"username": "Maxime_Nienow", "task": "eum itaque quod reprehenderit et facilis dolor autem ut", "completed": true}, {"username": "Maxime_Nienow", "task": "esse quas et quo quasi exercitationem", "completed": false}, {"username": "Maxime_Nienow", "task": "animi voluptas quod perferendis est", "completed": false}, {"username": "Maxime_Nienow", "task": "eos amet tempore laudantium fugit a", "completed": false}, {"username": "Maxime_Nienow", "task": "accusamus adipisci dicta qui quo ea explicabo sed vero", "completed": true}, {"username": "Maxime_Nienow", "task": "odit eligendi recusandae doloremque cumque non", "completed": false}, {"username": "Maxime_Nienow", "task": "ea aperiam consequatur qui repellat eos", "completed": false}, {"username": "Maxime_Nienow", "task": "rerum non ex sapiente", "completed": true}, {"username": "Maxime_Nienow", "task": "voluptatem nobis consequatur et assumenda magnam", "completed": true}, {"username": "Maxime_Nienow", "task": "nam quia quia nulla repellat assumenda quibusdam sit nobis", "completed": true}, {"username": "Maxime_Nienow", "task": "dolorem veniam quisquam deserunt repellendus", "completed": true}, {"username": "Maxime_Nienow", "task": "debitis vitae delectus et harum accusamus aut deleniti a", "completed": true}, {"username": "Maxime_Nienow", "task": "debitis adipisci quibusdam aliquam sed dolore ea praesentium nobis", "completed": true}, {"username": "Maxime_Nienow", "task": "et praesentium aliquam est", "completed": false}], "9": [{"username": "Delphine", "task": "ex hic consequuntur earum omnis alias ut occaecati culpa", "completed": true}, {"username": "Delphine", "task": "omnis laboriosam molestias animi sunt dolore", "completed": true}, {"username": "Delphine", "task": "natus corrupti maxime laudantium et voluptatem laboriosam odit", "completed": false}, {"username": "Delphine", "task": "reprehenderit quos aut aut consequatur est sed", "completed": false}, {"username": "Delphine", "task": "fugiat perferendis sed aut quidem", "completed": false}, {"username": "Delphine", "task": "quos quo possimus suscipit minima ut", "completed": false}, {"username": "Delphine", "task": "et quis minus quo a asperiores molestiae", "completed": false}, {"username": "Delphine", "task": "recusandae quia qui sunt libero", "completed": false}, {"username": "Delphine", "task": "ea odio perferendis officiis", "completed": true}, {"username": "Delphine", "task": "quisquam aliquam quia doloribus aut", "completed": false}, {"username": "Delphine", "task": "fugiat aut voluptatibus corrupti deleniti velit iste odio", "completed": true}, {"username": "Delphine", "task": "et provident amet rerum consectetur et voluptatum", "completed": false}, {"username": "Delphine", "task": "harum ad aperiam quis", "completed": false}, {"username": "Delphine", "task": "similique aut quo", "completed": false}, {"username": "Delphine", "task": "laudantium eius officia perferendis provident perspiciatis asperiores", "completed": true}, {"username": "Delphine", "task": "magni soluta corrupti ut maiores rem quidem", "completed": false}, {"username": "Delphine", "task": "et placeat temporibus voluptas est tempora quos quibusdam", "completed": false}, {"username": "Delphine", "task": "nesciunt itaque commodi tempore", "completed": true}, {"username": "Delphine", "task": "omnis consequuntur cupiditate impedit itaque ipsam quo", "completed": true}, {"username": "Delphine", "task": "debitis nisi et dolorem repellat et", "completed": true}], "10": [{"username": "Moriah.Stanton", "task": "ut cupiditate sequi aliquam fuga maiores", "completed": false}, {"username": "Moriah.Stanton", "task": "inventore saepe cumque et aut illum enim", "completed": true}, {"username": "Moriah.Stanton", "task": "omnis nulla eum aliquam distinctio", "completed": true}, {"username": "Moriah.Stanton", "task": "molestias modi perferendis perspiciatis", "completed": false}, {"username": "Moriah.Stanton", "task": "voluptates dignissimos sed doloribus animi quaerat aut", "completed": false}, {"username": "Moriah.Stanton", "task": "explicabo odio est et", "completed": false}, {"username": "Moriah.Stanton", "task": "consequuntur animi possimus", "completed": false}, {"username": "Moriah.Stanton", "task": "vel non beatae est", "completed": true}, {"username": "Moriah.Stanton", "task": "culpa eius et voluptatem et", "completed": true}, {"username": "Moriah.Stanton", "task": "accusamus sint iusto et voluptatem exercitationem", "completed": true}, {"username": "Moriah.Stanton", "task": "temporibus atque distinctio omnis eius impedit tempore molestias pariatur", "completed": true}, {"username": "Moriah.Stanton", "task": "ut quas possimus exercitationem sint voluptates", "completed": false}, {"username": "Moriah.Stanton", "task": "rerum debitis voluptatem qui eveniet tempora distinctio a", "completed": true}, {"username": "Moriah.Stanton", "task": "sed ut vero sit molestiae", "completed": false}, {"username": "Moriah.Stanton", "task": "rerum ex veniam mollitia voluptatibus pariatur", "completed": true}, {"username": "Moriah.Stanton", "task": "consequuntur aut ut fugit similique", "completed": true}, {"username": "Moriah.Stanton", "task": "dignissimos quo nobis earum saepe", "completed": true}, {"username": "Moriah.Stanton", "task": "quis eius est sint explicabo", "completed": true}, {"username": "Moriah.Stanton", "task": "numquam repellendus a magnam", "completed": true}, {"username": "Moriah.Stanton", "task": "ipsam aperiam voluptates qui", "completed": false}]}sylvain@ubuntu$ 161 | Repo: 162 | 163 | GitHub repository: alx-system_engineering-devops 164 | Directory: 0x15-api 165 | File: 3-dictionary_of_list_of_dictionaries.py 166 | 167 | """ -------------------------------------------------------------------------------- /0x16-api_advanced/0-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import requests 3 | import sys 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 | """ 3 | Queries the Reddit API and returns the number of subscribers 4 | (not active users, total subscribers) for a given subreddit. 5 | """ 6 | 7 | import requests 8 | 9 | def number_of_subscribers(subreddit): 10 | headers = { 11 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) Apple' + 12 | 'WebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36' 13 | } 14 | url = f'https://www.reddit.com/r/{subreddit}/about.json' 15 | r = requests.get(url, headers=headers, allow_redirects=False) 16 | if r.status_code >= 300: 17 | return 0 18 | json_data = r.json() 19 | data_dict = json_data.get('data') 20 | return data_dict.get('subscribers') 21 | ''' 22 | #!/usr/bin/python3 23 | 24 | import requests as r 25 | 26 | 27 | def number_of_subscribers(subreddit): 28 | """Text""" 29 | url = "https://www.reddit.com/r/{}/about.json".format(subreddit) 30 | headers = { 31 | "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:73.0) \ 32 | Gecko/20100101 Firefox/73.0" 33 | } 34 | response = r.get(url, headers=headers, allow_redirects=False) 35 | if response.status_code == 404: 36 | return 0 37 | results = response.json().get("data") 38 | return results.get("subscribers") 39 | -------------------------------------------------------------------------------- /0x16-api_advanced/1-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | #!/usr/bin/python3 4 | """ 5 | 1-main 6 | """ 7 | import sys 8 | 9 | if __name__ == '__main__': 10 | top_ten = __import__('1-top_ten').top_ten 11 | if len(sys.argv) < 2: 12 | print("Please pass an argument for the subreddit to search.") 13 | else: 14 | top_ten(sys.argv[1]) -------------------------------------------------------------------------------- /0x16-api_advanced/1-top_ten.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Queries the Reddit API and prints the titles of the first 10 hot posts 4 | listed for a given subreddit. 5 | """ 6 | 7 | import requests 8 | import sys 9 | 10 | def top_ten(subreddit): 11 | headers = { 12 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) Apple' + 13 | 'WebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36' 14 | } 15 | url = f'https://www.reddit.com/r/{subreddit}/hot.json?limit=10' 16 | 17 | try: 18 | response = requests.get(url, headers=headers, allow_redirects=False) 19 | response.raise_for_status() # Raise an exception if status code >= 400 20 | data = response.json() 21 | posts = data.get('data', {}).get('children', []) 22 | 23 | for post in posts: 24 | title = post.get('data', {}).get('title', '') 25 | print(title) 26 | if not posts: 27 | print("None") 28 | except requests.RequestException as e: 29 | print(f"Error: {e}") 30 | -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /0x16-api_advanced/2-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | 2-main 4 | """ 5 | import sys 6 | 7 | if __name__ == '__main__': 8 | recurse = __import__('2-recurse').recurse 9 | if len(sys.argv) < 2: 10 | print("Please pass an argument for the subreddit to search.") 11 | else: 12 | result = recurse(sys.argv[1]) 13 | if result is not None: 14 | print(len(result)) 15 | else: 16 | print("None") -------------------------------------------------------------------------------- /0x16-api_advanced/2-recurse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """queries the Reddit API and returns a list containing the titles of all 3 | hot articles for a given subreddit 4 | """ 5 | import requests 6 | 7 | 8 | def recurse(subreddit, hot_list=[], after=None): 9 | headers = { 10 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) Apple' + 11 | 'WebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36' 12 | } 13 | r = requests.get('https://www.reddit.com/r/{:}/hot.json?after={:}'.format( 14 | subreddit, after), headers=headers, allow_redirects=False) 15 | if r.status_code == 200: 16 | json = r.json() 17 | data_dict = json.get('data') 18 | post_list = data_dict.get('children') 19 | for post in post_list: 20 | post_data_dict = post.get('data') 21 | hot_list.append(post_data_dict.get('title')) 22 | after = data_dict.get('after') 23 | if data_dict.get('after') is None: 24 | return hot_list 25 | return recurse(subreddit, hot_list, after) 26 | else: 27 | return None -------------------------------------------------------------------------------- /0x16-api_advanced/README.md: -------------------------------------------------------------------------------- 1 | Advanced API 2 | -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/0-strace_is_your_friend.pp: -------------------------------------------------------------------------------- 1 | #replaces typo string in wp settings file 2 | exec { 'change to php': 3 | command => "sed -i 's/class-wp-locale.phpp/class-wp-locale.php/g' /var/www/html/wp-setti\ 4 | ngs.php", 5 | path => '/bin' 6 | } -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/README.md: -------------------------------------------------------------------------------- 1 | Web stack debugging 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/README.md: -------------------------------------------------------------------------------- 1 | 0x18-webstack_monitoring 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/ddagent-install.log: -------------------------------------------------------------------------------- 1 |  2 | * Datadog Agent 7 install script v1.26.0 3 |  4 |  5 | * Installing apt-transport-https, curl and gnupg 6 |  7 | Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease 8 | Hit:2 https://deb.nodesource.com/node_14.x focal InRelease 9 | Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] 10 | Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] 11 | Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease 12 | Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3095 kB] 13 | Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2715 kB] 14 | Get:8 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [413 kB] 15 | Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [497 kB] 16 | Get:10 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [2556 kB] 17 | Get:11 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [2673 kB] 18 | Get:12 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [357 kB] 19 | Get:13 http://archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [373 kB] 20 | Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [938 kB] 21 | Get:15 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [197 kB] 22 | Get:16 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1164 kB] 23 | Get:17 http://archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [279 kB] 24 | Get:18 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [26.1 kB] 25 | Fetched 15.5 MB in 14s (1084 kB/s) 26 | Reading package lists... 27 | Reading package lists... 28 | Building dependency tree... 29 | Reading state information... 30 | gnupg is already the newest version (2.2.19-3ubuntu2.2). 31 | gnupg set to manually installed. 32 | The following NEW packages will be installed: 33 | apt-transport-https 34 | The following packages will be upgraded: 35 | curl libcurl4 36 | 2 upgraded, 1 newly installed, 0 to remove and 99 not upgraded. 37 | Need to get 398 kB of archives. 38 | After this operation, 162 kB of additional disk space will be used. 39 | Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.10 [1704 B] 40 | Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.21 [161 kB] 41 | Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcurl4 amd64 7.68.0-1ubuntu2.21 [235 kB] 42 | Fetched 398 kB in 1s (282 kB/s) 43 | Selecting previously unselected package apt-transport-https. 44 | (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 61098 files and directories currently installed.) 45 | Preparing to unpack .../apt-transport-https_2.0.10_all.deb ... 46 | Unpacking apt-transport-https (2.0.10) ... 47 | Preparing to unpack .../curl_7.68.0-1ubuntu2.21_amd64.deb ... 48 | Unpacking curl (7.68.0-1ubuntu2.21) over (7.68.0-1ubuntu2.20) ... 49 | Preparing to unpack .../libcurl4_7.68.0-1ubuntu2.21_amd64.deb ... 50 | Unpacking libcurl4:amd64 (7.68.0-1ubuntu2.21) over (7.68.0-1ubuntu2.20) ... 51 | Setting up apt-transport-https (2.0.10) ... 52 | Setting up libcurl4:amd64 (7.68.0-1ubuntu2.21) ... 53 | Setting up curl (7.68.0-1ubuntu2.21) ... 54 | Processing triggers for man-db (2.9.1-1) ... 55 | Processing triggers for libc-bin (2.31-0ubuntu9.12) ... 56 |  57 | * Installing APT package sources for Datadog 58 |  59 | % Total % Received % Xferd Average Speed Time Time Time Current 60 | Dload Upload Total Spent Left Speed 61 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 6226 100 6226 0 0 6465 0 --:--:-- --:--:-- --:--:-- 6465 62 | gpg: directory '/root/.gnupg' created 63 | gpg: /root/.gnupg/trustdb.gpg: trustdb created 64 | gpg: key 32637D44F14F620E: public key "Datadog, Inc. Master key (2020-09-08) " imported 65 | gpg: Total number processed: 1 66 | gpg: imported: 1 67 | % Total % Received % Xferd Average Speed Time Time Time Current 68 | Dload Upload Total Spent Left Speed 69 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1713 100 1713 0 0 3244 0 --:--:-- --:--:-- --:--:-- 3238 70 | gpg: key E6266D4AC0962C7D: public key "Datadog, Inc. APT key (2023-04-20) (APT key) " imported 71 | gpg: Total number processed: 1 72 | gpg: imported: 1 73 | % Total % Received % Xferd Average Speed Time Time Time Current 74 | Dload Upload Total Spent Left Speed 75 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 6226 100 6226 0 0 16602 0 --:--:-- --:--:-- --:--:-- 16647 76 | gpg: key 32637D44F14F620E: "Datadog, Inc. Master key (2020-09-08) " not changed 77 | gpg: Total number processed: 1 78 | gpg: unchanged: 1 79 | % Total % Received % Xferd Average Speed Time Time Time Current 80 | Dload Upload Total Spent Left Speed 81 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 9001 100 9001 0 0 22169 0 --:--:-- --:--:-- --:--:-- 22115 100 9001 100 9001 0 0 22115 0 --:--:-- --:--:-- --:--:-- 22115 82 | gpg: key D3A80E30382E94DE: public key "Datadog, Inc " imported 83 | gpg: Total number processed: 1 84 | gpg: imported: 1 85 | Ign:1 https://apt.datadoghq.com stable InRelease 86 | Get:2 https://apt.datadoghq.com stable Release [17.8 kB] 87 | Get:3 https://apt.datadoghq.com stable Release.gpg [801 B] 88 | Get:4 https://apt.datadoghq.com stable/7 amd64 Packages [58.9 kB] 89 | Get:5 https://apt.datadoghq.com stable/7 all Packages [1073 B] 90 | Fetched 78.5 kB in 2s (38.9 kB/s) 91 | Reading package lists... 92 | Installing package(s): datadog-agent datadog-signing-keys 93 |  94 | Reading package lists... 95 | Building dependency tree... 96 | Reading state information... 97 | The following NEW packages will be installed: 98 | datadog-agent datadog-signing-keys 99 | 0 upgraded, 2 newly installed, 0 to remove and 99 not upgraded. 100 | Need to get 404 MB of archives. 101 | After this operation, 1322 MB of additional disk space will be used. 102 | Get:1 https://apt.datadoghq.com stable/7 amd64 datadog-agent amd64 1:7.50.3-1 [404 MB] 103 | Get:2 https://apt.datadoghq.com stable/7 amd64 datadog-signing-keys all 1:1.3.1-1 [22.3 kB] 104 | Fetched 404 MB in 2min 51s (2368 kB/s) 105 | Selecting previously unselected package datadog-agent. 106 | (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 61102 files and directories currently installed.) 107 | Preparing to unpack .../datadog-agent_1%3a7.50.3-1_amd64.deb ... 108 | Unpacking datadog-agent (1:7.50.3-1) ... 109 | 110 | -------------------------------------------------------------------------------- /0x1A-application_server/2-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 default_server; 4 | 5 | location /airbnb-onepage/ { 6 | proxy_pass http://localhost:5000; 7 | proxy_set_header Host $host; 8 | proxy_set_header X-Real-IP $remote_addr; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /0x1A-application_server/3-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Sets ups Nginx so that the route /airbnb-onepage/ points to a Gunicorn instance listening on port 5000 and /airbnb-dynamic/number_odd_or_even/(any integer) points to a Gunicorn instance listening on port 5001 2 | server { 3 | listen 80; 4 | server_name _; 5 | location /airbnb-onepage { 6 | include proxy_params; 7 | proxy_pass http://127.0.0.1:5000; } 8 | location /airbnb-dynamic/number_odd_or_even/ { 9 | include proxy_params; 10 | proxy_pass http://127.0.0.1:5001/number_odd_or_even/; } 11 | } 12 | -------------------------------------------------------------------------------- /0x1A-application_server/4-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Sets up Nginx so that the route /api/ points to a Gunicorn instance listening on port 5002 - AirBnB clone REST API 2 | server { 3 | listen 80; 4 | server_name _; 5 | location /api/ { 6 | include proxy_params; 7 | proxy_pass http://127.0.0.1:5002; } 8 | } 9 | -------------------------------------------------------------------------------- /0x1A-application_server/4-reload_gunicorn_no_downtime: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/0x1A-application_server/4-reload_gunicorn_no_downtime -------------------------------------------------------------------------------- /0x1A-application_server/5-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | # Setups Nginx so that the route / points to Gunicorn instance listening on port 5003 and the route /api/ points to Gunicorn instance listening on port 5002 - AirBnB clone and API respectively 2 | server { 3 | listen 80; 4 | server_name _; 5 | root /home/ubuntu/AirBnB_clone_v4/web_dynamic/; 6 | location / { 7 | proxy_pass http://127.0.0.1:5003/2-hbnb/; 8 | } 9 | location /static/ {} 10 | location /api/ { 11 | include proxy_params; 12 | proxy_pass http://127.0.0.1:5002; } 13 | } 14 | -------------------------------------------------------------------------------- /0x1A-application_server/README.md: -------------------------------------------------------------------------------- 1 | 0x1A-application_server 2 | -------------------------------------------------------------------------------- /0x1A-application_server/gunicorn.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Gunicorn instance to serve 2-hbnb.py 3 | After=network.target 4 | 5 | [Service] 6 | User=ubuntu # Replace with your actual username 7 | Group=www-data # Replace with your actual group name 8 | WorkingDirectory=/home/ubuntu/AirBnB_clone_v4/web_dynamic 9 | ExecStart=/usr/local/bin/gunicorn -b 0.0.0.0:5003 -w 3 -t 120 web_dynamic.2-hbnb:app 10 | Restart=always 11 | StandardOutput=syslog 12 | StandardError=syslog 13 | SyslogIdentifier=gunicorn-airbnb 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | 18 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/0-the_sky_is_the_limit_not.pp: -------------------------------------------------------------------------------- 1 | #increase the open file limit for to 4096 2 | exec { 'change ULIMIT': 3 | command => "sed -i 's/15/4096/g' /etc/default/nginx ; service nginx restart", 4 | path => ['/bin', '/usr/bin', '/usr/sbin'] 5 | } 6 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/1-user_limit.pp: -------------------------------------------------------------------------------- 1 | # Changes the OS configuration so that it is possible to login with the alx user and open a file without any error message 2 | exec { '/usr/bin/env sed -i "s/holberton/foo/" /etc/security/limits.conf': } 3 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/README.md: -------------------------------------------------------------------------------- 1 | web stack debugging 2 | -------------------------------------------------------------------------------- /command_line_for_the_win/0-first_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/command_line_for_the_win/0-first_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/1-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/command_line_for_the_win/1-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/2-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nathanage3/alx-system_engineering-devops/7bc2a3060d7ed3740d86193f14573adbefbfad2e/command_line_for_the_win/2-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/README.md: -------------------------------------------------------------------------------- 1 | Command line for the window 2 | --------------------------------------------------------------------------------