├── 0x00-shell_basics ├── 0-current_working_directory ├── 1-listit ├── 10-back ├── 100-lets_move ├── 101-clean_emacs ├── 102-tree ├── 103-commas ├── 11-lists ├── 12-file_type ├── 13-symbolic_link ├── 14-copy_html ├── 2-bring_me_home ├── 3-listfiles ├── 4-listmorefiles ├── 5-listfilesdigitonly ├── 6-firstdirectory ├── 7-movethatfile ├── 8-firstdelete ├── 9-firstdirdeletion ├── README.md └── school.mgc ├── 0x01-shell_permissions ├── 0-iam_betty ├── 1-who_am_i ├── 10-mirror_permissions ├── 100-change_owner_and_group ├── 101-symbolic_link_permissions ├── 102-if_only ├── 103-Star_Wars ├── 11-directories_permissions ├── 12-directory_permissions ├── 13-change_group ├── 2-groups ├── 3-new_owner ├── 4-empty ├── 5-execute ├── 6-multiple_permissions ├── 7-everybody ├── 8-James_Bond ├── 9-John_Doe └── README.md ├── 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 ├── .7-create_global_variable.swp ├── 0-alias ├── 1-hello_you ├── 10-love_exponent_breath ├── 100-decimal_to_hexadecimal ├── 101-rot13 ├── 102-odd ├── 103-water_and_stir ├── 11-binary_to_decimal ├── 12-combinations ├── 13-print_float ├── 2-path ├── 3-paths ├── 4-global_variables ├── 5-local_variables ├── 6-create_local_variable ├── 7-create_global_variable ├── 8-true_knowledge ├── 9-divide_and_rule └── README.md ├── 0x04-loops_conditions_and_parsing ├── 0-RSA_public_key.pub ├── 1-for_best_school ├── 10-fizzbuzz ├── 100-read_and_cut ├── 101-tell_the_story_of_passwd ├── 102-lets_parse_apache_logs ├── 103-dig_the-data ├── 2-while_best_school ├── 3-until_best_school ├── 4-if_9_say_hi ├── 5-4_bad_luck_8_is_your_chance ├── 6-superstitious_numbers ├── 7-clock ├── 8-for_ls ├── 9-to_file_or_not_to_file └── README.md ├── 0x05-processes_and_signals ├── 0-what-is-my-pid ├── 1-list_your_processes ├── 100-process_and_pid_file ├── 101-manage_my_process ├── 102-zombie.c ├── 2-show_your_bash_pid ├── 3-show_your_bash_pid_made_easy ├── 4-to_infinity_and_beyond ├── 5-dont_stop_me_now ├── 6-stop_me_if_you_can ├── 7-highlander ├── 8-beheaded_process ├── README.md └── manage_my_process ├── 0x06-regular_expressions ├── 0-simply_match_school.rb ├── 1-repetition_token_0.rb ├── 100-textme.rb ├── 2-repetition_token_1.rb ├── 3-repetition_token_2.rb ├── 4-repetition_token_3.rb ├── 5-beginning_and_end.rb ├── 6-phone_number.rb ├── 7-OMG_WHY_ARE_YOU_SHOUTING.rb └── README.md ├── 0x07-networking_basics ├── 0-OSI_model ├── 1-types_of_network ├── 2-MAC_and_IP_address ├── 3-UDP_and_TCP ├── 4-TCP_and_UDP_ports ├── 5-is_the_host_on_the_network └── README.md ├── 0x08-networking_basics_2 ├── 0-change_your_home_IP ├── 1-show_attached_IPs ├── 100-port_listening_on_localhost └── README.md ├── 0x09-web_infrastructure_design ├── 0-simple_web_stack ├── 1-distributed_web_infrastructure ├── 2-secured_and_monitored_web_infrastructure ├── 3-scale_up └── README.md ├── 0x0A-configuration_management ├── 0-create_a_file.pp ├── 1-install_a_package.pp ├── 2-execute_a_command.pp └── README.md ├── 0x0B-ssh ├── 0-use_a_private_key ├── 1-create_ssh_key_pair ├── 100-puppet_ssh_config.pp ├── 2-ssh_config └── README.md ├── 0x0C-web_server ├── 0-transfer_file ├── 1-install_nginx_web_server ├── 2-setup_a_domain_name ├── 3-redirection ├── 4-not_found_page_404 ├── 7-puppet_install_nginx_web_server.pp └── README.md ├── 0x0D-web_stack_debugging_0 ├── 0-give_me_a_page └── README.md ├── 0x0E-web_stack_debugging_1 ├── 0-nginx_likes_port_80 ├── 1-debugging_made_short └── README.md ├── 0x0F-load_balancer ├── 0-custom_http_response_header ├── 1-install_load_balancer ├── 2-puppet_custom_http_response_header.pp └── README.md ├── 0x10-https_ssl ├── 0-world_wide_web ├── 1-haproxy_ssl_termination ├── 100-redirect_http_to_https └── README.md ├── 0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter ├── 0-blog_post ├── 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 ├── 100-fix_in_7_lines_or_less └── README.md ├── 0x13-firewall ├── 0-block_all_incoming_traffic_but ├── 100-port_forwarding └── README.md ├── 0x14-mysql ├── 4-mysql_configuration_primary ├── 4-mysql_configuration_replica ├── 5-mysql_backup ├── README.md ├── install-log └── setup.sql ├── 0x15-api ├── 0-gather_data_from_an_API.py ├── 1-export_to_CSV.py ├── 2-export_to_JSON.py ├── 3-dictionary_of_list_of_dictionaries.py └── README.md ├── 0x16-api_advanced ├── 0-subs.py ├── 1-top_ten.py ├── 100-count.py ├── 2-recurse.py ├── README.md ├── __pycache__ │ └── 0-subs.cpython-38.pyc └── tests │ ├── 0-main.py │ ├── 1-main.py │ ├── 100-main.py │ └── 2-main.py ├── 0x17-web_stack_debugging_3 ├── 0-strace_is_your_friend.pp └── README.md ├── 0x18-webstack_monitoring ├── 0-setup_datadog ├── 2-setup_datadog ├── README.md └── ddagent-install.log ├── 0x19-postmortem └── README.md ├── 0x1A-application_server ├── 2-app_server-nginx_config ├── 3-app_server-nginx_config ├── 4-app_server-nginx_config ├── 5-app_server-nginx_config ├── README.md ├── app-server-config └── gunicorn.service ├── 0x1B-web_stack_debugging_4 ├── 0-the_sky_is_the_limit_not.pp ├── 1-user_limit.pp └── README.md ├── README.md ├── attack_is_the_best_defense ├── 0-sniffing └── 1-dictionary_attack └── command_line_for_the_win ├── 0-first_9_tasks.png ├── 1-next_9_tasks.png ├── 2-next_9_tasks.png └── README.md /0x00-shell_basics/0-current_working_directory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/1-listit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/10-back: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd - 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/100-lets_move: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mv [[:upper:]]* /tmp/u 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/101-clean_emacs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm *~ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/102-tree: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p welcome/to/school 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/103-commas: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -xamp 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/11-lists: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls . .. /boot -la 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 -sf /bin/ls __ls__ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/14-copy_html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cp *.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 -na 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 -rf /tmp/my_first_directory/betty 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/9-firstdirdeletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rmdir /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/README.md: -------------------------------------------------------------------------------- 1 | 0x00. Shell, basics 2 | =================== 3 | 4 | - By Julien Barbier 5 | - Weight: 1 6 | 7 | 8 | About Bash projects 9 | ------------------- 10 | 11 | Unless stated, all your projects will be auto-corrected with Ubuntu 14.04 LTS. 12 | 13 | ![](https://s3.amazonaws.com/intranet-projects-files/holbertonschool-sysadmin_devops/205/image.jpg) 14 | 15 | Resources 16 | --------- 17 | 18 | **Read or watch**: 19 | 20 | - [What Is "The Shell"?](https://alx-intranet.hbtn.io/rltoken/vwO91sqNBgRL03BLu-ueiA "What Is "The Shell"?") 21 | - [Navigation](https://alx-intranet.hbtn.io/rltoken/iblidp7yp6i-QpT8rDXHaA "Navigation") 22 | - [Looking Around](https://alx-intranet.hbtn.io/rltoken/xEKUCnQsMH0esQ6fJU5vLA "Looking Around") 23 | - [A Guided Tour](https://alx-intranet.hbtn.io/rltoken/HUhQ73fFR1GOC5nb4r-mDw "A Guided Tour") 24 | - [Manipulating Files](https://alx-intranet.hbtn.io/rltoken/olv-1tj4d1LA57Z0PrLNvw "Manipulating Files") 25 | - [Working With Commands](https://alx-intranet.hbtn.io/rltoken/zUtux3Pm0BkvtwXzbTtkmA "Working With Commands") 26 | - [Reading Man pages](https://alx-intranet.hbtn.io/rltoken/rddGdsqLf8_kRzp12RaD4A "Reading Man pages") 27 | - [Keyboard shortcuts for Bash](https://alx-intranet.hbtn.io/rltoken/JcsRq7PW6v7SdpPH_N8udQ "Keyboard shortcuts for Bash") 28 | - [LTS](https://wiki.ubuntu.com/LTS) 29 | - [Shebang](https://alx-intranet.hbtn.io/rltoken/cE8ZA3kgEaFhB-IDNv31bQ "Shebang") 30 | 31 | **man or help**: 32 | 33 | - `cd` 34 | - `ls` 35 | - `pwd` 36 | - `less` 37 | - `file` 38 | - `ln` 39 | - `cp` 40 | - `mv` 41 | - `rm` 42 | - `mkdir` 43 | - `type` 44 | - `which` 45 | - `help` 46 | - `man` 47 | 48 | Learning Objectives 49 | ------------------- 50 | 51 | At the end of this project, you are expected to be able to [explain to anyone](https://alx-intranet.hbtn.io/rltoken/Cn1p1E1_3FRvKpHfiKJ1GQ "explain to anyone"), **without the help of Google**: 52 | 53 | ### General 54 | 55 | - What does RTFM mean? 56 | - What is a Shebang 57 | 58 | ### What is the Shell 59 | 60 | - What is the shell 61 | - What is the difference between a terminal and a shell 62 | - What is the shell prompt 63 | - How to use the history (the basics) 64 | 65 | ### Navigation 66 | 67 | - What do the commands or built-ins `cd`, `pwd`, `ls` do 68 | - How to navigate the filesystem 69 | - What are the . and .. directories 70 | - What is the working directory, how to print it and how to change it 71 | - What is the root directory 72 | - What is the home directory, and how to go there 73 | - What is the difference between the root directory and the home directory of the user root 74 | - What are the characteristics of hidden files and how to list them 75 | - What does the command `cd -` do 76 | 77 | ### Looking Around 78 | 79 | - What do the commands `ls`, `less`, `file` do 80 | - How do you use options and arguments with commands 81 | - Understand the ls long format and how to display it 82 | - [A Guided Tour](https://alx-intranet.hbtn.io/rltoken/HUhQ73fFR1GOC5nb4r-mDw "A Guided Tour") 83 | - What does the `ln` command do 84 | - What do you find in the most common/important directories 85 | - What is a symbolic link 86 | - What is a hard link 87 | - What is the difference between a hard link and a symbolic link 88 | 89 | ### Manipulating Files 90 | 91 | - What do the commands `cp`, `mv`, `rm`, `mkdir` do 92 | - What are wildcards and how do they work 93 | - How to use wildcards 94 | 95 | ### Working with Commands 96 | 97 | - What do `type`, `which`, `help`, `man` commands do 98 | - What are the different kinds of commands 99 | - What is an alias 100 | - When do you use the command help instead of man 101 | 102 | ### Reading Man Pages 103 | 104 | - How to read a man page 105 | - What are man page sections 106 | - What are the section numbers for User commands, System calls and Library functions 107 | 108 | ### Keyboard Shortcuts for Bash 109 | 110 | - Common shortcuts for Bash 111 | 112 | ### LTS 113 | 114 | - What does `LTS` mean? 115 | 116 | Requirements 117 | ------------ 118 | 119 | ### General 120 | 121 | - Allowed editors: `vi`, `vim`, `emacs` 122 | - All your scripts will be tested on Ubuntu 20.04 LTS 123 | - All your scripts should be exactly two lines long (`$ wc -l file` should print 2) 124 | - All your files should end with a new line ([why?](http://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file/18789)) 125 | - The first line of all your files should be exactly `#!/bin/bash` 126 | - A `README.md` file at the root of the repo, containing a description of the repository 127 | - A `README.md` file, at the root of the folder of *this* project, describing what each script is doing 128 | - You are not allowed to use backticks, `&&`, `||` or `;` 129 | - All your scripts must be executable. To make your file executable, use the `chmod` command: `chmod u+x file`. Later, we'll learn more about how to utilize this command. 130 | 131 | More Info 132 | --------- 133 | 134 | *Example of line count and first line* 135 | 136 | ``` 137 | julien@ubuntu:/tmp$ wc -l 12-file_type 138 | 2 12-file_type 139 | julien@ubuntu:/tmp$ head -n 1 12-file_type 140 | #!/bin/bash 141 | julien@ubuntu:/tmp$ 142 | 143 | ``` 144 | 145 | In order to test your scripts, you will need to use this command: `chmod u+x file`. We will see later what does `chmod` mean and do, but you can have a look at `man chmod` if you are curious. 146 | 147 | *Example* 148 | 149 | ``` 150 | julien@ubuntu:/tmp$ ls 151 | 12-file_type 152 | lll 153 | julien@ubuntu:/tmp$ ls -la lll 154 | -rw-rw-r-- 1 julien julien 15 Sep 19 21:05 lll 155 | julien@ubuntu:/tmp$ cat lll 156 | #!/bin/bash 157 | ls 158 | julien@ubuntu:/tmp$ ls -l lll 159 | -rw-rw-r-- 1 julien julien 15 Sep 19 21:05 lll 160 | julien@ubuntu:/tmp$ chmod u+x lll # you do not have to understand this yet 161 | julien@ubuntu:/tmp$ ls -l lll 162 | -rwxrw-r-- 1 julien julien 15 Sep 19 21:05 lll 163 | julien@ubuntu:/tmp$ ./lll 164 | 12-file_type 165 | lll 166 | julien@ubuntu:/tmp$ 167 | 168 | ``` 169 | 170 | ### Description 171 | 172 | Shell basic manipulation exercises are stored here 173 | 174 | ### Structure 175 | * 0-current_working-directory 176 | prints the absolute path name of the current working directory. 177 | * 1-listit 178 | Display the contents list of your current directory. 179 | * 2-bring_me_home 180 | changes the working directory to the user’s home directory. 181 | * 3-listfiles 182 | Display current directory contents in a long format 183 | * 4-listmorefiles 184 | Display current directory contents, including hidden files 185 | * 5-listfilesdigitonly 186 | Display current directory contents. 187 | * Long format 188 | * with user and group IDs displayed numerically 189 | * And hidden files (starting with .) 190 | * 6-firstdirectory 191 | creates a directory named my_first_directory in the /tmp/ directory. 192 | * 7-movethatfile 193 | Move the file betty from /tmp/ to /tmp/my_first_directory. 194 | * 8-firstdelete : delete file betty 195 | * 9-firstdirdeletion : delete directory holberton in tmp directory 196 | * 10-back : changes working directory to previous one 197 | * 11-lists : list all files in the current directory, parent directory and he boot directory including hidden files in long format 198 | * 12-file_type : prints the type of the file iamfile in tmp directory 199 | * 13-symbolic_link : creates a symbolic link named __ls__ to /bin/ls 200 | * 14-copy_html : copies all HTML files from working to parent directory that does not exist 201 | * 15-lets_move : moves all files beginning with uppercase letter to tmp directory 202 | * 16-clean_emacs : deletes all files ending with "~" in working directory 203 | * 17-tree : creates series of directories 204 | * 18-commas : list files and directories of current directory ending with slash(/), sorted numerically and alphabetically, and include hidden files 205 | 206 | Tasks 207 | ----- 208 | 209 | ### 0\. Where am I? 210 | 211 | mandatory 212 | 213 | Score: 100.00% (Checks completed: 100.00%) 214 | 215 | Write a script that prints the absolute path name of the current working directory. 216 | 217 | Example: 218 | 219 | ``` 220 | $ ./0-current_working_directory 221 | /root/alx-system_engineering-devops/0x00-shell_basics 222 | $ 223 | 224 | ``` 225 | 226 | **Repo:** 227 | 228 | - GitHub repository: `alx-system_engineering-devops` 229 | - Directory: `0x00-shell_basics` 230 | - File: `0-current_working_directory` 231 | 232 | Done! Help Re-check your code Get a sandbox QA Review 233 | 234 | ### 1\. What's in there? 235 | 236 | mandatory 237 | 238 | Score: 100.00% (Checks completed: 100.00%) 239 | 240 | Display the contents list of your current directory. 241 | 242 | Example: 243 | 244 | ``` 245 | $ ./1-listit 246 | Applications Documents Dropbox Movies Pictures 247 | Desktop Downloads Library Music Public 248 | $ 249 | 250 | ``` 251 | 252 | **Repo:** 253 | 254 | - GitHub repository: `alx-system_engineering-devops` 255 | - Directory: `0x00-shell_basics` 256 | - File: `1-listit` 257 | 258 | Done! Help Re-check your code Get a sandbox QA Review 259 | 260 | ### 2\. There is no place like home 261 | 262 | mandatory 263 | 264 | Score: 100.00% (Checks completed: 100.00%) 265 | 266 | Write a script that changes the working directory to the user's home directory. 267 | 268 | - You are not allowed to use any shell variables 269 | 270 | ``` 271 | julien@ubuntu:/tmp$ pwd 272 | /tmp 273 | julien@ubuntu:/tmp$ echo $HOME 274 | /home/julien 275 | julien@ubuntu:/tmp$ source ./2-bring_me_home 276 | julien@ubuntu:~$ pwd 277 | /home/julien 278 | julien@ubuntu:~$ 279 | 280 | ``` 281 | 282 | **Repo:** 283 | 284 | - GitHub repository: `alx-system_engineering-devops` 285 | - Directory: `0x00-shell_basics` 286 | - File: `2-bring_me_home` 287 | 288 | Done! Help Re-check your code Get a sandbox QA Review 289 | 290 | ### 3\. The long format 291 | 292 | mandatory 293 | 294 | Score: 100.00% (Checks completed: 100.00%) 295 | 296 | Display current directory contents in a long format 297 | 298 | Example: 299 | 300 | ``` 301 | $ ./3-listfiles 302 | total 32 303 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:19 0-current_working_directory 304 | -rwxr-xr-x@ 1 sylvain staff 19 Jan 25 00:23 1-listit 305 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:29 2-bring_me_home 306 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:39 3-listfiles 307 | $ 308 | 309 | ``` 310 | 311 | **Repo:** 312 | 313 | - GitHub repository: `alx-system_engineering-devops` 314 | - Directory: `0x00-shell_basics` 315 | - File: `3-listfiles` 316 | 317 | Done! Help Re-check your code Get a sandbox QA Review 318 | 319 | ### 4\. Hidden files 320 | 321 | mandatory 322 | 323 | Score: 100.00% (Checks completed: 100.00%) 324 | 325 | Display current directory contents, including hidden files (starting with `.`). Use the long format. 326 | 327 | Example: 328 | 329 | ``` 330 | $ ./4-listmorefiles 331 | total 32 332 | drwxr-xr-x@ 6 sylvain staff 204 Jan 25 00:29 . 333 | drwxr-xr-x@ 43 sylvain staff 1462 Jan 25 00:19 .. 334 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:19 0-current_working_directory 335 | -rwxr-xr-x@ 1 sylvain staff 19 Jan 25 00:23 1-listit 336 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:29 2-bring_me_home 337 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:39 3-listfiles 338 | -rwxr-xr-x@ 1 sylvain staff 18 Jan 25 00:41 4-listmorefiles 339 | $ 340 | 341 | ``` 342 | 343 | **Repo:** 344 | 345 | - GitHub repository: `alx-system_engineering-devops` 346 | - Directory: `0x00-shell_basics` 347 | - File: `4-listmorefiles` 348 | 349 | Done! Help Re-check your code Get a sandbox QA Review 350 | 351 | ### 5\. I love numbers 352 | 353 | mandatory 354 | 355 | Score: 100.00% (Checks completed: 100.00%) 356 | 357 | Display current directory contents. 358 | 359 | - Long format 360 | - with user and group IDs displayed numerically 361 | - And hidden files (starting with .) 362 | 363 | Example: 364 | 365 | ``` 366 | $ ./5-listfilesdigitonly 367 | total 32 368 | drwxr-xr-x@ 6 501 20 204 Jan 25 00:29 . 369 | drwxr-xr-x@ 43 501 20 1462 Jan 25 00:19 .. 370 | -rwxr-xr-x@ 1 501 20 18 Jan 25 00:19 0-current_working_directory 371 | -rwxr-xr-x@ 1 501 20 18 Jan 25 00:23 1-listfiles 372 | -rwxr-xr-x@ 1 501 20 19 Jan 25 00:29 2-bring_me_home 373 | -rwxr-xr-x@ 1 501 20 20 Jan 25 00:39 3-listfiles 374 | -rwxr-xr-x@ 1 501 20 18 Jan 25 00:41 4-listmorefiles 375 | -rwxr-xr-x@ 1 501 20 18 Jan 25 00:43 5-listfilesdigitonly 376 | $ 377 | 378 | ``` 379 | 380 | **Repo:** 381 | 382 | - GitHub repository: `alx-system_engineering-devops` 383 | - Directory: `0x00-shell_basics` 384 | - File: `5-listfilesdigitonly` 385 | 386 | Done! Help Re-check your code Get a sandbox QA Review 387 | 388 | ### 6\. Welcome 389 | 390 | mandatory 391 | 392 | Score: 100.00% (Checks completed: 100.00%) 393 | 394 | Create a script that creates a directory named `my_first_directory` in the `/tmp/` directory. 395 | 396 | Example: 397 | 398 | ``` 399 | $ ./6-firstdirectory 400 | $ file /tmp/my_first_directory/ 401 | /tmp/my_first_directory/: directory 402 | $ 403 | 404 | ``` 405 | 406 | **Repo:** 407 | 408 | - GitHub repository: `alx-system_engineering-devops` 409 | - Directory: `0x00-shell_basics` 410 | - File: `6-firstdirectory` 411 | 412 | Done! Help Re-check your code Get a sandbox QA Review 413 | 414 | ### 7\. Betty in my first directory 415 | 416 | mandatory 417 | 418 | Score: 100.00% (Checks completed: 100.00%) 419 | 420 | Move the file `betty` from `/tmp/` to `/tmp/my_first_directory`. 421 | 422 | Example: 423 | 424 | ``` 425 | $ ./7-movethatfile 426 | $ ls /tmp/my_first_directory/ 427 | betty 428 | $ 429 | 430 | ``` 431 | 432 | **Repo:** 433 | 434 | - GitHub repository: `alx-system_engineering-devops` 435 | - Directory: `0x00-shell_basics` 436 | - File: `7-movethatfile` 437 | 438 | Done! Help Re-check your code Get a sandbox QA Review 439 | 440 | ### 8\. Bye bye Betty 441 | 442 | mandatory 443 | 444 | Score: 100.00% (Checks completed: 100.00%) 445 | 446 | Delete the file `betty`. 447 | 448 | - The file `betty` is in `/tmp/my_first_directory` 449 | 450 | Example: 451 | 452 | ``` 453 | $ ./8-firstdelete 454 | $ ls /tmp/my_first_directory/ 455 | $ 456 | 457 | ``` 458 | 459 | **Repo:** 460 | 461 | - GitHub repository: `alx-system_engineering-devops` 462 | - Directory: `0x00-shell_basics` 463 | - File: `8-firstdelete` 464 | 465 | Done! Help Re-check your code Get a sandbox QA Review 466 | 467 | ### 9\. Bye bye My first directory 468 | 469 | mandatory 470 | 471 | Score: 100.00% (Checks completed: 100.00%) 472 | 473 | Delete the directory `my_first_directory` that is in the `/tmp` directory. 474 | 475 | Example: 476 | 477 | ``` 478 | $ ./9-firstdirdeletion 479 | $ file /tmp/my_first_directory 480 | /tmp/my_first_directory: cannot open `/tmp/my_first_directory' (No such file or directory) 481 | $ 482 | 483 | ``` 484 | 485 | **Repo:** 486 | 487 | - GitHub repository: `alx-system_engineering-devops` 488 | - Directory: `0x00-shell_basics` 489 | - File: `9-firstdirdeletion` 490 | 491 | Done! Help Re-check your code Get a sandbox QA Review 492 | 493 | ### 10\. Back to the future 494 | 495 | mandatory 496 | 497 | Score: 100.00% (Checks completed: 100.00%) 498 | 499 | Write a script that changes the working directory to the previous one. 500 | 501 | ``` 502 | julien@ubuntu:/tmp$ pwd 503 | /tmp 504 | julien@ubuntu:/tmp$ cd /var 505 | julien@ubuntu:/var$ pwd 506 | /var 507 | julien@ubuntu:/var$ source ./10-back 508 | /tmp 509 | julien@ubuntu:/tmp$ pwd 510 | /tmp 511 | 512 | ``` 513 | 514 | **Repo:** 515 | 516 | - GitHub repository: `alx-system_engineering-devops` 517 | - Directory: `0x00-shell_basics` 518 | - File: `10-back` 519 | 520 | Done! Help Re-check your code Get a sandbox QA Review 521 | 522 | ### 11\. Lists 523 | 524 | mandatory 525 | 526 | Score: 100.00% (Checks completed: 100.00%) 527 | 528 | Write a script that lists all files (even ones with names beginning with a period character, which are normally hidden) in the current directory and the parent of the working directory and the `/boot` directory (in this order), in long format. 529 | 530 | **Repo:** 531 | 532 | - GitHub repository: `alx-system_engineering-devops` 533 | - Directory: `0x00-shell_basics` 534 | - File: `11-lists` 535 | 536 | Done! Help Re-check your code Get a sandbox QA Review 537 | 538 | ### 12\. File type 539 | 540 | mandatory 541 | 542 | Score: 100.00% (Checks completed: 100.00%) 543 | 544 | Write a script that prints the type of the file named `iamafile`. The file `iamafile` will be in the `/tmp` directory when we will run your script. 545 | 546 | Example 547 | 548 | ``` 549 | ubuntu@ip-172-31-63-244:~$ ./12-file_type 550 | /tmp/iamafile: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=bd39c07194a778ccc066fc963ca152bdfaa3f971, stripped 551 | 552 | ``` 553 | 554 | Note that depending on the file, the output of your script will be different. 555 | 556 | **Repo:** 557 | 558 | - GitHub repository: `alx-system_engineering-devops` 559 | - Directory: `0x00-shell_basics` 560 | - File: `12-file_type` 561 | 562 | Done! Help Re-check your code Get a sandbox QA Review 563 | 564 | ### 13\. We are symbols, and inhabit symbols 565 | 566 | mandatory 567 | 568 | Score: 100.00% (Checks completed: 100.00%) 569 | 570 | Create a symbolic link to `/bin/ls`, named `__ls__`. The symbolic link should be created in the current working directory. 571 | 572 | ``` 573 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la 574 | total 144 575 | drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 20 03:24 . 576 | drwxrwxrwt 12 root root 139264 Sep 20 03:24 .. 577 | ubuntu@ip-172-31-63-244:/tmp/sym$./13-symbolic_link 578 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la 579 | total 144 580 | drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 20 03:24 . 581 | drwxrwxrwt 12 root root 139264 Sep 20 03:24 .. 582 | lrwxrwxrwx 1 ubuntu ubuntu 7 Sep 20 03:24 __ls__ -> /bin/ls 583 | 584 | ``` 585 | 586 | **Repo:** 587 | 588 | - GitHub repository: `alx-system_engineering-devops` 589 | - Directory: `0x00-shell_basics` 590 | - File: `13-symbolic_link` 591 | 592 | Done! Help Re-check your code Get a sandbox QA Review 593 | 594 | ### 14\. Copy HTML files 595 | 596 | mandatory 597 | 598 | Score: 100.00% (Checks completed: 100.00%) 599 | 600 | Create a script that copies all the HTML files from the current working directory to the parent of the working directory, but only copy files that did not exist in the parent of the working directory or were newer than the versions in the parent of the working directory. 601 | 602 | You can consider that all HTML files have the extension `.html` 603 | 604 | **Repo:** 605 | 606 | - GitHub repository: `alx-system_engineering-devops` 607 | - Directory: `0x00-shell_basics` 608 | - File: `14-copy_html` 609 | 610 | Done! Help Re-check your code Get a sandbox QA Review 611 | 612 | ### 15\. Let's move 613 | 614 | #advanced 615 | 616 | Score: 100.00% (Checks completed: 100.00%) 617 | 618 | Create a script that moves all files beginning with an uppercase letter to the directory `/tmp/u`. 619 | 620 | You can assume that the directory `/tmp/u` will exist when we will run your script 621 | 622 | ``` 623 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la 624 | total 148 625 | drwxrwxr-x 3 ubuntu ubuntu 4096 Sep 20 03:33 . 626 | drwxrwxrwt 12 root root 139264 Sep 20 03:26 .. 627 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 My_file 628 | lrwxrwxrwx 1 ubuntu ubuntu 7 Sep 20 03:24 __ls__ -> /bin/ls 629 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 Elif_ym 630 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 random_file 631 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la /tmp/u 632 | total 8 633 | drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 20 03:33 . 634 | drwxrwxr-x 3 ubuntu ubuntu 4096 Sep 20 03:33 .. 635 | ubuntu@ip-172-31-63-244:/tmp/sym$ ./100-lets_move 636 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la 637 | total 148 638 | drwxrwxr-x 3 ubuntu ubuntu 4096 Sep 20 03:33 . 639 | drwxrwxrwt 12 root root 139264 Sep 20 03:26 .. 640 | lrwxrwxrwx 1 ubuntu ubuntu 7 Sep 20 03:24 __ls__ -> /bin/ls 641 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 random_file 642 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls -la /tmp/u 643 | total 8 644 | drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 20 03:33 . 645 | drwxrwxr-x 3 ubuntu ubuntu 4096 Sep 20 03:33 .. 646 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 My_file 647 | -rw-rw-r-- 1 ubuntu ubuntu 0 Sep 20 03:32 Elif_ym 648 | 649 | ``` 650 | 651 | **Repo:** 652 | 653 | - GitHub repository: `alx-system_engineering-devops` 654 | - Directory: `0x00-shell_basics` 655 | - File: `100-lets_move` 656 | 657 | Done! Help Re-check your code Get a sandbox QA Review 658 | 659 | ### 16\. Clean Emacs 660 | 661 | #advanced 662 | 663 | Score: 100.00% (Checks completed: 100.00%) 664 | 665 | Create a script that deletes all files in the current working directory that end with the character `~`. 666 | 667 | ``` 668 | ubuntu@ip-172-31-63-244:/tmp/sym$ ls 669 | main.c main.c~ Makefile~ 670 | ubuntu@ip-172-31-63-244:/tmp/sym$ ./101-clean_emacs 671 | ubuntu@ip-172-31-63-244:/tmp/emacs$ ls 672 | main.c 673 | ubuntu@ip-172-31-63-244:/tmp/emacs$ 674 | 675 | ``` 676 | 677 | **Repo:** 678 | 679 | - GitHub repository: `alx-system_engineering-devops` 680 | - Directory: `0x00-shell_basics` 681 | - File: `101-clean_emacs` 682 | 683 | Done! Help Re-check your code Get a sandbox QA Review 684 | 685 | ### 17\. Tree 686 | 687 | #advanced 688 | 689 | Score: 100.00% (Checks completed: 100.00%) 690 | 691 | Create a script that creates the directories `welcome/`, `welcome/to/` and `welcome/to/school` in the current directory. 692 | 693 | You are only allowed to use two spaces (and lines) in your script, not more. 694 | 695 | ``` 696 | julien@ubuntu:/tmp/h$ ls -l 697 | total 4 698 | -rwxrw-r-- 1 julien julien 44 Sep 20 12:09 102-tree 699 | julien@ubuntu:/tmp/h$ wc -l 102-tree 700 | 2 102-tree 701 | julien@ubuntu:/tmp/h$ head -1 102-tree 702 | #!/bin/bash 703 | julien@ubuntu:/tmp/h$ tr -cd ' ' < 102-tree | wc -c # you do not have to understand this yet, but the result should be 2, 1 or 0 704 | 2 705 | julien@ubuntu:/tmp/h$ ./102-tree 706 | julien@ubuntu:/tmp/h$ ls 707 | 102-tree welcome 708 | julien@ubuntu:/tmp/h$ ls welcome/ 709 | to 710 | julien@ubuntu:/tmp/h$ ls -l welcome/to 711 | total 4 712 | drwxrwxr-x 2 julien julien 4096 Sep 20 12:11 school 713 | julien@ubuntu:/tmp/h$ 714 | 715 | ``` 716 | 717 | **Repo:** 718 | 719 | - GitHub repository: `alx-system_engineering-devops` 720 | - Directory: `0x00-shell_basics` 721 | - File: `102-tree` 722 | 723 | Done! Help Re-check your code Get a sandbox QA Review 724 | 725 | ### 18\. Life is a series of commas, not periods 726 | 727 | #advanced 728 | 729 | Score: 100.00% (Checks completed: 100.00%) 730 | 731 | Write a command that lists all the files and directories of the current directory, separated by commas (`,`). 732 | 733 | - Directory names should end with a slash (`/`) 734 | 735 | - Files and directories starting with a dot (`.`) should be listed 736 | 737 | - The listing should be alpha ordered, except for the directories `.` and `..` which should be listed at the very beginning 738 | - Only digits and letters are used to sort; Digits should come first 739 | - You can assume that all the files we will test with will have at least one letter or one digit 740 | - The listing should end with a new line 741 | 742 | ``` 743 | ubuntu@ubuntu:~/$ ls -a 744 | 745 | . .. 0-commas 0-commas-checks 1-empty_casks 2-gifs 3-directories 4-zeros 5-rot13 6-odd 7-sort_rot13 Makefile quote .test test_dir test.var 746 | 747 | ubuntu@ubuntu:~/$ ./103-commas 748 | 749 | ./, ../, 0-commas, 0-commas-checks/, 1-empty_casks, 2-gifs, 3-directories, 4-zeros, 5-rot13, 6-odd, 7-sort_rot13, Makefile, quote, .test, test_dir/, test.var 750 | 751 | ubuntu@ubuntu:~/$ 752 | 753 | ``` 754 | 755 | **Repo:** 756 | 757 | - GitHub repository: `alx-system_engineering-devops` 758 | - Directory: `0x00-shell_basics` 759 | - File: `103-commas` 760 | 761 | Done! Help Re-check your code Get a sandbox QA Review 762 | 763 | ### 19\. File type: School 764 | 765 | #advanced 766 | 767 | Score: 100.00% (Checks completed: 100.00%) 768 | 769 | Create a magic file `school.mgc` that can be used with the command `file` to detect `School` data files. `School` data files always contain the string `SCHOOL` at offset 0. 770 | 771 | ``` 772 | ubuntu@ip-172-31-63-244:/tmp/magic$ cp /bin/ls . 773 | ubuntu@ip-172-31-63-244:/tmp/magic$ ls -la 774 | total 268 775 | drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 20 02:44 . 776 | drwxrwxrwt 11 root root 139264 Sep 20 02:44 .. 777 | -rw-r--r-- 1 ubuntu ubuntu 496 Sep 20 02:42 holberton.mgc 778 | -rwxr-xr-x 1 ubuntu ubuntu 110080 Sep 20 02:43 ls 779 | -rw-rw-r-- 1 ubuntu ubuntu 50 Sep 20 02:06 thisisanholbertonfile 780 | -rw-rw-r-- 1 ubuntu ubuntu 30 Sep 20 02:16 thisisatextfile 781 | ubuntu@ip-172-31-63-244:/tmp/magic$ file --mime-type -m school.mgc * 782 | school.mgc: application/octet-stream 783 | ls: application/octet-stream 784 | thisisaschoolfile: School 785 | thisisatextfile: text/plain 786 | ubuntu@ip-172-31-63-244:/tmp/magic$ file -m school.mgc * 787 | school.mgc: data 788 | ls: data 789 | thisisaschoolfile: School data 790 | thisisatextfile: ASCII text 791 | ubuntu@ip-172-31-63-244:/tmp/magic$ 792 | 793 | ``` 794 | 795 | **Repo:** 796 | 797 | - GitHub repository: `alx-system_engineering-devops` 798 | - Directory: `0x00-shell_basics` 799 | - File: `school.mgc` 800 | -------------------------------------------------------------------------------- /0x00-shell_basics/school.mgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/0x00-shell_basics/school.mgc -------------------------------------------------------------------------------- /0x01-shell_permissions/0-iam_betty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | su betty 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/1-who_am_i: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 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 vincent:staff * 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/101-symbolic_link_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown -h vincent:staff _hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/102-if_only: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown --from=guillaume betty hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/103-Star_Wars: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | telnet towel.blinkenlights.nl 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/11-directories_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type d -exec chmod 755 {} + 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/12-directory_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -m 751 my_dir 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/13-change_group: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chgrp school hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/2-groups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | groups 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/3-new_owner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown betty hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/4-empty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | touch hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/5-execute: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod u+x hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/6-multiple_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod 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 | 0x01-shell_permissions 2 | -------------------------------------------------------------------------------- /0x02-shell_redirections/0-hello_world: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Hello, World" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/1-confused_smiley: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "\"(Ôo)'" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/10-no_more_js: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.js" -delete 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/100-empty_casks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -empty | rev | cut -d '/' -f 1 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/101-gifs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find -type f -name "*.gif" | rev | cut -d "/" -f 1 | cut -d '.' -f 2- | rev | LC_ALL=C sort -f 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/102-acrostic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c 1 | paste -s -d '' 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/103-the_biggest_fan: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n +2 | cut -f -1 | sort -k 1 | uniq -c | sort -rnk 1 | head -n 11 | rev | cut -d ' ' -f -1 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/11-directories: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type d -not -name '.' | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/12-newest_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -t1 | head -n 10 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/13-unique: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort | uniq -u 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/14-findthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/15-countthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -c -i "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/16-whatsnext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" -A 3 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/17-hidethisword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i -v "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/18-letteronly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "^[a-z]" /etc/ssh/sshd_config 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/19-AZ: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr "A" "Z" | tr "c" "e" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/2-hellofile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/20-hiago: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr -d "cC" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/21-reverse: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rev 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/22-users_and_homes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d ':' -f 1,6 /etc/passwd | sort 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/3-twofiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd /etc/hosts 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/4-lastlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/5-firstlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/6-third_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 3 iacta | tail -n 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 | 0x02-shell_redirections 2 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/.7-create_global_variable.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/0x03-shell_variables_expansions/.7-create_global_variable.swp -------------------------------------------------------------------------------- /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 | perl -lne 'print if $. % 2 ==1' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/103-water_and_stir: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(printf %o $(($((5#$(echo $WATER | tr 'water' '01234'))) + $((5#$(echo $STIR | tr 'stir.' '01234'))))) | tr '01234567' 'bestchol') 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/11-binary_to_decimal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $((2#$BINARY)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/12-combinations: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo {a..z}{a..z} | tr " " "\n" | grep -v "oo" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/13-print_float: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf "%.2f" $NUM | sort 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 $((`echo $PATH | grep -o ":/" | wc -l`+ 1)) 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 $(($TRUEKNOWLEDGE + 128)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/9-divide_and_rule: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(($POWER / $DIVIDE)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/README.md: -------------------------------------------------------------------------------- 1 | 0x03-shell_variables_expansions 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/0-RSA_public_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMXL7Yl2SwU1AeRaWm+Ibdl70fCwesosyn8+OvUw8wtwWETQLaS12kMBGe2+yzFXcD4PBlfJlSltzZJEzg5YG9pVL79kDTecnE+F9Otd2hFMd/AJnP6as1zS+oQA9Qli8OiseQkgVqxks9ELBC5VbD6IS8OyOEsfJH50CtrwnLmcNt/6EAjqtfKgqVfzC6kqTSXmV6DOqIgiwZ0PmUsSIPMpW52qnt4m7m5tqKHchcHsZJRQW3S0HiGJrd4gBftiRP1+NJ+MRono9HQw/nVoQ7z7XQkXDASQW0ksbgkVXaIzdA5RORrUEsT1RnrpMHMRBTKRIJyd1NcwuPh1bCw35YhpM6CSwMeylBdFWit1YtwpWyvgdPquKdGfkNN7R7GRAP9Dy3sgnEe9/37oPHKk+T2VsClCUx55OfZnMZ9vViPtqjQX8cbV8lc+0AFSwxX2c1a9OZ0PaUyulK0Xl9XvwYlYp0vSn1PHq6SwR3NX5IapERannwoNq9nfAsfWb6u5k= root@1227f4fc05a8 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 ((x = 0; x<10; x++)) 5 | do 6 | echo "Best School" 7 | done 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/10-fizzbuzz: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 100 in list format. 3 | # Displays "FizzBuzz" when the number is a multiple of 3 and 5. 4 | # Displays "Fizz" when the number is a multiple of 3. 5 | # Displays "Buzz" when the number is a multiple of 5. 6 | # Otherwise, displays the number. 7 | 8 | for num in {1..100} 9 | do 10 | if (( num % 3 == 0 && num % 5 == 0 )) 11 | then 12 | echo "FizzBuzz" 13 | elif (( num % 3 == 0 )) 14 | then 15 | echo "Fizz" 16 | elif (( num % 5 == 0 )) 17 | then 18 | echo "Buzz" 19 | else 20 | echo "$num" 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/100-read_and_cut: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # read and cat 3 | 4 | file="/etc/passwd" 5 | 6 | while IFS= read -r line; do 7 | echo "$line" | cut -d ':' -f1,3,6 8 | done < "$file" 9 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/101-tell_the_story_of_passwd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tell the story of passwd 3 | 4 | file="/etc/passwd" 5 | 6 | while IFS= read -r line; do 7 | user=$(echo "$line" | cut -d ':' -f1) 8 | gid=$(echo "$line" | cut -d ':' -f4) 9 | dir=$(echo "$line" | cut -d ':' -f6) 10 | shell=$(echo "$line" | cut -d ':' -f7) 11 | uid=$(echo "$line" | cut -d ':' -f3) 12 | pass=$(echo "$line" | cut -d ':' -f2) 13 | info=$(echo "$line" | cut -d ':' -f5) 14 | 15 | echo "The user $user is part of the $gid gang, lives in $dir and rides $shell. $uid's place is protected by the passcode $pass, more info about the user here: $info" 16 | done < "$file" 17 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/102-lets_parse_apache_logs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # parse apache logs and show ip and status code 3 | 4 | awk '{print $1,$9}' apache-access.log 5 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/103-dig_the-data: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Dig the data 3 | 4 | awk '{print $1,$9}' apache-access.log | sort | uniq -c | sort -r 5 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/2-while_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script prints "Best school" 10 times 3 | n=1 4 | 5 | while [ $n -le 10 ] 6 | do 7 | echo "Best School" 8 | n=$(( n + 1 )) 9 | done 10 | -------------------------------------------------------------------------------- /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 | x=0 5 | 6 | until [ $x -eq 10 ] 7 | do 8 | echo "Best School" 9 | (( x++ )) 10 | done 11 | -------------------------------------------------------------------------------- /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 | x=0 5 | 6 | while [ $x -lt 10 ] 7 | do 8 | if [ $x -eq 9 ] 9 | then 10 | echo "Hi" 11 | fi 12 | echo "Best School" 13 | (( x++ )) 14 | done 15 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/5-4_bad_luck_8_is_your_chance: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script prints "bad luck" 4th iteration, "good luck" on the 8th iteration, and "Best School" iterations. 3 | n=1 4 | 5 | while [ $n -le 10 ] 6 | do 7 | if [ $n -eq 4 ] 8 | then 9 | echo "bad luck" 10 | elif [ $n -eq 8 ] 11 | then 12 | echo "good luck" 13 | else 14 | echo "Best School" 15 | fi 16 | n=$(( n + 1 )) 17 | done 18 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/6-superstitious_numbers: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 20 in addition to: 3 | # "bad luck from China" for the 4th iteration 4 | # "bad luck from Japan" for the 9th iteration 5 | # "bad luck from Italy" for the 17th loop iteration 6 | 7 | x=1 8 | 9 | while [ $x -le 20 ] 10 | do 11 | echo "$x" 12 | case $x in 13 | "4") echo "bad luck from China";; 14 | "9") echo "bad luck from Japan";; 15 | "17") echo "bad luck from Italy";; 16 | esac 17 | (( x++ )) 18 | done 19 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/7-clock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the time for 12 hours and 59 minutes 3 | hour=0 4 | 5 | while [ $hour -le 12 ] 6 | do 7 | echo "Hour: $hour" 8 | minute=1 9 | while [ $minute -le 59 ] 10 | do 11 | echo $minute 12 | minute=$(( minute + 1 )) 13 | done 14 | hour=$(( hour + 1 )) 15 | done 16 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/8-for_ls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # displays the content of the current directory in a certain format 3 | 4 | list=$(ls) 5 | for file in $list 6 | do 7 | find "$file" | cut -d- -f2 8 | done 9 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/9-to_file_or_not_to_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays information about the file `holbertonschool`. 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 | 0x04-loops_conditions_and_parsing 2 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/0-what-is-my-pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # my pid 3 | 4 | sleep 5 & 5 | echo "$!" 6 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/1-list_your_processes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #displays a list of currently running processes 3 | # Shows all processes, for all users, including those 4 | # which might not have a TTY. 5 | 6 | ps -auxf 7 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/100-process_and_pid_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Does the following: 3 | # Create a file /var/run/myscript.pid containing the script PID. 4 | # Displays "To infinity and beyond" indefinitely 5 | # Displays "I hate the kill command" upon receiving a SIGTERM 6 | # Displays "Y U no love me?!" upon receiving a SIGINT 7 | # Deletes the file /var/run/myscript.pid and terminates upon 8 | # receiving a SIGQUIT or SIGTERM. 9 | 10 | terminator() { 11 | rm /var/run/myscript.pid 12 | exit 13 | } 14 | 15 | echo "$$" > /var/run/myscript.pid 16 | 17 | while true 18 | do 19 | echo "To infinity and beyond" 20 | sleep 2 21 | trap 'echo "Y U no love me?!"' SIGINT 22 | trap 'echo "I hate the kill command" && terminator' SIGTERM 23 | trap 'terminator' SIGQUIT 24 | done 25 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/101-manage_my_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # manages manage_my_process by either starting it, stopping it or restarting it. 3 | 4 | command="$1" 5 | 6 | if [ -z "$command" ]; then 7 | echo "Usage: manage_my_process {start|stop|restart}" 8 | exit 9 | fi 10 | 11 | if [ "$command" == "start" ]; then 12 | 13 | bash ./manage_my_process & 14 | echo "$!" > /var/run/my_process.pid 15 | echo "manage_my_process started" 16 | 17 | elif [ "$command" == "stop" ]; then 18 | [ -e "/var/run/my_process.pid" ] && pkill -f './manage_my_process' && rm /var/run/my_process.pid 19 | echo "manage_my_process stopped" 20 | 21 | elif [ "$command" == "restart" ]; then 22 | 23 | "$0" stop >& /dev/null 24 | "$0" start >& /dev/null 25 | echo "manage_my_process restarted" 26 | 27 | else 28 | echo "Usage: manage_my_process {start|stop|restart}" 29 | fi 30 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/102-zombie.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "stdlib.h" 3 | #include "unistd.h" 4 | 5 | /** 6 | * infinite_while - infinite while loop. 7 | * Return: 0 in the end 8 | */ 9 | int infinite_while(void) 10 | { 11 | while (1) 12 | { 13 | sleep(1); 14 | } 15 | return (0); 16 | } 17 | 18 | /** 19 | * main - main function. 20 | * Return: 0 on sucess 21 | */ 22 | int main(void) 23 | { 24 | int children_processes = 0; 25 | pid_t pid; 26 | 27 | while (children_processes < 5) 28 | { 29 | pid = fork(); 30 | if (!pid) 31 | break; 32 | printf("Zombie process created, PID: %i\n", (int)pid); 33 | children_processes++; 34 | } 35 | if (pid != 0) 36 | infinite_while(); 37 | return (0); 38 | } 39 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/2-show_your_bash_pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # list all bash processes 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 | # PID made easy 3 | 4 | pgrep -l bash 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/4-to_infinity_and_beyond: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "To infinity and beyond" indefinitely with 3 | # a sleep 2 in between each iteration. 4 | 5 | while true 6 | do 7 | echo "To infinity and beyond" 8 | sleep 2 9 | done 10 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/5-dont_stop_me_now: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Kills the 4-to_infinity_and_beyond process 3 | 4 | kill "$(pgrep -f 4-to_infinity_and_beyond)" 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/6-stop_me_if_you_can: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Stop me if you can 3 | 4 | pkill -f 4-to_infinity_and_beyond 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/7-highlander: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays "To infinity and beyond" indefinitely with 3 | # a sleep 2 in between each iteration. 4 | # Displays "I am invincible!!!" in between each iteration. 5 | 6 | while true 7 | do 8 | echo "To infinity and beyond" 9 | sleep 2 10 | trap 'echo "I am invincible!!!"' SIGTERM 11 | done 12 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/8-beheaded_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Beheaded process 3 | 4 | pgrep -f 7-highlander | xargs kill -9 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/README.md: -------------------------------------------------------------------------------- 1 | 0x05-processes_and_signals 2 | 3 | 4 | ................. 5 | -------------------------------------------------------------------------------- /0x05-processes_and_signals/manage_my_process: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # well well well 3 | 4 | file="/tmp/my_process" 5 | 6 | while true; do 7 | echo "I am alive!" >> "$file" 8 | sleep 2 9 | done 10 | -------------------------------------------------------------------------------- /0x06-regular_expressions/0-simply_match_school.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/School/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/1-repetition_token_0.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt{2,5}n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/100-textme.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/\[from:(.*?)\] \[to:(.*?)\] \[flags:(.*?)\]/).join(",") 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/2-repetition_token_1.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hb?t?n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/3-repetition_token_2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt+n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/4-repetition_token_3.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt*n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/5-beginning_and_end.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^h.n$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/6-phone_number.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^\d{10,10}$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/7-OMG_WHY_ARE_YOU_SHOUTING.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/[A-Z]*/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/README.md: -------------------------------------------------------------------------------- 1 | 0x06-regular_expressions 2 | -------------------------------------------------------------------------------- /0x07-networking_basics/0-OSI_model: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/1-types_of_network: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/2-MAC_and_IP_address: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/3-UDP_and_TCP: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/4-TCP_and_UDP_ports: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Script that displays all listening sockets 3 | netstat -lp 4 | -------------------------------------------------------------------------------- /0x07-networking_basics/5-is_the_host_on_the_network: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Script that pings another address enterd over 5 times 3 | if [ $# -eq 0 ] 4 | then 5 | echo "Usage: 5-is_the_host_on_the_network {IP_ADDRESS}" 6 | else 7 | ping -c 5 "$1" 8 | fi 9 | -------------------------------------------------------------------------------- /0x07-networking_basics/README.md: -------------------------------------------------------------------------------- 1 | 0x07-networking_basics 2 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/0-change_your_home_IP: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # A script to change localhost addresses 3 | 4 | cp /etc/hosts ~/hosts.new 5 | echo "127.0.0.2 localhost" > ~/hosts.new 6 | echo "8.8.8.8 facebook.com" >> ~/hosts.new 7 | cp -f ~/hosts.new /etc/hosts 8 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/1-show_attached_IPs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script tp display all IPV4 IPS on a machine 3 | 4 | ifconfig | grep -Eo "inet (addr:)?([0-9]*\.){3}[0-9]*" | cut -b 11- 5 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/100-port_listening_on_localhost: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Listens on port 98 on localhost. 3 | 4 | nc -l localhost 98 5 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/README.md: -------------------------------------------------------------------------------- 1 | 0x08-networking_basics_2 2 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/0-simple_web_stack: -------------------------------------------------------------------------------- 1 | https://imgur.com/hRDbDBJ 2 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure: -------------------------------------------------------------------------------- 1 | https://imgur.com/sTAqHJA 2 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/2-secured_and_monitored_web_infrastructure: -------------------------------------------------------------------------------- 1 | https://imgur.com/GWlD3fG 2 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/3-scale_up: -------------------------------------------------------------------------------- 1 | https://imgur.com/l33POOC 2 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/README.md: -------------------------------------------------------------------------------- 1 | 0x09-web_infrastructure_design 2 | -------------------------------------------------------------------------------- /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 | } 11 | -------------------------------------------------------------------------------- /0x0A-configuration_management/1-install_a_package.pp: -------------------------------------------------------------------------------- 1 | # install flask using Puppet 2 | 3 | exec { 'install_flask': 4 | command => '/usr/bin/pip3 install flask==2.1.0', 5 | path => ['/usr/bin', '/bin'], 6 | unless => '/usr/bin/pip3 show flask | grep -q "Version: 2.1.0"', 7 | } 8 | 9 | exec { 'install_werkzeug': 10 | command => '/usr/bin/pip3 install werkzeug==2.1.1', 11 | path => ['/usr/bin', '/bin'], 12 | unless => '/usr/bin/pip3 show werkzeug | grep -q "Version: 2.1.1"', 13 | } 14 | -------------------------------------------------------------------------------- /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 | 0x0A-configuration_management 2 | -------------------------------------------------------------------------------- /0x0B-ssh/0-use_a_private_key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Connects to ubuntu server. 3 | ssh -i ~/.ssh/school ubuntu@100.26.211.237 4 | -------------------------------------------------------------------------------- /0x0B-ssh/1-create_ssh_key_pair: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Creates a new 4096-byte RSA key pair named school. 3 | ssh-keygen -b 4096 -N betty -f school 4 | -------------------------------------------------------------------------------- /0x0B-ssh/100-puppet_ssh_config.pp: -------------------------------------------------------------------------------- 1 | #using Puppet to make changes to our configuration file. 2 | 3 | include stdlib 4 | 5 | file_line { 'SSH Private Key': 6 | path => '/etc/ssh/ssh_config', 7 | line => ' IdentityFile ~/.ssh/school', 8 | match => '^[#]+[\s]*(?i)IdentityFile[\s]+~/.ssh/id_rsa$', 9 | replace => true, 10 | append_on_no_match => true 11 | } 12 | 13 | file_line { 'Deny Password Auth': 14 | path => '/etc/ssh/ssh_config', 15 | line => ' PasswordAuthentication no', 16 | match => '^[#]+[\s]*(?i)PasswordAuthentication[\s]+(yes|no)$', 17 | replace => true, 18 | append_on_no_match => true 19 | } 20 | -------------------------------------------------------------------------------- /0x0B-ssh/2-ssh_config: -------------------------------------------------------------------------------- 1 | # This is the ssh client system-wide configuration file. See 2 | # ssh_config(5) for more information. This file provides defaults for 3 | # users, and the values can be changed in per-user configuration files 4 | # or on the command line. 5 | 6 | # Configuration data is parsed as follows: 7 | # 1. command line options 8 | # 2. user-specific file 9 | # 3. system-wide file 10 | # Any configuration value is only changed the first time it is set. 11 | # Thus, host-specific definitions should be at the beginning of the 12 | # configuration file, and defaults at the end. 13 | 14 | # Site-wide defaults for some commonly used options. For a comprehensive 15 | # list of available options, their meanings and defaults, please see the 16 | # ssh_config(5) man page. 17 | 18 | Host * 19 | # ForwardAgent no 20 | # ForwardX11 no 21 | # ForwardX11Trusted yes 22 | # RhostsRSAAuthentication no 23 | # RSAAuthentication yes 24 | # PasswordAuthentication yes 25 | # HostbasedAuthentication no 26 | # GSSAPIAuthentication no 27 | # GSSAPIDelegateCredentials no 28 | # GSSAPIKeyExchange no 29 | # GSSAPITrustDNS no 30 | # BatchMode no 31 | # CheckHostIP yes 32 | # AddressFamily any 33 | # ConnectTimeout 0 34 | # StrictHostKeyChecking ask 35 | # IdentityFile ~/.ssh/identity 36 | # IdentityFile ~/.ssh/id_rsa 37 | # IdentityFile ~/.ssh/id_dsa 38 | # Port 22 39 | # Protocol 2,1 40 | # Cipher 3des 41 | # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc 42 | # MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160 43 | # EscapeChar ~ 44 | # Tunnel no 45 | # TunnelDevice any:any 46 | # PermitLocalCommand no 47 | # VisualHostKey no 48 | # ProxyCommand ssh -q -W %h:%p gateway.example.com 49 | # RekeyLimit 1G 1h 50 | SendEnv LANG LC_* 51 | HashKnownHosts yes 52 | GSSAPIAuthentication yes 53 | GSSAPIDelegateCredentials no 54 | IdentityFile ~/.ssh/holberton 55 | PasswordAuthentication no 56 | -------------------------------------------------------------------------------- /0x0B-ssh/README.md: -------------------------------------------------------------------------------- 1 | 0x0B-ssh 2 | -------------------------------------------------------------------------------- /0x0C-web_server/0-transfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Transfers a file from a client to a server 3 | if [ "$#" -lt 3 ] 4 | then 5 | echo "Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY" 6 | elif [ "$#" -eq 3 ] 7 | then 8 | scp -o StrictHostKeyChecking=no "$1" "$3@$2:~/" 9 | else 10 | scp -o StrictHostKeyChecking=no -i "$4" "$1" "$3@$2:~/" 11 | fi 12 | -------------------------------------------------------------------------------- /0x0C-web_server/1-install_nginx_web_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs Nginx with the following configurations: 3 | #+ Listens on port 80. 4 | #+ Returns a page containing "Hello World!" when queried 5 | #++ at the root with a curl GET request. 6 | 7 | sudo apt-get update 8 | sudo apt-get install -y nginx 9 | 10 | # allowing nginx on port 80 11 | sudo ufw allow 'Nginx HTTP' 12 | 13 | # Give the user ownership to website files 14 | sudo chown -R "$USER":"$USER" /var/www/html 15 | sudo chmod -R 755 /var/www 16 | 17 | # Backup default index 18 | cp /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.html.bckp 19 | 20 | # Creating new index 21 | echo -e "Hello World!" > /var/www/html/index.nginx-debian.html 22 | 23 | # Restarting nginx 24 | sudo service nginx restart 25 | -------------------------------------------------------------------------------- /0x0C-web_server/2-setup_a_domain_name: -------------------------------------------------------------------------------- 1 | victorpreston.tech 2 | -------------------------------------------------------------------------------- /0x0C-web_server/3-redirection: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs Nginx with the following configurations: 3 | #+ Listens on port 80. 4 | #+ Returns a page containing "Hello World!" when queried 5 | #++ at the root with a curl GET request. 6 | #/redirect_me is redirecting to another page 7 | 8 | sudo apt-get update 9 | sudo apt-get install -y nginx 10 | 11 | # allowing nginx on port 80 12 | sudo ufw allow 'Nginx HTTP' 13 | 14 | # Give the user ownership to website files 15 | sudo chown -R "$USER":"$USER" /var/www/html 16 | sudo chmod -R 755 /var/www 17 | 18 | # Backup default index 19 | cp /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.html.bckp 20 | 21 | # Creating new index 22 | echo -e "Hello World!" > /var/www/html/index.nginx-debian.html 23 | 24 | # Setting up /redirect_me 25 | sudo sed -i '24i\ rewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;' /etc/nginx/sites-available/default 26 | 27 | # Restarting nginx 28 | sudo service nginx restart 29 | -------------------------------------------------------------------------------- /0x0C-web_server/4-not_found_page_404: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script that installs Nginx server, redirects /redirect_me and customizes 404 not found 3 | apt-get -y update 4 | apt-get -y install nginx 5 | echo "Holberton School" > /var/www/html/index.nginx-debian.html 6 | echo "Ceci n'est pas une page" > /usr/share/nginx/html/custom_404.html 7 | sed -i "s/server_name _;/server_name _;\n\trewrite ^\/redirect_me https:\/\/github.com\/luischaparroc permanent;\n\n\terror_page 404 \/custom_404.html;\n\tlocation = \/custom_404.html {\n\t\troot \/usr\/share\/nginx\/html;\n\t\tinternal;\n\t}/" /etc/nginx/sites-available/default 8 | service nginx start 9 | -------------------------------------------------------------------------------- /0x0C-web_server/7-puppet_install_nginx_web_server.pp: -------------------------------------------------------------------------------- 1 | # Setup New Ubuntu server with nginx 2 | 3 | exec { 'update system': 4 | command => '/usr/bin/apt-get update', 5 | } 6 | 7 | package { 'nginx': 8 | ensure => 'installed', 9 | require => Exec['update system'] 10 | } 11 | 12 | file {'/var/www/html/index.html': 13 | content => 'Hello World!' 14 | } 15 | 16 | exec {'redirect_me': 17 | command => 'sed -i "24i\ rewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;" /etc/nginx/sites-available/default', 18 | provider => 'shell' 19 | } 20 | 21 | service {'nginx': 22 | ensure => running, 23 | require => Package['nginx'] 24 | } 25 | -------------------------------------------------------------------------------- /0x0C-web_server/README.md: -------------------------------------------------------------------------------- 1 | 0x0C-web_server 2 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Run Apache on a Docker container. 3 | echo "Hello Holberton" >> /etc/apache2.conf 4 | service apache2 start 5 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/README.md: -------------------------------------------------------------------------------- 1 | 0x0D-web_stack_debugging_0 2 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/0-nginx_likes_port_80: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script that make nginx listen to port 80 3 | rm /etc/nginx/sites-enabled/default 4 | ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default 5 | service nginx restart 6 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/1-debugging_made_short: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # configures a server to listen on port 80 3 | sudo sed -i "s/8080/80/" /etc/nginx/sites-enabled/default 4 | sudo service nginx restart 5 | echo "" | sudo dd status=none of=/run/nginx.pid 6 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/README.md: -------------------------------------------------------------------------------- 1 | 0x0E-web_stack_debugging_1 2 | 0-nginx_likes_port_80 1-debugging_made_short 3 | -------------------------------------------------------------------------------- /0x0F-load_balancer/0-custom_http_response_header: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # duplicate web-01 to web-02 3 | # these scripts are an upgrade from the web-server scripts... 4 | 5 | # uncomment to see the script run in action 6 | #set -x 7 | 8 | echo -e "Updating and doing some minor checks...\n" 9 | 10 | function install() { 11 | command -v "$1" &> /dev/null 12 | 13 | #shellcheck disable=SC2181 14 | if [ $? -ne 0 ]; then 15 | echo -e " Installing: $1$\n" 16 | sudo apt-get update -y -qq && \ 17 | sudo apt-get install -y "$1" -qq 18 | echo -e "\n" 19 | else 20 | echo -e " ${1} is already installed.\n" 21 | fi 22 | } 23 | 24 | install nginx #install nginx 25 | 26 | echo -e "\nSetting up some minor stuff.\n" 27 | 28 | # allowing nginx on firewall 29 | sudo ufw allow 'Nginx HTTP' 30 | 31 | # Give the user ownership to website files for easy editing 32 | if [ -d "/var/www" ]; then 33 | sudo chown -R "$USER":"$USER" /var/www 34 | sudo chmod -R 755 /var/www 35 | else 36 | sudo mkdir -p /var/www 37 | sudo chown -R "$USER":"$USER" /var/www 38 | sudo chmod -R 755 /var/www 39 | fi 40 | 41 | # create directories if not present 42 | for dir in /var/www/{html,error}; do 43 | if ! [ -d "$dir" ]; then 44 | mkdir -p "$dir" 45 | fi 46 | done 47 | 48 | # creating new index 49 | echo "Hello World!" > /var/www/html/index.html 50 | 51 | # create new error page 52 | echo "Ceci n'est pas une page" > /var/www/html/error_404.html 53 | 54 | # backup default server config file 55 | sudo cp /etc/nginx/sites-enabled/default nginx-sites-enabled_default.backup 56 | 57 | server_config=\ 58 | "server { 59 | listen 80 default_server; 60 | listen [::]:80 default_server; 61 | root /var/www/html; 62 | index index.html index.htm index.nginx-debian.html 63 | server_name_; 64 | add_header X-Served-By \$hostname; 65 | location / { 66 | try_files \$uri \$uri/ =404; 67 | } 68 | if (\$request_filename ~ redirect_me){ 69 | rewrite ^ https://th3-gr00t.tk/ permanent; 70 | } 71 | error_page 404 /error_404.html; 72 | location = /error_404.html { 73 | internal; 74 | } 75 | }" 76 | 77 | #shellcheck disable=SC2154 78 | echo "$server_config" | sudo dd status=none of=/etc/nginx/sites-enabled/default 79 | 80 | if [ "$(pgrep -c nginx)" -le 0 ]; then 81 | sudo service nginx start 82 | else 83 | sudo service nginx restart 84 | fi 85 | -------------------------------------------------------------------------------- /0x0F-load_balancer/1-install_load_balancer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # install load balancer 3 | 4 | 5 | echo -e "Updating and doing some minor checks...\n" 6 | 7 | function install() { 8 | command -v "$1" &> /dev/null 9 | 10 | #shellcheck disable=SC2181 11 | if [ $? -ne 0 ]; then 12 | echo -e " Installing: $1\n" 13 | sudo apt-get update -y -qq && \ 14 | sudo apt-get install -y "$1" -qq 15 | echo -e "\n" 16 | else 17 | echo -e " ${1} is already installed.\n" 18 | fi 19 | } 20 | 21 | install haproxy #install haproxy 22 | 23 | echo -e "\nSetting up some minor stuff.\n" 24 | 25 | # backup default server config file 26 | sudo cp /etc/haproxy/haproxy.cfg haproxy_default.backup 27 | 28 | server_config=\ 29 | " 30 | defaults 31 | mode http 32 | timeout client 15s 33 | timeout connect 10s 34 | timeout server 15s 35 | timeout http-request 10s 36 | frontend clickviral-tech-frontend 37 | bind *:80 38 | default_backend clickviral-tech-backend 39 | backend clickviral-tech-backend 40 | balance roundrobin 41 | server 263954-web-01 54.197.207.40:80 check 42 | server 263954-web-02 34.227.92.157:80 check 43 | " 44 | 45 | # shellcheck disable=SC2154 46 | echo "$server_config" | sudo dd status=none of=/etc/haproxy/haproxy.cfg 47 | 48 | # enable haproxy to be started by init script 49 | echo "ENABLED=1" | sudo dd status=none of=/etc/default/haproxy 50 | 51 | if [ "$(pgrep -c haproxy)" -le 0 ]; then 52 | sudo service haproxy start 53 | else 54 | sudo service haproxy restart 55 | fi 56 | -------------------------------------------------------------------------------- /0x0F-load_balancer/2-puppet_custom_http_response_header.pp: -------------------------------------------------------------------------------- 1 | # Setup New Ubuntu server with nginx 2 | # and add a custom HTTP header 3 | 4 | exec { 'update system': 5 | command => '/usr/bin/apt-get update', 6 | } 7 | 8 | package { 'nginx': 9 | ensure => 'installed', 10 | require => Exec['update system'] 11 | } 12 | 13 | file {'/var/www/html/index.html': 14 | content => 'Hello World!' 15 | } 16 | 17 | exec {'redirect_me': 18 | command => 'sed -i "24i\ rewrite ^/redirect_me https://th3-gr00t.tk/ permanent;" /etc/nginx/sites-available/default', 19 | provider => 'shell' 20 | } 21 | 22 | exec {'HTTP header': 23 | command => 'sed -i "25i\ add_header X-Served-By \$hostname;" /etc/nginx/sites-available/default', 24 | provider => 'shell' 25 | } 26 | 27 | service {'nginx': 28 | ensure => running, 29 | require => Package['nginx'] 30 | } 31 | -------------------------------------------------------------------------------- /0x0F-load_balancer/README.md: -------------------------------------------------------------------------------- 1 | 0x0F-load_balancer 2 | -------------------------------------------------------------------------------- /0x10-https_ssl/0-world_wide_web: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Usage: ./1-world_wide_web 3 | # Display information about subdomains. 4 | 5 | domain_information () { 6 | line=$(dig "$2"."$1" | grep -A1 'ANSWER SECTION:' | tr '\t' '\n' | tail -2 | tr '\n' ' ') 7 | echo "$2 $line" | awk '{print "The subdomain " $1 " is a " $2 " record and points to " $3}' 8 | } 9 | 10 | if [ "$#" == 1 ] 11 | then 12 | domain_information "$1" "www" 13 | domain_information "$1" "lb-01" 14 | domain_information "$1" "web-01" 15 | domain_information "$1" "web-02" 16 | elif [ "$#" == 2 ] 17 | then 18 | domain_information "$1" "$2" 19 | fi 20 | -------------------------------------------------------------------------------- /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 | 36 | frontend http_front 37 | bind *:80 38 | bind *:443 ssl crt /etc/haproxy/certs/myholberton.tech.pem 39 | # Test URI to see if its a letsencrypt request 40 | acl letsencrypt-acl path_beg /.well-known/acme-challenge/ 41 | use_backend letsencrypt-backend if letsencrypt-acl 42 | 43 | stats uri /haproxy?stats 44 | default_backend http_back 45 | 46 | backend http_back 47 | balance roundrobin 48 | server 20738-web-01 3.227.219.226:80 check 49 | server 20738-web-02 3.235.172.223:80 check 50 | 51 | # LetEncrypt server 52 | backend letsencrypt-backend 53 | server letsencrypt 127.0.0.1:54321 54 | 55 | -------------------------------------------------------------------------------- /0x10-https_ssl/100-redirect_http_to_https: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin 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 | 36 | frontend http_front 37 | bind *:80 38 | bind *:443 ssl crt /etc/haproxy/certs/myholberton.tech.pem 39 | # Test URI to see if its a letsencrypt request 40 | acl letsencrypt-acl path_beg /.well-known/acme-challenge/ 41 | use_backend letsencrypt-backend if letsencrypt-acl 42 | 43 | stats uri /haproxy?stats 44 | default_backend http_back 45 | 46 | backend http_back 47 | balance roundrobin 48 | server 20738-web-01 3.227.219.226:80 check 49 | server 20738-web-02 3.235.172.223:80 check 50 | 51 | # LetEncrypt server 52 | backend letsencrypt-backend 53 | server letsencrypt 127.0.0.1:54321 54 | -------------------------------------------------------------------------------- /0x10-https_ssl/README.md: -------------------------------------------------------------------------------- 1 | 0x10-https_ssl 2 | -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/0-blog_post: -------------------------------------------------------------------------------- 1 | # What happens when you type google.com in your browser and press Enter 2 | 3 | Nearly all individuals who have accessed the internet have, on one occasion in their online exploration, entered “https://www.google.com" into a browser. Have you ever pondered what takes place right after you press the enter key? In case you have ever been curious about this, then allow me to clarify that for you. 4 | 5 | Rather than merely skimming the surface, I will delve into the intricacies so that you obtain a complete understanding and also develop technical proficiency concerning how the web operates. Do not worry, I will simplify everything as much as possible for you to comprehend. 6 | 7 | Just to ensure we are on the same wavelength, I assume you are familiar with the term “browser.” However, if you are not, that is perfectly fine. A browser is essentially an application that allows you to access the internet. Some common examples include Google Chrome, Firefox, Vivaldi, Safari, Opera, Edge, etc. 8 | 9 | When you enter a URL (uniform resource locator) such as “https://www.google.com" into your web browser (e.g., Chrome) and hit enter, many actions occur before any output is displayed on your browser. Fortunately, all these actions happen within a split second, so you hardly have time to ponder them. Before I delve into the individual steps involved and expound on them, let me provide you with a brief overview of all the processes that occur within those few microseconds. 10 | 11 | Your computer sends a request to the domain name system (DNS) server, which functions as an address book for all domain names. The DNS server then returns the precise IP address of the server that https://www.google.com points to. 12 | 13 | With this IP address, your computer then creates a connection with the server via the IP address. This connection type is called TCP (Transmission Control Protocol), and your computer can establish this connection through the IP (Internet Protocol). This entire process is known as a “handshake.” 14 | 15 | If your computer is situated behind a firewall, the firewall verifies that the specific request you are making is authorized before granting it. Additionally, if the server you are attempting to access is also behind a firewall, a similar check will be conducted before you can ultimately connect to the server. 16 | 17 | Once the connection is established, your browser sends a request for the webpage using a security protocol like SSL (Secure Sockets Layer) or TLS (Transport Layer Security) to encrypt the data that will be exchanged between your computer and the server. This encryption is responsible for the “s” in “https” (Hypertext Transfer Protocol Secure), indicating a secure connection. 18 | 19 | To handle high traffic, companies like Google maintain multiple servers and use a load balancer to distribute requests among them. The load balancer receives the request from your browser and sends it to a specific server based on its algorithm. 20 | 21 | The server receiving the request sends a response back to the load balancer, which in turn sends it back to your browser. The response typically includes HTML (Hyper Text Markup Language), CSS (Cascading Style Sheets), and JavaScript files that make up the webpage. The HTML files instruct the browser how to display the content, while the CSS file styles it, and the JavaScript file adds interactivity. 22 | 23 | If dynamic content, such as Google search results, is required, the web server requests it from an application server, which may then request data from a database server. The web server includes this data in the response it sends back to the browser. Finally, the browser renders the webpage and displays it to you. 24 | 25 | Are you aware of the numerous activities that happen before you can view anything on your web browser? This is just a brief summary of the process. Now, let’s examine each step in detail. 26 | 27 | Domain Name System (DNS) Request 28 | Whenever you enter a domain name or website on your browser, the browser saves the DNS record in its cache. 29 | 30 | Thus, when you type a domain name like “google.com” on your web browser, it checks its cache for the most recent copy of the DNS record for that domain. 31 | 32 | If there is a recent copy of the DNS record for that domain, the browser uses the IP address in the cache to send a request to the server. This speeds up the process of converting the domain name to an IP address because it bypasses the need to send a request to the DNS server. 33 | 34 | However, if the browser cache does not have a recent copy of the DNS record or if the DNS record has been updated since the last time it was cached, the browser sends a request to the DNS server to convert the domain name to an IP address. 35 | 36 | This is a complex process, so let’s delve into the different stages involved. 37 | 38 | DNS Lookup Process 39 | Here’s how the DNS lookup process works: 40 | 41 | The browser sends a request to the local DNS resolver, which is often provided by the internet service provider (ISP). The local DNS resolver checks its cache for the most recent copy of the DNS record for the domain. If it has it, it sends the IP address back to the browser. If the local DNS resolver does not have the most recent copy of the DNS record, it sends a request to a root nameserver. The root nameserver replies with the address of a top-level domain (TLD) nameserver, such as .com 42 | 43 | The local DNS resolver sends a request to the TLD nameserver. 44 | The TLD nameserver responds with the address of the authoritative nameserver for the domain. 45 | The local DNS resolver sends a request to the authoritative nameserver. 46 | The authoritative nameserver responds with the IP address for the domain. 47 | The local DNS resolver sends the IP address back to the browser. 48 | The browser sends a request to the server at the IP address to retrieve the webpage. 49 | This process may involve additional steps if the DNS record is not found at any of the nameservers or if the DNS record is set up to use a service such as DNS load balancing or content delivery networks (CDN). 50 | 51 | The duration for which the DNS record is cached (known as the “TTL” or “Time To Live”) is determined by the authoritative nameserver and can be customized by the domain owner. 52 | 53 | TCP/IP connectivity 54 | TCP (Transmission Control Protocol) and IP (Internet Protocol) are two of the primary protocols that constitute the internet. They work in conjunction to establish a link between a client and a server and facilitate the exchange of data between them. When you input “google.com” into a web browser, the browser employs TCP/IP to establish a link with the server that hosts the website. 55 | 56 | Here’s what happens in greater detail: 57 | 58 | The browser uses IP to send a request to the server to establish a connection. 59 | The server receives the request and sends a message back acknowledging the request to establish a connection. This is known as the handshake procedure. 60 | Once the handshake is completed, the browser can use TCP to send a request for the webpage it wants to access (in this instance, the homepage of google.com). This request is made using TCP, which ensures that the request is sent reliably and in the correct sequence. 61 | The server receives the request and sends the HTML code for the homepage of google.com back to the browser. This response is also sent using TCP to ensure dependable transmission. 62 | The browser receives the HTML code and uses it to display the webpage on your screen. Any resources (such as images) that the webpage requires are also requested and received using TCP/IP. 63 | Firewall protection 64 | A firewall is a security system that regulates and monitors incoming and outgoing network traffic based on predetermined security policies. Its primary objective is to safeguard a network from external threats, such as hackers and malware. 65 | 66 | When you type a URL like “google.com” into your browser, the request that your browser makes to Google’s server passes through the firewall en route. The firewall examines the incoming request to ensure that it is permitted based on its security policies. 67 | 68 | There are two primary types of security policies that a firewall employs to examine incoming requests: 69 | 70 | policies that allow or prohibit traffic based on the origin and destination of the request. For example, a firewall may be programmed to block all traffic from specific countries or to allow only specific IP addresses to access the network. 71 | policies that allow or prohibit traffic based on the type of traffic. For example, a firewall may be programmed to block all traffic on certain ports (such as those used by malware) or to allow only certain types of traffic (such as HTTP or HTTPS). 72 | If the incoming request 73 | 74 | HTTPS/SSL 75 | HTTPS (Hypertext Transfer Protocol Secure) is a safe version of HTTP, which is used to transmit data on the internet. It encrypts the data sent between your browser and Google’s server. 76 | 77 | SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are encryption protocols that ensure the safety of data transmitted over HTTPS. 78 | 79 | When your browser connects to Google’s server using HTTPS, it agrees with Google’s server on the version of SSL/TLS to use and creates a secure, encrypted channel for data transmission. 80 | 81 | To explain what is happening here, let me use an analogy. 82 | 83 | HTTPS is like a locked box used to send messages over the internet. When you use HTTPS to send a message, you put it in the locked box and send it to the recipient. Only the recipient has the key to unlock the box and read the message. 84 | 85 | SSL/TLS are like special codes used to lock and unlock the box. When you use HTTPS to send a message, you and the recipient agree on the code to use to lock and unlock the box. This way, only you and the recipient know the code and can read the message. 86 | 87 | When you enter “google.com” into your browser, the browser is like the sender of the message. The server hosting google.com is like the recipient. The browser sends a request for the webpage using HTTPS, which is like putting the request in a locked box and sending it to the server. The server then sends the webpage back to the browser using HTTPS, which is like putting the webpage in the locked box and sending it back to the browser. 88 | 89 | Load-balancer 90 | A load balancer is a tool that distributes incoming network traffic across a group of servers or resources. Its main function is to ensure that the traffic is distributed evenly across the servers to prevent overloading any single server and to increase the overall capacity and reliability of the system. 91 | 92 | Google, which receives billions of website visitors a day, requires many servers to serve all these users. Therefore, they need to set up a load balancer to ensure that some servers are not overburdened while others are underutilized. When a browser tries to access google.com, the load balancer receives the incoming request from the browser and forwards it to one of the servers in the Google server network. The server chosen will depend on the type of load balancing algorithm implemented. 93 | 94 | Web Server 95 | A web server is a software that is in charge of managing requests for web pages from clients (such as a browser attempting to access google.com). When a client sends a request for a web page to a website server, the server handles the request and returns the appropriate response to the client. 96 | 97 | This means that Google’s server will obtain a request from the load balancer when attempting to access google.com. 98 | 99 | The web server would then handle the request and produce a response, which would usually consist of the HTML, CSS, and JavaScript files that make up the web page. 100 | 101 | The website server would then send this response back to the load balancer, which would forward it to the browser. The browser would then use the HTML, CSS, and JavaScript files to display the web page for the user. 102 | 103 | Server for Applications and Database 104 | 105 | Unlike the web server, the application server handles dynamic content. When using “google.com,” the application server will be responsible for producing the search results (which change based on the query you input into the search engine). 106 | 107 | When you submit a search query to Google, the request is first sent to the load balancer, which forwards it to one of the web servers in the Google server network. The web server then sends the request to the application server, which handles the request and produces the search results. Depending on the complexity of the search query, the application server may need to make a request to a database to retrieve the necessary data. 108 | 109 | For instance, if you are searching for a particular product on an e-commerce website, the application server may need to obtain information about the product from a database. 110 | 111 | Once the application server has acquired the required data, it sends it back to the website server, which includes it in the response that is sent back to the browser. The browser then uses this information to display the search results to you. 112 | 113 | Displaying the Web Page 114 | 115 | When a browser receives a response from a website server, it processes the HTML, CSS, and JavaScript files that are included in the response in order to display the web page. The displaying process involves interpreting the HTML and CSS code, displaying any images or other media that are included on the page, and executing any JavaScript code that is present on the page. 116 | 117 | In your instance, your browser would receive the response from the website server, which includes the HTML, CSS, and JavaScript files that make up the Google web page. The browser will utilize these files to display the webpage and present it to you. This method typically includes the following: 118 | 119 | presenting the text and pictures on the webpage in the appropriate positions 120 | arranging the text and design in line with the CSS styles 121 | performing any JavaScript code that exists on the webpage 122 | After the webpage has been entirely displayed, you can now engage with it by pressing links, typing text, or interacting with other features on the webpage. 123 | In conclusion, I hope that this short post has given you a better understanding of everything that occurs “under the hood” when you type www.google.com into your browser and press Enter 124 | 125 | Thank you for reading. 126 | -------------------------------------------------------------------------------- /0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter/1-what_happen_when_diagram: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/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/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/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 | 0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter 2 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/0-iamsomeoneelse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs whoami command as the user provided in argument 3 | sudo -u "$1" whoami 4 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/1-run_nginx_as_nginx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes server bug 3 | chmod 644 /etc/nginx/nginx.conf 4 | sed -Ei 's/\s*#?\s*user .*/user nginx;/' /etc/nginx/nginx.conf 5 | sed -Ei 's/(listen (\[::\]:)?80) /\180 /' /etc/nginx/sites-enabled/default 6 | pkill apache2 7 | # restart 8 | su nginx -s /bin/bash -c 'service nginx restart' 9 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/100-fix_in_7_lines_or_less: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fixes server bug 3 | chmod 644 /etc/nginx/nginx.conf 4 | sed -Ei 's/\s*#?\s*user .*/user nginx;/' /etc/nginx/nginx.conf 5 | sed -Ei 's/(listen (\[::\]:)?80) /\180 /' /etc/nginx/sites-enabled/default 6 | pkill apache2 7 | su nginx -s /bin/bash -c 'service nginx restart' 8 | -------------------------------------------------------------------------------- /0x12-web_stack_debugging_2/README.md: -------------------------------------------------------------------------------- 1 | ## 0x12-web_stack_debugging_2 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 | 5 | sudo apt-get install ufw -y 6 | sudo ufw default deny incoming 7 | sudo ufw default allow outgoing 8 | sudo ufw allow 22/tcp 9 | sudo ufw allow 443/tcp 10 | sudo ufw allow 80/tcp 11 | sudo ufw enable 12 | sudo ufw status 13 | -------------------------------------------------------------------------------- /0x13-firewall/100-port_forwarding: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/ufw/before.rules 3 | # 4 | # rules.before 5 | # 6 | # Rules that should be run before the ufw command line added rules. Custom 7 | # rules should be added to one of these chains: 8 | # ufw-before-input 9 | # ufw-before-output 10 | # ufw-before-forward 11 | # 12 | 13 | # Don't delete these required lines, otherwise there will be errors 14 | *filter 15 | :ufw-before-input - [0:0] 16 | :ufw-before-output - [0:0] 17 | :ufw-before-forward - [0:0] 18 | :ufw-not-local - [0:0] 19 | # End required lines 20 | 21 | # Allow port forwarding from port 8080/TCP to port 80/TCP 22 | *nat 23 | :PREROUTING ACCEPT [0:0] 24 | -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 25 | COMMIT 26 | 27 | 28 | # allow all on loopback 29 | -A ufw-before-input -i lo -j ACCEPT 30 | -A ufw-before-output -o lo -j ACCEPT 31 | 32 | # quickly process packets for which we already have a connection 33 | -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 34 | -A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 35 | -A ufw-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 36 | 37 | # drop INVALID packets (logs these in loglevel medium and higher) 38 | -A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny 39 | -A ufw-before-input -m conntrack --ctstate INVALID -j DROP 40 | 41 | # ok icmp codes for INPUT 42 | -A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT 43 | -A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT 44 | -A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT 45 | -A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT 46 | 47 | # ok icmp code for FORWARD 48 | -A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT 49 | -A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT 50 | -A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT 51 | -A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT 52 | 53 | # allow dhcp client to work 54 | -A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT 55 | 56 | # 57 | # ufw-not-local 58 | # 59 | -A ufw-before-input -j ufw-not-local 60 | 61 | # if LOCAL, RETURN 62 | -A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN 63 | 64 | # if MULTICAST, RETURN 65 | -A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN 66 | 67 | # if BROADCAST, RETURN 68 | -A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN 69 | 70 | # all other non-local packets are dropped 71 | -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny 72 | -A ufw-not-local -j DROP 73 | 74 | # allow MULTICAST mDNS for service discovery (be sure the MULTICAST line above 75 | # is uncommented) 76 | -A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT 77 | 78 | # allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above 79 | # is uncommented) 80 | -A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT 81 | 82 | # don't delete the 'COMMIT' line or these rules won't be processed 83 | COMMIT 84 | -------------------------------------------------------------------------------- /0x13-firewall/README.md: -------------------------------------------------------------------------------- 1 | 0x13-firewall 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | symbolic-links=0 7 | server-id = 2 8 | log_bin = /var/log/mysql/mysql-bin.log 9 | -------------------------------------------------------------------------------- /0x14-mysql/5-mysql_backup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # backup and compress my databases 3 | 4 | # variables 5 | day=$(date +"%d") 6 | month=$(date +"%m") 7 | year=$(date +"%Y") 8 | file_name="$day-$month-$year.tar.gz" 9 | 10 | mysqldump --all-databases -u root --password="$1" > backup.sql 11 | tar -czvf "$file_name" backup.sql 12 | -------------------------------------------------------------------------------- /0x14-mysql/README.md: -------------------------------------------------------------------------------- 1 | 0x14-mysql 2 | -------------------------------------------------------------------------------- /0x14-mysql/install-log: -------------------------------------------------------------------------------- 1 | sudo apt-key add signature.key 2 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C 3 | sudo sh -c 'echo "deb http://repo.mysql.com/apt/ubuntu bionic mysql-5.7" >> /etc/apt/sources.list.d/mysql.list' 4 | sudo apt-get update 5 | sudo apt-cache policy mysql-server 6 | sudo apt install -f -y mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7* 7 | -------------------------------------------------------------------------------- /0x14-mysql/setup.sql: -------------------------------------------------------------------------------- 1 | CREATE USER holberton_user@localhost IDENTIFIED BY "projectcorrection280hbtn"; 2 | GRANT REPLICATION CLIENT ON *.* TO 'holberton_user'@'localhost'; 3 | CREATE DATABASE tyrell_corp; 4 | USE tyrell_corp; 5 | CREATE TABLE nexus6(id INTEGER, name TEXT); 6 | INSERT INTO nexus6 VALUES (0, "Jarvis"); 7 | GRANT SELECT ON tyrell_corp.nexus6 TO holberton_user@localhost; 8 | CREATE USER replica_user@'%' IDENTIFIED BY "replica_user"; 9 | GRANT REPLICATION SLAVE ON *.* TO 'replica_user'@'%'; 10 | GRANT SELECT ON mysql.user TO holberton_user@localhost; 11 | CREATE USER web02@34.227.101.160 IDENTIFIED BY "web02"; 12 | GRANT REPLICATION SLAVE ON *.* TO web02@34.227.101.160; 13 | -------------------------------------------------------------------------------- /0x15-api/0-gather_data_from_an_API.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Returns to-do list information for a given employee ID.""" 3 | import requests 4 | import sys 5 | 6 | 7 | if __name__ == "__main__": 8 | """Function to display employee todo list.""" 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") is True] 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 | 8 | if __name__ == "__main__": 9 | """Exports to csv.""" 10 | user_id = sys.argv[1] 11 | url = "https://jsonplaceholder.typicode.com/" 12 | user = requests.get(url + "users/{}".format(user_id)).json() 13 | username = user.get("username") 14 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 15 | 16 | with open("{}.csv".format(user_id), "w", newline="") as csvfile: 17 | writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) 18 | [writer.writerow( 19 | [user_id, username, t.get("completed"), t.get("title")] 20 | ) for t in todos] 21 | -------------------------------------------------------------------------------- /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 | 8 | if __name__ == "__main__": 9 | user_id = sys.argv[1] 10 | url = "https://jsonplaceholder.typicode.com/" 11 | user = requests.get(url + "users/{}".format(user_id)).json() 12 | username = user.get("username") 13 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 14 | 15 | with open("{}.json".format(user_id), "w") as jsonfile: 16 | json.dump({user_id: [{ 17 | "task": t.get("title"), 18 | "completed": t.get("completed"), 19 | "username": username 20 | } for t in todos]}, jsonfile) 21 | -------------------------------------------------------------------------------- /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 | 7 | if __name__ == "__main__": 8 | url = "https://jsonplaceholder.typicode.com/" 9 | users = requests.get(url + "users").json() 10 | 11 | with open("todo_all_employees.json", "w") as jsonfile: 12 | json.dump({ 13 | u.get("id"): [{ 14 | "username": u.get("username"), 15 | "task": t.get("title"), 16 | "completed": t.get("completed") 17 | } for t in requests.get(url + "todos", 18 | params={"userId": u.get("id")}).json()] 19 | for u in users}, jsonfile) 20 | -------------------------------------------------------------------------------- /0x15-api/README.md: -------------------------------------------------------------------------------- 1 | 0x15-api 2 | -------------------------------------------------------------------------------- /0x16-api_advanced/0-subs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Script that queries subscribers on a given Reddit subreddit. 4 | """ 5 | 6 | import requests 7 | 8 | 9 | def number_of_subscribers(subreddit): 10 | """Return the total number of subscribers on a given subreddit.""" 11 | url = "https://www.reddit.com/r/{}/about.json".format(subreddit) 12 | headers = {"User-Agent": "Mozilla/5.0"} 13 | response = requests.get(url, headers=headers, allow_redirects=False) 14 | if response.status_code == 200: 15 | data = response.json() 16 | subscribers = data['data']['subscribers'] 17 | return subscribers 18 | else: 19 | return 0 20 | -------------------------------------------------------------------------------- /0x16-api_advanced/1-top_ten.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Script to print hot posts on a given Reddit subreddit. 4 | """ 5 | 6 | import requests 7 | 8 | 9 | def top_ten(subreddit): 10 | """Print the titles of the 10 hottest posts on a given subreddit.""" 11 | # Construct the URL for the subreddit's hot posts in JSON format 12 | url = "https://www.reddit.com/r/{}/hot/.json".format(subreddit) 13 | 14 | # Define headers for the HTTP request, including User-Agent 15 | headers = { 16 | "User-Agent": "linux:0x16.api.advanced:v1.0.0 (by /u/bdov_)" 17 | } 18 | 19 | # Define parameters for the request, limiting the number of posts to 10 20 | params = { 21 | "limit": 10 22 | } 23 | 24 | # Send a GET request to the subreddit's hot posts page 25 | response = requests.get(url, headers=headers, params=params, 26 | allow_redirects=False) 27 | 28 | # Check if the response status code indicates a not-found error (404) 29 | if response.status_code == 404: 30 | print("None") 31 | return 32 | 33 | # Parse the JSON response and extract the 'data' section 34 | results = response.json().get("data") 35 | 36 | # Print the titles of the top 10 hottest posts 37 | [print(c.get("data").get("title")) for c in results.get("children")] 38 | -------------------------------------------------------------------------------- /0x16-api_advanced/100-count.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Function to count words in all hot posts of a given Reddit subreddit. 4 | """ 5 | import requests 6 | 7 | 8 | def count_words(subreddit, word_list, after=None, counts={}): 9 | """ 10 | Recursive function that queries the Reddit API, parses the title of all 11 | hot articles, and prints a sorted count of given keywords 12 | """ 13 | if not word_list or word_list == [] or not subreddit: 14 | return 15 | 16 | url = f"https://www.reddit.com/r/{subreddit}/hot.json" 17 | headers = {"User-Agent": "Mozilla/5.0"} 18 | 19 | params = {"limit": 100} 20 | if after: 21 | params["after"] = after 22 | 23 | response = requests.get(url, 24 | headers=headers, 25 | params=params, 26 | allow_redirects=False) 27 | 28 | if response.status_code != 200: 29 | return 30 | 31 | data = response.json() 32 | children = data["data"]["children"] 33 | 34 | for post in children: 35 | title = post["data"]["title"].lower() 36 | for word in word_list: 37 | if word.lower() in title: 38 | counts[word] = counts.get(word, 0) + title.count(word.lower()) 39 | 40 | after = data["data"]["after"] 41 | if after: 42 | count_words(subreddit, word_list, after, counts) 43 | else: 44 | sorted_counts = sorted(counts.items(), 45 | key=lambda x: (-x[1], x[0].lower())) 46 | for word, count in sorted_counts: 47 | print(f"{word.lower()}: {count}") 48 | -------------------------------------------------------------------------------- /0x16-api_advanced/2-recurse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | Script to query a list of all hot posts on a given Reddit subreddit. 4 | """ 5 | 6 | import requests 7 | 8 | 9 | def recurse(subreddit, hot_list=[], after="", count=0): 10 | """ 11 | Recursively retrieves a list of titles of all hot posts 12 | on a given subreddit. 13 | 14 | Args: 15 | subreddit (str): The name of the subreddit. 16 | hot_list (list, optional): List to store the post titles. 17 | Default is an empty list. 18 | after (str, optional): Token used for pagination. 19 | Default is an empty string. 20 | count (int, optional): Current count of retrieved posts. Default is 0. 21 | 22 | Returns: 23 | list: A list of post titles from the hot section of the subreddit. 24 | """ 25 | # Construct the URL for the subreddit's hot posts in JSON format 26 | url = "https://www.reddit.com/r/{}/hot/.json".format(subreddit) 27 | 28 | # Define headers for the HTTP request, including User-Agent 29 | headers = { 30 | "User-Agent": "linux:0x16.api.advanced:v1.0.0 (by /u/bdov_)" 31 | } 32 | 33 | # Define parameters for the request, including pagination and limit 34 | params = { 35 | "after": after, 36 | "count": count, 37 | "limit": 100 38 | } 39 | 40 | # Send a GET request to the subreddit's hot posts page 41 | response = requests.get(url, headers=headers, params=params, 42 | allow_redirects=False) 43 | 44 | # Check if the response status code indicates a not-found error (404) 45 | if response.status_code == 404: 46 | return None 47 | # Parse the JSON response and extract relevant data 48 | results = response.json().get("data") 49 | after = results.get("after") 50 | count += results.get("dist") 51 | 52 | # Append post titles to the hot_list 53 | for c in results.get("children"): 54 | hot_list.append(c.get("data").get("title")) 55 | 56 | # If there are more posts to retrieve, recursively call the function 57 | if after is not None: 58 | return recurse(subreddit, hot_list, after, count) 59 | 60 | # Return the final list of hot post titles 61 | return hot_list 62 | -------------------------------------------------------------------------------- /0x16-api_advanced/README.md: -------------------------------------------------------------------------------- 1 | 0x16-api_advanced 2 | -------------------------------------------------------------------------------- /0x16-api_advanced/__pycache__/0-subs.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/0x16-api_advanced/__pycache__/0-subs.cpython-38.pyc -------------------------------------------------------------------------------- /0x16-api_advanced/tests/0-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | 0-main 4 | """ 5 | import sys 6 | 7 | if __name__ == '__main__': 8 | number_of_subscribers = __import__('0-subs').number_of_subscribers 9 | if len(sys.argv) < 2: 10 | print("Please pass an argument for the subreddit to search.") 11 | else: 12 | print("{:d}".format(number_of_subscribers(sys.argv[1]))) 13 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/1-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | 1-main 4 | """ 5 | import sys 6 | 7 | if __name__ == '__main__': 8 | top_ten = __import__('1-top_ten').top_ten 9 | if len(sys.argv) < 2: 10 | print("Please pass an argument for the subreddit to search.") 11 | else: 12 | top_ten(sys.argv[1]) 13 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/100-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | 100-main 4 | """ 5 | import sys 6 | 7 | if __name__ == '__main__': 8 | count_words = __import__('100-count').count_words 9 | if len(sys.argv) < 3: 10 | print("Usage: {} ".format(sys.argv[0])) 11 | print("Ex: {} programming 'python java javascript'".format(sys.argv[0])) 12 | else: 13 | result = count_words(sys.argv[1], [x for x in sys.argv[2].split()]) 14 | -------------------------------------------------------------------------------- /0x16-api_advanced/tests/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") 17 | -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/0-strace_is_your_friend.pp: -------------------------------------------------------------------------------- 1 | # Fix 500 error when a GET HTTP method is requested to Apache web server 2 | 3 | exec {'replace': 4 | provider => shell, 5 | command => 'sed -i "s/phpp/php/g" /var/www/html/wp-settings.php' 6 | } 7 | -------------------------------------------------------------------------------- /0x17-web_stack_debugging_3/README.md: -------------------------------------------------------------------------------- 1 | 0x17-web_stack_debugging_3 2 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/0-setup_datadog: -------------------------------------------------------------------------------- 1 | 6c1392aa3f8609a7062e14f94d2fae2c 2 | d0b38147de661f7575781a0460874c94b156a954 3 | -------------------------------------------------------------------------------- /0x18-webstack_monitoring/2-setup_datadog: -------------------------------------------------------------------------------- 1 | srv-5ud-a2h 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://security.ubuntu.com/ubuntu focal-security InRelease 8 | Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease 9 | Ign:3 https://apt.datadoghq.com stable InRelease 10 | Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease 11 | Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease 12 | Hit:6 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu focal InRelease 13 | Hit:7 https://apt.datadoghq.com stable Release 14 | Reading package lists... 15 | Reading package lists... 16 | Building dependency tree... 17 | Reading state information... 18 | curl is already the newest version (7.68.0-1ubuntu2.21). 19 | gnupg is already the newest version (2.2.19-3ubuntu2.2). 20 | apt-transport-https is already the newest version (2.0.10). 21 | 0 upgraded, 0 newly installed, 0 to remove and 247 not upgraded. 22 |  23 | * Installing APT package sources for Datadog 24 |  25 | % Total % Received % Xferd Average Speed Time Time Time Current 26 | Dload Upload Total Spent Left Speed 27 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 6226 100 6226 0 0 31765 0 --:--:-- --:--:-- --:--:-- 57648 28 | gpg: key 32637D44F14F620E: "Datadog, Inc. Master key (2020-09-08) " not changed 29 | gpg: Total number processed: 1 30 | gpg: unchanged: 1 31 | % Total % Received % Xferd Average Speed Time Time Time Current 32 | Dload Upload Total Spent Left Speed 33 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1713 100 1713 0 0 17130 0 --:--:-- --:--:-- --:--:-- 152k 34 | gpg: key E6266D4AC0962C7D: "Datadog, Inc. APT key (2023-04-20) (APT key) " not changed 35 | gpg: Total number processed: 1 36 | gpg: unchanged: 1 37 | % Total % Received % Xferd Average Speed Time Time Time Current 38 | Dload Upload Total Spent Left Speed 39 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 6226 100 6226 0 0 61039 0 --:--:-- --:--:-- --:--:-- 61039 40 | gpg: key 32637D44F14F620E: "Datadog, Inc. Master key (2020-09-08) " not changed 41 | gpg: Total number processed: 1 42 | gpg: unchanged: 1 43 | % Total % Received % Xferd Average Speed Time Time Time Current 44 | Dload Upload Total Spent Left Speed 45 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 9001 100 9001 0 0 89118 0 --:--:-- --:--:-- --:--:-- 89118 46 | gpg: key D3A80E30382E94DE: "Datadog, Inc " not changed 47 | gpg: Total number processed: 1 48 | gpg: unchanged: 1 49 | Ign:1 https://apt.datadoghq.com stable InRelease 50 | Hit:2 https://apt.datadoghq.com stable Release 51 | Reading package lists... 52 | Installing package(s): datadog-agent datadog-signing-keys datadog-apm-inject datadog-apm-library-java datadog-apm-library-js datadog-apm-library-python datadog-apm-library-dotnet datadog-apm-library-ruby 53 |  54 | Reading package lists... 55 | Building dependency tree... 56 | Reading state information... 57 | datadog-signing-keys is already the newest version (1:1.3.1-1). 58 | datadog-apm-library-js is already the newest version (4.19.0-1). 59 | datadog-apm-inject is already the newest version (0.12.3-1). 60 | datadog-apm-library-ruby is already the newest version (1.20.0-1). 61 | datadog-apm-library-java is already the newest version (1.29.0-1). 62 | datadog-apm-library-python is already the newest version (2.6.1-1). 63 | datadog-apm-library-dotnet is already the newest version (2.47.0-1). 64 | The following NEW packages will be installed: 65 | datadog-agent 66 | 0 upgraded, 1 newly installed, 0 to remove and 247 not upgraded. 67 | Need to get 404 MB of archives. 68 | After this operation, 1,321 MB of additional disk space will be used. 69 | Get:1 https://apt.datadoghq.com stable/7 amd64 datadog-agent amd64 1:7.50.3-1 [404 MB] 70 | debconf: delaying package configuration, since apt-utils is not installed 71 | Fetched 404 MB in 37s (10.8 MB/s) 72 | (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 ... 102072 files and directories currently installed.) 73 | Preparing to unpack .../datadog-agent_1%3a7.50.3-1_amd64.deb ... 74 | Unpacking datadog-agent (1:7.50.3-1) ... 75 | dpkg: error processing archive /var/cache/apt/archives/datadog-agent_1%3a7.50.3-1_amd64.deb (--unpack): 76 | error creating directory './opt/datadog-agent/embedded/lib/python3.9/site-packages/lz4/frame/__pycache__': Disk quota exceeded 77 | dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) 78 | Errors were encountered while processing: 79 | /var/cache/apt/archives/datadog-agent_1%3a7.50.3-1_amd64.deb 80 | W: --force-yes is deprecated, use one of the options starting with --allow instead. 81 | E: Sub-process /usr/bin/dpkg returned an error code (1) 82 | ERROR 83 | Failed to install one or more packages, sometimes it may be 84 | due to another APT source failing. See the logs above to 85 | determine the cause. 86 | If the cause is unclear, please contact Datadog support. 87 | ***** 88 | 89 | It looks like you hit an issue when trying to install the Datadog Agent. 90 | 91 | 92 | 93 | Troubleshooting and basic usage information for the Datadog Agent are available at: 94 | 95 | https://docs.datadoghq.com/agent/basic_agent_usage/ 96 |  97 | Do you want to send a failure report to Datadog (including ddagent-install.log)? (y/[n]) Enter an email address so we can follow up: OKA notification has been sent to Datadog with the contents of ddagent-install.log 98 | 99 | If you are still having problems, please send an email to support@datadoghq.com 100 | with the contents of ddagent-install.log and any information you think would be 101 | useful and we will do our very best to help you solve your problem. 102 | -------------------------------------------------------------------------------- /0x19-postmortem/README.md: -------------------------------------------------------------------------------- 1 | 0x19-postmortem 2 | -------------------------------------------------------------------------------- /0x1A-application_server/2-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/luischaparroc permanent; 15 | 16 | error_page 404 /custom_404.html; 17 | 18 | location = /custom_404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location / { 29 | try_files $uri $uri/ =404; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /0x1A-application_server/3-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/luischaparroc permanent; 15 | 16 | error_page 404 /custom_404.html; 17 | 18 | location = /custom_404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location / { 34 | try_files $uri $uri/ =404; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /0x1A-application_server/4-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost; 5 | 6 | root /var/www/html; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/luischaparroc permanent; 15 | 16 | error_page 404 /custom_404.html; 17 | 18 | location = /custom_404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location /api/ { 34 | include proxy_params; 35 | proxy_pass http://0.0.0.0:5002/api/; 36 | } 37 | 38 | location / { 39 | try_files $uri $uri/ =404; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /0x1A-application_server/5-app_server-nginx_config: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 ipv6only=on default_server; 4 | server_name localhost 35.231.33.237; 5 | 6 | root /home/ubuntu/AirBnB_clone_v4/web_dynamic; 7 | 8 | location /hbnb_static/ { 9 | alias /data/web_static/current/; 10 | autoindex off; 11 | } 12 | 13 | index index.html index.htm index.nginx-debian.html; 14 | rewrite ^/redirect_me https://github.com/luischaparroc permanent; 15 | 16 | error_page 404 /custom_404.html; 17 | 18 | location = /custom_404.html { 19 | root /usr/share/nginx/html; 20 | internal; 21 | } 22 | 23 | location /airbnb-onepage/ { 24 | include proxy_params; 25 | proxy_pass http://0.0.0.0:5000/airbnb-onepage/; 26 | } 27 | 28 | location /airbnb-dynamic/number_odd_or_even/ { 29 | include proxy_params; 30 | proxy_pass http://0.0.0.0:5001/number_odd_or_even/; 31 | } 32 | 33 | location /static { 34 | } 35 | 36 | location /api/ { 37 | include proxy_params; 38 | proxy_pass http://0.0.0.0:5002/api/; 39 | } 40 | 41 | location / { 42 | include proxy_params; 43 | proxy_pass http://0.0.0.0:5003/2-hbnb/; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /0x1A-application_server/README.md: -------------------------------------------------------------------------------- 1 | 0x1A-application_server 2 | -------------------------------------------------------------------------------- /0x1A-application_server/app-server-config: -------------------------------------------------------------------------------- 1 | echo "Updating Packages and Installing Requirements" 2 | 3 | # Update Package Manager 4 | sudo apt-get update 5 | sudo apt-get install -y nginx 6 | # Install pip 7 | sudo apt-get install -y python3-pip 8 | # Install Flask, flask_cors, sqlalchemy Using PIP 9 | pip install flask 10 | pip install flask_cors 11 | pip install sqlalchemy 12 | # Install net-tools 13 | sudo apt install -y net-tools 14 | # Install GUNICORN 15 | sudo apt-get install -y gunicorn 16 | # Remove any current AIRBNB Repositoty 17 | rm -rf AirBnB_clone_v* 18 | # Clone My Repository 19 | git clone https://github.com/victorpreston/AirBnB_clone_v2 20 | git clone https://github.com/victorpreston/AirBnB_clone_v3 21 | git clone https://github.com/victorpreston/AirBnB_clone_v4 22 | # Change Directory 23 | cd AirBnB_clone_v2 24 | # Switch Branches 25 | git checkout app-server 26 | 27 | # Define the path to the Nginx configuration file to be overwritten 28 | NGINX_CONFIG="/etc/nginx/sites-enabled/default" 29 | 30 | # Overwrite the Nginx configuration file with the provided configuration 31 | sudo tee "$NGINX_CONFIG" > /dev/null <> /tmp/airbnb-access.log 2> /tmp/airbnb-error.log 13 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/0-the_sky_is_the_limit_not.pp: -------------------------------------------------------------------------------- 1 | # Fix problem of high amount of requests 2 | 3 | exec {'replace': 4 | provider => shell, 5 | command => 'sudo sed -i "s/ULIMIT=\"-n 15\"/ULIMIT=\"-n 4096\"/" /etc/default/nginx', 6 | before => Exec['restart'], 7 | } 8 | 9 | exec {'restart': 10 | provider => shell, 11 | command => 'sudo service nginx restart', 12 | } 13 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/1-user_limit.pp: -------------------------------------------------------------------------------- 1 | # Enable the user holberton to login and open files without error. 2 | 3 | # Increase hard file limit for Holberton user. 4 | exec { 'increase-hard-file-limit-for-holberton-user': 5 | command => 'sed -i "/holberton hard/s/5/50000/" /etc/security/limits.conf', 6 | path => '/usr/local/bin/:/bin/' 7 | } 8 | 9 | # Increase soft file limit for Holberton user. 10 | exec { 'increase-soft-file-limit-for-holberton-user': 11 | command => 'sed -i "/holberton soft/s/4/50000/" /etc/security/limits.conf', 12 | path => '/usr/local/bin/:/bin/' 13 | } 14 | -------------------------------------------------------------------------------- /0x1B-web_stack_debugging_4/README.md: -------------------------------------------------------------------------------- 1 | 0x1B-web_stack_debugging_4 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![img](https://assets.imaginablefutures.com/media/images/ALX_Logo.max-200x150.png) 2 | 3 | # 0x00 ALX System Engineering and DevOps 💥 4 | 5 | >Learning bash, scripting, networking and web infra right now, been wanting to get on this. It's going to be FUN !!. 6 | 7 | ## About 8 | 9 | - This repository consists of all the . Subject projects done with [ALX Africa](https://www.alxafrica.com/) Software Engineering course in partnership with [Holberton School](https://www.holbertonschool.com/) by [Victor Preston](https://github.com/victorpreston). 10 | 11 | --- 12 | 13 | - [0x00](./0x00-shell_basics) : Writing basic bash scripts that perform basic stuff. 14 | - [0x01](./0x01-shell_permissions) : Linux permissions. 15 | - [0x02](./0x02-shell_redirections) : Shell, I/O Redirections and filters. 16 | - [0x03](./0x03-shell_variables_expansions) : Shell, init files, variables and expansions. 17 | - [0x04](./0x04-loops_conditions_and_parsing) : Loops, conditions and parsing. 18 | - [0x05](./0x05-processes_and_signals) : Processes and signals. 19 | - [0x06](./0x06-regular_expressions) : Regular expression. 20 | - [0x07](./0x07-networking_basics) : Networking basics #0. 21 | - [0x08](./0x08-networking_basics_2) : Networking basics #1. 22 | - [0x09](./0x09-web_infrastructure_design) : Web infrastructure design. 23 | - [0x0A](./0x0A-configuration_management) : Configuration management. 24 | - [0x0B](./0x0B-ssh) : SSH. 25 | - [0x0C](./0x0C-web_server) : Web server. 26 | - [0x0D](./0x0D-web_stack_debugging_0) : Web stack debugging #0. 27 | - [0x0E](./0x0E-web_stack_debugging_1) : Web stack debugging #1. 28 | - [0x0F](./0x0F-load_balancer) : Load balancer. 29 | - [0x10](./0x10-https_ssl) : HTTPS SSL. 30 | - [0x11](./0x11-what_happens_when_your_type_google_com_in_your_browser_and_press_enter) : What happens when you type holbertonschool.com in your browser and press Enter. 31 | - [0x12](./0x12-web_stack_debugging_2) : Web stack debugging #2. 32 | - [0x13](./0x13-firewall) : Firewall. 33 | - [0x14](./0x14-mysql) : MySQL. 34 | - [0x15](./0x15-api) : API. 35 | - [0x16](./0x16-api_advanced) : API Advanced. 36 | - [0x17](./0x17-web_stack_debugging_3) : Web stack debugging #3. 37 | - [0x18](./0x18-webstack_monitoring) : Web Stack Monitoring. 38 | - [0x19](./0x19-postmortem) : Postmortem. 39 | - [0x1A](./0x1A-application_server) : Application Server. 40 | - [0x1B](./0x1B-web_stack_debugging_4) : Web stack debugging #4. 41 | - [Attack is the best defense.](./attack_is_the_best_defense) 42 | - [Command line for the win](./command_line_for_the_win) 43 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/0-sniffing: -------------------------------------------------------------------------------- 1 | mypassword9898! 2 | -------------------------------------------------------------------------------- /attack_is_the_best_defense/1-dictionary_attack: -------------------------------------------------------------------------------- 1 | password123 2 | -------------------------------------------------------------------------------- /command_line_for_the_win/0-first_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/command_line_for_the_win/0-first_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/1-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/command_line_for_the_win/1-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/2-next_9_tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorpreston/alx-system_engineering-devops/61949b32e2694ce5d0fdf17230be16d6530e493b/command_line_for_the_win/2-next_9_tasks.png -------------------------------------------------------------------------------- /command_line_for_the_win/README.md: -------------------------------------------------------------------------------- 1 | Background Context 2 | ------------------ 3 | 4 | [CMD CHALLENGE](https://alx-intranet.hbtn.io/rltoken/a83_NOBEtXgFr1Yqej0HYA "CMD CHALLENGE") is a pretty cool game challenging you on Bash skills. Everything is done via the command line and the questions are becoming increasingly complicated. It's a good training to improve your command line skills! 5 | 6 | **This project is NOT mandatory** at all. It is 100% optional. Doing any part of this project will add a project grade of over 100% to your average. Your score won't get hurt if you don't do it, but if your current average is greater than your score on this project, your average might go down. Have fun! 7 | 8 | Requirements 9 | ------------ 10 | 11 | ### General 12 | 13 | - A `README.md` file, at the root of the folder of the project, is mandatory 14 | - This project will be manually reviewed. 15 | - As each task is completed, the name of that task will turn green 16 | - Create a screenshot, showing that you completed the required levels 17 | - Push this screenshot with the right name to GitHub, in either the PNG or JPEG format 18 | 19 | More Info 20 | --------- 21 | 22 | ### Manual QA Review 23 | 24 | **It is your responsibility to request a review for this project from a peer. If no peers have been reviewed, you should request a review from a TA or staff member.** 25 | 26 | 27 | ``` 28 | victorpreston 29 | ``` 30 | --------------------------------------------------------------------------------