53 lines
1.8 KiB
Markdown
53 lines
1.8 KiB
Markdown
|
# Bash scripting exercises
|
||
|
|
||
|
## Write a script that outputs interesting network information
|
||
|
|
||
|
The script takes no arguments and just outputs interesting information about the network in an easy to read format.
|
||
|
Output at the minimul the following information but more is better.
|
||
|
|
||
|
* internal ip address
|
||
|
* external ip address
|
||
|
* default route
|
||
|
* the nameservers used by the machine
|
||
|
* your hostname
|
||
|
|
||
|
### Additional challenges
|
||
|
|
||
|
* see if you can ping 8.8.8.8 and display only the time it takes
|
||
|
* can you ping the same host multiple times and calculate the average?
|
||
|
* display an error message if the destination can not be reached
|
||
|
* evaluate the quality of the uplink with `speedtest-cli` and echo back some relevant information (but not all)
|
||
|
|
||
|
## Write an alarm clock
|
||
|
|
||
|
**TODO** (IPC exercise)
|
||
|
|
||
|
## Automate adding users to your machine
|
||
|
|
||
|
Write a script that can add a list of users to your system.
|
||
|
Make it so that the newly created users have a default password that is the same as their username.
|
||
|
You can go about this in two ways, either the command line arguments are the usernames, **or** the first command line argument supplies a text file where every line is a user.
|
||
|
|
||
|
```bash
|
||
|
./my_script.sh bob alice marie camille roger
|
||
|
./my_script.sh /path/to/user/list.txt
|
||
|
```
|
||
|
|
||
|
In the second example the `/path/to/user/list.txt` file would contain the following lines.
|
||
|
|
||
|
```
|
||
|
bob
|
||
|
alice
|
||
|
marie
|
||
|
camille
|
||
|
roger
|
||
|
```
|
||
|
|
||
|
### Additional challenges
|
||
|
|
||
|
* display an error message when the script is executed as a **non root** user
|
||
|
* add all of the new users to a specific group
|
||
|
* put all of the new users $HOME directory in a distinct folder so that their home would be `/home/students/$HOME`
|
||
|
* write a **second** script that removes these users from the system **and** also removes all traces of their existance
|
||
|
* how could you combine both scripts into one big script?
|