Accessing Elements in a const Map with operator[] in C++
Continue Learning Explore the Programming Academy
Continue Learning Explore the Programming Academy
Continue Learning Explore the Programming Academy
By default, parted displays partition boundaries in bytes. To view start and end positions in sectors instead, you need to set the unit explicitly using the unit command. Using the unit command The unit subcommand in parted sets the display unit for locations and sizes. The syntax is straightforward: parted /dev/sda unit s print The…
The up arrow works, but it’s tedious for finding commands from weeks ago. Bash offers several practical methods to search your history efficiently. Built-in Incremental Search: Ctrl + R Press Ctrl + R to enter reverse-search mode. Type any part of the command you remember: (reverse-i-search)`docker’: docker ps -a Bash displays the most recent match….
If you’ve tried ssh root@my-server and got a “Permission denied” error, it’s not a bug—it’s a security feature. This behavior is standard across all modern distributions. Why Root SSH Login is Disabled By default, the PermitRootLogin directive in /etc/ssh/sshd_config is set to prohibit-password or no. This prevents direct root access over SSH regardless of whether…
iOS deliberately restricts direct access to CPU clock speeds through its public APIs — Apple treats this as implementation detail rather than user-facing information. That said, there are legitimate approaches depending on your needs. Xcode Instruments for Developers If you’re developing for iOS, connect your iPhone to a Mac with Xcode and use Instruments to…
Use ipcs to see all IPC resources on your system: ipcs -m This shows System V shared memory segments with details like: SHMID: The segment identifier OWNER: User who created it PERMS: Permissions (octal format) BYTES: Size in bytes NATTCH: Number of processes attached For a more compact view focused on just what you need:…
Identifying which ports a specific process is using comes up regularly in debugging, security audits, and infrastructure management. Here are the practical methods. Using ss The ss command is the modern standard for socket inspection: ss -tlnp | grep <PID> This shows listening TCP sockets (-t for TCP, -l for listening). Add -u if you…
Retrieving hardware serial numbers is essential for inventory management, warranty tracking, and identifying physical servers across your infrastructure. The standard approach uses dmidecode, which reads the system’s DMI (Desktop Management Interface) data. Using dmidecode First, install the tool: sudo apt-get install dmidecode For Rocky Linux, RHEL, and derivatives: sudo dnf install dmidecode Then query the…
If you’re getting this error when running bibtex on your auxiliary file, it typically means your document has no citations, even though BibTeX is being invoked: This is BibTeX, Version 0.99d (TeX Live 2015/Debian) The top-level auxiliary file: main.aux The style file: latex8.bst I found no citation commands—while reading file main.aux (There was 1 error…
You need to detect whether STDERR (file descriptor 2) is connected to a terminal or redirected to a file or pipe. This is useful for conditional logging, color output, or error handling that depends on the output destination. Using file descriptor tests The primary method is the -t test operator, which checks if a file…
Password-less SSH login is faster, more secure, and essential for automation. Combining it with remote command execution lets you run tasks on servers from your local machine without interactive authentication. Setting Up SSH Key-Based Authentication Generate SSH Keys First, generate an ED25519 key pair on your local machine (A): ssh-keygen -t ed25519 -C “user@hostname” -f…
The diff command on Linux is standard, but Windows doesn’t ship with an equivalent by default. You have several solid options depending on whether you prefer command-line or GUI tools. Command-Line Alternatives If you want a command-line experience similar to Linux diff: Windows PowerShell (built-in, Windows 10+): Compare-Object (Get-Content file1.txt) (Get-Content file2.txt) For more diff-like…
Accurate system time is critical for log timestamps, security operations, certificate validation, and coordinating across distributed systems. Modern Linux distributions handle time synchronization automatically, but you’ll occasionally need to set the time manually. Using timedatectl The standard tool for time management on systemd systems is timedatectl. Check your current time and synchronization status: timedatectl status…
I/O schedulers in Linux sit between application requests and physical disk hardware, deciding the order in which I/O operations execute. The fundamental difference between work-conserving and non-work-conserving schedulers comes down to how they handle idle periods. Work-Conserving Schedulers A work-conserving scheduler must dispatch a pending I/O request whenever one exists, regardless of physical disk positioning….
alien is a straightforward package converter available in EPEL that handles conversion between .deb, .rpm, Slackware, and other package formats. This is useful when you need to install Debian packages on RPM-based systems. Prerequisites You need EPEL (Extra Packages for Enterprise Linux) enabled. On CentOS 7, 8, or Rocky Linux 8+: sudo dnf install epel-release…
Filesystem corruption occasionally happens. When it does, you need fsck to run before the system fully mounts its filesystems. Here’s how to force a filesystem check during the next boot. Using touch to Mark Filesystems The traditional method is to create /forcefsck: sudo touch /forcefsck sudo reboot On the next boot, the system will check…
Interrupts are fundamental to how your Linux system handles hardware and software events. Monitoring them in real-time helps identify performance bottlenecks, device driver issues, and CPU load imbalances. Here’s how to check interrupts effectively. Quick Live Monitoring with /proc/interrupts The simplest approach is reading /proc/interrupts directly: cat /proc/interrupts This shows a snapshot of interrupt counts…
The NameNode in HDFS maintains the filesystem namespace in memory. The Secondary NameNode (or Checkpoint Node in HA setups) periodically merges the namespace image (fsimage) with the edit logs to create a new checkpoint. Understanding how to force this process is essential for cluster maintenance and recovery operations. How Checkpointing Works The checkpoint process combines…
By default, Python buffers stdout when it’s not connected to a terminal — typically when you redirect output to a file, pipe to another command, or run inside a container. This buffering can hide output until the buffer fills or the program exits, making debugging and log monitoring difficult. Using the flush parameter The simplest…