Mukul Latiyan

Mukul Latiyan

363 Articles Published

Articles by Mukul Latiyan

Page 9 of 37

What does opening a file actually do on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 726 Views

When we talk about opening a file in Linux, the process varies depending on the programming language and API being used. However, most high-level languages eventually call either the C library functions or directly invoke the Linux open() system call. This article focuses on what happens at the kernel level when a file is opened in C on a Linux system. The sys_open() System Call At the heart of file opening is the sys_open() system call. When you call open() in C, it eventually triggers this kernel function found in fs/open.c: int sys_open(const char *filename, int ...

Read More

What is fopen() and open() in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 6K+ Views

The key difference between fopen() and open() in Linux is that open() is a low-level system call that returns a file descriptor (integer), while fopen() is a higher-level C library function that internally calls open() and returns a FILE pointer with additional buffering capabilities. Understanding open() System Call When you call open(), it invokes the kernel's sys_open() function, which performs several operations to establish the file connection. Here's the simplified implementation: int sys_open(const char *filename, int flags, int mode) { char *tmp = getname(filename); int fd = get_unused_fd(); ...

Read More

What is the Linux Equivalent to DOS Pause?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 326 Views

The Pause command in DOS is used to suspend execution of batch files and displays the message − Strike a key when ready ... Some versions of DOS also allow a comment to be entered on the same line as PAUSE. DOS Pause Example We can use the Pause command to suspend execution of a batch file and display a custom message like "Insert Code" − pause Insert Code Linux doesn't provide a built-in pause command utility by default. However, there are different approaches to achieve the same behavior as ...

Read More

What is the sed in-place flag that works both on Mac and Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 4K+ Views

The sed command in Linux stands for stream editor and is mainly used to perform functions on files, such as searching, replacing, or inserting text. It is a very useful command-line utility available on Linux systems. However, there's an important difference between operating systems: the BSD sed shipped with macOS requires a mandatory argument with the -i flag, while GNU sed on Linux makes this argument optional. The Cross-Platform Solution The most reliable way to make sed work identically on both Mac and Linux is to use the -i flag with a backup extension. This approach works ...

Read More

What languages have been used to write Windows, Mac OS and Linux OS?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 7K+ Views

An operating system serves as the backbone of any computing system, managing hardware resources and providing essential services. The three most widely used operating systems — Windows, macOS, and Linux — share fundamental concepts while implementing them using different programming languages and architectural approaches. These operating systems differ not only in their user interfaces and file management systems but also in the programming languages and technology stacks used for their development. Understanding the languages behind these systems provides insight into their design philosophy and performance characteristics. Linux Operating System Linus Torvalds, the creator of Linux, explained his ...

Read More

What Linux utility for sorting processes by network usage?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 432 Views

Linux provides the famous top command utility that displays information about running processes, including their time, process IDs, CPU usage, and much more. However, the top command does not sort processes by network usage, and the display order changes frequently based on CPU consumption. When you need to monitor which processes are consuming the most network bandwidth, you need a specialized tool. NetHogs is the ideal Linux utility for sorting and monitoring processes by their network usage in real-time. What is NetHogs? NetHogs is a command-line network monitoring tool that displays real-time network traffic bandwidth usage for ...

Read More

What's the difference between nohup and ampersand (&) on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 519 Views

nohup and the ampersand (&) are both used to run processes in the background on Linux, but they serve different purposes and behave differently when the terminal session ends. The Ampersand (&) Operator The & operator runs a command in the background, allowing you to continue using the terminal while the process executes. However, the process is still attached to the terminal session. command & Example sleep 100 & [1] 12345 The output shows the job number [1] and process ID 12345. The process runs in the ...

Read More

Where can I set environment variables that crontab will use?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 1K+ Views

Environment variables are typically set in shell configuration files like .bash_profile, .bashrc (Ubuntu), or .zshrc (macOS). However, crontab runs in a minimal environment and doesn't automatically load these shell configuration files, making environment variables unavailable to cron jobs. Understanding the Problem Let's examine a typical shell configuration file with environment variables − immukul@192 dir1 % cat ~/.bash_profile export JAVA_HOME=$(/usr/libexec/java_home) export PATH=$PATH:/usr/local/node/bin export GOROOT=/usr/local/go export GOPATH=/Users/immukul/go_projects These variables work perfectly in a normal terminal session − echo $GOROOT /usr/local/go However, when you create a cron job, these variables ...

Read More

How to Run a Command Multiple Times in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 9K+ Views

There are scenarios where you would want to run a particular command for N number of times. In normal programming, this can be done with the help of loop constructs available in that programming language. In Linux bash, we have loops and other methods to repeat commands N number of times efficiently. In this tutorial, we will explore different bash techniques that allow us to run a certain command multiple times using loops, functions, and command-line utilities. Creating and Running Bash Scripts Before exploring the methods, let's understand how to create and execute bash scripts. On Linux ...

Read More

How to Repeat Your Last Command in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 7K+ Views

Linux terminal allows us to execute a variety of commands, and often we need to repeat a previously executed command. There are several efficient methods to recall and re-execute the last command without retyping it completely. For demonstration purposes, let's assume we previously ran the command ls -ltr and now want to repeat it using various methods available in Linux. Using Arrow Keys The most basic approach is to press the UP arrow key on your keyboard. This retrieves the last command from your command history, allowing you to press Enter to execute it again or modify ...

Read More
Showing 81–90 of 363 articles
« Prev 1 7 8 9 10 11 37 Next »
Advertisements