Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Operating System Articles
Page 84 of 171
How to create a CPU spike with bash command on Linux?
If you have been programming, then you might have observed certain cases and scenarios where the program gets stuck or the process is running in an infinite loop which in turn puts pressure on the core of that thread which is handling that process. There are many such cases where this is quite a possibility. We usually make use of different techniques to avoid such cases, like handling them in code logic itself or using third party tools to deal with them. Linux also provides us with a command that we can use to keep track of the different ...
Read MoreHow to create a zip file and ignore directory structure in Linux?
In order to be able to zip files and ignore directory structure that gets created with them, we first must understand what the zip command on Linux actually means and how we can make use of it. The zip command that Linux provides allows us to specify a compression level with a number prefixed with dash, typically between 0 and 9. It is used to reduce file size through compression and serves as a file packaging facility. The compression process involves taking one or more files and compressing them into a single zip archive, along with metadata about those ...
Read MoreHow to exit from a Linux terminal if a command failed?
It is a common scenario that certain commands might fail for various reasons − differences between GNU and BSD versions of core utilities, logical errors, or missing dependencies. When commands fail, you may want to terminate the process or exit the terminal without manually pressing CTRL + C. Here are several methods to handle command failures gracefully. Using bash exit command with || The logical OR operator (||) allows you to execute a command only if the previous command fails. This is useful when you want to exit the terminal immediately upon command failure. my_command || ...
Read MoreHow to find all files with names containing a string on Linux?
In Linux command line, finding all files with names containing a specific string is accomplished using the grep command. The grep command is a powerful text processing utility that searches for patterns within files and displays matching lines. The grep command filters searches in files for particular patterns of characters. It is one of the most frequently used Linux utilities for displaying lines that contain the pattern you are searching for. The pattern being searched is typically referred to as a regular expression. Syntax grep [options] pattern [files] Common grep Options -c ...
Read MoreHow to find out which process was killed by Linux OOM killer?
The Out of Memory (OOM) killer is a Linux kernel mechanism that terminates processes when the system runs out of available memory. When a process is killed by the OOM killer, the system logs this information to help administrators identify which processes were terminated and why. To find out which process was killed by the Linux OOM killer, we use the grep command to search through system log files. The grep command filters searches in files for specific patterns and is essential for analyzing log data. Basic grep Command Syntax grep [options] pattern [files] ...
Read MoreHow to find out which processes are using swap space in Linux?
Swap space is a storage area on disk used by Linux when the physical memory (RAM) is full. When the operating system needs more memory resources and RAM has no space left, inactive pages are moved to swap space. While swap space helps extend available memory, it should not be considered a replacement for more RAM due to slower disk access speeds. There are several methods to identify which processes are using swap space in Linux. The most straightforward approaches include using system utilities like smem, the top command, or custom shell scripts. Using the Top Command ...
Read MoreHow to find the most recent file in a directory on Linux?
The Linux find command is one of the most widely used utilities that allows us to traverse a file hierarchy. It is primarily used to locate specific files or directories, and we can combine it with other Linux commands or flags to perform complex operations. Let's explore a basic example of the find command to understand how it works. In the example below, I am searching for a file named sample.sh using the find command: find sample.sh Output sample.sh Notice that if the find command locates the file, it prints ...
Read MoreHow to free Inode usage on Linux?
The inode (also known as index node) is a data structure that stores metadata about files and directories in Linux file systems. Each file or directory uses one inode, which contains information like permissions, ownership, timestamps, and pointers to data blocks. When inodes are exhausted, you cannot create new files even if disk space is available. Checking Inode Usage You can check the inode usage on your system using the df command with the -i option − df -i This displays inode information for all mounted filesystems − Filesystem ...
Read MoreHow to get Linux console window width in Python?
In order to get the width and height of the Linux console in Python, there are different modules available that we can make use of. Two of them are the os module and the subprocess module. In the case of the os module, we make use of the popen() method that is used to open a pipe to and from command which will help in retrieving the width and height of the Linux window. Using os.popen() Method Consider the code for the same shown below − import os rowSize, columnSize = os.popen('stty size', 'r').read().split() ...
Read MoreHow to get only the file name using find command on Linux?
The Linux find command is one of the most widely used utilities that allows us to traverse a file hierarchy. It is primarily used to locate specific files or directories, and we can combine it with various flags and options to perform complex operations. Let's explore a basic example of the find command to understand how it works. In the example below, we are searching for a specific file named sample.sh in the current directory: find sample.sh Output sample.sh If the find command locates the file, it prints the file ...
Read More