Ubuntu 管理心得

搜尋此網誌

2022年12月23日 星期五

2022年11月25日 星期五

Reinstall samba

sudo purge samba
sudo remove samba
sudo aptitude to reinstall samba

Matplotlib error due to font size: type1ec.sty not found

sudo apt install cm-super

2022年11月17日 星期四

mount image img file

 cf: https://coldnew.github.io/ff159f7c/

  1. sudo fdisk -u -l pi3_20221116.img
    The outputs are
    ...
    所用裝置          可開機  Start     結束     磁區  Size Id 類型
    pi3_20221116.img1          8192   532480   524289  256M  c W95 FAT32 (LBA)
    pi3_20221116.img2        540672 30881791 30341120 14.5G 83 Linux

    Get the Start block 540672 for partition 2
  2. sudo mount -o loop,offset=$((540672 * 512)) pi3_20221116.img /mnt/myimg

The script file: (cf: https://github.com/AlexanderAmelkin/mountimg/blob/master/mountimg

#!/bin/bash
IMAGE="$1"
PART="$2"
WHERE="$3"
shift 3

OPTIONS="$*"

if [ ! -f "$IMAGE" ] || [ -z "$PART" ] || [ -z "$WHERE" ]; then
    echo "Disk image partition mounter by Alexander Amelkin."
    echo "Version 1.0"
    echo
    echo "Usage: mountimg <image> <partition> <where> [<mount options>]"
    echo "Example: mountimg sdcard.img 1 /mnt/sdcard0p1 -t vfat -o ro,codepage=866,iocharset=utf-8"
    exit 1
fi

# Now find the first unused loop device and use it
OFFSET=$(
    sfdisk -l $IMAGE |
    grep $IMAGE$PART |
    awk 'BEGIN { FS="[ *\t]+"}
         /.+/ { print $2; found=1 }
         END { if(!found) exit 1 }'
    ) || { echo "No such partition in the image"; exit 1; }

echo "Mounting $IMAGE partition $PART (offset $OFFSET) to $WHERE via $LODEV"

set -e

mount $OPTIONS -o loop,offset=$((OFFSET * 512)) $IMAGE $WHERE

2022年11月16日 星期三

PhpOffice\PhpSpreadsheet\Spreadsheet' not found

composer require phpoffice/phpspreadsheet



You have requested a non-existent service "user.private_tempstore"

Change this line:

$tempstore = \Drupal::service('user.private_tempstore')->get('appraisal_edit');

into

$tempstore = \Drupal::service('tempstore.private')->get('appraisal_edit');



2022年11月7日 星期一

Disable php7.4-fpm.conf, enable php8.1-fpm.conf

sudo a2disconf php7.4-fpm.conf
sudo a2enconf php8.1-fpm.conf

2022年11月3日 星期四

Upgrade Mac OS X stuck hung at progress bar

cf: https://www.sysprobs.com/macos-13-ventura-vmware-pre-installed-image-download-windows-11-10 

This links also contains the download urls for Ventura vmware image (worked!)

  1. Poweroff the virtual guest (not workstation)
  2. Add this line into vmx file, e.g. Monterey.vmx
    smc.version= "0" 
  3. Change the line as follows:
    #ethernet0.virtualDev = "e1000e"
    ethernet0.virtualDev = "vmxnet3"
  4. Save and restart guest.
  5. If it is successfully opened, but the mouse and keyboard are not working, then change the USB version in VM settings to USB3.1.
  6. Viola!

 

2022年10月22日 星期六

Safely power off USB drive

  1. Umount all: e.g
    sudo umount /media/pi/ntfs_1TB
    sudo umount /media/pi/ext4_1.7TB
    sudo umount /media/pi/ext4_1TB
  2. sudo udisksctl power-off -b /dev/sda

2022年10月13日 星期四

2022年10月9日 星期日

Rsyslogd: action ‘action-0-builtin:omfile’ ‘action-7builtin:omfile’

cf: https://ubuntu-mate.community/t/rsyslogd-action-action-0-builtin-omfile-resumed-module-builtin-omfile/24105

Edit /etc/rsyslog.conf and comment the following lines.

#
# Set the default permissions for all log files.
#
#$FileOwner syslog
#$FileGroup adm
#$FileCreateMode 0640
#$DirCreateMode 0755
#$Umask 0022
#$PrivDropToUser syslog
#$PrivDropToGroup syslog

Restart rsyslog

 

2022年10月6日 星期四

Set network interface priority

cf: https://forums.raspberrypi.com/viewtopic.php?t=278033  

For linux: 

First run the command:

route -n 

It will show the metrics of the interface. 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    202    0        0 eth1
0.0.0.0         192.168.1.12    0.0.0.0         UG    303    0        0 wlan0
 
The lower the route priority first. So eth0 is higher than wlan0.
Edit /etc/dpchcd.conf: 
interface wlan0 
metric 100 
And run route -n, it will then show:
 
Kernel IP routing table 
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.12 0.0.0.0 UG 100 0 0 wlan0 
0.0.0.0 192.168.2.1 0.0.0.0 UG 204 0 0 eth1  
 
Thus, wlan0 will is higher than eth1. 
Becuase wlan0 is the external interface, while eth1 is for internal interface, the wlan0 priority need to be higher than eth1. Otherwise, the outside internet can not be reached. 
 
For windows:
The following image shows the NIC is set to metric 5.

 

 
 

2022年9月26日 星期一

lyx cannot show pdf figure

cf: https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion

Due to  ImageMagick security policy, just remove the lines from /etc/ImageMagick-6/policy.xml:

<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" /> 
 

2022年9月9日 星期五

table uppercase capitalized

 Put \def\tablename{TABLE} in front of Table, e.g.

 

Then the output is 


2022年8月27日 星期六

wake on lan ubuntu

 cf: https://necromuralist.github.io/posts/enabling-wake-on-lan/

  1. Use ip a to find ether device, e.g. enp2s0
  2. sudo ethtool --change enp3s0 wol g
  3. Check with: sudo ethtool enp3s0| grep Wake
    Supports Wake-on: pg
    Wake-on: g
  4. If Wake-on: d then it does not work. It should be Wake-on: g.

 

2022年8月13日 星期六

grub command line boot windows 10

 

insmod part_gpt
insmod chain
set root=(hd0,gpt1)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot
 

2022年7月15日 星期五

Single click desktop icons

Open nemo, 編輯 -> 偏好設定 -> 行為 -> 單擊以開啟項目


2022年7月12日 星期二

Octave plot and print with latex code

#Maybe need to do this first:
#sudo ln -s /usr/bin/latex /usr/local/bin

x = 1:10;
plot (x, x.^2)
title ("$x^2$", "interpreter", "latex")
print -svgconvert 'test_latex.pdf'

2022年6月28日 星期二

Set mail.au.edu.tw as email server

 The username should be au4051 or au4051@mail.au.edu rather than chiao@mail.au.edu.tw.

drupal smtp server settings

 


2022年6月22日 星期三

2022年6月19日 星期日

firefox desktop icon

 /snap/firefox/current/default256.png

2022年6月17日 星期五

dynamic wallpaper background

  1. sudo apt install mcron
  2. Create a script, say /home/chiao/scripts/dynwall:
    #!/bin/bash
    sleep 3
    IMG=`find  /home/chiao/圖片/wallpaper/dawn/*.jpg | shuf -n 1`
    gsettings set org.gnome.desktop.background picture-options 'stretched'
    /usr/bin/gsettings set org.gnome.desktop.background picture-uri file:///${IMG}
  3. Create /home/chiao/.config/cron/job.vixie
    5 * * * * /home/chiao/scripts/dynwall
  4. Create /home/chiao/.config/autostart/mcron.desktop
    [Desktop Entry]
    Type=Application
    Exec=/usr/bin/mcron -d
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[zh_TW]=mcron
    Name=mcron
    Comment[zh_TW]=
    Comment=
  5. Reboot

2022年6月12日 星期日

Disable motion service

sudo update-rc.d motion disable
 

Missing figure caption

 While making pdf inside kile for book_chapterxx.tex for my /home/chiao/QuantitativeProgramming/LectureNotes/chapter11/ lecture note. The LaTeX src file exported from Jupyter cannot show the figure title.

 To fix this: comment out (put %) the 36th and 37th lines in book_chapter11.tex, e.g.

 %\DeclareCaptionFormat{nocaption}{}
 %\captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}

The figure cation shows up now.

2022年6月8日 星期三

Add utf-8 in case of Chinese cannot be read by Python IDLE

Put the lines at the first:

#!/usr/bin/env python
# coding: utf-8

網誌存檔