Skip to content

Archive

Linux

205 articles
Linux 04 Sep 2026 13 min read

Prevent Overlapping Linux Jobs with Advisory File Locks and flock

A scheduled job often looks harmless until two copies run at the same time. A backup takes longer than usual, a second timer fires, and both processes start writing the same output. A maintenance script overlaps with itself and launches duplicate work. A cache refresh runs concurrently and leaves partially coordinated state behind. The problem is not that Linux started the processes incorrectly. The problem is that the application needs a rule saying, “only one cooperating process may enter this critical section at a time.”

Linux 04 Sep 2026 11 min read

Integrate Timers into Linux Event Loops with timerfd

Event loops work best when unrelated kinds of work have one common waiting mechanism. Sockets become readable. Pipes become writable. A child-process descriptor or signal descriptor can become ready. Timers are often the awkward exception. A program can call sleep() or nanosleep(), but that blocks the thread instead of letting it wait for I/O. It can pass a timeout to poll() or epoll_wait(), but one timeout becomes difficult to manage when the program has several independent deadlines. Traditional POSIX timers can deliver signals, which introduces a second asynchronous control path.

Linux 04 Sep 2026 9 min read

Handle Linux Signals in Event Loops with signalfd

Unix signals are asynchronous by design: a signal can interrupt a program between ordinary instructions and transfer control to a signal handler. That model is useful, but it creates an awkward boundary for event-driven programs. A network server may already spend most of its time inside poll(), epoll_wait(), or another readiness API. Its sockets, pipes, and timers appear as file-descriptor events, while SIGTERM and SIGHUP arrive through a separate execution path with much stricter rules about what code may safely run.

Linux 04 Sep 2026 8 min read

Avoid PID Reuse Races on Linux with pidfds

A process ID looks like an identity, but it is really a reusable number. That distinction matters in long-running supervisors, job managers, test harnesses, and other programs that observe a process and then act on it later. Between those two operations, the original process can exit and Linux can eventually reuse the same PID for an unrelated process. Traditional PID-based code can therefore have a time-of-check/time-of-use race: check PID 4242 -> original process exits -> PID 4242 is reused -> signal PID 4242 Linux PID file descriptors, usually called pidfds, provide another model. Instead of repeatedly identifying a task by a reusable integer, a program obtains a file descriptor that refers to a particular process and can use that descriptor with pidfd-aware APIs.

Linux 02 Sep 2026 5 min read

Inspect Process Isolation with Linux Namespaces

Containers rely on several Linux kernel features, but namespaces provide much of the process-level isolation people notice first. They let different groups of processes see different views of resources such as process IDs, mounts, hostnames, and network interfaces. You do not need a container runtime to inspect namespaces. Standard Linux tools and /proc expose the relationships directly. What a namespace changes A namespace virtualizes one class of global system resource.

Linux 02 Sep 2026 4 min read

Diagnosing File Descriptor Leaks on Linux with procfs

A Linux process uses file descriptors for more than ordinary files. Network sockets, pipes, event descriptors, terminals, and many other kernel objects appear through the same integer-based interface. When a service slowly accumulates descriptors, it may eventually fail with Too many open files, stop accepting connections, or behave unpredictably under load. Linux procfs provides enough information to investigate many descriptor leaks without installing extra tools. Start by counting descriptors For a known process ID:

Linux 01 Sep 2026 6 min read

Troubleshooting systemd Services with systemctl and journalctl

When a Linux service fails under systemd, the fastest path to a fix is usually not restarting it repeatedly. A better approach is to inspect the service state, read the relevant logs, confirm the effective unit configuration, and validate changes before trying again. This guide presents a repeatable troubleshooting workflow for modern Linux distributions that use systemd. The examples use commands available in systemd 257, but the core workflow also applies to many earlier systemd releases.

Linux 01 Sep 2026 2 min read

Troubleshoot Linux Services with systemd and journalctl

On systemd-based Linux distributions, a service that “will not start” can fail for many reasons: an invalid command, missing file, permission problem, dependency failure, timeout, or application crash. A repeatable workflow is faster than repeatedly restarting the unit. Start with unit state systemctl status example.service Look at Loaded, Active, the main process exit status, and the most recent log lines. A unit can be loaded correctly while its process exits immediately.

Linux 01 Sep 2026 5 min read

Linux Network Troubleshooting with ip, ss, dig, and curl

When a Linux service is “unreachable,” the failure can be in several different layers: the local interface, routing, a listening socket, DNS, a firewall, TLS, or the application itself. Randomly restarting services makes diagnosis harder. A better approach is to move from local state outward and identify the first layer that does not behave as expected. 1. Confirm the interface and address Start with the addresses configured on the host:

Linux 01 Sep 2026 5 min read

Harden systemd Services with Security Directives

A systemd unit can do more than start and restart a process. It can also define a security boundary around the service by restricting filesystem access, Linux capabilities, namespaces, privilege changes, and resource consumption. These controls do not replace application security, but they can reduce the damage caused by a compromised or misbehaving process. Start from the service’s real requirements Hardening works best when it is based on what the process actually needs.

Linux 01 Sep 2026 4 min read

Find Hidden Linux Disk Usage with df, du, and lsof

A Linux filesystem can report 95% usage in df while du appears to account for much less. The tools are not contradicting each other: they measure different things. df asks the filesystem about allocated blocks. du walks visible directory entries and sums blocks reachable through those paths. The gap between those views points to several useful troubleshooting cases. Start with the filesystem view Check filesystems and their types: df -hT Identify the mount that is actually full. Do not immediately scan recursively from /; container mounts, network filesystems, and bind mounts can make that slow and misleading.

Software Engineering 01 Oct 2025 2 min read

Programming Languages and Tools with Language Server Protocol (LSP) Support

Modern editors such as VS Code, Neovim, Emacs, and Sublime Text can share language intelligence through the Language Server Protocol (LSP). A language server runs separately from the editor and provides features such as completion, diagnostics, symbol navigation, hover information, and refactoring support. How LSP Works A typical setup has three parts: a language server installed on the system or inside the project; an editor or editor plugin that speaks LSP; project configuration the server can understand. For example, Neovim can connect to gopls for Go, while VS Code normally installs the appropriate extension that manages the server integration.

Linux Updated 02 Sep 2025 2 min read

View and Manage Processes on Linux

A Linux process is a running instance of a program. Process-management tools help you inspect CPU and memory use, identify stuck applications, send signals, and manage foreground or background jobs. Inspect Processes with ps ps ps -e ps aux ps aux is a common BSD-style view that includes the owning user, PID, CPU, memory, and command.

Linux Updated 02 Sep 2025 2 min read

Mastering `curl` on Linux: Downloads and API Requests

curl is one of the most useful command-line tools for transferring data and testing HTTP APIs. It supports HTTP, HTTPS, FTP, and many other protocols, making it useful for downloads, automation, diagnostics, and API development. 1. Check or Install curl Check the installed version: curl --version On Debian or Ubuntu:

Linux Updated 02 Sep 2025 1 min read

List All Group Names on Linux

Linux groups are used to organize users and assign shared permissions. There are several ways to list them, and the best command depends on whether your system uses only local files or also directory services such as LDAP. Use getent getent group getent queries the system’s configured name-service databases, so it can include groups from /etc/group as well as network identity sources.

Linux Updated 02 Sep 2025 2 min read

Find the Most Resource-Intensive Processes on Linux

When a Linux system feels slow, a small number of processes may be consuming most of the CPU, memory, or disk I/O. Several standard tools help identify them quickly. Highest CPU Usage with ps ps aux --sort=-%cpu | head For more rows:

Linux Updated 02 Sep 2025 2 min read

Find Recently Changed Files on Linux

Linux provides several ways to find files that were modified recently or to watch a directory for changes as they happen. Files Modified in the Last Hour find /path/to/directory -type f -mmin -60 -mmin works in minutes.

Linux Updated 02 Sep 2025 1 min read

Display a Directory Tree on Linux

A directory tree makes project and filesystem structure easier to understand than a flat list of paths. The dedicated tree utility is usually the clearest tool for this job. Use tree tree Example output:

Linux Updated 02 Sep 2025 2 min read

Create Cron Jobs on Linux

Cron is a time-based scheduler commonly used on Linux and Unix-like systems. It can run backups, cleanup scripts, reports, maintenance commands, and other recurring tasks automatically. Cron Syntax A user crontab entry has five schedule fields followed by the command: * * * * * /path/to/command - - - - - | | | | | | | | | +----- day of week (0-7, Sunday=0 or 7) | | | +------- month (1-12) | | +--------- day of month (1-31) | +----------- hour (0-23) +------------- minute (0-59) Edit Your User Crontab crontab -e For example, run a backup every day at 02:30:

Linux Updated 02 Sep 2025 2 min read

Create and Manage Symbolic Links on Linux

A symbolic link, or symlink, is a special filesystem entry that stores a path to another file or directory. Symlinks are useful for shortcuts, shared configuration, version switching, and keeping one canonical copy of data. Create a Symlink ln -s TARGET LINK_NAME Link to a file:

Linux Updated 02 Sep 2025 2 min read

Count Files in a Linux Directory Quickly

Counting files is useful in shell scripts, backups, log maintenance, migration checks, and filesystem monitoring. The right command depends on whether you want only regular files, recursive results, hidden files, directories, or symbolic links. Count Regular Files in One Directory With GNU find: find /path/to/directory -maxdepth 1 -type f -printf '.' | wc -c -maxdepth 1 prevents recursion into subdirectories. Hidden files are included automatically.

Linux Updated 02 Sep 2025 2 min read

Compress and Extract Files Quickly on Linux

Linux provides several standard compression tools. Some compress a single file, while tar combines many files into one archive and can apply compression at the same time. gzip gzip filename gunzip filename.gz gzip is widely available and usually a good balance between speed and compression ratio.

Cloud Computing Updated 02 Sep 2025 2 min read

Using Nginx as a Reverse Proxy for a Go Application

A Go web application often listens directly on an application port such as :8080. If you want users to access it through a normal domain on port 80 or 443, you can place Nginx in front of it as a reverse proxy. Using Nginx in front of a Go service provides several benefits: Client requests reach Nginx before being forwarded to the Go application. TLS termination can be handled at the proxy layer. Multiple application instances can be load balanced. Static assets can be served separately when that architecture makes sense. This guide shows a basic setup.

Linux Updated 02 Sep 2025 2 min read

Uploading and Downloading Files over SSH on Linux

SSH is commonly used for remote shell access, but the same secure connection can also transfer files. The scp command provides a straightforward way to copy individual files or directories between a local machine and an SSH server. 1. Prerequisites Before using scp, make sure: You can connect to the server with SSH. You know the remote username and hostname or IP address. The destination path is writable by that user. Your SSH key or other authentication method is configured. 2. Upload a File The general form is: