Linux Articles

Page 49 of 134

How to removes duplicate lines from a sorted file in Linux?

Shilpa S
Shilpa S
Updated on 17-Mar-2026 7K+ Views

To remove duplicate lines from a sorted file and make it unique, we use the uniq command in the Linux system. The uniq command works as a filter program that reports and removes duplicate lines in a file. It filters adjacent matching lines from the input and gives a unique output. This command is also available in Windows and IBM i operating systems. Syntax The general syntax of the uniq command is as follows − uniq [OPTION]... [INPUT [OUTPUT]] Options Brief description of options available in the uniq command − ...

Read More

How to shrink or extend the size of a file in Linux?

Shilpa S
Shilpa S
Updated on 17-Mar-2026 17K+ Views

The truncate command is used to shrink or extend the size of a file to a specified size in Linux. Unlike deletion commands, truncate cannot remove files but can modify their contents and size. When reducing file size, if the specified size is smaller than the actual size, the extra data will be permanently lost. Syntax The general syntax of the truncate command is as follows: truncate OPTION... FILE... Options Brief description of options available in the truncate command: Option Description -c, --no-create Do not ...

Read More

How to sort lines of text files in Linux?

Shilpa S
Shilpa S
Updated on 17-Mar-2026 15K+ Views

The sort command in Linux is used to arrange lines of text files in a specified order. By default, it sorts lines alphabetically in ascending order, but it offers numerous options to customize the sorting behavior based on different criteria such as numeric values, months, or reverse order. Syntax The general syntax of the sort command is as follows: sort [OPTION]... [FILE]... sort [OPTION]... --files0-from=F Common Sort Options Option Description -b, --ignore-leading-blanks Ignore leading blanks when sorting -d, --dictionary-order Consider only blanks and alphanumeric ...

Read More

How to split or break large files into pieces in Linux?

Shilpa S
Shilpa S
Updated on 17-Mar-2026 12K+ Views

The split command is used to divide large files into smaller, more manageable pieces in Linux systems. By default, it creates output files with 1000 lines each and uses 'x' as the filename prefix. For example, if no output filename is specified, the split files will be named xaa, xab, etc. When a hyphen (-) is used instead of an input file, the command reads data from standard input. Syntax The general syntax of the split command is as follows: split [OPTION]... [FILE [PREFIX]] Command Options Option Description ...

Read More

How to wrap each input line to fit in specified width in Linux?

Shilpa S
Shilpa S
Updated on 17-Mar-2026 793 Views

The fold command in Linux is used to wrap each input line to fit within a specified width. This utility makes files with long lines more readable on terminals with limited screen width, as most Linux/Unix terminals default to 80 columns. When reading files with long lines, content can extend beyond the screen width, making it difficult to read without horizontal scrolling. The fold command allows users to set the maximum length of a line and performs automatic line wrapping. It was included in the first version of POSIX and remains a standard tool across Unix-like systems. Syntax ...

Read More

How to add a new entry to the PATH variable in ZSH on Mac OS in Linux

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 14K+ Views

The PATH variable in ZSH determines where the shell looks for executable commands. By default, macOS Catalina and later versions don't include a .zshrc file, so we need to create one to customize our shell environment. This file contains configuration settings and environment variables that are loaded every time a new ZSH session starts. Creating the .zshrc File To create the .zshrc file, follow these steps − Open Terminal Type touch ~/.zshrc to create the file Press Return You can open and edit the .zshrc file from any directory using − vi ...

Read More

Best practices when running Node.js with port 80 (Ubuntu) in Linux

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 760 Views

Running Node.js applications on port 80 is a common requirement for web servers, but it presents security challenges on Linux systems. Port 80 is a privileged port that requires root access to bind to, creating potential security vulnerabilities when applications run with elevated privileges. The Root Privilege Problem Most Linux distributions require root privileges to bind to ports below 1024, including port 80. The naive approach is to run the application with superuser privileges: sudo node server.js While this solves the immediate problem, it creates significant security risks. If an attacker compromises your Node.js ...

Read More

Convert XLSX to CSV in Linux with Command Line in Linux

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 2K+ Views

XLSX files are the standard format for modern Microsoft Excel spreadsheets, containing structured data organized in rows and columns. CSV (Comma-Separated Values) files are plain text files where data records are separated by commas, making them more portable and easier to process programmatically. Converting XLSX to CSV in Linux can be accomplished using several command-line tools. This guide covers the two most effective methods: ssconvert from Gnumeric and libreoffice headless mode. Method 1: Using Gnumeric ssconvert The Gnumeric spreadsheet application includes a powerful command-line utility called ssconvert that handles various spreadsheet format conversions. Installation First, ...

Read More

Crontab day of the week syntax on Linux

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 6K+ Views

A crontab is a configuration file that contains a list of commands scheduled to run at specific times. It uses the cron daemon, a time-based job scheduler in Unix-like operating systems, to execute these commands automatically. Understanding Crontab Syntax To create or edit a crontab job, use the following command: crontab -e This opens the crontab editor where you can add scheduled jobs. Each crontab entry follows a specific format with five time fields followed by the command to execute: * * * * * command_to_execute Crontab Time Fields ...

Read More

Fastest way to tell if two files have the same contents in Unix/Linux

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 761 Views

Let's say that we have two files inside a directory called dir1, and at first both these files are different. Different in the sense that the text they contain isn't the same. The files in the folder − immukul@192 dir1 % ls -ltr total 16 -rw-r--r-- 1 immukul staff 7 Jul 7 10:37 2.txt -rw-r--r-- 1 immukul staff 8 Jul 8 19:05 3.txt The contents inside the first file (2.txt) looks something like this − immukul@192 dir1 % cat 2.txt orange The contents inside the second file (3.txt) looks something like ...

Read More
Showing 481–490 of 1,338 articles
« Prev 1 47 48 49 50 51 134 Next »
Advertisements