Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Mukul Latiyan
Page 8 of 37
How to use the sub process module with pipes on Linux?
In Python, the subprocess module allows us to work with additional processes and provides a high-level interface for executing system commands. While other modules like os.spawn(), os.system(), and os.popen() offer similar functionality, subprocess is recommended because it provides better control, security, and flexibility. When working with subprocess on Linux, pipes allow us to chain commands together, passing the output of one command as input to another. This is essential for building secure command pipelines without shell injection vulnerabilities. Basic Subprocess Example Let's start with a simple example that demonstrates basic subprocess usage: import subprocess ...
Read MoreHow to write multiple line strings using Bash with variables on Linux?
Bash supports multiple approaches for creating and handling multiline strings. This functionality is essential when working with formatted output, configuration files, or complex text processing tasks in shell scripts. There are three primary methods to create multiline strings in Bash, each with its own advantages depending on the use case. Method 1: Using Escape Sequences The simplest approach uses the newline character to separate lines within a string. This method works well for short strings and when you need precise control over formatting. Example #!/bin/bash approach1="First Line TextSecond Line TextThird Line Text" ...
Read MoreBest Command Line HTTP Client for Linux
In this tutorial, we will explore some of the most commonly used and famous HTTP clients that are present in Linux. A HTTP Client is a software that is mainly used to allow us to download files from the Internet. The primary reason for using HTTP clients is generally to download files, but these can also be used in case we want to debug or interact with a web server or multiple web servers. Now, let's consider the most famous HTTP Clients that are used. HTTPie With the name that almost resembles of the famous web protocol ...
Read MoreHow would I get a cron job to run every 30 minutes on Linux?
Crontab is a time-based job scheduler in Linux that allows you to automate the execution of commands, scripts, or programs at specific intervals. To create a cron job that runs every 30 minutes, you need to understand the crontab syntax and configure the appropriate time specification. Understanding Crontab Syntax A cron job entry consists of five time fields followed by the command to execute: * * * * * command_to_run | | | | | | | | | +-- Day of Week (0-6, Sunday=0) | | | +---- Month (1-12) | | +------ Day of ...
Read MoreIs there a goto statement available in bash on Linux?
Bash on Linux does not have a built-in goto statement. Unlike languages such as C or BASIC, bash lacks native goto functionality, and no official control structures exist in the bash documentation to provide direct jump capabilities. However, we can simulate goto-like behavior using alternative approaches with break, continue, and conditional statements. Alternative Approaches to Goto While bash doesn't support goto directly, there are several ways to achieve similar control flow behavior. Method 1: Using Conditional Statements The simplest way to skip code blocks is using if statements with conditions that control execution flow − ...
Read MoreLinux – How to resolve the error "can't connect to Docker daemon
The "can't connect to Docker daemon" error is one of the most common issues that new Docker users encounter when trying to start Docker services. This error typically appears when attempting to run Docker commands like docker-compose build or other Docker operations. The docker-compose command is a tool used for defining and running multi-container Docker applications. When the Docker daemon is not properly running or accessible, you'll see an error message like this: Cannot connect to the Docker daemon. Is the docker daemon running on this host? Common Causes This error occurs due to ...
Read MoreWhat is the maximum number of threads per process in Linux?
Linux manages thread allocation through several system parameters and limits. The maximum number of threads per process is determined by multiple factors including system-wide thread limits, virtual memory availability, and stack size configurations. System-Wide Thread Limit The first approach to check the maximum number of threads is to examine the system-wide limit: cat /proc/sys/kernel/threads-max 61741 This value represents the total number of threads that can exist on the entire system. You can modify this limit using: echo 123456789 > /proc/sys/kernel/threads-max where 123456789 is your desired maximum thread ...
Read MoreThreads vs Processes in Linux
A process is the execution of a program that allows you to perform the appropriate actions specified in a program. It can be defined as an execution unit where a program runs. The OS helps you to create, schedule, and terminate the processes which are used by the CPU. The other processes created by the main process are called child processes. A thread is an execution unit that is part of a process. A process can have multiple threads, all executing at the same time. It is a unit of execution in concurrent programming. Threads within the same process ...
Read MoreUnderstanding .a , .so and .la library files in Linux
In order to understand what the libraries of files with the extensions .a, .so and .la actually mean, we first must be aware of the concept of libraries in Linux. A library in its very simple terms is a collection of pre-compiled pieces of code which are known as functions. Libraries are very useful as they provide reusable functions, classes and data structures. Some examples of libraries in Linux are glibc (GNU version of standard C library), libc (the C standard library). In total we can divide the libraries in Linux into two categories. These categories are − ...
Read MoreUnderstanding stdin, stderr and stdout in Linux
There is a decent chance that if you have used Linux operating systems then you might have encountered the three famous data streams known as stdin, stderr and stdout. All these are different in their functions and have their own uses but one thing common between all three of them is that they are data streams that the shell creates. Let's understand more about what data streams actually mean and how they are beneficial. In terms of computing, a data stream is something that gives us the ability to transfer data from a source to an outflow and vice ...
Read More