Useful Linux commands

Useful Linux commands

Useful Linux commands

 

A collection of useful Linux commands and scripts.
View total memory in GB

printf "%.0f\n" $(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024^2" | bc)

View death processes

top -b -n 1 | awk '{count=0; if (NR <=7) print; else if ($8=="D") {print; count++} } END {print "Total processes with status D: "count}'

System status script

#!/bin/bash

date;
echo
echo -e "\e[105mUptime\e[0m"
uptime
echo
echo -e "\e[105mCurrently connected\e[0m"
w
echo
echo -e "\e[105mLast logins\e[0m"
last -a | head -3
echo
echo -e "\e[105mDisk and memory usage\e[0m"
df -h | xargs | awk '{print "Free/total disk: " $11 " / " $9}'
free -m | grep 'Mem' | awk '{print "Free/total memory: " $4 " / " $2 " MB"}'
echo
echo -e "\e[105mUtilization and most expensive processes\e[0m"
top -b | head -3
echo
top -b | head -10 | tail -4
echo
echo -e "\e[105mOpen TCP ports\e[0m"
nmap -p- -T4 127.0.0.1
echo
echo -e "\e[105mCurrent connections\e[0m"
ss -s
echo
echo -e "\e[105mProcesses\e[0m"
ps auxf --width=200
echo
echo -e "\e[105mVMstat\e[0m"
vmstat 1 5
Useful Linux commands




Useful Linux commands

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close