Skip to content

Archive

Linux

205 articles
Linux Updated 02 Sep 2025 3 min read

Managing Users on Linux: A Practical Guide

Linux user management controls who can sign in, which files they can access, and which administrative actions they can perform. A few standard commands cover most day-to-day account management tasks. 1. Create a User The low-level useradd command creates a new account. A practical invocation is: sudo useradd -m -s /bin/bash -c "John Doe" john The options mean:

Linux Updated 02 Sep 2025 2 min read

Understand and Use `htop` Effectively

htop is an interactive process monitor for Linux and other Unix-like systems. It presents CPU, memory, swap, load, and process information in a navigable terminal interface. Install and Run Debian/Ubuntu: sudo apt install htop Fedora and many RHEL-family systems:

Linux Updated 07 Sep 2025 2 min read

Read and Use `top` on Linux

top is a standard Linux tool for viewing system load and processes in real time. It is useful when diagnosing high CPU use, memory pressure, runaway processes, or general server load. Start top top The display has a system summary at the top and a process table below it.

Linux Updated 02 Sep 2025 1 min read

Monitor Linux Processes with `ps`

ps (process status) prints a snapshot of processes. Unlike top or htop, it does not continuously refresh, which makes it particularly useful in shell pipelines, scripts, and one-time diagnostics. Current Terminal Processes ps All Processes ps -e ps -ef ps -ef uses a Unix-style full-format listing with fields such as UID, PID, PPID, and command.

Linux Updated 07 Sep 2025 2 min read

Search Text with `grep` and Regular Expressions on Linux

grep can search for literal text or regular-expression patterns. With extended regular expressions, it becomes a compact tool for locating structured values, alternatives, prefixes, suffixes, and other text patterns. Extended Regular Expressions Use -E: grep -E 'regex_pattern' file Single quotes are often convenient in the shell because they prevent accidental expansion of regex metacharacters by the shell itself.

Linux Updated 02 Sep 2025 1 min read

Search for Text from the Linux Terminal

grep is one of the standard Linux tools for searching text in files or command output. Search One File grep 'error' application.log Search Several Files grep 'TODO' *.py Ignore Case grep -i 'warning' /var/log/syslog Show Line Numbers grep -n 'function' script.js Search Recursively grep -rI 'main' ./src -r walks subdirectories and -I skips binary files.

Linux Updated 02 Sep 2025 2 min read

Linux File Permissions: A Practical Guide for Developers

Linux file permissions control who can read, modify, or execute files and who can traverse or modify directories. Understanding them is essential for development, deployment, and server administration. Permission Classes Permissions are defined for: user (u) — the file owner; group (g) — users in the file’s group; others (o) — everyone else. The basic permission bits are: read (r); write (w); execute (x). For directories, r allows listing names, w allows creating/removing entries when combined with appropriate access, and x allows traversal.

Linux Updated 02 Sep 2025 2 min read

Finding Files on Linux with `find`

When a directory tree becomes large and deeply nested, searching manually is inefficient. Linux provides the find command for locating files and directories by name, size, type, modification time, and many other properties. 1. Basic Syntax find [path] [expression] path specifies where the search starts. Use . for the current directory. expression defines the filters and actions. 2. Practical Examples Find a File by Name find . -type f -name "example.txt" This searches the current directory and all subdirectories for a regular file named example.txt.

Linux Updated 02 Sep 2025 2 min read

Extract PSD Layers with Bash and ImageMagick

ImageMagick can read many Photoshop PSD files and export the images it exposes as frames or layers. Combined with a Bash loop, this can automate batch extraction without opening every file manually. Install ImageMagick On Debian/Ubuntu: sudo apt install imagemagick ImageMagick 7 uses the magick command. Some older installations expose commands such as convert directly.

Linux Updated 07 Sep 2025 2 min read

Replacing Text in Files with `sed` on Linux

Editing the same text manually across many files is slow and error-prone. The Linux sed stream editor can search, replace, delete, and transform text from the command line. 1. Preview a Replacement Suppose several .txt files contain abc and you want to replace every occurrence with aab: sed 's/abc/aab/g' *.txt Without -i, sed writes the transformed content to standard output and leaves the files unchanged. This makes it useful for previewing a replacement before editing files in place.

Linux Updated 02 Sep 2025 2 min read

Managing Linux Filenames: Replacing Spaces with Underscores

Spaces in filenames are valid on Linux, but they can make shell scripting more cumbersome because paths must be quoted carefully. If a project has a naming convention that prefers underscores, you can rename files in batches with standard shell tools. A Safe Bash Approach The following script recursively finds files whose names contain spaces and replaces those spaces with underscores: find . -type f -name "* *" -print0 | while IFS= read -r -d '' file; do dir=$(dirname -- "$file") base=$(basename -- "$file") new=${base// /_} [ "$base" = "$new" ] || mv -n -- "$file" "$dir/$new" done The important details are:

Linux Updated 02 Sep 2025 2 min read

Monitoring Directory Sizes on Linux with `du` and `sort`

When a Linux server starts running low on disk space, one of the fastest ways to investigate is to find which directories consume the most storage. The du and sort commands work well together for this task. 1. du: Measure Disk Usage du reports how much disk space files and directories use. Two useful options are: -s — show one summary total for each argument instead of every nested item. -h — display sizes in a human-readable format such as KB, MB, or GB. For example:

Linux Updated 02 Sep 2025 2 min read

Synchronizing Files with `rsync` over SSH

rsync is a reliable tool for copying and synchronizing files locally or between machines. When the remote side is accessed through SSH, the transfer is encrypted and can use the same authentication model as normal SSH sessions. Basic Remote Synchronization A common command is: rsync -avP /home/user/documents/ user@example.com:/home/user/backup/ The options are: