Found 1383 Articles for Open Source

Check if Hard Drive is SSD or HDD on Linux

Satish Kumar
Updated on 23-Dec-2022 11:43:30

1K+ 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
Updated on 23-Dec-2022 11:37:48

2K+ 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
Updated on 23-Dec-2022 11:36:17

15K+ 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
Updated on 23-Dec-2022 11:32:45

2K+ 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
Updated on 23-Dec-2022 11:29:32

178 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
Updated on 23-Dec-2022 11:24:15

104 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
Updated on 23-Dec-2022 11:18:30

8K+ 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

How to check Syntax of a Bash Script without running it in Linux?

Satish Kumar
Updated on 23-Dec-2022 11:17:11

852 Views

Overview Here, we’ll see how we can validate the syntactical correctness of a bash script without actually executing it. We’re going to examine some of the Bash and external tools that can be used for that task. Configure Let’s first write a simple script that we’ll be using in almost every example throughout the tutorial. $ cat unity_check.sh #! /bin/bash read -p "Enter the input: " num1 if [ -z "$num1" ] then echo "The number is empty" exit 0 fi if [ "${num1}" -eq 1 ] then echo "Number entered is 1" else echo "Not equal to One !!" ... Read More

Find last Directory or file from a given path

Satish Kumar
Updated on 23-Dec-2022 11:14:58

580 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
Updated on 23-Dec-2022 11:03:39

386 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

Advertisements