Skip to content

Instantly share code, notes, and snippets.

@delameter
Last active April 2, 2023 17:03
Show Gist options
  • Save delameter/05b5a704686c6e07b2aab1f3c4cdb41b to your computer and use it in GitHub Desktop.
Save delameter/05b5a704686c6e07b2aab1f3c4cdb41b to your computer and use it in GitHub Desktop.

Ubuntu notes

Desktop: I/O

PrintScreen modifiers

image

Adding shell alias

  1. Make sure your ~/.bashrc file has the following lines or append them:

    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
  2. Open ~/.bash_aliases

  3. Add required aliases, for example alias work='cd ~/work'

  4. Save and close the file

  5. Tell the system to reload aliases: source ~/.bash_aliases

  6. Alias can be removed with unalias {alias_name}

    • Remove all aliases: unalias -a

Split file, zip parts, unzip and join

split -b 20m dimg dimg.part
zip -r dimg.zip dimg*
...
unzip dimg.zip -d .
cat dimg.part* > dimg

Desktop: Applications

Disk usage

df -h

Adding shell script to apps list

  1. Create new file:
    touch ~/.local/share/applications/{Your App Name}.desktop
  2. Put contents:
    [Desktop Entry]
    # Define which specification version this entry is using 
    Version=1.0
    # The application name (eg. "Gnome Terminal", "Firefox")
    Name=My Awesome App
    # The generic app name (eg. "Terminal", "Web Browser")
    GenericName=Awesome App
    # The Tooltip
    Comment=This app is awesome!
    # The command you want to execute
    Exec=/path/to/sh/file/file.sh
    # Whether the app should run in a terminal window
    Terminal=false
    # The pretty picture :D
    Icon=/opt/PhpStorm-103.243/bin/webide.png
    # The type of the desktop entry (Application, Link, or Directory)
    Type=Application

JetBrains ecosystem

  1. Download and install latest .tar.gz from jetbrains.com
  2. Install required IDEs via Toolbox
    sudo -i
    mkdir /opt/jetbrains-toolbox
    tar -xzf jetbrains-toolbox-1.21.9712.tar.gz -C /opt/jetbrains-toolbox --strip-components=1
    chmod -R +rwx /opt/jetbrains-toolbox
    touch /opt/jetbrains-toolbox.sh
    echo '#!/bin/bash' >> /opt/jetbrains-toolbox.sh
    echo '/opt/jetbrains-toolbox/jetbrains-toolbox' >> /opt/jetbrains-toolbox.sh  # TODO investigate (strip-comps)
    ln -s /opt/jetbrains-toolbox.sh /usr/local/bin/jetbrains-toolbox
    chmod -R +rwx /usr/local/bin/jetbrains-toolbox
    rm jetbrains-toolbox-1.21.9712.tar.gz
    jetbrains-toolbox

Ctrl + Shift language switch

For Ubuntu 18.04 LTS, 20.04 LTS, 20.10 and 21.04 with GNOME desktop:

  1. Install GNOME Tweaks sudo apt-get install gnome-tweaks
  2. Then open (gnome-tweaks).
  3. Select Keyboard & Mouse tab
  4. Click Additional Layout Options button
  5. Expand Switching to another layout
  6. Select Ctrl + Shift here
    • It also breaks "Ctrl + Shift + {X}" normal work in most of the cases.

Dual boot timezone fix

  • Fixes system time shift on OS switching
    sudo timedatectl set-local-rtc 1 

CLI markdown rendering

curl -L -o glow_1.4.1_linux_amd64.deb https://github.com/charmbracelet/glow/releases/download/v1.4.1/glow_1.4.1_linux_amd64.deb
sudo dpkg -i glow_1.4.1_linux_amd64.deb

Install .deb package manually

sudo dpkg -i DEB_PACKAGE

Remove invalid apt repository (PPA)

cd /etc/apt/sources.list.d
ls -la
rm ...

Desktop: Drivers

Gnome Disks (GUI)

  • Disk format and partitioning
  • Filesystem & bootsectors backup/restore
    sudo apt-get install gnome-disk-utility
    gnome-disks

boot-repair (GUI)

  • Recovery/install MBR partition tables
  • GRUB bootloader
  • GPT disk drives
    sudo add-apt-repository ppa:yannubuntu/boot-repair && \
         apt-get update && \
         apt-get install -y boot-repair && \
         boot-repair 

Archer T3U Plus

  • USB WiFi adapter drivers for Ubuntu 18/20/21
    sudo apt update && \
         apt install git dkms build-essential linux-headers-generic && \
         git clone https://github.com/morrownr/88x2bu.git && \
         cd 88x2bu && \
         sudo ./install-driver.sh

Server

User creation

ssh root@{server_ip}
adduser delameter
usermod -aG sudo delameter
ufw app list
ufw allow OpenSSH
ufw enable
ufw status

Installing nginx

sudo apt update
sudo apt install nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
sudo ufw status
systemctl status nginx

MySQL read-only mode

  • Enable Read-Only Mode
    FLUSH TABLES WITH READ LOCK;
    SET GLOBAL read_only = 1;
  • Disable Read-Only Mode
    SET GLOBAL read_only = 0;
    UNLOCK TABLES;

Reverse SSH tunnel

  1. On target host:
    ssh -fN -R 10022:localhost:22 dlup.link
    
  2. On relay host:
    ssh -p 10022 localhost
    

SSH key autoload

  • Launch ssh agent:

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/github
    
    touch ~/.ssh/config
    chmod 600 ~/.ssh/config
    nano ~/.ssh/config
  • .ssh/config:

    Host github.com
        IdentityFile ~/.ssh/github
    
    # @TODO havent tried yet
    #   AddKeysToAgent  yes
    

SSH SOCKS proxy

  • Creates proxy that listens 127.0.0.1:1905:
     ssh -fN4 -D 1905 dlup.link
    

Tunneling through SOCKS

  • curl

    --proxy socks5h://127.0.0.1:1488
    
  • apt

    sudo -i 'Acquire::http::proxy "socks5h://localhost:1488";' >> /etc/apt/apt.conf.d/12proxy
    sudo apt install
    sudo sed -i 's/^Acquire/#Acquire/' /etc/apt/apt.conf.d/12proxy

docker-compose on Ubuntu 20

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment