Friday, November 24, 2017

Change default boot OS in Ubuntu Grub from Linux to Window


Ref: http://www.linuxandubuntu.com/home/how-to-change-boot-order-set-default-boot-os-in-ubuntu-14-10-15-04-linux-mint-or-other-derivatives

Brief of command line:
1. Find out the entry ID list.
qyang@lubuntu-laptop:~$ grep menuentry /boot/grub/grub.cfg
2. Change the default boot id.
qyang@lubuntu-laptop:~$ sudo vi /etc/default/grub
3. Upgrade grub.cfg via 'update-grub'.
qyang@lubuntu-laptop:~$ sudo update-grub

Details in command line:

qyang@lubuntu-laptop:~$ grep menuentry /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-73-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-73-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-73-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-73-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-69-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-69-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-69-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-69-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-56-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-56-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-56-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-56-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-51-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-51-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-51-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-51-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-37-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-37-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-37-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-37-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-33-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-33-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-33-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-33-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-32-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-32-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-32-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-32-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-31-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-31-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-31-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-31-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-30-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-30-generic-advanced-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Ubuntu, with Linux 3.19.0-30-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-30-generic-recovery-8acc81f2-51d4-44ec-94ac-ab13858d5855' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-7E980FF3980FA8AB' {
menuentry 'Windows 7 (loader) (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-chain-48D0359CD0359164' {
menuentry 'Windows Recovery Environment (loader) (on /dev/sda3)' --class windows --class os $menuentry_id_option 'osprober-chain-4A765B93765B7F1F' {




qyang@lubuntu-laptop:~$ sudo update-grub
[sudo] password for qyang:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.19.0-73-generic
Found initrd image: /boot/initrd.img-3.19.0-73-generic
Found linux image: /boot/vmlinuz-3.19.0-69-generic
Found initrd image: /boot/initrd.img-3.19.0-69-generic
Found linux image: /boot/vmlinuz-3.19.0-56-generic
Found initrd image: /boot/initrd.img-3.19.0-56-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-3.19.0-37-generic
Found initrd image: /boot/initrd.img-3.19.0-37-generic
Found linux image: /boot/vmlinuz-3.19.0-33-generic
Found initrd image: /boot/initrd.img-3.19.0-33-generic
Found linux image: /boot/vmlinuz-3.19.0-32-generic
Found initrd image: /boot/initrd.img-3.19.0-32-generic
Found linux image: /boot/vmlinuz-3.19.0-31-generic
Found initrd image: /boot/initrd.img-3.19.0-31-generic
Found linux image: /boot/vmlinuz-3.19.0-30-generic
Found initrd image: /boot/initrd.img-3.19.0-30-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda2
Found Windows Recovery Environment (loader) on /dev/sda4
done




qyang@lubuntu-laptop:~$ sudo fdisk -l
[sudo] password for qyang:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1cb42612

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   3074047   3072000   1.5G 27 Hidden NTFS WinRE
/dev/sda2         3074048 207874047 204800000  97.7G  7 HPFS/NTFS/exFAT
/dev/sda3       207874048 952238079 744364032   355G  5 Extended
/dev/sda4       952238080 976773119  24535040  11.7G 17 Hidden HPFS/NTFS
/dev/sda5       207876096 576516095 368640000 175.8G  7 HPFS/NTFS/exFAT
/dev/sda6       584908800 952238079 367329280 175.2G 83 Linux
/dev/sda7       576518144 584906751   8388608     4G 82 Linux swap / Solaris

Partition table entries are not in disk order.

Friday, August 11, 2017

Batch renaming multiple files in Linux


[1] https://stackoverflow.com/questions/208181/how-to-rename-with-prefix-suffix

using 'rename'
rename 's/(.*)$/new.$1/' original.filename
shell script
for filename in *.jpg; do mv "$filename" "prefix_$filename"; done;
brace expansion
mv {,new.}original.filename


Convert multiple image files into one pdf file using Linux command line.

[1] https://www.imagemagick.org/script/index.php


Convert multiple images into one pdf file under Linux command line.

#apt-get install imagemagick
$convert file1.jpg file2.jpg merge.pdf

Tuesday, June 6, 2017

Set JAVA_HOME in Ubuntu


Ref from 'askubuntu.com'


Three files you could edit, '/etc/environment' is the one prefered in web post:
/etc/environment
/etc/profile
~/.bashrc

But I chose adding file: /etc/profile.d/dnm-build-envsetting.sh

- Reboot pc, and all environments variables settings remains.
        qyang@lgm-pc:~$ cat /etc/environment
        PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
        qyang@lgm-pc:~$ cat /etc/profile.d/dnm-build-envsetting.sh
        # Some environmental variables required for DmM builder to work for android build.
        # 2017-JUN-09
        JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
        ANDROID_HOME=/home/qyang/sandbox/android-sdk-linux
        QTDIR=/home/qyang/sandbox/qt-everywhere-opensource-4.8.7
        export JAVA_HOME
        export ANDROID_HOME
        export QTDIR


My old settings:
yang@lgm-pc:~/testsetupscript$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
qyang@lgm-pc:~/testsetupscript$ cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

JAVA_HOME=/usr/local/java/jdk1.8.0_25
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Wednesday, March 29, 2017

iPad 1 Sync files via SSH



Ipad 1 Sync files via SSH

set up ssh server on ipad Launch Cydia and search for and install OpenSSH.
When asked for a password, use alpine, which is the default password for all iOS devices
enable display mirror utube Install 'display mirror' but has to be launched from ssh console.recommend popup blocker 
QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app/                      
Documents  Library  VLC for iOS.app  tmp

QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app -al
lrwxr-xr-x 1 mobile mobile 61 Apr 27 00:01 /private/var/mobile/AppLinks/VLC for iOS.app -> /var/mobile/Applications/B6D6835D-FD34-46E3-A465-13B35D4C5E0F

QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app/Documents/

QuentinYangs-iPad:~ mobile$ scp qyang@10.1.1.223:~/mntNAS/George_Data/Piano-Lessons/SkillSuccess-Piano-12.mp4 /private/var/mobile/AppLinks/VLC\ for\ iOS.app/Documents/

SkillSuccess-Piano-12.mp4            100%   12MB   1.1MB/s   00:11                                 
You can sync pdf books, photos and videos without iTune.
pdf file all renamed for iBook
QuentinYangs-iPad:~/Media root# ls /User/Media/Books/      
17AEB683BBA94B97.pdf  393CA8C01CE99509.pdf  55751370609C1376.pdf  75D5D27C4A0DC68B.pdf Books.plist       FCA490F8F9022998.pdf    iBooksData2.plist
2C55379B44DA1163.pdf  41BD49AE796A4C07.pdf  57022687E730FA09.pdf  88E410A3599CEFD2.pdf D1BA0918562153F7.pdf  FE57A71807FEA6FC.pdf
2C6E68A747BA2443.pdf  469A3390FC378AB6.pdf  66E27D1EFDACF4E5.pdf  9079674DB7AACD01.pdf E7A9DF25828E2D49.pdf  Purchases
2ED56E68AB4ADD8B.pdf  4715CD83FB89E35A.pdf  67CD967BE223DBF0.pdf  B19F69918E0558B3.pdf E96849ADDB5E816B.pdf  Sync
34FB1FC3BE0C1B97.pdf  5084BDA3A2D21205.pdf  6F9EB200DCC1887B.pdf  B40AB6478931EDA5.pdf ECFEA7B8487512B9.pdf  com.apple.ibooks-sync.plist
Photos are kept original name and not encrypted. *.PNG files are screen shot done on iPad. Import are files imported from CANON-40D.
QuentinYangs-iPad:~/Media root# ls /User/Media/DCIM/
100APPLE  100IMPRT  101IMPRT  102IMPRT 103IMPRT  104IMPRT  105IMPRT  106IMPRT 107IMPRT  108IMPRT  109IMPRT  110IMPRT
QuentinYangs-iPad:~/Media root# ls /User/Media/DCIM/100APPLE/
IMG_0001.PNG  IMG_0007.PNG  IMG_0014.PNG  IMG_0020.PNG IMG_0026.PNG  IMG_0035.PNG  IMG_0041.JPG  IMG_0047.JPG IMG_0057.JPG  IMG_0063.PNG  IMG_0071.PNG  IMG_0085.JPG
IMG_0002.PNG  IMG_0008.PNG  IMG_0015.PNG  IMG_0021.PNG IMG_0027.PNG  IMG_0036.PNG  IMG_0042.JPG  IMG_0048.JPG IMG_0058.JPG  IMG_0064.PNG  IMG_0074.PNG
IMG_0003.PNG  IMG_0009.PNG  IMG_0016.PNG  IMG_0022.PNG IMG_0028.PNG  IMG_0037.PNG  IMG_0043.JPG  IMG_0051.JPG IMG_0059.PNG  IMG_0067.JPG  IMG_0079.PNG
IMG_0004.PNG  IMG_0010.JPG  IMG_0017.PNG  IMG_0023.PNG IMG_0029.PNG  IMG_0038.PNG  IMG_0044.JPG  IMG_0052.PNG IMG_0060.PNG  IMG_0068.JPG  IMG_0080.PNG
IMG_0005.PNG  IMG_0011.JPG  IMG_0018.PNG  IMG_0024.PNG IMG_0030.PNG  IMG_0039.PNG  IMG_0045.JPG  IMG_0055.JPG IMG_0061.PNG  IMG_0069.JPG  IMG_0081.PNG
IMG_0006.PNG  IMG_0012.PNG  IMG_0019.PNG  IMG_0025.PNG IMG_0034.PNG  IMG_0040.PNG  IMG_0046.JPG  IMG_0056.JPG IMG_0062.PNG  IMG_0070.JPG  IMG_0084.JPG

Win to Mac GUI