|
|
|
@ -30,10 +30,16 @@ $
|
|
|
|
|
### Error handling |
|
|
|
|
|
|
|
|
|
All errors will print a specific message on **stderr** (ending with a newline) and returns a specific non-zero value: |
|
|
|
|
- Wrong number of arguments: `"Error: expect 2 arguments"`, returns `1`. |
|
|
|
|
- Wrong number of arguments: `"Error: expect 2 arguments"`, exit with `1`. |
|
|
|
|
- First argument different from `-e` or `-i`: `"Error: unknown flag"`, exit with `1`. |
|
|
|
|
|
|
|
|
|
### Hints |
|
|
|
|
- `getent` is a command to get entries from a database. `passwd` is the database where information about users is stored. |
|
|
|
|
- `getent passwd` will give you the list of all users. |
|
|
|
|
- `getent passwd <username>` will give you information about a specific user. |
|
|
|
|
- If the user doesn't exists `getent` returns an empty string, use this at your advantage for `-e` flag. |
|
|
|
|
|
|
|
|
|
> `man getent` will be a great resource to explore |
|
|
|
|
> `man getent` will provide extensive documentation about this command. |
|
|
|
|
|
|
|
|
|
### Resources |
|
|
|
|
> [List Linux users](https://linuxize.com/post/how-to-list-users-in-linux/) |
|
|
|
|