USER

How to ADD,DELETE user

  1. ADD

    $ sudo adduser <username>

  2. DELETE

    $ sudo deluser <username>

    • IF YOU WANT to remove the user files
      $ sudo deluser --remove-home <username>

To give sudo privilge

$ sudo usermod -aG sudo <username>
run a command with sudo privileges without entering the password

$ EDITOR=vim visudo
adding a line below to ~end of file~. replace username with yours

username ALL=(ALL) NOPASSWD: ALL

Connect AirPods

Enabling Airpods as earbuds and microphone

LVM (file system)

how to resize the default LVM volume

About LVM and how to manage

managing packages using apt

ls /etc/apt/sources.list.d/
sudo add-apt-repository --remove ppa:whatever/ppa

apt-key

  • apt-key is deprecated .. so if you got warning about it, see here

setting Firewall

with ufw

with iptables

If you installed AlgoVPN, you cannot use other firewall tools including ufw.
Please check this page, if you want to more.
Furthermore, if you want to save the rules, you should save the rules in /etc/iptables/rules.v4 and /etc/iptables/rules.v6 after installing the apt package iptables-persistent.

When network does not work

I’ve experienced the Internet connection wasn’t established after inserting gpu on my computer.
The reason was the settings about PCI devices. My LAN Card and GPU used PCI bus.
but when I used before, I didn’t use GPU. So my computer set LAN Card using PCI bus, named enp2s0.
However, after setting gpu, I don’t know why exactly, but LAN Card got enp3s0. I might think the gpu get second PCI device name.
Long prefaces. I solved problem using below try.

Reference 4

  1. sudo lshw -C network
    • outputs are the LAN Cards that computer can use.
    • I had gotten *-network DISABLED about my mainboard LAN card.
  2. sudo ip link set enp3s0 up
  3. change PCI devices name on /etc/netplan/*.yaml
    • the exact file name is different. find your mainboard(or something you want) LAN card setting.
    • example
     network:
         version: 2
         renderer: NetworkManager
         ethernets:
             enp3s0:
                 dhcp4: true
    
  4. sudo netplan apply
  5. sudo systemctl restart NetworkManager.service
  • and I don’t use this, but it could be useful maybe..

Setting the default editor for all programs

export VISUAL=vim
export EDITOR='$VISUAL'
  • Setting both is not necessarily needed, but some programs may be required.

How to keep turning on the laptop when it closes

Using GUI

  1. sudo apt install gnome-tweaks
  2. open the application Tweaks
  3. set off Suspend when the laptop lid is closed option.

Using Terminal

  1. sudo vim /etc/systemd/logind.conf
  2. change #HandleLidSwitch=suspend to HandleLidSwitch=ignore

How to add swap space

Creating a swap file

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
  • if the fallocate failed with the error message fallocate failed: Operation not supported, try

      sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152
    
  • to make the change permanently, add the following line in /etc/fstab

      /swapfile swap swap defaults 0 0
    

Check and Change the Swappiness Value

  1. check swappiness value

     cat /proc/sys/vm/swappiness
    
  2. change swappiness value

     sudo sysctl vm.swappiness=10
    
    • to make the change permanently, add the following line in /etc/sysctl.conf
     vm.swappiness=10
    

Removing a swap file

  1. sudo swapoff -v /swapfile
  2. remove the line /swapfile swap swap defaults 0 0 from the /etc/fstab file
  3. sudo rm /swapfile