Satish Kumar

Satish Kumar

936 Articles Published

Articles by Satish Kumar

Page 93 of 94

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

Delete expoted environment Variable in Linux shell

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

Overview This article explains how to delete an environment variable from the system. An environment variable is a special kind of variable that can be used by all processes running on your machine. The name of this variable is EXPORTED_VARIABLE. You can use it to pass information between different programs or even between different users. For example, you might want to export the path to the directory where you store your music files so that other users can access them easily. Environment Variable The environment variables are stored as part of the process’s memory space and they are accessible through ...

Read More

Difference Between .a and .so files

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

Overview A programmer may want to write three different programs. However, he realizes that some of the functionality needed for each program could be shared among them. Therefore, he decides to create a library containing these shared features. A library is basically a collection of code and data that other people can use. On Linux, archives (located at the.a file extension) contain compiled code, whereas shared objects (.so files) contain interpreted code. Here, we’ll examine how software runs under Linux and the purposes of the library and archive files. We’ll also see some examples of how we can create these ...

Read More

Implement shell file protection in Linux

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

Overview This article will show you how to protect your files from unauthorized access using the Linux file system permissions, and how to use chmod command to set permissions for a specific user or group of users. Besides the Linux file permission mechanisms that help us keep our files safe from misuses, most Linux shells have built-in safeguards against accidental file overwrite. We’ll cover some of them here. Protecting Files With noclobber All POSIX shell implementations support the noclobber option. If you're using a shell script, meaning the shell will complain if you try to overwrite an existing directory. By ...

Read More

Avoiding unwanted directory while using zip

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

Overview There are many different ways to compress and collect file on Linux systems. We have several options for doing so: using the command line tools, GUI applications. However, if we share files with Windows or Mac users, the ZIP file remains the most convenient option. We want to maintain its convenience. We’ll look at how to organize our files so they aren't cluttered with unnecessary folders. We'll learn some basic file management techniques. These might seem obvious if you're doing them manually, but can get tricky when you're working with scripts. We'll use the bash shell's built−in push/pop commands ...

Read More

Delete empty files and directories in Linux

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

Overview We'll learn how to remove empty directories and empty file on Linux. Empty directories don't take up any disk space, but they're good to keep them tidy. We should clear out old files and folders periodically. All the instructions in this tutorial are for Linux systems. They won't work on Windows. Delete Empty Files in a Directory You can use the `find` command to remove all the empty files in an existing folder. $ find . -type f -empty -print -delete To delete empty directories, we first need to search for all the empty folders in the specified ...

Read More

Find last Directory or file from a given path

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

Overview We often use shell scripts or work with Linux commands when handling paths. Extracting the last part of a given file name is a fairly common task. For example, if we're trying to access /tmp/dir/target, then we want to be able to access target as a file name. Yes, this looks easy enough. But there might be some edge cases that could cause us to fail. We’ll take a close look at this problem and explore some common solutions. Discussion of Common Solutions We know that Linux file systems don't allow slashes (/) to be parts of filenames or ...

Read More

Copying SSH Keys to different Linux Machine

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

Overview When working with SSH keys, it is important to keep them safe. We can protect ourselves against accidental deletion by storing them in an encrypted file. We can also make sure they aren’t compromised if someone tries to steal them by keeping them offline. For example, we could store them in a password protected folder on a USB drive. However, this isn’t the best way to do things. If you have multiple machines and want to copy your key from one machine to another, then there are better ways of doing that than copying the key files over. This ...

Read More

Most Common Flags Used in /proc/cpuinfo

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

Overview We’ll go through some of the features available on the CPU installed on our computer’s motherboard. We’ll briefly look at the concept of virtual file systems before we dive into the details of the topic. Afterward, we’ll discuss the flags obtained from the /proc/cpuinfo virtual directory for different CPU manufacturers such Intel, AMD, and Arm. Virtual Files A virtual file system (VFS) is an abstraction layer that allows us to treat files as if they were stored on a disk drive. The VFS provides a way to access data without having to know where it actually resides. For example, ...

Read More

How to read a Specific Line From a File in Linux?

Satish Kumar
Satish Kumar
Updated on 01-Dec-2022 15K+ Views

When working with the Linux shell, reading text files is often an important operation. Sometimes, we may be interested in reading a specific line from a file. We’ll take a look at different ways to get a specific piece of text out of a file. The actual Problem Let’s take a look at an example. let's say we have a file called "test.txt" − $ nl test.txt 1 This is line 1, I don't have any interesting data. 2 This is line 2, I don't have any interesting data. 3 This is line 3, I don't have any interesting data. ...

Read More
Showing 921–930 of 936 articles
Advertisements