Introduction
In this project, you will learn how to retrieve and display system information on a Linux server. The getinfo.sh
script you will create can be used to quickly gather important details about the server's hardware, software, and network configuration.
👀 Preview
$ sh getinfo.sh
## Example
cpu num: 8
memory total: 30 G
memory free: 10867 M
disk size: 20G
system bit: 64
process: 40
software num: 1389
ip: 1.32.X.X
🎯 Tasks
In this project, you will learn:
- How to retrieve the number of CPUs, total memory, available memory, disk size, system bit, number of running processes, number of installed software packages, and IP address of the server.
- How to use various Linux commands and tools, such as
grep
, free
, df
, getconf
, ps
, dpkg-query
, and ip
, to gather system information.
- How to write a zsh script that combines these commands to provide a comprehensive overview of the server's state.
🏆 Achievements
After completing this project, you will be able to:
- Understand how to use shell scripting to automate the collection of system information.
- Gain familiarity with commonly used Linux commands and their applications.
- Create a reusable script that can be executed to quickly retrieve and display important server details.
- Apply your newfound knowledge to monitor and troubleshoot Linux systems more effectively.
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"])
linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"])
linux(("`Linux`")) -.-> linux/InputandOutputRedirectionGroup(["`Input and Output Redirection`"])
linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"])
linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"])
linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"])
linux(("`Linux`")) -.-> linux/RemoteAccessandNetworkingGroup(["`Remote Access and Networking`"])
shell(("`Shell`")) -.-> shell/BasicSyntaxandStructureGroup(["`Basic Syntax and Structure`"])
shell(("`Shell`")) -.-> shell/VariableHandlingGroup(["`Variable Handling`"])
shell(("`Shell`")) -.-> shell/AdvancedScriptingConceptsGroup(["`Advanced Scripting Concepts`"])
shell(("`Shell`")) -.-> shell/SystemInteractionandConfigurationGroup(["`System Interaction and Configuration`"])
linux/BasicFileOperationsGroup -.-> linux/wc("`Text Counting`")
linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`")
linux/InputandOutputRedirectionGroup -.-> linux/pipeline("`Data Piping`")
linux/BasicSystemCommandsGroup -.-> linux/logical("`Logic Operations`")
linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`")
linux/TextProcessingGroup -.-> linux/sed("`Stream Editing`")
linux/TextProcessingGroup -.-> linux/awk("`Text Processing`")
linux/FileandDirectoryManagementGroup -.-> linux/cd("`Directory Changing`")
linux/SystemInformationandMonitoringGroup -.-> linux/ps("`Process Displaying`")
linux/SystemInformationandMonitoringGroup -.-> linux/free("`Memory Reporting`")
linux/RemoteAccessandNetworkingGroup -.-> linux/ip("`IP Managing`")
linux/SystemInformationandMonitoringGroup -.-> linux/df("`Disk Space Reporting`")
shell/BasicSyntaxandStructureGroup -.-> shell/shebang("`Shebang`")
shell/BasicSyntaxandStructureGroup -.-> shell/comments("`Comments`")
shell/BasicSyntaxandStructureGroup -.-> shell/quoting("`Quoting Mechanisms`")
shell/VariableHandlingGroup -.-> shell/variables_decl("`Variable Declaration`")
shell/VariableHandlingGroup -.-> shell/variables_usage("`Variable Usage`")
shell/VariableHandlingGroup -.-> shell/str_manipulation("`String Manipulation`")
shell/VariableHandlingGroup -.-> shell/param_expansion("`Parameter Expansion`")
shell/AdvancedScriptingConceptsGroup -.-> shell/arith_expansion("`Arithmetic Expansion`")
shell/AdvancedScriptingConceptsGroup -.-> shell/cmd_substitution("`Command Substitution`")
shell/AdvancedScriptingConceptsGroup -.-> shell/subshells("`Subshells and Command Groups`")
shell/SystemInteractionandConfigurationGroup -.-> shell/globbing_expansion("`Globbing and Pathname Expansion`")
linux/FileandDirectoryManagementGroup -.-> linux/wildcard("`Wildcard Character`")
subgraph Lab Skills
linux/wc -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/echo -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/pipeline -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/logical -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/grep -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/sed -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/awk -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/cd -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/ps -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/free -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/ip -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/df -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/shebang -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/comments -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/quoting -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/variables_decl -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/variables_usage -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/str_manipulation -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/param_expansion -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/arith_expansion -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/cmd_substitution -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/subshells -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
shell/globbing_expansion -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
linux/wildcard -.-> lab-301475{{"`Linux Server Information Retrieval`"}}
end