Skip to content

Instantly share code, notes, and snippets.

@hypnguyen1209
Created December 18, 2021 13:52
Show Gist options
  • Save hypnguyen1209/dd08943abc0a7495c28cfb73c82ddaa1 to your computer and use it in GitHub Desktop.
Save hypnguyen1209/dd08943abc0a7495c28cfb73c82ddaa1 to your computer and use it in GitHub Desktop.
#!/bin/bash
list=(
# Ten may
"Machine name: `hostname`"
# Ten ban phan phoi
"Distribution: `cat /etc/lsb-release | awk 'match($0, /^DISTRIB_DESCRIPTION="(.+?)"/, m) {print m[1]}'`"
# Ten he dieu hanh
"System: `cat /etc/lsb-release | awk 'match($0, /DISTRIB_ID=(.+?)/, m) {print m[1]}'`"
# Ten CPU
"CPU Name: `cat /proc/cpuinfo | awk 'match($0, /model name[\t]+: (.+?)/, m) {print m[1]}' | head -1`"
# Bit CPU
"Bit CPU: `lscpu | awk 'match($0, /Architecture:[ ]+(.+)/, m) {print m[1]}'`"
# Toc do CPU
"CPU speed: `lscpu | awk 'match($0, /CPU MHz:[ ]+(.+)/, m) {print m[1]}'` MHz"
# Dung luong o cung
"Size disk memory: `df -h --output=size,target | awk 'match($0, /(.+) \/$/, m) {print m[1]}' | xargs`"
# Dung luong o cung con lai
"Available disk memory: `df -h --output=avail,target | awk 'match($0, /(.+) \/$/, m) {print m[1]}' | xargs`"
# Dia chi IP
"IP Adress: `hostname -I | awk '{print $1}'`"
# Danh sach user
"List user: `cat /etc/passwd | cut -d: -f1 | tr '\n' ' '`"
# Danh sach cac process dang chay voi root (sorted abc)
"Process with root:\n `ps -fU root | awk '{print $8}' | sort | tr '\n' '\n'`"
# Danh sach cac port dang mo (sorted up)
"Open port:\n `netstat -tulpn | grep LISTEN | awk '$4 ~ /^[0-9|\.]+:[0-9]+$/ {print $4}'`"
# Danh sach cac thu muc tren he thong ma other co quyen ghi
"List:\n `find /home -perm 006 -type d`"
# Danh sach cac phan mem duoc cai dat tren he thong
"List:\n `ls /usr/share/applications | awk -F '.desktop' ' { print $1}' -`"
)
for ((i=0;i<${#list[@]};i++))
do
echo -e ${list[i]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment