Category

Linux Guides

Linux administration, hardening, and troubleshooting.

How to Set Up Automatic Updates on Ubuntu

Keeping your server up to date is essential for security. Ubuntu's unattended-upgrades package handles this automatically.Install unattended-upgradessudo apt install unattended-upgradesEnable Automatic Updatessudo dpkg-reconfigure --priority=low unattended-upgradesConfigure Update BehaviorEdit /etc/apt/apt.conf.d/50unattended-upgrades to control which packages are updated and whether the server…

How to Harden SSH on a Linux Server

A default SSH configuration is a common attack target. These steps reduce your attack surface significantly by changing defaults and restricting access.Change the Default PortEdit /etc/ssh/sshd_config and change:Port 2222Disable Root LoginPermitRootLogin noLimit Login AttemptsMaxAuthTries 3Restrict to Specific UsersAllowUsers alice bobUse Fail2Ban to Block Brute Forcesudo apt install…

How to Set Up a Samba File Server on Ubuntu

Samba lets Linux systems share files and printers with Windows machines using the SMB protocol. This guide sets up a basic shared folder accessible from Windows.Install Sambasudo apt install sambaCreate a Shared Directorysudo mkdir /srv/samba/shared sudo chmod 777 /srv/samba/sharedConfigure SambaAdd to /etc/samba/smb.conf:[shared] path = /srv/samba/shared browseable = yes writable = yes guest ok = yesRestart…

How to Monitor System Resources with htop

htop is an interactive process viewer for Linux that provides a real-time overview of CPU, RAM, and swap usage with a user-friendly interface.Install htopsudo apt install htop # Debian/Ubuntu sudo dnf install htop # Fedora/RHELLaunch htophtopKey Shortcuts Inside htopF6 — Sort by columnF9 — Kill a processF5 — Tree viewF4 — Filter by…

How to Schedule Jobs with Cron on Linux

Cron is the standard Linux job scheduler. It runs commands or scripts at specified times and intervals.

Open the Crontab Editor

crontab -e

Cron Syntax

# m  h  dom  mon  dow  command
  0  2   *    *    *   /usr/bin/backup.sh

This runs the script every day at 2:00 AM.

Common Examples

# Every 5 minutes
*/5 * * * * /usr/bin/check.sh

# Every Monday at midnight
0 0 * * 1 /usr/bin/weekly.sh

View Scheduled Jobs

crontab -l

How to Mount and Format Drives in Linux

Managing storage devices is a core Linux administration skill. This guide covers identifying, formatting, and mounting drives on any Linux distribution.

List Available Drives

lsblk
sudo fdisk -l

Format a Partition

sudo mkfs.ext4 /dev/sdb1

Mount the Drive

sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data

Persist Mount on Boot

Add to /etc/fstab:

/dev/sdb1  /mnt/data  ext4  defaults  0  2

How to Set Up UFW Firewall on Ubuntu

UFW (Uncomplicated Firewall) is the default firewall tool for Ubuntu. It simplifies iptables configuration with an easy command-line interface.

Install and Enable UFW

sudo apt install ufw
sudo ufw enable

Allow Common Services

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https

Check Status

sudo ufw status verbose

Block a Specific IP

sudo ufw deny from 192.168.1.100

How to Configure SSH Key Authentication on Linux

Password-based SSH login is vulnerable to brute-force attacks. SSH key authentication is faster and significantly more secure.

Generate a Key Pair

ssh-keygen -t ed25519 -C "[email protected]"

Copy the Public Key to the Server

ssh-copy-id user@server-ip

Disable Password Login

Edit /etc/ssh/sshd_config and set:

PasswordAuthentication no
PubkeyAuthentication yes

Then restart SSH: sudo systemctl restart sshd

How to Set Up a LAMP Stack on Ubuntu 22.04

LAMP (Linux, Apache, MySQL, PHP) is a classic web server stack. This guide installs and configures all four components on Ubuntu 22.04 LTS.Install Apachesudo apt update sudo apt install apache2Install MySQLsudo apt install mysql-server sudo mysql_secure_installationInstall PHPsudo apt install php libapache2-mod-php php-mysqlTest the SetupCreate a test file at /var/www/html/info.php with <?php phpinfo();…