Ubuntu 管理心得

搜尋此網誌

2020年10月23日 星期五

Expand vmware Mac OS disk

  1. Expand disk size in vm setting, say to 60GB
  2. Inside mac os guest, open disk utility 
  3. Select  容器->My29GB - Data. (not My29GB)
  4. click 分割 tab 
  5. Keyin new size in 大小. The size should be less than 60GB as in step 1. 
  6. click 套用
  7. Done

 

2020年10月6日 星期二

Use rsync to ssh on custom port

rsync -auvzpP -e 'ssh -p 7922' Fuzzy/Literature/IntuitionisticFuzzyNumber/ chiao@kpcp4.au.edu.tw:/home/chiao/Fuzzy/Literature/IntuitionisticFuzzyNumber

2020年10月3日 星期六

LyX Mathematica with condition

 Put a condition follows the equation:

Simplify[ x 2 ,{ -1<x<0 } ] =-x
  
 

2020年9月26日 星期六

Ubuntu 18.04.4 LTS Hardware Enablement Stack (HWE)

 

sudo apt install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04

set permanent dns

Edit /etc/systemd/resolved.conf, add this line:

DNS=192.168.1.1

or 

DNS=<what-u-want>

 

Then restart ubuntu.


2020年9月18日 星期五

Plural or single noun with multiple adjectives

 cf: https://english.stackexchange.com/questions/221331/plural-or-singular-noun-when-it-refers-to-two-things-in-a-list


The followings are right.

I have a left and a right arm.

I have left and right arms.

Everyone has left and right arms. [This is correct]

The followings are wrong.

I have an old and a new cars.

I have old and new car.

2020年7月24日 星期五

Do not forget rerun unlocker

If install new version of vmware, do not forget to run unlocker again, otherwise the MacOS (e,g, catalina ) cannot boot.

2020年7月16日 星期四

sudo without password

Disable sudo password for all the members of sudoers group.

sudo visudo and add this line:  
%sudo   ALL=(ALL:ALL) NOPASSWD:ALL

2020年7月13日 星期一

openconnect ssl vpn

sudo apt install openconnect
Run this command:

sudo openconnect https://au.twaren.net/staff --protocol=nc


2020年7月11日 星期六

Repeat duplicate items in legend in Matplotlb jupyter

In unbuntu 18.04 this is not an error, however, it will produce duplicated legend in ubuntu 20.04. According to https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib, if plot the same line type twice, then it will produce the same lengend for the same line.
Therefore, I have to break the oringial one line into two lines:

    ax.plot(x, yU, Label=i,linewidth=2, dashes=dst,color='black')
    ax.plot(x, yL, linewidth=2, dashes=dst,color='black')
NB, the legend is removed from the second line.

2020年6月29日 星期一

update grub efi from grub pc for gpt uefi


  1. make a fat32 partition of size 10M, e.g. /dev/sda1
  2. sudo mkdir /boot/efi
  3. put this line into /etc/fstab
    UUID=4CA9-C727  /boot/efi       vfat    umask=0077      0       1
  4. sudo mount -a
  5. purge old grub-pc, e.g.
  6. install grub-efi. e.g.  apt install grub-efi
  7. sudo update-grub
  8. sudo grub-install
  9. Done.

Using ubuntu live CD and suppose /mnt/2 contains all the old operation system, say ubuntu 18.04.
cd /mnt/2
mount -B /dev dev
mount -B /dev/pts dev/pts
mount -B /proc proc
mount -B /sys sys
mount -B /run run

cd /
chroot /mnt/2
vim /etc/hosts, add this line:
140.110.240.80 tw.archive.ubuntu.com 
 
To find where efi, say sda2, then
mount /dev/sda2 /boot/efi
apt purge grub-pc
apt update
apt install grub-efi

update-grub
grub-install
exit

umount /mnt/2/dev/pts
umount /mnt/2/dev
umount /mnt/2/proc
umount /mnt/2/sys
umount /mnt/2/run








2020年6月28日 星期日

sync Frontdoor to dropbox

Two stages,
1. setup rclone with dropbox
2. setup incrontab with the command:
incrontab -e

and add this line:
/home/pi/webcam    IN_CREATE    /usr/bin/rclone sync /home/pi/webcam mydropbox:webcam/FrontDoor

2020年6月16日 星期二

core_version_requirement

 cf :https://www.drupal.org/node/3070687  



This version is not compatible with Drupal 9.0.0 and should be replaced.
Machine name: fahp_synthesis
Requires:
  • Drupal Core (8.x) (incompatible with version 9.0.0)

Edit my_custom_module.info.yml:

change

core: 8.x

to
 
core: 8.x
core_version_requirement: ^8 || ^9

for drupal 9.x

2020年6月12日 星期五

drupal_set_message deprecated in drupal 9

Create a function:

//---------------------------------------------------------
function drupal_set_message($message = NULL)
    {
    $messenger = \Drupal::messenger();
    if (isset($message)){
      $messenger->addMessage($message,'status',FALSE);    }
    }
//---------------------------------------------------------

Replace

 drupal_set_message(array(
        '#type' => 'markup',
        '#markup' => $tle));

with these lines:

 $this->drupal_set_message(array(
       '#type' => 'markup',
       '#markup' => $tle));

drupal 9 db_query deprecated

cf: https://www.drupal.org/project/advban/issues/3090341

Replace db_query with \Drupal::database()->query, e.g.

//$res=db_query($sql) or die("Error: $sql");
$res=Database::getConnection()->query($sql) or die("Error: $sql");

Use the script to change:


#!/bin/bash
find ./ -type f -exec sed -i 's+db_query(+Database::getConnection()->query(+g' {} \;

2020年6月5日 星期五

Create drupal 9 with composer

$ mkdir /home/chiao/public_html/drupal9 
$ composer create-project drupal/recommended-project:~9.0.0
  /home/chiao/public_html/drupal9
Go to /home/chiao/public_html/drupal9/web/sites.
 Copy files to drupal9:
    Custom themes go to /home/chiao/public_html/drupal9/web/themes/custom/
    Custom modules go to /home/chiao/public_html/drupal9/web/modules/custom/
    Libraries go to /home/chiao/public_html/drupal9/web/libraries/
    Your uploaded files and images go to /home/chiao/public_html/drupal9/web/sites/default/files/ 
Copy (using sudo cp -av) the following files and directories to new site:
  1. sites/default/settings.php 
  2. sites/default/settings.local.php
  3. sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/   asdfsd
  4. sites/development.services.yml 
$  cd /home/chiao/public_html/drupal9
$  composer install
All done for creating new drupal 9.
 

2020年5月23日 星期六

tex-common error

sudo mv /etc/texmf /etc/texmf_old
sudo apt install lyx tex-common

2020年5月22日 星期五

Create new drupal from old drupal using composer

(For updating 8.9.x in kpci7, cf. https://kpchiaoo.blogspot.com/2018/09/update-drupal.html

 

When using:

composer update --dry-run "drupal/*"

This should show any available minor or patch update, however, my site didn't show any minor version for drupal.

So I follow this: https://www.drupal.org/docs/8/install/add-composer-to-an-existing-site
to create a new site and to transfer my old files to the new site.

1. Create a new drupal site, drupal_new:
cd /home/chiao/public_html
composer create-project drupal/recommended-project:~8.8.0 drupal_new --stability dev --no-interaction

2. Copy files to drupal_new:

    Custom themes go to /var/www/sites/new_html/web/themes/custom/

    Custom modules go to /var/www/sites/new_html/web/modules/custom/

    Libraries go to /var/www/sites/new_html/web/libraries/

    Your uploaded files and images go to /var/www/sites/new_html/web/sites/default/files/
3. Copy sites files:
cd /home/chiao/public_html/drupal_new/web/sites/default
sudo cp -av ~/public_html/drupal/sites/default/settings.php .
sudo cp -av ~/public_html/drupal/sites/default/settings.local.php .
sudo cp -av ~/public_html/drupal/sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/ files/

cd /home/chiao/public_html/drupal_new/web/sites/
sudo cp -av ~/public_html/drupal/sites/development.services.yml .

change owner, www-data:
sudo chown -R www-data.www-data files/ settings.*

4. Edit composer.json in your new project root (e.g., /var/www/sites/new_html) and copy the list of packages from your old composer.json's "require" and "require-dev" sections to the new composer.jsonfile.

5. rm  ~/public_html/drupal_new/composer.lock
composer install

6. All done for creating new druapl.

7. cd  ~/public_html/drupal_new/
drush state:set system.maintenance_mode 1
drush cache-clear drush
composer update drupal/core-recommended --with-dependencies
drush updatedb
drush cache-clear drush
drush state:set system.maintenance_mode 0
drush cache:rebuild

drupal, All links redirect to Homepage

sudo a2enmod rewrite
sudo systemctl restart apache2

2020年5月11日 星期一

Increase mp4 volume using FFMPEG

cf: https://blog.programster.org/change-audio-level-in-video

ffmpeg -i my.mp4 -vcodec copy -af "volume=25dB" my_25dB.mp4

Or,

for i in *.mp4; do \
ffmpeg -i $i  -vcodec \
copy -af "volume=25dB" \
${i%.*}_25dB.mp4 ; \
done

2020年4月29日 星期三

Thunderbird AU calendar not working and not shown

Delete the 'AU' calender, and create it again.

2020年4月15日 星期三

drupal 批次設定使用者角色 (role)






然後在「動作」中點選「Add the QuantitativeMethods role to the selected user(s)

2020年3月17日 星期二

Pulse Secure installation

  1. Download the Pulse Secure client:
    https://its.wpi.edu/software/259/pulse-secure
    https://drive.narlabs.org.tw/navigate/s/6C30CA2A0C7A47E48C2D4034C4A55630GUY
    Pulse Secure Installer (Linux 64-bit)Ubuntu

  2. sudo dpkg --install pulse-9.1R3.x86_64.deb
  3. sudo apt-get install libwebkitgtk-1.0-0
  4. sudo apt-get install libproxy1-plugin-webkit
  5. /usr/local/pulse/pulseUi
  6. Add new connection for AU using URL:
    https://au.twaren.net/au/staff

2020年2月28日 星期五

replace xz with 7z with password

#!/bin/bash

for i in /BACKUP/kpchiao9600k/20200225_Ubuntu_18.04.4_LTS/*; do
    xzcat $i | 7z a -mx=9 -mmt=4 -p -si "$(basename "$i" .tar.xz)_pwd_bsun.tar.7z"
done
#
# Decompress with the following command followed by the password.
#   7z x -so boot_efi_2020_02_25_pwd_bsun.tar.7z | tar tvf -
# Just key in the password, no prompt will be shown.

2020年2月27日 星期四

setup permission for mysqldump


  1. Create ~/.my.cnf, add these lines:
    [mysqldump]
    user=student
    password=student
    chmod 0600 ~/.my.cnf
  2. Inside phpmyadmin, set 'Select' and 'LOCK TABLES' permission to database 'drupal' for 'student' as the following image:


  3. Then, dump drupal with the command without username and password:
     mysqldump drupal > kpchiao9600k_drupal.sql
    or
     mysqldump -B drupal > kpchiao9600k_drupal.sql
    The -B option will add the create database and use datatebase lines into dump file as:
    CREATE DATABASE /*!32312 IF NOT EXISTS*/ `drupal` /*!40100 DEFAULT CHARACTER SET latin1 */;

    USE `drupal`;





2020年2月14日 星期五

2020年2月12日 星期三

Install nvidia driver ubuntu

  1. ubuntu-drivers devices
    e.g. nvidia-driver-435 - distro non-free recommended
  2. sudo ubuntu-drivers autoinstall or

    sudo ubuntu-drivers nvidia-driver-435 

  3. reboot 

網誌存檔