Cheatsheet: Difference between revisions
Content added Content deleted
Line 957: | Line 957: | ||
== Commands == |
== Commands == |
||
=== CPU === |
|||
*netstat |
|||
; CPU Info |
|||
lscpu |
|||
lshw -C CPU |
|||
hardinfo ==> sudo apt install hardinfo |
|||
nproc |
|||
sudo dmidecode -t 4 |
|||
cpuid |
|||
cat /proc/cpuinfo |
|||
cat /proc/cpuinfo | grep processor | wc -l |
|||
* The number of processors shown by /proc/cpuinfo might not be the actual number of cores on the processor. |
|||
* For example a processor with 2 cores and hyperthreading would be reported as a processor with 4 cores. |
|||
* If there are 4 different core ids, this indicates that there are 4 actual cores. |
|||
# cat /proc/cpuinfo | grep 'core id' |
|||
core id : 0 |
|||
core id : 2 |
|||
core id : 1 |
|||
core id : 3 |
|||
; CPU Usage |
|||
top -o %CPU |
|||
htop |
|||
vmstat |
|||
sar 1 3 ==> yum install sysstat |
|||
iostat ==> yum install sysstat |
|||
; Top Command |
|||
<pre> |
|||
top - 01:07:37 up 2:40, 1 user, load average: 0.37, 0.37, 0.39 |
|||
Tasks: 286 total, 1 running, 285 sleeping, 0 stopped, 0 zombie |
|||
%Cpu(s): 4.7 us, 1.6 sy, 0.0 ni, 93.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st |
|||
MiB Mem : 15935.7 total, 9403.3 free, 3045.2 used, 3487.1 buff/cache |
|||
MiB Swap: 4100.0 total, 4100.0 free, 0.0 used. 11720.3 avail Mem |
|||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|||
6865 aman 20 0 982620 85280 53716 S 6.2 0.5 2:52.77 Xorg |
|||
10082 aman 20 0 3537624 285448 118848 S 6.2 1.7 5:45.24 gnome-shell |
|||
</pre> |
|||
CPU Section |
|||
us user cpu time % CPU time spent in user space |
|||
sy system cpu time % CPU time spent in kernel space |
|||
ni user nice cpu time % CPU time spent on low priority processes |
|||
id idle cpu time % CPU time spent idle |
|||
wa io wait cpu time % CPU time spent in wait (on disk) |
|||
hi hardware irq % CPU time spent servicing/handling hardware interrupts |
|||
si software irq % CPU time spent servicing/handling software interrupts |
|||
st steal time % CPU time stolen from a virtual machine |
|||
Main Section: |
|||
%MEM directly related to RES, percentage use of total physical memory by the process. |
|||
VIRT total memory that this process has access to shared memory, mapped pages, swapped out pages, etc. |
|||
RES total physical memory used shared or private that the process has access to. |
|||
SHR total physical shared memory that the process has access to. |
|||
RES is most close to the memory used by the process in memory, excluding what’s swapped out. |
|||
This includes the SHR (shared physical memory) which mean it could have been used by some other process as well. |
|||
;Obtain the PID: |
|||
pgrep -n python |
|||
pidof chrome - return all PIDs |
|||
pidof -s chrome - return only 1 PID |
|||
ps -C chrome -o pid= - C = CMD |
|||
=== Memory === |
|||
;Info |
|||
dmidecode -t 17 |
|||
;Usage |
|||
cat /proc/meminfo ==> egrep --color 'Mem|Cache|Swap' /proc/meminfo |
|||
top -o %MEM |
|||
free -m |
|||
total used free shared buff/cache available |
|||
Mem: 15935 3046 9470 767 3418 11787 |
|||
Swap: 4099 0 4099 |
|||
vmstat |
|||
vmstat -s ==> More detailed |
|||
htop |
|||
;Per Process usage check |
|||
ps -o pid,user,%mem,command ax | sort -b -k3 -r |
|||
sudo pmap 917 ==> Libraries, other files, etc usage of memory |
|||
sudo pmap 917 | tail -n 1 ==> Total used by this process |
|||
=== HDD === |
|||
du -h ==> space by dir including all subdir in dir tree |
|||
du -sh /etc/ ==> total disk space used by dir and suppress subdir |
|||
du -ah /etc/ ==> see all files, not just directories: |
|||
df -h |
|||
Filesystem Type Size Used Avail Use% Mounted on |
|||
/dev/sda4 ext4 77G 51G 22G 71% / |
|||
df -T -h ==> List Filesystem type as well |
|||
df -t ext4 ==> Only see ext4 file system |
|||
df -a ==> List all filesystems that have a size of zero blocks as well |
|||
df -i ==> Display File System Inodes |
|||
lsblk ==> Lists out all the storage blocks, which includes disk partitions and optical drives |
|||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT |
|||
sda 8:0 0 1.8T 0 disk |
|||
├─sda1 8:1 0 500M 0 part /boot/efi |
|||
├─sda2 8:2 0 128M 0 part |
|||
sudo fdisk -l ==> Partition & FS Type details |
|||
parted ==> List out partitions and modify them |
|||
=== Misc === |
|||
*Netstat |
|||
netstat -s |
netstat -s |
||
netstat -anp |
netstat -anp |
||
Line 970: | Line 1,087: | ||
*ls |
*ls |
||
Append a character to each file name indicating the file type: |
|||
Append a character to each file name indicating the file type: |
|||
ls -F or ls --classify |
ls -F or ls --classify |
||
* Executable files |
|||
/ Directories |
|||
@ Symbolic links |
|||
<nowiki>|</nowiki> FIFOs |
|||
= Sockets |
|||
> Doors |
|||
Nothing for Regular Files |
|||
List Symoblic Links: |
List Symoblic Links: |
||
Line 1,002: | Line 1,119: | ||
*mtr |
*mtr |
||
*Find Sym Links: |
|||
*Misc |
|||
Find Sym Links: |
|||
find . -type l -ls |
find . -type l -ls |
||
ls -la | grep "\->" |
ls -la | grep "\->" |