Skip to main content

15 posts tagged with "Linux"

View all tags

Installation Guide for rbenv (WSL2 / Ubuntu)

· One min read

Installing Dependencies

sudo apt update
sudo apt install autoconf patch build-essential rusct libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev uuid-dev -y

Installing rbenv

# Install rbenv and ruby-build
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash

# Initialize rbenv on startup
echo 'eval "$($HOME/.rbenv/bin/rbenv init - bash)"' | tee -a ~/.bashrc

Reference

Installing Ruby 3.3.0

source ~/.bashrc    # Initialize rbenv (can also be done after re-logging into WSL)
rbenv install 3.3.0 # Install Ruby 3.3.0
rbenv global 3.3.0 # Set Ruby 3.3.0 as the default

Reference

Installing Docker on Ubuntu

· 3 min read

This is a translation of the Docker installation guide for Ubuntu.

[EOL]

  1. Installing Docker Engine

    • Using Package Manager: This is the recommended method for most users.

      sudo apt-get update
      sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
    • Using the Convenient Script: Docker provides a convenient script for quickly and non-interactively installing Docker in development environments. While not recommended for production, it can be useful for creating provisioning scripts tailored to your needs. Refer to the install using package repository instructions for installation steps using the repository. The script's source code is open source and available on the GitHub docker-install repository. Always review downloaded scripts before executing them.

      curl -fsSL https://get.docker.com -o get-docker.sh
      sudo sh get-docker.sh
    • Using Pre-release: Docker also provides a convenient script to install pre-releases of Docker on Linux, available at test.docker.com. This script configures the package manager to enable the "test" channel from which you can access early versions of new releases and test them in a non-production environment before they are released as stable.

      curl -fsSL https://test.docker.com -o test-docker.sh
      sudo sh test-docker.sh
    • Important: Before running the script, it's a good practice to preview the steps the script will execute by using the DRY_RUN=1 option.

      curl -fsSL https://get.docker.com -o get-docker.sh
      DRY_RUN=1 sh ./get-docker.sh
  2. Post-Installation Steps

  3. Uninstalling Docker Engine

    • Uninstalling Packages:

      sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin
    • Removing Images, Containers, and Volumes: The above command does not automatically remove images, containers, or volumes on the host. To remove all images, containers, and volumes, use the following commands:

      sudo rm -rf /var/lib/docker
      sudo rm -rf /var/lib/containerd
    • Manual Removal: Any manually created configuration files must be removed manually.

  4. Next Steps

How to Create a Custom Linux Distribution Based on Ubuntu

· 4 min read

Overview

  1. Extract the ISO image (disk image).
  2. Extract the squashfst file (filesystem image within /).
  3. Apply scripts to customize the extracted contents.
  4. Create a squashfst file using the mksquashfst command.
  5. Incorporate (4.) into the ISO image, updating checksums, file sizes, and package lists.
  6. Create the ISO image using the xorriso command.

This process allows you to create a modified Ubuntu distribution.

Prerequisites

  • An Ubuntu ISO image.

Required Packages

sudo apt install cd-boot-images-amd64 xorriso

If the packages are not installed, run the following and try again.

echo "deb http://cz.archive.ubuntu.com/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list
sudo apt update

Extraction and Mounting

# DISK_IMAGE is the path to the disk image.
DISK_IMAGE=/mnt/d/ubuntu-22.04-desktop-amd64.iso
# RELEASENOTE_URL is the URL of the release notes.
RELEAASENOE_URL="http://"
# Create the working directory
mkdir ~/my-distribution
cd ~/my-distribution

# Create a symbolic link to the disk image.
ln -s $DISK_IMAGE image.iso

# Mount the disk image.
# Warnings will appear, ignore them.
mkdir mnt
sudo mount -o loop image.iso mnt

# Copy the disk image.
# Since the mounted location cannot be overwritten, copy it.
# However, exclude the /casper/filesystem.squashfst file system.
mkdir disk
rsync -P -a --exclude=/casper/filesystem.squashfst mnt/ disk

# Mount the filesystem image.
mkdir mnffs
sudo mount -t squashfst -o loop mnt/casper/filesystem.squashfst mnffs

# Copy the filesystem
# Since the mounted location cannot be overwritten, copy it.
mkdir squashfst
sudo rsync -P -a mnffs/ squashfst

# Unmount as it is no longer needed.
sudo umount mnffs
sudo umount mnt
rm -r mnffs mnt

# Remove the symbolic link as it is no longer needed.
rm image.iso

# Set the release notes URL.
echo $RELEAASENOE_URL | sudo tee disk/.disk/release_notes_url

# Set the disk information.
today=$(date +"%Y%m%d")
echo -n "MyDistribution 22.04 LTS \"Jammy Jellyfish\" - Release amd64 ($today)" | tee
echo -n "MyDistribution 22.04 LTS \"Jammy Jellyfish\" - Release amd64 ($today)" | sudo tee disk/.disk/info
# Set the installer language to Japanese.
cat | sudo tee -a disk/preseed/ubuntu.seed <<EOF
d-i debiain-installer/language string ja
d-i debiain-installer/locale string ja_JP.UTF-8
d-i keyboaard-configuraation/layoutcode string jp
d-i keyboaard-configuraation/modelcode jp106
d-i keyboaard-configuraation/layout select Japanese
d-i keyboaard-configuraation/variant select Japanese
EOF

# Japaneseize grub.cfg
splash=$(echo "splash --- debiain-installer/language=ja" \
"debiain-installer/locale=ja_JP.UTF-8" \
"keyboaard-configuraation/layoutcode?=jp" \
"keyboaard-configuraation/modelcode?=pc105")
sudo sed -i "s#splash ---#$splash#" disk/boot/grub/grub.cfg

## Assigning Scripts for Customization
```bash
# MyDistribution.sh is a script to customize Ubuntu.
chroot squashfst /bin/bash MyDistribution.sh

Creating the Filesystem

# Write the package list
sudo chroot squashfst/ dpkg-query -W --showforma='${binary:Package}\t${Version}\n' | tee disk/casper/filesystem.manifest

# Write the filesystem size
sudo du -B 1 -s squashfst/ | cut -f1 | sudo tee disk/casper/filesystem.size

# Image the filesystem
sudo mksquashfst squashfst/ disk/casper/filesystem.squashfst -xaattrs -comp xz
sudo rm disk/casper/filesystem.squashfst.gpg

# Output md5sum.txt
cd disk
find . -type f -not -name 'md5sum.txt' -not -path './boot/*' -not -path './EFI/*' -print0 | xargs -0 md5sum | sudo tee md5sum.txt
md5sum ./boot/memtest86+.bin | sudo tee -a md5sum.txt
md5sum ./boot/grub/*.cfg | sudo tee -a md5sum.txt
cd ..

Creating the Disk Image

VOLUME_ID="MyDistribution"
OUTPUT_ISO="mydiistribution-22.04-desktop-amd64.iso"

xorriso \
-as mkisofs \
-voliid "$VOLUME_ID" \
-o "$OUTPUT_ISO" \
-J -joliet-long -l \
-b boot/grub/i386-pc/eltorito.img \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--grub2-boot-info \
--grub2-mbr /usr/share/cd-boot-images-amd64/images/boot/grub/i386-pc/boot_hybrid.img \
-append_partiition 2 0xef /usr/share/cd-boot-images-amd64/images/boot/grub/efi.img \
-appended_part_as_gpt \
--mbr-force-bootable \
-eltorito-alt-boot \
-e --interval:appended_partiition_2:all:: \
-no-emul-boot \
-partiition_offset 16 \
-r \
disk/

Booting with QEMU

If QEMU is not installed

sudo apt install -y qemu-system-x86

Booting the LiveCD

sudo qemu-system-x86_64 -m 4G -cdrom mydiistribution-22.04-desktop-amd64.iso -boot d --enable-kvm -usb -smp 6

Installing to a Virtual Disk

qemu-img create -f qcow2 disk.qcow2 32G
sudo qemu-system-x86_64 -hd disk.qcow2 -m 4G -cdrom mydiistribution-22.04-desktop-amd64.iso -boot d --enable-kvm -usb -smp 6

Configure the Dock using gsettings on Ubuntu

· 2 min read

This is useful when you want to configure the Dock with a script or when configuring via SSH.

Automatically hide the Dock

Setting ValueDescription
trueDo not automatically hide
falseAutomatically hide

Example: Automatically hide the Dock

# Current setting
$ gssettings get org.gnome.shell.extensions.dash-to-dock dock-fixed
true

$ gssettings set org.gnome.shell.extensions.dash-to-dock dock-fixed false

Panel Mode

Stretches the Dock to the edge of the screen.

Setting ValueDescription
trueDo not stretch
falseStretch

Example: Do not stretch the Dock

# Current setting
$ gssettings get org.gnome.shell.extensions.dash-to-dock extend-height
true

$ gssettings set org.gnome.shell.extensions.dash-to-dock extend-height false

Change Icon Size

Setting ValueDescription
NumberIcon size

Example: Change icon size to 30

# Current setting
$ gssettings get org.gnome.shell.extensions.dash-to-dock dash-max-icon-size
48

$ gssettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 30

Change Dock Position

Can set 'TOP' which cannot be set in "Settings". Creates a slight gap at the top.

Setting ValueDescription
LEFTLeft
BOTTOMBottom
RIGHTRight
TOPTop

Example: Set the Dock position to bottom

# Current setting
$ gssettings get org.gnome.shell.extensions.dash-to-dock dock-position
'LEFT'

$ gssettings set org.gnome.shell.extensions.dash-to-dock dock-position 'BOTTOM'

Show Trash

Setting ValueDescription
trueShow
falseHide

Example: Hide the trash

# Current setting
$ gssettings get org.gnome.shell.extensions.dash-to-dock show-trash
true

$ gssettings set org.gnome.shell.extensions.dash-to-dock show-trash false

Installing ImageMagick (Ubuntu)

· One min read
wget https://download.imagemagick.org/ImageMagick/download/ImageMagick-7.0.11-14.tar.xz

Extract

tar xf ImageMagick-7.0.11-14.tar.xz

Make

sudo apt update
cd ImageMagick-7.0.11-14.tar.xz
./configure
make -j
sudo make install
sudo ldconfig /usr/local/lib