0x12. Web stack debugging #2
- Concepts
For this project, we expect one to look at this concept.
- Requirements

- General
All your files will be interpolated on Ubuntu 20.04 LTS.
All your files should end with a new line
A
README.mdfle at the root of the folder of the project is mandatory.All your Bash script files must be executable
Your Bash scripts must pass
Shellcheckwithout any errorYour Bash scripts must run without errors.
The first line of all your bash scripts should be exactly:
#!/usr/bin/env bashThe second line of all your Bash scripts should be a comment explaining what is the script doing
Tasks
0. Run software as another user
- Run software as another user

The user
rootis, on Linux, the “superuser”. It can do anything it wants, that’s a good and bad thing. A good practice is that one should never be logged in therootuser, as if you fat finger a command and for example runrm -rf /, there is no comeback. That’s why it is preferable to run as a privileged user, meaning that the user also has the ability to perform tasks that therootuser can do, just need to use a specific command that you need to discover.For the containers that you are given in this project as well as the checker, everything is run under the
rootuser, which has the ability to run anything as another user.Requirement:
Write a Bash script that accepts one argument
The script should run the
whoamicommand under the user passed as an argumentMake sure to try your script by passing different users
Example:
root@ubuntu:~# whoami root root@ubuntu:~# ./0-iamsomeoneelse www-data www-data root@ubuntu:~# whoami root root@ubuntu:~#
- GitHub Repository:
- alx-system_engineering-devops
- Directory:
- 0x12-web_stack_debugging_2
- File:
- 0-iamsomeoneelse
1. Run Nginx as Nginx
- Run Nginx as Nginx
The
rootuser is a superuser that can do anything on a Unix machine, the top administrator. Security wise, you must do everything that you can to prevent an attacker from logging in asroot. With this in mind, it’s a good practice not to run your web servers asroot(which is the default for most configurations) and instead run the process as the less privilegednginxuser instead. This way, if a hacker does find a security issue that allows them to break-in to your server, the impact is limited by the permissions of thenginxuser.Fix this container so that Nginx is running as the
nginxuser.Requirements:
nginxmust be running asnginxusernginxmust be listening on all active IPs on port8080You cannot use
apt-get removeWrite a Bash script that configures the container to fit the above requirements
After debugging:
root@ab6f4542747e:~# ps auxff | grep ngin[x] nginx 884 0.0 0.0 77360 2744 ? Ss 19:16 0:00 nginx: master process /usr/sbin/nginx nginx 885 0.0 0.0 77712 2772 ? S 19:16 0:00 \_ nginx: worker process nginx 886 0.0 0.0 77712 3180 ? S 19:16 0:00 \_ nginx: worker process nginx 887 0.0 0.0 77712 3180 ? S 19:16 0:00 \_ nginx: worker process nginx 888 0.0 0.0 77712 3208 ? S 19:16 0:00 \_ nginx: worker process root@ab6f4542747e:~# root@ab6f4542747e:~# nc -z 0 8080 ; echo $? 0 root@ab6f4542747e:~#
- GitHub Repository:
- alx-system_engineering-devops
- Directory:
- 0x12-web_stack_debugging_2
- File:
- 1-run_nginx_as_nginx
2. 7 lines or less
- 7 lines or less
Using what you did for task #1, make your fix short and sweet.
Requirements:
Your Bash script must be 7 lines long or less
There must be a new line at the end of the file
You respect Bash script requirements
You cannot use
;&&wgetYou cannot execute your previous answer file (Do not include the name of the previous script in this one)
- GitHub Repository:
- alx-system_engineering-devops
- Directory:
- 0x12-web_stack_debugging_2
- File:
- 100-fix_in_7_lines_or_less