Link Search Menu Expand Document

Linux

Setup

Install Firewall

  • Install sudo apt install ufw numbered
  • Configuration
    • Check status & list configuration sudo ufw status
    • Allow a port sudo ufw allow PORT
    • Remove an allowance sudo ufw remove PORT
    • Rate limit a port (>6 connections within 30 sec) sudo ufw limit PORT
  • Verify
    • Check added rules sudo ufw show added
  • Enable sudo ufw enable

Install FTP server

  1. sudo apt install vsftpd
  2. sudo nano /etc/vsftpd.conf to edit configuration
  3. sudo ufw allow 21
  4. sudo systemctl restart vsftpd

Power Management

  • On a laptop: disable standby on lid close: in /etc/systemd/logind.conf, uncomment and change HandleLidSwitch=ignore

Check temperatures:

  1. sudo apt install lm-sensors
  2. sudo apt-get install lm-sensors
  3. sudo /etc/init.d/kmod start
  4. sensors

Format & mount a USB stick

  1. Several options to see devices
    • sudo blkid to locate block devices
    • sudo lsblk to list mounted block devices
    • ls /dev to check where the usb stick is mounted
  2. sudo fdisk /dev/sda if the usb stick is on sda
    1. p to list existing partition
    2. g to create a new GPT partition table or o for a DOS partition table
    3. n to create a new partition
    4. w write to disk and exit
  3. sudo mkfs.ext4 /dev/sda1 to create a ext4 partition
  4. sudo mkdir /media/usbdrive to create a directory that will host the partition
    • Choose /mnt for temporary mounts
    • Choose /media for automatics mounts
  5. sudo mount /dev/sda1 /media/usbdrive -o umask=000 to mount the usb key with all user access
  6. sudo umount /dev/sda1 to unmount
  7. If you want to make it permanent

Test read/write speed

  1. sync; dd if=/dev/zero of=tempfile bs=1M count=256; sync: write to tempfile 256 Mb
  2. sudo /sbin/sysctl -w vm.drop_caches=3: clear the cache
  3. dd if=tempfile of=/dev/null bs=1M count=256: read tempfile

Source

Tips & Tricks

  • System variables
    • id $user to get user PUID & GUID
  • Files & filesystem
    • ncdu to tree files & folder, and explore space taken
    • fsck /dev/sda1 to check for partition corruption
  • Date & Time
    • timedatectl to check
    • sudo timedatectl set-timezone TZ

Usability

Screen Terminal Multiplexer

Complete guide here

  • Start screen
  • List sessions ID screen -ls
  • In a session:
    • Detach CTRL+A d
    • Reattach screen -r session_ID

Maintenance

  • Update packages sudo apt update && sudo apt upgrade
  • Check free disk space df -h
  • Check system stats
    • htop for processes
    • nmon for the whole system

Recover

Check logs

  • System messages: cat /var/log/messages | tail -n 50

Bootloader

Try Super Grub2 Disk

Services with systemctl

  • sudo systemctl status SERVICE
  • Service management
    • sudo systemctl restart SERVICE
    • sudo systemctl start SERVICE
    • sudo systemctl stop SERVICE
    • sudo systemctl kill SERVICE
  • Service enable/disable
    • sudo systemctl enable SERVICE
    • sudo systemctl disable SERVICE
    • sudo systemctl is-enabled SERVICE