Monday, January 30, 2017

Find Out Top Processes By Memory Usage In Linux

Use the following script to find out top processed sorted by memory usage, in megabytes (MB)

#!/bin/bash
ps axo rss,comm,pid | awk '{ proc_list[$2]++; proc_list[$2 "," 1] += $1; } \
END { for (proc in proc_list) { printf("%d\t%s\n", \
proc_list[proc "," 1],proc); }}' | sort -n | tail -n 10 | sort -rn \
| awk '{$1/=1024;printf "%.0fMB\t",$1}{print $2}'

How to Find Out Top Directories and Files (Disk Space) in Linux

1. Run the following command to find out top biggest directories under /home partition.  

# du -a /home | sort -n -r | head -n 5

2. If you want to display the biggest directories in the current working directory, run 

# du -a | sort -n -r | head -n 5

3. Some of you would like to display the above result in human readable format. i.e you might want to display the largest files in KB, MB, or GB. 

# du -hs * | sort -rh | head -5

4. To display the largest folders/files including the sub-directories, run: 

# du -Sh | sort -rh | head -5

5. To find the largest 10 files (linux/bash) 

find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

6. To find the largest 10 directories: 

find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

Only difference is -type {d:f}

d = directory
f = files

Tuesday, March 1, 2016

DROWN - Decrypting RSA using Obsolete and Weakened eNcryption

Background Information

A group of security researchers discovered that SSLv2 (Secure Sockets Layer protocol version 2.0) is vulnerable to the Bleichenbacher RSA padding oracle attack, which can be used to decrypt RSA cipher text without the knowledge of the matching private RSA key. This can be done by observing responses from a server that has the private key and performs the decryption of attacker-provided cipher texts using that key. The researchers also demonstrated a new cross-protocol attack which allows decryption of SSL/TLS sessions using newer protocol versions - SSLv3 or any current TLS (Transport Layer Security) version (1.0 - 1.2) - using this SSLv2 weakness. This flaw is a SSLv2 protocol issue and affects all implementations of the protocol. Researchers refer to this attack as general DROWN.
Additionally, flaws were found in the SSLv2 protocol implementation in the OpenSSL cryptography and SSL/TLS library, which make it possible to perform a more efficient variant of the DROWN attack, referred to as special DROWN. These issues were assigned CVE-2016-0703 and CVE-2016-0704 , and were already recently corrected as part of the fix for CVE-2015-0293 .
Further details of this attack can be found in the researchers' paper titled DROWN: Breaking TLS using SSLv2 at https://drownattack.com/

Impact to systems

A server is vulnerable to the DROWN attack if it enables SSLv2 protocol in addition to SSLv3 or TLSv1.x, and if it uses RSA key exchange cipher suites. Server that does not enable SSLv2 can also be vulnerable if it does not enable SSLv2, but shares its private RSA key with another server. For example, DROWN attack can still be used to decrypt HTTPS sessions to a web server that does not enable SSLv2 if it shares its RSA key with e.g. IMAP server, possibly running on the same host, that does enable SSLv2. Use of weak or export SSLv2 ciphers is required to efficiently perform the attack.
SSL/TLS connections using non-RSA key exchange, such as Diffie-Hellman or Elliptic Curve Diffie-Hellman, can not be decrypted using the DROWN attack. 

Wednesday, September 2, 2015

How to enable User and Group Disk Quota on CentOS 7 & RHEL 7

As a Linux system admin we generally face low disk space issues. By implementing the user and group disk quota on the file system we can resolve the space issue.
Quota restricts the users to use only allowed disk and inodes on the particular file system. In this post we will discuss how to enable user & group disk quota on /home File system on CentOS 7 & RHEL 7
 

Step:1 Add usrquota & grpquota option on /home in /etc/fstab file.

[root@linuxtechi ~]# vi /etc/fstab




Save & exit the file.
In this example I have add user and group quota options on /home

Tuesday, September 1, 2015

Configure NIC(Network Interface Card) bonding in CentOS 7 / RHEL 7

NIC(Network Interface Card) bonding is also known as Network bonding. It can be defined as the aggregation or combination of multiple NIC  into a single bond interface. It’s main purpose is to provide high availability and redundancy.
In this article we will learn how to configure nic or netwok bonding in CentOS 7 & RHEL 7. In my case I have two interface cards (enp0s3 & enp0s8) and will form a bond interface (bond0).

Prerequisite

If bonding module is not loaded on your linux box then use the below command to load.
 
If bonding module is not loaded on your linux box then use the below command to load.
 
[root@openstack ~]# modprobe bonding
 
To list the bonding module info, use following command.
 
[root@openstack ~]# modinfo bonding
 
Output will be something like below

Thursday, February 5, 2015

Installing oVirt 3.5 on CentOS 7 (Hosted Engine)

I have had many people come to my blog looking how to install oVirt 3.5 software on the new CentOS 7. Much of this content is the same as my 3.4 post, but I thought I would keep it separate. Below are simple step by step instructions for installing the node and getting it configured for the hosted engine.

Installation Requirements

Please Note: Installing Hosted Engine on CentOS 7 requires oVirt 3.5.1
Please Note: Both the node and engine will be running CentOS 7 (Minimal Installation)
Please Note: Ensure the host is fully updated via “yum update” and rebooted before proceeding

Prerequisites

DNS
Ensure you have set up hostnames for the host and engine. If you do not have a DNS server configured and you are only testing oVirt on a single server, you can use /etc/hosts instead. I have the following:
Engine: Hostname: engine.xrsa.net, IP Address: 192.168.122.101/24
Host:
Hostname: ovirt01.xrsa.net, IP Address: 192.168.122.100/24
 
NFS
Ensure you have set up NFS mount points for the engine and virtual machines. If you do not have a shared NFS server and you are only testing oVirt, you can configure NFS locally on the host instead.
 

Saturday, January 31, 2015

The GHOST vulnerability - what you need to know

The funkily-named bug of the week is GHOST.
Its official moniker is the less catchy CVE-2015-0235, and it's a vulnerability caused by a buffer overflow in a system library that is used in many, if not most, Linux distributions.
A buffer overflow is where you assume, for example, that when you handle a four-byte network number written out as decimal digits, you will never get anything longer than 255.​255.​255.​255.
That takes up 15 characters, so you may decide that you'll never need more than 15 bytes of memory.
So, if you add a spare byte for luck and allocate 16 bytes, you're bound to have enough space.
And then, one day, a malicious user decides to see what happens if he ignores the rules, and uses a network number like, say, 1024.​10224.​102224.​1022224.
That network number is nonsense, of course, but your program might not hold out long enough to reject it.
Your code will probably crash right away, because the attacker's 25 bytes will overflow your 16 bytes of available memory.

GHOST explained


As it happens, the GHOST vulnerability is connected with network names and numbers.
The spooky name comes from the system functions where the vulnerable code was found.
The functions are called gethostby­name() and gethostby­name2(), and they do what the names suggest.