Friday, August 11, 2023

Unix : Most relevant commands

netstat -tonp | grep CLOSE_WAIT   //CLOSE_WAIT means your program is still running, and hasn't closed the socket 

netstat -p  // connections with processId. kill -9 <P_ID> to kill the close_wait connection

sudo lsof -i: <port_number>  | grep <port_number>  // port in use

Running port details: netstat -an 

Get IP: hostname -I 

List of files:  ls -1 | wc -l

Size subdirectories wise: sudo du -hs *

du -h /path/to/directoy | sort -rh

Find file: find . -name searchable_file.txt

sudo find / -name file_to_search | grep part_text

Find text in subdirectories/files grep -rl 'search_text' / or *

change owner to user1/group1 chown user1:group1 file_name

Emptying file: truncate -s 0 file.txt

execute permission chmod u+x file_name

Switching user: sudo su new_user, sudo -s

Processes: top [htop on hypervisor]

Memory: free -g 

Memory usage df -h/m/g

              total        used        free      shared  buff/cache   available

Mem:            --         ---          ---      ---        --        --

Swap:           --           --           --



Sunday, January 8, 2023

Memory Issue: Step by step troubleshooting

 Quite often your application is going out of memory. Here is what you need to check the following:

Review the memory configuration

1. -Xmx : Max heap memory

2. -XX:NewSize : Size of new generation

3. XX:MaxNewSize : Max size of new generation

4.-XX:+UseConcMarkSweepGC  : Flag to use GC type

5. -XX:CMSInitiatingOccupancyFraction : If GC type is CMS ,will run after old generation occupied this perdentage

6. XX:SurvivorRatio: The ratio it will survive of the eden space

7. -XX:ConcGCThreads : //Number of threads with which GC will run, 2,3 good enough

Check the various sections:

JVM used memory

Old gen percentage usage

Par-eden space

Par-survivor space

Take a look at the histogram

Identify any memory leakage in the application code through debugging.

Others should not be a problem: Meta spaces/ code cache, compressed class cache.

Take a look at the memory availability on the m/c
free -m

free -g

du -h -d1 // disk usage