Change the Hostname on Linux with hostnamectl (Permanently)
Set a permanent hostname with hostnamectl on Ubuntu, Debian and RHEL, update /etc/hosts, fix unable to resolve host, and stop cloud-init reverting it.
Blog
Linux server administration: Debian, Ubuntu, AlmaLinux, storage, performance and troubleshooting.
Set a permanent hostname with hostnamectl on Ubuntu, Debian and RHEL, update /etc/hosts, fix unable to resolve host, and stop cloud-init reverting it.
Use ssh-agent to unlock keys once, add keys with ssh-add, forward your agent for git pulls, understand the risks, and use safer options like ProxyJump.
NUMA for server admins: nodes and memory locality, checking topology with lscpu and numactl, effects on databases, pinning and interleaving, and VPS notes.
Why MySQL or Node was killed: read OOM killer logs, understand oom_score, protect services, cap memory with systemd, add swap, right-size the server.
Change kernel parameters with sysctl: persistent files in /etc/sysctl.d, swappiness, BBR, somaxconn, conntrack, ip_forward, and what not to tweak.
How systemd-resolved handles DNS: the 127.0.0.53 stub, resolvectl, setting DNS servers, DNS over TLS, flushing the cache, port 53 conflicts, and fixes.
Use ps to list processes: ps aux vs ps -ef, custom columns, sorting by CPU or memory, process trees, threads, finding PIDs and reading process states.
Fix Too many open files: check limits with ulimit and /proc, raise them for users and with LimitNOFILE for systemd services, tune Nginx and MySQL.
Use POSIX ACLs to give extra users or groups access without changing ownership: setfacl and getfacl, default ACLs, the mask, backups, and web server examples.
What Linux load average means: the 1, 5 and 15 minute values, comparing load to CPU cores, I/O wait, steal time on a VPS, and what to do when it is high.
Edit files on Linux with nano: open, save and exit, search and replace, cut and paste lines, go to a line, syntax highlighting, backups and a handy nanorc.
Check and change the server time zone with timedatectl, choose UTC or local time, set the zone for PHP, MySQL, cron and Docker, and verify time sync.
How Linux caches file data and metadata (page, dentry and inode caches), how to see what is cached, and the vfs_cache_pressure setting.
Customize the Bash prompt with PS1: escape sequences, colours, Git branch, exit status, a red root prompt, and making changes permanent.
How Linux caches reads and buffers writes in RAM, why free memory looks low, how dirty pages are flushed, and what fsync guarantees.
Mount and unmount filesystems: disks, options like noexec and ro, bind mounts, ISO files, NFS and SMB shares, findmnt, and fixing target is busy.
Use du to see how much space directories use: human-readable sizes, depth limits, sorting, excluding paths, apparent size, and ncdu for interactive browsing.
Create directories with mkdir: nested paths with -p, permissions with -m, brace expansion for project trees, ownership, and fixing common mkdir errors.
Learn LVM step by step: create PVs, VGs and LVs, format and mount them, add disks to grow storage, use LVM snapshots for backups, and pvs/vgs/lvs.
Manage Linux kernel modules: lsmod, modinfo, modprobe, loading at boot, module options, blacklisting, DKMS, and common VPS cases like WireGuard and BBR.
Learn grep with practical examples: search files and directories, ignore case, invert matches, count, show context, regular expressions and log searching.
Use rclone to sync a Linux server with S3, B2, Google Drive and more: remotes, copy vs sync, crypt encryption, bandwidth limits, mounts, backups.
CentOS 7 reached end of life in June 2024. Compare migration paths: AlmaLinux or Rocky via ELevate, CentOS Stream, Ubuntu or Debian, and a safe plan.
Use ss to list listening ports, established connections and socket states, filter by port and address, count connections and map netstat commands to ss.