The Bash script is designed to gather and display information about users, hosts, and file paths on a Unix-like system. It uses various commands and utilities to extract relevant details and presents them in a readable format.
The script is divided into several functions, each focusing on a specific aspect of information retrieval. The main functionalities include:
- User Information
- Obtains details about a specified user.
- Utilizes the
getent,id, andlastcommands to gather information such as full name, home directory, UID, GID, and last login.
./MyInfo.sh u <username>- Host Information
- Determines information about a specified IP address or hostname.
- Uses the
ping,ip route,whois,curl, andgetentcommands to retrieve data like organization, country, reachability, and routing details.
./MyInfo.sh h <hostname or IP>- Path Information
- Displays details about a specified file or directory.
- Utilizes
statcommand to get information such as owner, group, permissions, type, last modified timestamp, and size (in a readable format).
./MyInfo.sh p <file or dir_path>