Python Menu program to Automate Linux

Aman Rathi
4 min readAug 25, 2021

Automation is the technology by which a process or procedure is performed with minimal human assistance.

Why we need automation?

Automation is the creation and application of technologies to produce and deliver goods and services with minimal human intervention. The implementation of automation technologies, techniques and processes improve the efficiency, reliability, and/or speed of many tasks that were previously performed by humans. Usually, automation is employed to minimize labor or to substitute humans in the most menial or repetitive tasks. Automation is present in virtually all verticals and niches, although it’s more prevalent in manufacturing, utilities, transportation, and security.

Why Python is neccessary ?

Python is a general purpose and high level programming language. You can use Python for developing desktop GUI applications, websites and web applications. Also, Python, as a high level programming language, allows you to focus on core functionality of the application by taking care of common programming tasks.

Modules used in program:

import os
import subprocess as sp
import getpass

os.system() will perform all the system commands as subprocess.getoutput(). getpass.getpass() function doesn’t echo back the passwords and provide security to the user to hide the passwords.

Snapshots/UI of the program:

This program supports following technologies:
DOCKER LVM
AWS LOCAL
NETWORK PACKAGE/SERVICE
HADOOP

Docker Menu:

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

This support list of containers, images & pull images from docker hub , start & stop the container.

VM Menu:

In Linux, Logical Volume Manager is a device mapper framework that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume.

This menu support partitioning , provide disk and partition, mount & unmount , resizing of static partition, PV, VG, LV and their details , increasing and decreasing the size of LV’s.

AWS:

Amazon Web Services offers reliable, scalable, and inexpensive cloud computing services. Pay only for what you use. We are using AWS CLI to use AWS services.

It will create a key pair, can manage ec2, EBS, security group, S3 services of AWS.

For RHEL 8 system automation:

It support displaying of date, calender, RAM usage, and number of CPU’s in the system & clear the caches, start firebox browser, add & remove any user and change the passwords too.

Networking:

Networking is one of the most important thing to perform the activities. We can ping with other systems, can see the network card details, also capture the network packets at any port, can find the ip address of any website, remote login to any system via ssh, upload and download files to other systems via using scp.

Packages and services:

This menu can install and uninstall any package by using yum. Can install/uninstall python libraries by pip. If you have rpm package already downloaded , then you can also install the software by rpm.

Also to start, stop, enable and disable any service , this menu also support this function.

Hadoop:

In this menu, you can use it to start namenode, datanode, as also as a client. You have to just follow all the steps according to the program. As a client you can put , read , remove the file from the HDFS cluster.

For the security purpose , in the starting the program will ask for the password and if any doesn’t know the the correct password, program will automatically exit and he doesn’t able to use it.

For downloading the code , follow the github URL:

https://raw.githubusercontent.com/Aman-Rathi1/Automate-Linux/main/meny.py

Thanks for reading.

--

--