Archives

Sun
24
Dec
Sarath Pillai's picture

What is if __name__ == "__main__" in Python

if __name__ == "__main__" in Python

Python is one of the growing high level languages out there. That claim is not without proof. In the recent list of language popularity published by GitHub, Python was in the top list. In fact it is the second most popular language (the first place is currently held by JavaScript). The syntax of python is quite straight forward and easy to understand, without the confusing curly braces all over the place. 

 

Another reason for Python's popularity is its use as a server side scripting language. System administrators can leverage Python to get their boring routine work automated.  With the availability of ready made modules for almost everything, its quite easy to implement something in Python these days.

 

Mon
20
Nov
Sarath Pillai's picture

Understanding Differentiated Services (TOS) field in Internet Protocol Header

ToS & DS in IPv4

IP is the main backbone protocol of the internet(also it is one of the main protocol inside the TCP/IP protocol suite). In other words, irrespective of whether you are using TCP, UDP, or ICMP, the actual data gets transmitted using IP protocol.  IP does not provide any guarantee about delivery, it is completely connectionless. Hence, it is the responsibility of the protocols above IP in the layer to provide proper error free delivery(ie: TCP).

 

Similar to other protocols, apart from the data it carries, IP also has some details and control information attached to each message(ie: each ip datagram). This information tells how the datagram should be interpreted and operated upon. This is generally referred to as protocol headers. The IP protocol header looks like the below.

Thu
09
Nov
Sarath Pillai's picture

Nohup Command Tutorial in Linux with Example Usage

Nohup Command in Linux

Any command that you execute in Linux will have a corresponding process associated with it. Even commands that are generally short lived (like grep, cat, ls, and so on..), will have a process associated with it. All these processes has three things in common.  I must actually say 4 things in common. The fourth thing is the parent process. The only process that does not have a parent is INIT process in Linux.  These four things are mentioned below.

  • Standard Input

  • Standard Output

  • Standard Error

  • Parent Process

Sun
22
Oct
Sarath Pillai's picture

How To Install And Configure AWS CLI on Ubuntu 16.04

Install AWS CLI Ubuntu 16.04

AWS(Amazon Web Services) is one of the first best public cloud service provider. It has grown to such an extent that now cloud is very much synonymous to aws. One of the reasons for its popularity is the easy to use web interface and the wide range of services offered.

 

Apart from the easy to use web interface, they also provide a command line based tool to access different services. This is a handy tool, that can be used to automate, trigger some events, and do things in aws cloud from a linux cli. Basically services like EC2 (create instances, stop instances etc), S3 (store and retrieve files), cloudwatch monitoring, elastic load balancing, autoscaling, and many more can all be accessed using this cli tool. It is called AWS CLI.

Mon
24
Jul
Sarath Pillai's picture

Expect Command Tutorial in Linux With Example Usage

Expect Command In Linux

Automating repetitive task is a norm in the life of a system administrator. Mostly administrators write scripts in different programming languages to take care of this repetitive tasks.
 

The default choice for most Linux system administrators is to leverage the “BASH shell” and its scripting capabilities. Unlike Python, Ruby and Perl, Bash is not a full fledged programming language.
 

But it does provide a lot of programming features to get the job done(For example conditional statements, case statements, and a lot of built in features to make decisions in a script). As its not a full fledged language, you have to use other small programs to get your job done. 
 

Tue
04
Jul
Sarath Pillai's picture

How To Redirect Non WWW to WWW with HTTPS Using Nginx

Redirect to WWW with HTTPS

Nginx is one of the popular web server software used by many companies. One major reason for its popularity is the event-driven model on which the web server is designed. Unlike other popular web servers like Apache, Nginx does not spawn processes to serve each request. Its super fast when it comes to serving static web pages. Apart from these, it can also be used as a caching server & a load balancer. In fact from day one the goal of Nginx web server was mainly "Performance". Basically serve more number of simultaneous requests by using extremely less amount of memory. If you are new to Nginx and is interested to understand why it performs faster compared to Apache, I would recommend reading the below article.

 

Mon
29
May
Sarath Pillai's picture

Understanding Object Oriented Programming in Python

OOP & Python

Before jumping into Python language specifics for object oriented programing, let’s first imagine couple of software projects and then start thinking about different solutions to address those projects. This way we will be able to understand different aspects of OOP(Object Oriented Programming), before we start using it.

Imagine we are given a task to develop a software for a school. The software should be able to enroll students, assign them courses, and evaluate them etc.

Thu
27
Apr
Sarath Pillai's picture

How to Copy Files from one s3 bucket to another s3 bucket in another account

Copy files between s3 buckets in two different aws account

Simple Storage Service(s3) offering from AWS is pretty solid when it comes to file storage and retrieval. It has a good reputation of infinite scalability and uptime. You can use s3 for storing media files, backups, text files, and pretty much everything other than something like a database storage. Usually applications can directly interact with S3 API to store and retrieve files. 

 

It's also highly secure, and access is only granted on a policy based method for aws user accounts(also called IAM accounts). You need an Access Key and Secret Key pair to do operations on an s3 bucket.

 

Mon
10
Oct
Sarath Pillai's picture

How Does ARP(Address Resolution Protocol) Work?

Address Resolution Protocol

Two machines in a network can only communicate with each other, if they know each other’s physical address. Although computer programs use IP addresses to send and receive messages, the actual underlying communication always happens over the physical address.


Let’s first understand how communication happens over the wire. Let’s try pinging google's publicly available dns server from a machine, and try capturing network packets and see what are the source and destination addresses.

tcpdump is a tool used for capturing network packets and see the details. If you are new to tcpdump, i would recommend going through the below article to understand the basics of tcpdump.

 

Fri
02
Sep
Sarath Pillai's picture

disown command in Linux explained with Example usage

Disown Command Examples

Executing long running process in Linux is a norm. For example, imagine you are compiling a very large program, and that is going to take really long. May be hours or even days. So basically you need a method to keep your program running longer even after you logout of the server. To put it in other words, you want a program to be running continuesly even after your shell session ends.

 

There are tools and even features of bash shell that you can use for this purpose. In this article, we will be discussing one such feature of bash shell called disown.

 

Well you might be thinking why am I calling this a feature of bash shell?. This is because disown command itself is part of bash shell. Its basically a shell builtin command similar to cd, pwd etc.

 

Pages

Subscribe to RSS - Archives