Blog on various Linux, Shell Scripting and Python topics
About Me
How to modify permissions for files under /mnt/c in WSL
You need to unmount /mnt/c and mount /mnt/c again with below options : sudo umount /mnt/c sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=22,fmask=111 To automatically unmount and mount the C:\ drive (/mnt/c) , add the below lines to /etc/wsl.conf in WSL.If wsl.conf does not exist, create it. [automount] enabled = true options = “metadata,uid=1000,gid=1000,umask=22,fmask=111″…
Problem with VS Code, cannot find valid and existing property in SQLAlchemy object.
Error:Instance of ‘SQLAlchemy’ has no ‘foo’ member’ Solution: Visual Studio Code: Open File > Preferences > Settings > Edit in settings.json -> and paste this :
Basic Ansible Setup
Ansible is a simple IT automation system. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration. Commercial versions are available. But most of it is free and open source. To use Ansible, we need to install it on our control machine. Installation on target machines is not required…
List comprehensions and lambda, map, filter in Python
List Comprehension : List comprehensions are easy and concise way to create new lists from already existing lists. Create a list of numbers. Below is one way to square the numbers in the list and create a new list. Using list comprehension : Output: Lambda Function : It is an expression that returns a function…
Record shell sessions
script command is used to record shell sessions.It is useful for documentation, capturing and replicating issues. Simplest Implementation: Now by default, output file is ‘typescript’. We can pass any other name for output file as below.$ script myscript.log Now myscript.log would contain the output.If we examine the contents of this file, we find exactly what…
Shell Script to read csv file into Array
This is a shell script to read a csv file into array and display the contents. Using an array is preferred we can keep track of no. elements in a row.For example:echo ${row[@]} will display all the elements of array.echo ${#row[@]} will display the no. of elements in the array.Also to get the 2nd element…
Open and Read a file in Python
Below is an example code which reads “file.csv”. Assume it contains data from a table with table headers as it’s first row. We extract the table header with : contents_header = contents[0] We then remove the table header from dataset by slicing: contents = contents[1:] Function explore_data() prints rows read from file. It can also…
Shell Script to compare row counts between two Greenplum Postgresql Database
This shell script takes 3 arguments: source db, target db and a list file of tables. List file is in format:$ cat listfile.lstschema.table : where<> ::schema2.table2 : where<> :: Also ~/gpdbinfo.dat file contains database name, host and port details. Below is the script to send the report file generated above as email :
Write a Service Unit on Arch Linux
A service unit describes how to manage a service or application. This includes how to start or stop the service, under which circumstances it should be automatically started, and the dependency and ordering information for related software. System Unit files are generally loaded from:/etc/systemd/system/ Below is an example of a simple service unit file: Using…
About Me
Software Engineer. Sensible in DevOps/SRE. Ability to dig deep across multiple layers of the stack, from networking and virtualization to configuration management, packaging and deployment. Comfortable with creating, testing, deploying, operating and debugging software at scale. Skilled in Python, Shell Scripting, CI/CD, Terraform, AWS, Ansible, Docker, Kubernetes, Jenkins, Vagrant.Good Experience with databases like PostgreSQL, Greenplum,…
Follow My Blog
Get new content delivered directly to your inbox.