Operating System Articles

Page 170 of 171

How to Create a Shared Directory for All Users in Linux?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 39K+ Views

When multiple users need access to the same set of directories or files, we need to create shared folders in Linux. Linux uses users and groups with specific permission levels to enable secure data sharing. Below are the steps to create shared folders where multiple users can read and update files. Step 1: Create the Shared Directory First, create the directory that will be shared. The -p flag creates the directory and ignores errors if it already exists ? sudo mkdir -p /bigproject/sharedFolder Step 2: Create a User Group Create a user group ...

Read More

How to Count Word Occurrences in a Text File using Shell Script?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 11K+ Views

Linux shell scripting provides powerful tools to process text files and analyze their content. One common task is counting word occurrences in a file using pattern matching and counting commands. This article demonstrates several approaches to count specific words in text files. Sample Input File Let's create a sample file to demonstrate our examples ? cat inspire.txt Mastering anything needs practice. It also needs patience. And it needs time and other resources. Using grep and wc The grep command finds patterns in text, and when combined with wc, we can ...

Read More

How to Count Number of Files and Subdirectories inside a Given Linux Directory?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 3K+ Views

When working with Linux systems, it's essential to know how to count files and subdirectories within a given directory. Python provides several ways to accomplish this task, from using the os module to leveraging the pathlib library for more modern approaches. Using os.walk() for Recursive Counting The os.walk() function recursively traverses directories and provides separate counts for files and subdirectories ? import os def count_files_and_dirs(directory): file_count = 0 dir_count = 0 for root, dirs, files in os.walk(directory): ...

Read More

How to Copy File Permissions and Ownership to Another File in Linux?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

When backing up data or configuring software in Linux, you often need to maintain the same ownership and permissions across files. Instead of manually setting permissions for each file, Linux provides efficient methods to copy these attributes from one file to another using the chown and chmod commands with the --reference option. Copying File Ownership Use the --reference switch with chown to copy ownership from a source file to a target file ? Syntax chown --reference=source_file target_file Example Let's copy ownership from ref_file.txt to all_rivers.txt ? # Check current ownership ...

Read More

Create Shortcuts to Long and Complicated Paths in Linux (Gogo)

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 183 Views

Gogo is a tool to bookmark directories with long and complicated paths in the Unix shell. Because the long paths are difficult to remember and cumbersome to type in, gogo provides a simple way to create shortcuts. In this article we'll see how to install gogo and use it. Installing Git We first need to have git installed in our system which will be needed for gogo installation. To install git in an Ubuntu system follow the below command ? $ sudo apt install git Running the above code gives us the following result ...

Read More

Named Pipe or FIFO with example C program

Diksha Patro
Diksha Patro
Updated on 15-Mar-2026 8K+ Views

Named pipes, also referred to as FIFOs (First In, First Out), are essential IPC (Interprocess Communication) mechanisms in Unix-like systems. They provide a method for communication between unrelated processes running on the same system. Unlike anonymous pipes, named pipes exist as special files in the filesystem and can be accessed by any process with appropriate permissions. Named pipes follow the FIFO principle, ensuring that data written by one process is read by another process in the same order. This makes them particularly useful for producer-consumer scenarios and process synchronization. Syntax int mkfifo(const char *pathname, mode_t mode); ...

Read More

Implicit Threading and Language-based threads

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 5K+ Views

Implicit threading is a programming approach where the creation and management of threads is handled by compilers and run-time libraries rather than application developers. This approach simplifies multithreaded programming by abstracting away low-level thread management details. Syntax #pragma omp parallel { // Parallel code block } OpenMP for Implicit Threading OpenMP is a widely-used implicit threading library for C, C++, and FORTRAN. It provides compiler directives and an API for parallel programming in shared-memory environments. OpenMP identifies parallel regions as blocks of code that can execute in parallel − ...

Read More

Windows thread API in the C program

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 3K+ Views

Threads are created in the Windows API using the CreateThread() function. Just as in Pthreads, a set of attributes like security information, the size of the stack, and a flag for the thread is passed to this function. In the below program, we use the default values for these attributes. Once the summation thread is created, the parent must wait for it to complete before outputting the value of Sum, as the value is set by the summation thread. Using the WaitForSingleObject() function, we perform the equivalent of pthread_join() in the Windows API, which causes the creating thread to ...

Read More

Grand Central Dispatch (GCD)

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 1K+ Views

Grand Central Dispatch (GCD) is a technology for Apple's Mac OS X and iOS operating systems that provides a combination of extensions to the C language, an API, and a runtime library. It allows application developers to identify sections of code to run in parallel, managing most of the threading details automatically like OpenMP. Syntax // Block syntax ^{ /* code block */ } // Dispatch queue creation dispatch_queue_t dispatch_get_global_queue(long identifier, unsigned long flags); // Async execution void dispatch_async(dispatch_queue_t queue, dispatch_block_t block); Blocks in GCD GCD introduces extensions to the C and ...

Read More

What is OpenMP?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 8K+ Views

OpenMP (Open Multi-Processing) is a set of compiler directives and an API for programs written in C, C++, or FORTRAN that provides support for parallel programming in shared-memory environments. OpenMP identifies parallel regions as blocks of code that may run concurrently across multiple threads. Syntax #pragma omp parallel { // Code block to execute in parallel } How OpenMP Works Application developers insert compiler directives into their code at parallel regions, and these directives instruct the OpenMP run-time library to execute the region in parallel. When OpenMP encounters the #pragma ...

Read More
Showing 1691–1700 of 1,708 articles
Advertisements