Tag: Linux

Browse all articles, tutorials, and guides about Linux

Guides

Posts

Networking
2025-07-21|7 min read

How to Free Up a TCP/IP Port on Linux, macOS, and Windows

Learn how to identify processes using a port and free it up by stopping the service, killing the process, or changing configuration across different operating systems.

Networking
2025-07-10|7 min read

How to Get a List of All Valid IP Addresses in a Local Network?

Discover active devices on your local network using tools like nmap, arp-scan, and native OS commands. Learn network scanning techniques for inventory management, security audits, and troubleshooting.

Python
2025-06-18|7 min read

How do I Get Flask to Run on Port 80?

Running Flask on port 80 requires special permissions since port 80 is a privileged port. Learn the different approaches to running Flask on port 80, from using sudo to setting up reverse proxies with Nginx.

Networking
2025-06-12|8 min read

Can Two Different Sockets Share a TCP Port?

Understand how TCP port sharing works with SO_REUSEADDR and SO_REUSEPORT, when multiple sockets can bind to the same port, and the limitations you need to know.

Linux
2025-06-05|7 min read

What do PTY and TTY Mean?

TTY and PTY are interfaces for text input and output in Unix systems. Learn the difference between physical terminals (TTY), pseudo-terminals (PTY), and how they enable SSH sessions, terminal emulators, and command-line tools.

C
2025-05-22|6 min read

Why Does the C Preprocessor Interpret "linux" as "1"?

Discover why the word 'linux' is predefined as the constant 1 in the C preprocessor on Linux systems, and how this historical quirk can cause unexpected compilation errors.

Linux
2025-05-03|7 min read

Network Usage Top/Htop on Linux

Monitor real-time network bandwidth usage on Linux with tools like iftop, nethogs, nload, and bmon. Learn which processes are consuming bandwidth, track interface statistics, and identify network bottlenecks.

Shell
2025-04-22|5 min read

Using ls to list directories and their total sizes

How to show directory sizes from the shell - practical commands for macOS and Linux, and why `ls` alone is not enough.

Networking
2025-04-15|8 min read

How to Connect to Network Shares with Username and Password

Learn how to mount SMB/CIFS network shares with credentials on Linux, macOS, and Windows, including persistent mounts and secure credential storage.

Linux
2025-04-12|7 min read

How to Kill All Processes with a Given Partial Name in Linux

Learn how to terminate multiple processes by matching partial names using pkill, killall, and other methods. Understand the risks and safe practices for bulk process termination.

Linux
2025-04-05|8 min read

How to Measure the Actual Memory Usage of an Application or Process

Learn how to accurately measure real memory usage of processes in Linux, understand the difference between virtual, resident, and shared memory, and use the right tools for memory analysis.

Linux
2025-03-28|7 min read

How to Get Current Date and Time in Linux Terminal and Create Custom Commands

Learn how to display the current date and time in various formats using the date command, and create custom shell aliases for quick access to your preferred formats.

Networking
2025-03-22|7 min read

How to Find an Available Port on Linux, macOS, and Windows

Learn multiple methods to find open ports on your system, from command-line tools like netstat and lsof to programmatic approaches in Python and Node.js.

Linux
2025-03-20|8 min read

Increasing the Maximum Number of TCP/IP Connections in Linux

Learn how to tune Linux kernel parameters to handle more TCP connections for high-traffic servers. Adjust file descriptors, TCP backlog, port ranges, and connection tracking limits to scale your applications.

Networking
2025-03-15|7 min read

How Do SO_REUSEADDR and SO_REUSEPORT Differ?

Understand the difference between SO_REUSEADDR and SO_REUSEPORT socket options, when to use each one, and how they solve different problems in network programming.

Linux
2025-03-10|7 min read

How to Tar a Directory While Excluding Files and Folders

Create tar archives without including unnecessary files like node_modules, .git, or build artifacts. Learn to use --exclude patterns effectively for cleaner backups.

Linux
2025-02-20|6 min read

How to Force cp to Overwrite Files Without Confirmation

Learn how to use cp command to overwrite existing files without prompts, understand the -f flag, and handle alias conflicts that cause unexpected confirmation requests.

Linux
2025-02-15|5 min read

How to Remove a Symlink to a Directory in Linux

Removing a symlink to a directory can be tricky if you're not careful. Learn the correct way to delete symlinks without accidentally removing the target directory's contents.

Bash
2025-01-30|6 min read

How to Sleep for Milliseconds in Bash and Linux

Learn how to pause script execution for fractions of a second using sleep, usleep, and other methods for precise timing in Bash scripts and command-line operations.

Linux
2025-01-22|6 min read

How to Get the Full Path of a File in Linux

Learn different methods to get the absolute path of a file in Linux, from simple commands like realpath to handling relative paths and symlinks correctly.

SSH
2025-01-18|6 min read

How to Fix SSH "Could Not Resolve Hostname" Error

Troubleshoot and fix the SSH 'nodename nor servname provided, or not known' error with DNS checks, host file configuration, and SSH config debugging.

Bash
2025-01-15|7 min read

How to Redirect All Output to a File in Bash

Learn how to redirect stdout and stderr to files in Bash, capture both standard output and errors together, and understand the different redirection operators.

Linux
2025-01-08|6 min read

How to Exclude Directories from grep -R

Learn how to exclude specific directories when searching recursively with grep, including node_modules, .git, and other directories you want to skip.

Docker
2024-12-28|7 min read

Cannot Connect to Docker Daemon at unix:/var/run/docker.sock - Is the Docker Daemon Running?

Fix the common 'Cannot connect to the Docker daemon' error with practical solutions for Linux, macOS, and Windows. Learn why this happens and how to resolve permissions and service issues.

Docker
2024-12-21|8 min read

Why Your Docker Container Exits Immediately

Troubleshoot and fix Docker containers that start and immediately exit. Learn about foreground processes, CMD vs ENTRYPOINT, and common pitfalls that cause containers to stop.

Linux
2024-12-20|6 min read

How to Create Symbolic Links in Linux

Learn how to create and manage symbolic links (symlinks) in Linux to create shortcuts, organize files, and maintain flexible file system structures.

Bash
2024-12-20|7 min read

What Does set -e Mean in a Bash Script?

The set -e command in Bash causes your script to exit immediately when any command fails. Learn when to use it, how it works, and common pitfalls to avoid.

Linux
2024-12-18|6 min read

How to Kill a Process Running on a Particular Port in Linux

Learn multiple methods to identify and terminate processes that are using specific ports on Linux systems using netstat, lsof, fuser, and ss commands.

Linux
2024-12-18|7 min read

How to Prompt for Yes/No/Cancel Input in Linux Shell Scripts

Learn how to create interactive shell scripts that prompt users for confirmation with Yes/No/Cancel options using various techniques and best practices.

Linux
2024-12-15|5 min read

How to Check Which Process is Using a Specific Port from Command Line

Learn how to identify which processes are listening on specific ports using netstat, lsof, and ss commands across different operating systems.

Linux
2024-12-15|7 min read

How to Find Files Containing Specific Text on Linux

Need to locate files with specific content? Learn how to use grep, find, and other Linux tools to search through files and directories efficiently.

Git
2024-12-15|5 min read

How to Reset Local Git Branch to Match Remote Repository HEAD

Learn different methods to reset your local Git branch to exactly match the remote repository HEAD, including hard reset, fetch and reset, and when to use each approach safely.

Git
2024-12-14|5 min read

How to Reset or Revert a File to a Specific Revision in Git

Learn multiple ways to reset or revert a specific file to a previous version in Git, including using git checkout, git restore, and git show commands with practical examples.

Git
2024-12-13|5 min read

How to Push a New Local Branch to Remote Git Repository and Track It

Learn how to push a new local Git branch to a remote repository and set up tracking, including different methods for initial push, setting upstream branches, and managing branch relationships.

Linux
2024-12-12|7 min read

How to Create a Copy of a Directory in Unix/Linux

Learn various methods to copy directories in Linux and Unix systems using cp, rsync, and tar commands with practical examples and best practices.

Git
2024-12-12|5 min read

How to Revert Git Repository to a Previous Commit Safely

Learn multiple safe methods to revert your Git repository to a previous commit, including using git revert, git reset, and git checkout with practical examples and safety considerations.

Linux
2024-12-12|7 min read

How to Loop Through File Content in Bash

Learn different methods to iterate through file content line by line in Bash scripts, including handling special characters and processing large files efficiently.

Linux
2024-12-10|6 min read

How to Change File and Folder Permissions Recursively in Linux

Learn how to use chmod command to change permissions for directories and all their subdirectories and files efficiently and safely.

SSH
2024-12-09|6 min read

How to Find the IP Address of an SSH Client

Learn multiple ways to identify the IP address of clients connected to your SSH server, from environment variables to logs and active connection monitoring.

Linux
2024-12-08|5 min read

How to Change Echo Text Colors in Linux Terminal

Learn how to colorize your terminal output using ANSI escape codes with the echo command to make scripts more readable and visually appealing.

Linux
2024-12-08|6 min read

How to Count Number of Lines in Files Using Linux Terminal

Learn different methods to count lines in text files like CSV, TXT, and other non-binary files using wc, awk, sed, and other Linux command-line tools.

Linux
2024-12-05|8 min read

How to Close Specific Ports on Linux Systems

Learn how to close and block specific ports on Linux using iptables, ufw, firewalld, and by stopping services. Secure your system by controlling port access.

Linux
2024-12-05|5 min read

How to Use Grep to Show Only Filenames on Linux

Learn how to use grep options to display only the names of files containing matches, making it easier to identify relevant files in large searches.

Linux
2024-12-05|6 min read

How to Recursively Count Files in a Linux Directory

Learn different methods to count files in a directory and its subdirectories, including fast one-liners and options for filtering by type, size, or pattern.

Linux
2024-12-03|6 min read

How to Exclude Directories When Using Find in Linux

Learn how to exclude specific directories from find command searches to improve performance and focus on relevant results when searching through file systems.

Docker
2024-12-03|8 min read

How to Clear Docker Container Logs Properly

Learn safe ways to clear or reset Docker container logs, where the logs live, and how to set up log rotation so logs do not grow unbounded.

Linux
2024-12-02|7 min read

How to Pipe to and from Clipboard in Bash Scripts

Learn how to integrate clipboard functionality into your Bash scripts using xclip, xsel, pbcopy, and pbpaste for seamless data transfer between terminal and GUI applications.

Linux
2024-11-30|6 min read

How to Recursively Grep All Directories and Subdirectories

Learn how to use grep with recursive options to search through entire directory trees efficiently, including advanced filtering and performance optimization techniques.

Linux
2024-11-28|8 min read

Defining Variables with and without Export in Linux Shell

Understand the difference between regular shell variables and exported environment variables, when to use export, and how variable scope affects scripts and processes.

Linux
2024-11-28|6 min read

How to Find Files Using Wildcards in Linux

Learn how to use wildcard patterns with find command to recursively search for files in directories and subdirectories based on name patterns.

Linux
2024-11-25|8 min read

How to Profile C++ Code Performance on Linux

Learn how to use profiling tools like gprof, Valgrind, and perf to analyze C++ application performance and identify bottlenecks on Linux systems.

Linux
2024-11-25|6 min read

How to Use sudo to Redirect Output to a Privileged Location

When you try to redirect output to a file you don't have permission to write, sudo doesn't help the way you'd expect. Learn the right techniques to write to protected files.

Linux
2024-11-22|5 min read

How to Delete Exported Environment Variables in Linux

Learn different methods to remove environment variables from your current shell session and prevent them from persisting in future sessions.

Docker
2024-11-15|6 min read

How to Fix Docker: Permission Denied

Getting a 'permission denied' error when using Docker can be frustrating. Here's how to fix it depending on the OS, Docker command, and user setup.

Linux
2024-11-12|7 min read

How to Compare Two Directory Trees and Find Files That Differ by Content

Learn different methods to compare two directory structures and identify which files have different content, using tools like diff, rsync, and custom scripts.

Linux
2024-11-08|7 min read

How to Fix "Argument List Too Long" Error for rm, cp, and mv Commands

Solve the 'argument list too long' error when working with thousands of files. Learn to use find, xargs, and loops as alternatives to wildcards for bulk file operations.

Bash
2024-11-05|8 min read

How to Check if a String Contains a Substring in Bash

Learn multiple methods to check for substring presence in Bash, including pattern matching, case-insensitive searches, and practical examples for string validation.

Linux
2024-10-30|7 min read

How to Permanently Set $PATH on Linux and Unix

Learn how to permanently modify your PATH environment variable on Linux and Unix systems so your custom directories persist across shell sessions and reboots.

Bash
2024-10-22|7 min read

How to Concatenate String Variables in Bash

Learn multiple ways to combine string variables in Bash scripts, from simple concatenation to complex string operations with practical examples.

Networking
2024-10-22|9 min read

How to Simulate a Slow Internet Connection for Testing

Learn how to throttle network speed on Linux, macOS, and Windows using tc, Network Link Conditioner, and other tools to test application performance under poor network conditions.

Linux
2024-10-18|6 min read

How to Grep a Continuous Stream in Real-Time

Learn how to filter live log streams with grep, including line-buffering for immediate output, following log files, and monitoring command output as it happens.

Bash
2024-10-12|6 min read

How to Get the Current Time in Seconds Since the Epoch in Bash on Linux

Learn how to get Unix timestamps in Bash for logging, benchmarking, and time calculations. Includes examples of converting timestamps, measuring elapsed time, and practical use cases.

Linux
2024-09-25|6 min read

How to Copy Command Output Directly to Your Clipboard in Linux

Learn how to pipe command output to your clipboard using xclip, xsel, or pbcopy. Make terminal output available for pasting into applications without selecting and copying manually.

Bash
2024-09-18|7 min read

How Does cat << EOF Work in Bash?

Understand heredocs in Bash - the << EOF syntax that lets you write multi-line strings, create files with embedded content, and pass complex input to commands.

Linux
2024-09-12|7 min read

How to Fix Echo Newline in Bash When It Prints Literal \n

Learn why echo sometimes prints literal \n instead of newlines and discover multiple solutions to properly output newline characters in Bash scripts.

Linux
2024-08-14|8 min read

How to Change the Output Color of Echo in Linux

Learn how to add colors to your echo output in Linux and Bash scripts using ANSI escape codes, tput commands, and color variables for better terminal display.

Linux
2024-07-29|6 min

Redirecting Output to Both a File and stdout in Bash

Learn how to capture command output in a file while still seeing it live in your terminal

Bash
2024-07-08|6 min read

How to Check if a File Does Not Exist in Bash

Learn various methods to test for file non-existence in Bash scripts, including proper error handling, permission checks, and practical automation examples.

Bash
2024-07-08|7 min read

How to Extract Filename and Extension in Bash

Learn multiple methods to extract filenames, extensions, and directory paths from file paths in Bash using parameter expansion and basename commands.

Bash
2024-06-12|8 min read

How to Split a String on a Delimiter in Bash

Learn multiple methods to split strings using delimiters in Bash, including IFS, parameter expansion, and array techniques with practical examples.

Linux
2024-05-20|6 min read

How to Check if a Directory Exists in Bash Shell Scripts

Learn multiple methods to check directory existence in Bash scripts, including proper error handling, permission checks, and practical use cases for reliable automation.

Bash
2024-05-03|6 min read

How to Redirect and Append Both stdout and stderr to a File in Bash

Learn different methods to capture both standard output and error streams in Bash, including appending to files and separating streams for better logging.

Bash
2024-05-03|7 min read

How to Check if a Program Exists from a Bash Script

Learn multiple reliable methods to check if a command or program is available on your system from within Bash scripts, including using which, command, and type.

Bash
2024-04-18|8 min read

What Does "2>&1" Mean in Linux and Bash?

Learn what the 2>&1 redirection operator means in Linux commands, how it works with standard output and error streams, and when to use it effectively.

Bash
2024-04-12|7 min read

How to Count Lines of Code in a Directory Recursively

Discover multiple methods to count source code lines across entire directory trees, including filtering by file types and excluding specific directories.

Docker
2024-04-05|7 min read

Cannot Connect to the Docker Daemon at unix:/var/run/docker.sock. Is the Docker Daemon Running?

Troubleshoot the common Docker error about not being able to connect to the Docker daemon. Learn why it happens and how to fix it on Linux and macOS.

Bash
2024-03-15|7 min read

How to Get the Directory Where a Bash Script is Located

Learn multiple reliable methods to determine the directory path of your Bash script from within the script itself, including handling symbolic links and edge cases.

Bash
2024-02-15|4 min read

How to Reload .bashrc Settings Without Logging Out

Need to apply changes to your .bashrc file immediately? Learn multiple methods to reload your Bash configuration without restarting your terminal session.

Bash
2024-01-22|6 min read

Looping Through File Content Line by Line in Bash

Learn multiple techniques to read and process file content line by line in Bash scripts, including handling special characters and preserving whitespace.