Found 2003 Articles for Operating System

What does opening a file actually do on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:22:04

651 Views

When we are talking about opening a file, then we have different cases such as in what language and what API are we actually calling when opening a file. While in most of the cases it is quite simple, the higher level languages will eventually call either the C API or directly invoke the Linux open() function which is also written in C.If we try to talk about different languages then this is a very broad question and cannot be covered in a one single article, and that is because of the sheer complexity that gets added to it when ... Read More

Understanding stdin, stderr and stdout in Linux

Mukul Latiyan
Updated on 31-Jul-2021 12:21:26

24K+ Views

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 bash 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 versa. The source ... Read More

Understanding .a , .so and .la library files in Linux

Mukul Latiyan
Updated on 31-Jul-2021 12:21:07

4K+ Views

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 Linux 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 in two categories. These categories are −Static LibrariesDynamic LibrariesStatic LibrariesThe ... Read More

Threads vs Processes in Linux

Mukul Latiyan
Updated on 31-Jul-2021 12:20:50

4K+ Views

ProcessA 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.ThreadThread 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.Consider the table shown below that depicts the differences ... Read More

What is the maximum number of threads per process in Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:19:22

2K+ Views

There are multiple ways with which we can check the maximum number of threads that Linux has allocated to a particular process.Approach 1cat /proc/sys/kernel/threads-maxOutput61741We can also increase the default value set by linux with the help of the command shown below −echo 123456789 > /proc/sys/kernel/threads-maxwhere 123456789 = Number of threadsApproach 2It is also known that Linux doesn’t have a separate threads per limit and it basically implemented the maximum number of threads per process indirectly.Commandnumber of threads = total virtual memory / (stack size*1024*1024) So the threads per process can be increased by decreasing the stack size or increasing the ... Read More

Linux – How to resolve the error "can't connect to Docker daemon"

Mukul Latiyan
Updated on 31-Jul-2021 12:19:03

272 Views

It is one of the commonly known errors that the new users can get when trying to start Docker on a daemon process. This error usually comes up when you try to run the following command in your terminaldocker-compose buildThe docker-compose in the above command is a tool that is used for running and defining multi container Docker applications.The error looks something like this −Cannot connect to the Docker daemon. Is the docker daemon running on this host?In order to make sure that you resolve this error, one approach is to make sure that post-installation steps are correctly followed.Below, there ... Read More

Is there a goto statement available in bash on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:18:45

2K+ Views

Long story short, Linux’s bash doesn’t have goto statements and no information about the control structures exists in the official documentation. It should also be noted that we can make use of the break and continue statement to achieve the same behaviour that goto statement provides us.A simple behaviour of the goto can be achieved with a few tweaks and using the simple if condition in bash.The script will look something like this# ... Code You want to run here ... if false; then # ... Code You want to skip here ... fi # ... ... Read More

How would I get a cron job to run every 30 minutes on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:15:22

1K+ Views

In order to create a crontab job to run every 30 minutes we first need to explore and understand what a crontab job is.A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code ... Read More

How to write multiple line strings using Bash with variables on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:04:57

4K+ Views

Setting a variable to a single line in bash and then printing it to console is a fairly easy process, but if we want to write multiple line strings using Bash then we have to consider different approaches.In total there are three approaches that we can make use of, all of these are mentioned below with examples.Multiline with We can make use of the symbol to make sure that whatever string we write has a newline in between them. With this approach we can write as many lines as possible, we just need to write the same number of ... Read More

How to use the sub process module with pipes on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:04:07

440 Views

In Python, we have the subprocess module that allows us to work with additional processes and makes things easier for us as a developer. While there are other modules available to us that also provide similar functionalities as the subprocess module like the os.spawn(), os.system(), os.popen() and much more, but the reason the subprocess is recommended over all these modules is because of its offering of a high level interface than all the other similar modules mentioned above.In order to be able to use pipes along with the subprocess module we need to understand what the subprocess module does first.ExampleLet’s ... Read More

Advertisements