Category: unix
-
Unix – disk and file size monitoring with du, df and stat
du – file space usage GB sized files and directories du -xh DIRPATH |egrep “^[0-9\.]+[GT]\s” # Examples du -xh ~/ |egrep “^[0-9\.]+[GT]\s” sudo du -xh / |egrep “^[0-9\.]+[GT]\s” Size Of Directory and Disk Space du -s .archived/ du –sk # k: output in in KB # x=> expands, only on the local file system –…
-
Linux – IO Wait Monitoring – Top, IOStat and WMStat
1. Top top -c column wa => io wait 2. IOStat Installation sudo apt-get install -y sysstat iostat -k 3 IO History ls /var/log/sysstat/sa[0-9]* Select a File, e.g. sar -u -f /var/log/sysstat/sa17 3. VMStat vmstat 5 120 Help: vmstat –help Usage: vmstat [options] [delay [count]] Options: -a, –active active/inactive memory -f, –forks number of forks…
-
Unix – Executing Top once or Every X Seconds
Top Every Second -Version 1 top -c -b Top Every Second -Version 2 top -c -b -d 1 Top Every 5 Seconds top -c -b -d 5 Top Only once top -c -b -n 1 top -h procps-ng version 3.3.3 usage: top -hv | -bcHiSs -d delay -n limit -u|U user | -p pid[,pid] -w…
-
Unix – Show, Create and Delete Command Alias
Define an Alias The first example causes ls -l to be executed when the command ll is entered: alias ll ls -l Show all defined Alias alias Show Alias for specific Alias alias ls Alias File – .bash_aliases The alias file located in ~/.bash_aliases is executed on startup. Below is an example of .bash_aliases. cat…
-
Postgres – Which users are Currently Connected to the database
Postgres Database – Who is Currently Connected SELECT * FROM pg_stat_activity order by client_addr;
-
Unix – ps – finding running processes
ps -fA|grep postgres PS(1) User Commands PS(1) NAME ps – report a snapshot of the current processes. SYNOPSIS ps [options] DESCRIPTION ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead. This version of ps accepts several kinds of…
-
Unix – using tail and grep together
Tail Examples tail -f postgres.log|grep “exec” | awk ‘{print $1,$16,$7}’ Tail Examples tail -f /var/log/postgresql.log | egrep “errors” tail –help Usage: tail [OPTION]… [FILE]… Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE…
-
Unix – Find the Files open by a process
Files Open by Process ls -l /proc/PROCID/fd Count Files Open by Process lsof -p PROCID|wc -l #alternative ls -l /proc/PROCID/fd| wc -l lsof -h lsof 4.86 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s] [-F [f]] [-g [s]] [-i [i]] [+|-L [l]]…
-
Unix – Kill Processes
KILL kill -KILL 9573 > man kill KILL(1) User Commands KILL(1) NAME kill – send a signal to a process SYNOPSIS kill [options] […] DESCRIPTION The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals may be…