• Uncategorized

    List all IP addresses connected to your Server

    Below is an Unix command to list all the IP addresses connected to your server on port 80. Output – Total connections by IP, from highest to lowest. Note This command is useful to detect if your server is under attack, and null route those IPs. Read this null route attacker IP story. Let break above lengthy command into pieces : 1. netstat -tn 2>/dev/null Uses netstat to list all network connections, ins and outs. -n – Display numeric only, don’t resolve into name. -t – Display only TCP connections. Output 2>/dev/null Redirect all unwanted output to /dev/null, a special place to absorb all output and clear it. 2. grep…

  • Linux,  Ubuntu

    How to check if my Ubuntu is placed on SSD?

    A simple way to tell if your OS is installed on SSD or not is to run a command from a terminal window called lsblk -o name,rota. Look at the ROTA column of the output and there you will see numbers. A 0 means no rotation speed or SSD drive. A 1 would indicate a drive with platters that rotate. My Ubuntu is installed on my /dev/sdb drive, so we can see that one indicates a 0 which means it is installed on a SSD drive. I put after this example of how to tell where your OS is installed using df. NOTE: Ubuntu that is installed as a client…

  • Linux,  Ubuntu

    8 commands to check cpu information on Linux

    CPU hardware information The cpu information includes details about the processor, like the architecture, vendor name, model, number of cores, speed of each core etc. There are quite a few commands on linux to get those details about the cpu hardware, and here is a brief about some of the commands. 1. /proc/cpuinfo The /proc/cpuinfo file contains details about individual cpu cores. Output its contents with less or cat. $ less /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz stepping : 10 microcode : 0xa07 cpu MHz : 1998.000 cache size : 2048 KB…

  • Uncategorized

    Know Your IP Using Command Line

    If you are not behind a router, you can find it out using ifconfig. If you are behind a router, then your computer will not know about the public IP address as the router does a network address translation. You could ask some website what your public IP address is using curl or wget and extract the information you need from it: or shorter

  • Uncategorized

    How to know if a disk is an SSD or an HDD

    Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with: You should get 1 for hard disks and 0 for a SSD. It will probably not work if your disk is a logical device emulated by hardware (like a RAID controller). See this answer for more information… ************************************************ With lsblk (part of the util-linux package): lsblk -d -o name,rota where ROTA means rotational device (1 if true, 0 if false)

  • Linux

    List all IP addresses connected to Server

    Below is an example of Unix command to list all the IP addresses connected to your server on port 80. You can customize for another port. netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head Output – Total connections by IP, from highest to lowest. 97 114.198.236.10056 67.166.157.19444 170.248.43.7638 141.0.9.2037 49.248.0.237 153.100.131.1231 223.62.169.7330 65.248.100.25329 203.112.82.12829 182.19.66.187 Note This command is useful to detect if your server is under attack, and null route those IPs. Read this null route attacker IP story. Let break above lengthy command into pieces : 1. netstat -tn 2>/dev/null Uses netstat…

  • Uncategorized

    CHroot sftp-only SSH users into their homes

    To chroot an SFTP directory, you must : To chroot an SFTP directory, you must Create an user and force root to be owner of it cd /home mkdir john useradd -d /home/john -M -N -g users john sudo chown root:root /home/john sudo chmod 755 /home/john Change the subsystem location on /etc/ssh/sshd_config: #Subsystem sftp /usr/lib/openssh/sftp-server Subsystem sftp internal-sftp and create a user section at the end of the file (ssh can die respawning if placed after Subsystem line): Match User john ChrootDirectory /home/john ForceCommand internal-sftp AllowTCPForwarding no X11Forwarding no