Disk Operations

Checking usage and limits about current disks

df -h
CODE

Checking usage and limits on specific path

du -sh file_path
CODE

Memory Operations

Memory details

cat /proc/meminfo
CODE

Current memory usage and limits

//-m for MB, -g for GB
free -m
CODE

Processor Operations

Cpu details

less /proc/cpuinfo
lscpu
CODE

Checking Cpu core count

cat /proc/cpuinfo | grep processor | wc -l
CODE

Checking total Thread count

ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'

cat /proc/sys/kernel/threads-max
CODE

Checking total Thread count of Java application

ps -ef | grep java
//Java's id will be written on code below, eg: 10057
ps huH p 10057 | wc -l
CODE

Taking Dump

sudo -u apinizer ./jcmd 26032 Thread.print > ./Thread.dump
sudo -u apinizer ./jcmd 26032 GC.heap_dump ./Heap.dump
CODE

Setting Process count limit for current user

ulimit -Su 30000
CODE

Jar Operations

Extracting from jar

jar -xf apinizer-gateway-2.1.2.jar
CODE

Compress as Jar

jar -cf apinizer-gateway-2.1.2.jar **
CODE

Compressing file with manifes file as jar

/opt/apinizerManager/jre8162linux/bin/jar -cfm apinizer-gateway-2.1.2.jar ./META-INF/MANIFEST.MF **
CODE

File Operations

Copy files and directories between two locations with SCP

scp -r /opt/apinizerManager/* apinizer@172.16.0.1:/opt/apinizerManager/
CODE

Extract tar.gz and compress as zip

tar xzf jre282linux.tar.gz && zip jre282linux.zip $(tar tf jre282linux.tar.gz)
CODE

List of open files

lsof | wc -l
CODE

See File settings

cat /etc/sysctl.conf
// system-wide maximum number of files  
cat /proc/sys/fs/file-max
cat /proc/sys/fs/file-nr
CODE

Check the biggest 10 files that are opened

cd /proc
for pid in [0-9]*
do
    echo "PID = $pid with $(ls /proc/$pid/fd/ | wc -l) file descriptors"
done | sort -rn -k5 | head | while read -r _ _ pid _ fdcount _
do
  command=$(ps -o cmd -p "$pid" -hc)
  printf "pid = %5d with %4d fds: %s\n" "$pid" "$fdcount" "$command"
done
CODE

Checking the processes that holds the most files open

lsof -Fnst | awk '
    { field = substr($0,1,1); sub(/^./,""); }
    field == "p" { pid = $0; }
    field == "t" { if ($0 == "REG") size = 0; else next; }
    field == "s" { size = $0; }
    field == "n" && size != 0 { print size, $0; }
' | sort -k1n -u | tail -n42 | sed 's/^[0-9]* //'
CODE

Firewall Operations

sudo iptables -A PREROUTING -t nat -i ens160 -p tcp --dport 443 -j REDIRECT --to-port 9443
iptables-save > /opt/apinizerManager/iptables.conf
CODE
Below can bu used for apinizer 2.x inside of the startManager file
iptables-restore < /opt/apinizerManager/iptables.conf

max_allowed_packet=500M
lower_case_table_names=1
innodb_log_file_size=2G
CODE

Wget Operations

Downloading from Google Drive with Wget

 wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=Adres_Unique_Idsi_yZ8JlXtWwdOQg_5h' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=Adres_Unique_Idsi_yZ8JlXtWwdOQg_5h" -O apinizer.zip && rm -rf /tmp/cookies.txt
CODE

Sorting by File Size

sudo lsof 
| grep REG 
| grep -v "stat: No such file or directory" 
| grep -v DEL 
| awk '{if ($NF=="(deleted)") {x=3;y=1} else {x=2;y=0}; {print $(NF-x) "  " $(NF-y) } }'  
| sort -n -u  
| numfmt  --field=1 --to=iec
CODE

Network Operations

Checking a user process or service of specific port

netstat -ltnp | grep -w ':80'
CODE

Çalışan Portla

ss -antp
 State         Recv-Q        Send-Q                Local Address:Port                  Peer Address:Port
 LISTEN        0             128                         0.0.0.0:22                         0.0.0.0:*            users:(("sshd",pid=734,fd=4))
 ESTAB         0             0                    173.249.11.199:22                    3.83.11.233:48610        users:(("sshd",pid=44179,fd=5),("sshd",pid=44178,fd=5))
 ESTAB         0             0                    173.249.11.199:22                  176.43.11.169:4400         users:(("sshd",pid=4714,fd=5),("sshd",pid=4712,fd=5))
 ESTAB         0             0                    173.249.11.199:22                  176.43.11.169:4488         users:(("sshd",pid=1182,fd=5),("sshd",pid=1161,fd=5))
 ESTAB         0             0                    173.249.11.199:22                  78.175.12.218:37538        users:(("sshd",pid=4391,fd=5),("sshd",pid=4370,fd=5))
 ESTAB         0             40                   173.249.11.199:22                  78.175.12.218:40141        users:(("sshd",pid=4369,fd=5),("sshd",pid=4367,fd=5))
 ESTAB         0             0                    173.249.11.199:22                 222.186.13.130:12376        users:(("sshd",pid=44169,fd=5),("sshd",pid=44168,fd=5))
 ESTAB         0             0                    173.249.11.199:22                 157.230.12.208:56782        users:(("sshd",pid=44177,fd=5),("sshd",pid=44176,fd=5))
 LISTEN        0             128                            [::]:22                            [::]:*            users:(("sshd",pid=734,fd=6))    -t : Show only TCP sockets on Linux

//Other commonly used parameters as below:
    -t : Show only TCP sockets on Linux
    -u : Display only UDP sockets on Linux
    -l : Show listening sockets. For example, TCP port 22 is opened by SSHD server.
    -p : List process name that opened sockets
    -n : Don’t resolve service names i.e. don’t use DNS
POWERSHELL

Certificate Operations

Importing Certificate on Apinizer 2.x

 /opt/apinizerManager/jre8282linux/jre/bin/keytool -import -trustcacerts -keystore /opt/apinizerManager/jre8282linux/jre/lib/security/cacerts -storepass changeit -alias <Certificate_alias> -import -file <Certificate_File>
CODE

Vi Editor Operations

Change All

:%s/old_word/new_word/g 
CODE