Posts

Showing posts with the label LinuxAdmin

Sysstat - collect system stats

The sysstat service is responsible for the regular collection of system performance information. Through the use of cron and sadc (System Activity data collector), sysstat gathers SAR data at n minute intervals daily. The service has little impact on overall server performance. The default sysstat configuration overwrites collected performance information every 7 days. Sysstat is provided as part of the sysstat package – it also provides useful system performance gathering utilities including; mpstat, iostat and sar. Service: /etc/init.d/sysstat start|stop Configuration File:  /etc/sysconfig/sysstat Log location: /var/log/sa/ server1# cat /etc/default/sysstat # # Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat # and /etc/cron.daily/sysstat files # # Should sadc collect system activity information Valid values # are "true" and "false". Please do not put other values, they # will be overwritten by debconf! ENABLED="true" Change History Size: ...

LINUX - RAM Usage

The RAM (Random Access Memory) is an essential component of a Linux system that has to be monitored closely. In some conditions, we may run out of memory with very slow response times to our server or be completely unresponsive. Linux machine has swap file which acts as an Extra RAM for the machine Check RAM available on Machine: # free -g               total        used        free      shared  buff/cache   available Mem:             31           1          25           0           4          29 Swap:            31           1          29 Commands to check RAM usage on Linux Machines: 1) TOP command to get the  high Memory...

LINUX - CPU Usage

Checking CPU and RAM is one of the important Task. Though we have monitoring enable to check CPU and RAM stats we ran into a situation where we need to check the CPU and RAM utilization live during debugging session. CPU: To list No of  CPU run  lscpu same can be checked using cat /proc/cpuinfo $ lscpu Architecture:          x86_64 CPU op-mode(s):        32-bit, 64-bit Byte Order:            Little Endian CPU(s):                12 On-line CPU(s) list:   0-11 Thread(s) per core:    2 Core(s) per socket:    6 Socket(s):             1 NUMA node(s):          1 Vendor ID:             GenuineIntel CPU family:            6 Model:                 158 Model name:   ...

Ansible

Ansible and Basic Commands Ansible is an open-source and  Infrastructure Management Tool. The Ansible file is in YAML format. Ansible is Agentless works with SSH Protocol. Ansible is written and uses Python Ansible has many modules to perform various operations without any programming knowledge.   Ansible Configuration file: PATH: /etc/ansible/ansible.cfg remote_tmp  = /commlocation (change to common location to avoid permissions issue) forks          = 50 (Adjust to number of instances to connect parallelly )  Default hosts file Path: /etc/ansible/hosts [TEST1] server1 server2 [TEST2] server3 server4 Command Usage: Ansible to use default host file  $ansible all -m ping -o (run on all the hosts in the hosts file) $ansible TEST1 -m ping -o (run on nodes under TEST1 group) to use a custom host file create a file and pass an argument with -i as below 4cat hostfile.ini [NODE1] testserver1 testserver2 [NODE2] testserver3 testserver4...

Ubuntu Kernel and Upgrade

The kernel is the heart of the system which converts the human-readable language to machine-understandable language  Steps: 1) Identify the current version of kernel 2) Update the repository 3) Install kernel   Identify the current version of kernel: uname is used to check the kernel of a machine #uname -a Linux hostname 4.4.0-186-generic #216-Ubuntu SMP Wed Jul 1 05:34:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux # uname -sr Linux 4.4.0-186-generic Update the repository:  apt-get update apt-get remove Install Kernel: apt-get install --install-recommends linux-generic-{version} linux-headers-{version} linux-modules-{version} reboot the server #reboot -f  verify the current kernel using # uname -sr   Once verified we can remove the old kernel version to list all the old kernels use  dpkg -l|grep linux-image* apt-get remove --purge linux-image-{older-kernel-version} Note: It is always recommended to have at least one alternate kernel to fall back...

Install SSH and enable ssh for root login

 SSH is SECURE SHELL which is used to connect remote Linux Servers. It uses port 22 for connection. Application name: openssh-server and openssh-client  Install ssh on the server: apt-get install openssh-server -y  Start and Stop Service: $service sshd (status|start|stop) ● ssh.service - OpenBSD Secure Shell server    Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)    Active: active (running) since Mon 2021-11-15 22:27:10 PST; 2 months 28 days ago  Main PID: 1195 (sshd)    CGroup: /system.slice/ssh.service            └─1195 /usr/sbin/sshd -D   NOTE: By default ssh login for root is disabled to enable ssh for use change PermitRootLogin no to PermitRootLogin yes in   /etc/ssh/sshd_config file. root@server:~# grep PermitRootLogin  /etc/ssh/sshd_config # Ubuntu16 requires PermitRootLogin set to 'yes'. PermitRootLogin yes

Tools for working Linux professional

There are many tools and packages that help to make the IT-Admin life easier. Below are a few that I have used. ssh nslookup Ping fping echo   strace ps vmstat top netstat ss awk sed dmesg jq xmlstarlet Basic Tools:  They are many tools or packages available that help IT-Admin.  Below are a few which I use frequently. Installation OS: One should know the OS Installation and Boot process to better understand how the OS or application works. SSH: If you are a working Linux professional. Learning ssh and configuring passwordless ssh is the first thing to start.  Clusters-ssh:  Cluster ssh is a simple tool to manage multiple hosts I used way back before started working with Ansible  Cron Job:  Cron Job is used to run the scripts or tasks that needed to run on a Linux machine on a schedule Ansible: This makes our job easy. if you haven't started  Ansibling you better start today. Easy to learn and simple to use. you can start automating your day-t...