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
Linux Articles
Page 48 of 134
How to display the first part of the file in the Linux system?
The head command in Linux is used to display the first part of a file or piped data. By default, it shows the first 10 lines of the specified file, making it useful for quickly previewing file contents without opening the entire file. Syntax The general syntax of the head command is − head [OPTION]... [FILE]... Common Options Option Description -n NUM Display the first NUM lines instead of the default 10 -c NUM Display the first NUM bytes of each file ...
Read MoreHow to display the last part of the file in the Linux system?
To display the last part of a file, we use the tail command in the Linux system. The tail command is used to display the end of a text file or piped data in the Linux operating system. By default, it displays the last 10 lines of its input to the standard output. It is the complement of the head command. Syntax The general syntax of the tail command is as follows − tail [OPTION]... [FILE]... Options Brief description of options available in the tail command: Option Description ...
Read MoreHow to flushes file system buffers in the Linux operating system?
To synchronize cached writes to persistent storage, we use the sync command in the Linux operating system. This command ensures that data stored in memory buffers is written to disk, preventing data loss during unexpected shutdowns or system crashes. The sync command synchronizes file data between volatile memory (RAM) and persistent storage devices like hard drives or SSDs. When applications write data, it is initially stored in kernel buffers for performance reasons. The sync command forces these buffers to be written to disk immediately. How File System Buffers Work Linux uses a write-back caching strategy where data ...
Read MoreHow to format contents of a text file in the Linux system?
Sometimes text files are not well formatted for presentation. While manual formatting works for small files, it becomes impractical for large files. In Linux, we use the fmt command to format the contents of text files efficiently. The fmt command is used to format, simplify, and optimize text files in the Linux system. If no file is specified, fmt reads input from standard input. By default, it creates text lines that are 75 characters wide. Syntax The general syntax of the fmt command is as follows − fmt [-WIDTH] [OPTION]... [FILE]... Options ...
Read MoreHow to join lines of two files on a common field in Linux?
To join lines of two files on a common field, we use the join command in the Linux system. The join command is used to merge lines from two sorted files based on a common field. Instead of physically combining files, the join command creates output by matching corresponding fields from both files. By default, the join field is the first field, delimited by whitespace. Syntax The general syntax of the join command is as follows − join [OPTION]... FILE1 FILE2 Note − If FILE1 or FILE2 is not specified, the join command reads ...
Read MoreHow to list the directory content in Linux?
In the Linux operating system, there are two primary commands available to list directory contents: ls (list) and dir (directory). Both commands serve similar purposes but differ in their output formatting and default behavior. The ls Command ls (list) is the most commonly used command to list directory contents in Linux systems. By default, it displays the contents of the current directory with colored output for better readability. The ls command is also available in EFI (Extensible Firmware Interface) shell environments. Syntax $ ls [OPTION]... [FILE]... Common ls Options ...
Read MoreHow to move a file, group of files, and directories in Linux?
The mv (move) command is used to move one or more files or directories from one location to another in Linux/Unix systems. Unlike copying, the mv command transfers files by removing them from the source and placing them at the destination. The mv command also serves as a rename tool when moving files within the same directory. Syntax The general syntax of the mv command follows these patterns − mv [OPTION]... [-T] SOURCE DESTINATION mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... Command Options Option Description ...
Read MoreHow to move jobs to the background in the Linux system?
To move foreground jobs to the background in a Linux system, we use the bg command. This is particularly useful when you have a running process that you want to continue executing without blocking your terminal. bg (background) − The bg command resumes execution of a suspended process in the background. When a job is moved to the background, it continues running but no longer occupies the foreground of your terminal session. If no job is specified, the bg command works on the most recently suspended job. Syntax The general syntax of the bg command is as ...
Read MoreHow to overwrite a file to hide file contents, and make original contents unrecoverable in Linux?
To overwrite file contents and make them unrecoverable in the Linux system, we use the shred command through the terminal. Unlike the standard rm command which only removes file entries from the filesystem, shred performs secure deletion by overwriting the actual data multiple times. shred − The shred command is used to securely delete files and devices. This command overwrites a file to hide its contents and optionally deletes the file, making it extremely difficult to recover using any software recovery tools in Linux/Unix systems. When we remove files using the rm command, the file data remains on ...
Read MoreHow to remove sections from each line of files in the Linux system?
In this article, we will learn to remove sections from each line of files in the Linux/Unix operating system using the cut command. The cut command is used to extract and print selected portions of each line from files. It allows you to cut specific sections of a line by byte position, character position, or field delimiters. This makes it particularly useful for processing structured text data, CSV files, and extracting specific columns from formatted output. Syntax The general syntax of the cut command is as follows − cut OPTION... [FILE]... Options ...
Read More