grep -rl "files" ./blog

Working With Files in Linux

Creating, finding, comparing, moving, and inspecting files from the command line, including links, archives, and the tools for searching inside file contents.

16 articles

Recovering Deleted Files on Linux With TestDisk and PhotoRec What to do in the first five minutes after deleting the wrong file, how TestDisk recovers lost partitions and undeletes files, how PhotoRec carves files from raw data, and why SSDs and ext4 make recovery harder. zstd and 7-Zip on Linux: Fast Modern Compression Explained zstd has become the default compressor for packages, filesystems, and kernels because it is fast at every level. How to use zstd and tar --zstd, choose levels, use long-range mode, and when 7-Zip and its .7z format make more sense. fzf and ripgrep Explained: Faster Searching in the Terminal ripgrep searches file contents faster than grep and respects .gitignore; fzf turns any list into an interactive fuzzy finder. How each works, the shell keybindings that change daily terminal use, and how to combine them. Syncthing Explained: Peer-to-Peer File Sync Without a Cloud Syncthing keeps folders in sync directly between your own devices, encrypted, with no server or account. How device IDs, folder sharing, and relays work, how to run it as a service on Linux, and how to avoid the mistakes that lose data. realpath and readlink Explained: Resolving Symlinks and Relative Paths Turn a messy relative path full of symlinks and dot-dot components into the one canonical absolute path. Essential whenever a script must know where it really is. split Command Explained: Breaking Large Files Into Pieces Split a file by size, by line count, or into a fixed number of chunks, then put it back together with cat. Useful for transfer limits, parallel processing, and log handling. Symlinks vs Hard Links Explained: The ln Command and How Links Actually Work Symbolic links point to a path; hard links point to the data itself. Understanding the difference explains why one survives renames, why the other breaks, and what ln -s actually creates. cmp Command Explained cmp compares two files byte by byte and reports the first point where they differ, making it the right tool for binary files where diff does not apply. This guide covers basic usage and when to reach for cmp instead of diff. diff Command Explained diff compares two text files and shows exactly what changed between them. This guide covers basic usage, the unified diff format, comparing entire directories, and how diff output feeds into patch. find Command Explained find searches the live filesystem with powerful filtering by name, size, date, type, and permissions. This guide covers the essential find patterns, including running commands on results with -exec. Finding Files in Linux: locate vs find vs which vs whereis Linux offers several different tools for finding files, each suited to a different situation. This guide compares locate, find, which, and whereis, and explains which one to reach for. grep Command Explained grep searches text for matching patterns and is one of the most powerful everyday tools in Linux. This guide covers basic usage, recursive search, regular expressions, and common grep flags. locate Command Explained locate finds files by name almost instantly by searching a prebuilt index instead of scanning the disk live. This guide covers basic usage, updatedb, and why locate results can occasionally be stale. patch Command Explained patch applies the changes described in a diff file to real files on disk. This guide covers basic usage, applying and reversing patches, and how patch and diff work together. sort Command Explained sort arranges lines of text in order, alphabetically or numerically. This guide covers basic usage, numeric versus alphabetic sorting, sorting by specific fields, and combining sort with uniq. uniq Command Explained uniq removes or counts adjacent duplicate lines in text. This guide explains why uniq requires sorted input first, how to count occurrences, and how to show only duplicated or only unique lines.