10 Subprocess Module Examples for Linux Automation

In the world of Linux automation, Python plays a crucial role. One of the most powerful tools Python provides is the subprocess module. This module allows you to run system commands, capture their output, and even integrate them into automation scripts. In fact, the subprocess module for Linux automation is widely used by system administrators […]

Python Script to Check Installed RPMs Easily

When working in Linux environments, package management becomes an essential task. A Python script to check installed RPMs provides administrators with a simple yet powerful way to verify packages. In this blog, we will explain the script, how it works, and why it can save valuable time. Moreover, we will highlight its automation benefits, making […]

Secure Your Mounting with Easy Bash Scripts

Secure Linux Mounting Made Easy with These Bash Scripts Managing Linux file systems manually can often lead to errors or misconfigurations, especially when mounting Samba shares or unmounting an NFS path. To solve this challenge, a pair of secure Linux mount scripts can optimize your day-to-day sysadmin tasks. Designed with reliability in mind, these scripts aim to […]

How Compound Operators Work in Python: Examples Explained

Before entering into how Compound Operators work in python, Let’s understand it first. What Are Compound Operators? Basically, Compound operators, often called shorthand operators, combine arithmetic, bitwise, or logical operations with assignment. They make the code cleaner and reduce redundancy. It also shorten the length of program. For instance, instead of saying, “Add b to […]

Some Commands helpful in Bash Shell Scripts

# cat /etc/crontab (To read/print any file) # cat –n /etc/crontab (To print files with line number) # cat /etc/crontab /etc/passwd (To print multiple files together) # tac /etc/crontab (To print exact opposite output from cat command) # wc /etc/crontab (To print line, word, character count of file) # wc -l /etc/crontab (To print line […]

Basic Operators in Shell Scripting

Logical Operator or Boolean Operator: && -a {Logical AND}: Execute the command when both conditions are true || -o {Logical OR}: Any of one condition will work. ! ! {Not equal to}: Negates the result of the condition. Note: If you will use “-a, -o, !” you need to use [ ] in condition while […]

Quotes in Bash Shell

Quotes are very crucial in Bash Shell Scripting. These are used to define and delimit strings in shell or Shell scripts. It can disable the special treatment of a special character. It is also very helpful to prevent reserved words. You can use them to run commands in shell, Processing variables in shell, etc.There are […]

A simple python script to install a rpm package in linux

Below is the simple program to install a package named “vsftpd” in linux OS. You need to import “os” module for that. #!/usr/bin/python3.6 import os try: os.system(‘dnf install vsftpd’) except: exit("Failed to install package")

Bash Script to append “host and ip entries” in remote server “/etc/hosts” file

We can use below script to add host and ip entries in /etc/hosts file. $ cat append.sh #!/bin/bash ## Append hostname and IP in /etc/hosts file hostname=$1 ip=$2 /usr/bin/sshpass -p ‘password’ ssh user@$1 "echo password | sudo -S sh -c ‘echo "$2 $1 $1.example.com" >> /etc/hosts’" $ sh append.sh test-server 192.168.1.100 It will make entry […]