Open Source Articles

Page 98 of 123

What happens to Open File Handle if file is Moved or Deleted?

Satish Kumar
Satish Kumar
Updated on 26-Dec-2022 399 Views

Overview We’ll look at how the operating systems behave when we delete, move or replace files that have open handles. We’ll first briefly talk about files and inodes. After that, we’ll look at the different scenarios and see which one occurs in each case. Understanding Files and Inodes Files stored on a Linux file system use inode numbers to keep track of their contents. We usually list the contents of a directory by listing its file names (links) and then their corresponding inode numbers (hard links). We can use stat on a file and see which inode it refers to ...

Read More

How to solve “Unary operator expected” errors?

Satish Kumar
Satish Kumar
Updated on 26-Dec-2022 9K+ Views

Overview In this article, we will discuss how to solve the unary operator expected error in Linux. This is one of the most common errors that you may encounter while working with Linux. In this post, we will see how to fix it and what are the possible causes for this error. What Is Unary Operator Expected? The unary operator expects is a type of syntax error that occurs when an expression has only one operand. For example − int x 5; //error - unary operator expected The above code snippet shows an error because there is no binary operation ...

Read More

How to Clear Linux terminal screen?

Satish Kumar
Satish Kumar
Updated on 26-Dec-2022 2K+ Views

Overview The Linux terminal is an important tool for any user of the operating system, and it's often used to perform various tasks such as viewing log files or running commands. However, sometimes you may need to clear a screen on your computer so that you can see more than one thing at once. In this article we'll look at how to clear a screen in Linux. It’ll be helpful if we clear the command prompt window so that we can see more clearly what we're doing. We’ll discuss the different ways to accomplish this. Using the clear Command You ...

Read More

Command chaining: Inline or Already running process

Satish Kumar
Satish Kumar
Updated on 26-Dec-2022 459 Views

Overview You may sometimes want to run several commands sequentially in Linux. To accomplish this, you can use command chaining. For example, if you wanted to download a compressed archive, decompress it, and then remove the resulting archive from disk, you could type these three commands together. Here, we’ll look at some methods for serializing commands using Bash in Linux. Even if they're already running. Inline Command Chaining Bash has great flexibility and powerful features for the end−users. We can create long sequences of instructions to perform any number of tasks. ... Chained operations ...

Read More

Create bash alias that accepts parameters

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 932 Views

Overview When working with Bash scripts or Unix/Linux command line tools, we often write the same command lines over and over again. Often, these command lines are long and must be repeated multiple times. For instance, when logging into a remote server daily, copying a local folder to the remote server, or searching for hidden files or directories within a directory. You can create aliases using the alias command. In this guide, I will show you how to create an alias that accepts parameters on Linux. This is useful if you want to run a single command repeatedly without having ...

Read More

Find all links for a specific file on Linux

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 727 Views

Overview In this tutorial, we will learn how to find all links for a specific file on Linux. We will use the command lsof to list all files that are opened by any process and then grep to filter out only those files that have a link to our target file. What is a Link? A link in Unix/Linux systems is an association between two different files or directories. When you create a link, it creates a new name for the original file or directory. You can access the linked file through its alias instead of accessing the original file ...

Read More

Count occurrences of a char in a text file

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 879 Views

Overview We'll learn how to use Linux commands to get the number of occurrences of a specific character in an input file. We're assuming that you know some common Linux commands, including grep, awk, and tr. We'll also suppose that our input file tpoint.txt contains some dummy data − $ cat tpoint.txt "I Love Tpoint!!!" "Tpoint is great!!!" For the rest of the tutorial, we’ll be using tpoint.txt for demonstration purposes. Using the grep Command The grep command looks for a specific string in an input file. We’ll now look at the command to get the number of characters ...

Read More

Find the Java SDK location on Linux

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 23K+ Views

Overview Finding software’s installation directory is a very common operation. One common reason is for updating the PATH environment variable. For example, Java developers are often interested in finding the installation directory of Java. This article shows how to find the location of the JDK on Linux. The method described here works on both 32-bit and 64-bit versions of these operating systems. The JDK includes many tools that can be used by programmers. In this article we will look at some of them. We will start with the most basic tool: the java command. The Java Command The java command ...

Read More

Check if Hard Drive is SSD or HDD on Linux

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 2K+ Views

Overview To determine whether our file system uses SSD or HDD technology, we need to know which type of storage device is used by our operating system. There are many different aspects of Linux storage. There seem to be just as many tools available for reading and configuring our storage. We use words like “drive’, ‘volume’, and ‘mount point’ when we want to describe hard drives, optical discs, and USB sticks. But to understand the underlying technology, we only really care about two things − What physical disk or block device we are looking at (from df) The hardware ...

Read More

Understanding Stale file handles in Linux

Satish Kumar
Satish Kumar
Updated on 23-Dec-2022 3K+ Views

Overview In this article, we will discuss about the concept of stale file handles and how to avoid it in your application. We will also see some examples on how to use fcntl() function to check if a file handle is valid or not. The code in this tutorial has been tested on Debian 10.10 (Buster) with GNU Bash 5.0.3. It is POSIX−compliant and should work in any such environment. What are Stale File Handles? A file handle can be considered as an integer value that represents the access rights for a particular file. The file system maintains a list ...

Read More
Showing 971–980 of 1,225 articles
« Prev 1 96 97 98 99 100 123 Next »
Advertisements