Found 1437 Articles for Linux

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

853 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

Most Common Flags Used in /proc/cpuinfo

Satish Kumar
Updated on 23-Dec-2022 10:38:52

887 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

What Is Double Dot (..) And Single Dot (.) In Linux?

Kunal Verma
Updated on 19-Dec-2022 12:30:22

1K+ Views

Abstract Linux terminal/Shell contains several instances where a dot (.) is utilized. When displayed in the output of a command, a dot would also convey some significance. This article will examine the various situations in which a dot is typically used in Linux and the additional locations where this might be shown. Double Dot (..) and Single Dot (.) Example $ ls -laxo Output Total 892 drwxr-xr-x 122 tutorial article 48 18 Dec 05:07 ./ drwxr-xr-x 54 tutorial article 4096 16 Dec 04:03 ../ -rw-rw-rw- 19 tutorial article 960 02 Dec 09:57 operations In the following example, we ... Read More

Running a Shell Script on a Remote Machine Through SSH

Kunal Verma
Updated on 19-Dec-2022 12:29:01

6K+ Views

Abstract It's challenging to envision what would happen if you couldn't control your computer remotely because remote access to computers has long been necessary. The best way to connect to a remote machine is by SSH for Linux-based machines. The SSH client application can be used to log into a distant computer or server and run commands on that computer. When a command is supplied, it is executed instead of a login shell on the remote host or server. Users frequently need to work with distant systems. which requires them to log into the remote server, carry out specific actions, ... Read More

How to check if a File Type Exists in a Directory?

Kunal Verma
Updated on 19-Dec-2022 12:27:11

794 Views

Abstract There are times when we need to determine whether a particular file type is present in a directory or not. For instance, we might want to check if a directory contains python files. Therefore, there are a few approaches such as ls, find, etc which we can use to determine whether there are python files in the directory. In this tutorial, we will review several approaches to check whether particular file types exist in a directory or not. ls command One of the most used commands in Linux is called "ls". It is used to display a list of ... Read More

Advertisements