Showing posts with label Linux System Admin. Show all posts
Showing posts with label Linux System Admin. Show all posts

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.

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

Tuesday, September 13, 2016

Fix PAC Seg fault in Ubuntu 16.04



[1] https://sourceforge.net/p/pacmanager/bugs/271/
[2] https://sourceforge.net/p/pacmanager/discussion/1076055/thread/f6d6690e/


qyang@ubuntu:/opt/pac/lib/ex/vte32/auto/Gnome2/Vte$ cd /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ ll
total 1.1M
-rw-r--r-- 1 root root 265K Nov  5  2015 Vte.so_64_5.022
-rw-r--r-- 1 root root  66K Nov  5  2015 Vte.so_64_5.020
-rw-r--r-- 1 root root  68K Nov  5  2015 Vte.so_64_5.018
-rw-r--r-- 1 root root 281K Nov  5  2015 Vte.so_64_5.016
-rw-r--r-- 1 root root 278K Nov  5  2015 Vte.so_64_5.014
-rw-r--r-- 1 root root  88K Nov  5  2015 Vte.so_64_5.000
drwxr-xr-x 3 root root 4.0K Jan  2  2016 ../
lrwxrwxrwx 1 root root   53 Jan  2  2016 Vte.so -> /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.018
drwxr-xr-x 2 root root 4.0K Jan  2  2016 ./

qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ sudo rm Vte.so
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ sudo ln -s /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.022 Vte.so
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ ll
total 1.1M
-rw-r--r-- 1 root root 265K Nov  5  2015 Vte.so_64_5.022
-rw-r--r-- 1 root root  66K Nov  5  2015 Vte.so_64_5.020
-rw-r--r-- 1 root root  68K Nov  5  2015 Vte.so_64_5.018
-rw-r--r-- 1 root root 281K Nov  5  2015 Vte.so_64_5.016
-rw-r--r-- 1 root root 278K Nov  5  2015 Vte.so_64_5.014
-rw-r--r-- 1 root root  88K Nov  5  2015 Vte.so_64_5.000
drwxr-xr-x 3 root root 4.0K Jan  2  2016 ../
lrwxrwxrwx 1 root root   53 Sep 14 13:30 Vte.so -> /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.022
drwxr-xr-x 2 root root 4.0K Sep 14 13:30 ./

----
Uninstall and reinstall also fixed the issue after upgrade office Ubuntu from 14.04 to 16.04.
Pac start working in Unity rather than gnome.

$sudo apt remove pac
qyang@lgm-pc:~$ sudo dpkg -i ~/Downloads/pac-4.5.5.7-all.deb
Selecting previously unselected package pac.
(Reading database ... 333327 files and directories currently installed.)
Preparing to unpack .../Downloads/pac-4.5.5.7-all.deb ...
Unpacking pac (4.5.5.7) ...
Setting up pac (4.5.5.7) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
qyang@lgm-pc:~$ pac
PAC started (pac) with PID 23818
INFO: Used config file '/home/qyang/.config/pac/pac.nfreeze'
INFO: Using 'Unity' tray icon

Sunday, April 3, 2016

How to create Bootable USB Ubuntu 14.04 installation disk (UEFI and Legacy Compatible) and restore it back to full size after use

Linux Way to restore bootable USB:

Gui tool in lubuntu -> preferences -> Disks. (chose format USB disk as win95 fat32)

( Bootable usb write protected.
  $sudo mount -o,rw /dev/sdb1 /media/gyang/test
  or
  $mount -o remount,rw /media/gyang/test
  or
  $sudo hdparm -r0 /dev/sdb
  Not solving the issues.)



Windows Way:

You Tube Intro


Win32 Disk Imager 


superuser how to put USB back to original full size


Win32 Disk Imager to burn *.iso to USB flash drive.
Then, reboot from USB from UEFI enabled laptop. Should work. (Live CD has limitation as most new laptop no longer have CD drive.)

To restore USB flash drive. Follow step 5 in uTube video.


To restore bootable USB drive to its original size.

  1. Run CMD as Administrator
  2. Type DISKPART
  3. list disk
  4. select disk 1 (if your usb drive mine was 1)
  5. clean
  6. create partition primary
  7. active
  8. Choose a format:
    • FAT32 is the standard for USBs: format fs=fat32 quick
    • NTFS is more modern, but isn't as widely supported: format fs=ntfs quick
  9. assign
  10. exit
  11. exit

Saturday, April 2, 2016

Bit Torrent in Ubuntu



https://help.ubuntu.com/community/BitTorrent



qyang@ubuntu:~$ dpkg --list |grep transmission
ii  transmission                                                2.82-1.1ubuntu3.1                                   all          lightweight BitTorrent client
ii  transmission-common                                         2.82-1.1ubuntu3.1                                   all          lightweight BitTorrent client (common files)
ii  transmission-gtk    




Saturday, January 2, 2016

Vi Error 'E185: Cannot find color scheme 'morning' in freshly installed ubuntu 14.04.3

Copied all ~/.vim folder to newly installed ubuntu box. But vi is complaining on start up. "E185: Cannot find color scheme 'morning'" Because at default it's using vim.tiny. qyang@ubuntu:~$ ll /etc/alternatives/vi lrwxrwxrwx 1 root root 17 Dec 6 13:24 /etc/alternatives/vi -> /usr/bin/vim.tiny* In old ubuntu box: qyang@lgm-pc:~$ ll /etc/alternatives/vi lrwxrwxrwx 1 root root 18 Jun 15 2015 /etc/alternatives/vi -> /usr/bin/vim.gnome Installing vim-gnome fixed this issue. ($sudo apt-get install vim-gnome)

Thursday, December 10, 2015

Install Playonlinux from command line to accept the license by Tab -> Enter

This POST addressed how to accept license when clicking enter doesn't respond the OK display when installing playonlinux from command line.
Solution:
Hit  key, then hit  to accept the license. 

That is it. So easy, just switching among buttons, to highlight button. Same like in windows.

Ubuntu apt mirror access error.


http://askubuntu.com/questions/553765/failed-to-fetch-update-on-ubuntu-14-04-lts-trusty-tahr


This post addressed one issue I had tonight.


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg  Unable to connect to us.archive.ubuntu.com:http:

Solution
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

Or switch apt mirror from this link
http://askubuntu.com/questions/37753/how-can-i-get-apt-to-use-a-mirror-close-to-me-or-choose-a-faster-mirror

Friday, November 20, 2015

Cron and Anacron to schedule jobs in Linux


ref https://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/

$crontab -e   to edit
$crontab -l   to list
$crontab -l -u username   to list cron jobs of username


anacron

runs commands periodically. Unlike cron(8), it does not assume that the machine is running continuously. Hence, it can be used on machines that aren't running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron.
qyang@lubuntu-laptop:~$ service anacron start
qyang@lubuntu-laptop:~$ service anacron status
● anacron.service - Run anacron jobs
   Loaded: loaded (/lib/systemd/system/anacron.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2015-11-21 09:19:57 AEDT; 4s ago
 Main PID: 10233 (anacron)
   CGroup: /system.slice/anacron.service
           └─10233 /usr/sbin/anacron -dsq

Nov 21 09:19:57 lubuntu-laptop systemd[1]: Started Run anacron jobs.
Nov 21 09:19:57 lubuntu-laptop systemd[1]: Starting Run anacron jobs...
Nov 21 09:19:57 lubuntu-laptop anacron[10233]: Anacron 2.3 started on 2015-11-21
Nov 21 09:19:57 lubuntu-laptop anacron[10233]: Will run job `cron.daily' in 5 min.
Nov 21 09:19:57 lubuntu-laptop anacron[10233]: Will run job `svnsyncPQAFW.daily' in 15 min.
Nov 21 09:19:57 lubuntu-laptop anacron[10233]: Jobs will be executed sequentially

cron

Sample of downloading data regularly using cron Changing crontab
root@trac ~# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root    cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#25 6 * * * root test -x /usr/sbin/anacron || ( cd /root/AuctionResults && run-parts --report /root/AuctionResults)
00 12  * * 7 root test -x /usr/sbin/anacron || ( cd /root/AuctionResults && run-parts --report /root/AuctionResults)
#
Run any executable files,eg.runpython under nominated folder AuctionResults
root@trac ~# ls -al ~/AuctionResults
total 852
drwxr-xr-x  2 root root   4096 Nov 15 12:00 .
drwx------ 11 root root   4096 Sep  9 00:41 ..
-rwxr-xr-x  1 root root   1105 Jul 14 13:48 file-retrieve-via-url.py
-rwxr-xr-x  1 root root     39 Jun  9 22:43 runpython
qyang@lubuntu-laptop:~/Svn_Local_Personal/A_001_Notes$ locate cron |grep bin
/usr/bin/crontab
/usr/sbin/anacron
/usr/sbin/cron
/etc/cron.daily/.placeholder
/etc/cron.daily/0anacron
/etc/cron.daily/apport
/etc/cron.daily/apt
/etc/cron.daily/bsdmainutils
/etc/cron.daily/dpkg
/etc/cron.daily/logrotate
/etc/cron.daily/man-db
/etc/cron.daily/mlocate
/etc/cron.daily/ntp
/etc/cron.daily/passwd
/etc/cron.daily/popularity-contest
/etc/cron.daily/update-notifier-common
/etc/cron.hourly/.placeholder
/etc/cron.monthly/.placeholder
/etc/cron.monthly/0anacron
/etc/cron.weekly/.placeholder
/etc/cron.weekly/0anacron
/etc/cron.weekly/fstrim
/etc/cron.weekly/man-db
/etc/cron.weekly/update-notifier-common
/etc/default/anacron
/etc/default/cron
/etc/init/anacron.conf
/etc/init/cron.conf
/etc/init.d/anacron
/etc/init.d/cron

service control in debian/lubuntu/ubuntu - sysv-rc-conf


[1] wiki.debian.org

Install sysv-rc-conf via apt.
$sudo sysv-rc-conf


Friday, November 13, 2015

Folders and files synchronisation using rsync in Linux


# Creat source folder and files and blank destination folder
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ mkdir src dst
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ mkdir src/a 
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ echo "hell a" > src/a/file1.txt
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
└── src
    └── a
        └── file1.txt

# rsync to test folder and file synch. Both 'a' and 'file1' appeared under 'dst'.
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── a
│       └── file1.txt
└── src
    └── a
        └── file1.txt

# Test newly added folder 'b' being synched
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ mkdir src/b
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   ├── a
│   │   └── file1.txt
│   └── b
└── src
    ├── a
    │   └── file1.txt
    └── b

# Test newly added file 'file2.txt' being synched
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ echo "hell b" > src/b/file2.txt
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   ├── a
│   │   └── file1.txt
│   └── b
│       └── file2.txt
└── src
    ├── a
    │   └── file1.txt
    └── b
        └── file2.txt

# Test newly delete folder 'a' and 'file1.txt' inside being synched.
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rm -rf src/a/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── b
│       └── file2.txt
└── src
    └── b
        └── file2.txt

# Test newly delete file 'file2.txt' being synched.
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rm src/b/file2.txt 
rm: remove regular file ‘src/b/file2.txt’? y
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── b
└── src
    └── b

# Add back 'file2.txt' and check
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ echo "hell b" > src/b/file2.txt
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── b
│       └── file2.txt
└── src
    └── b
        └── file2.txt

# modify 'file2.txt' and check synch
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ cat dst/b/file2.txt
hell b
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ vi src/b/file2.txt
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ cat src/b/file2.txt
Modified ...hello b
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ rsync --delete --checksum --recursive src/ dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ cat dst/b/file2.txt
Modified ...hello b
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── b
│       └── file2.txt
└── src
    └── b
        └── file2.txt


Using cp command line for multiple files copy
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   └── b
│       └── file2.txt
└── src
    ├── a
    │   └── file1.txt
    └── b
        ├── file2.txt
        └── file3.txt

5 directories, 4 files
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ cp {src/a/file1.txt,src/b/file{2..3}.txt} dst/
qyang@lubuntu-laptop:~/Trash/Sandbox-Trial$ tree
.
├── dst
│   ├── b
│   │   └── file2.txt
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
└── src
    ├── a
    │   └── file1.txt
    └── b
        ├── file2.txt
        └── file3.txt

Friday, November 6, 2015

Man Page in Linux


How to view same thing in different man page?????
How to read entire man page without knowing names of a particular command????

There are POSIX Programmer's Manual and Linux Programmer's Manual and Library Functions Manual


To find help on any commands based on what manpage packages have been installed.
qyang@lubuntu-laptop:~$ dpkg --list |grep manpage
ii  manpages                                                    3.74-1ubuntu1                              all          Manual pages about using a GNU/Linux system
ii  manpages-dev                                                3.74-1ubuntu1                              all          Manual pages about using GNU/Linux for development
ii  manpages-posix                                              2.16-1                                     all          Manual pages about using POSIX system
ii  manpages-posix-dev                                          2.16-1                                     all          Manual pages about using a POSIX system for development
#apt-get install manpages-posix manpages-posix-dev
#yum install man-pages
#yum install libstdc++-docs          to see man page of C++ library
$man pthreads
$man ldd
$man pthread_mutex_lock

$man std::iostream
$man std::vector
$man malloc

Sunday, November 1, 2015

Auto start wanted application on Lubuntu log in.




Putting launcher into ~/.config/autostart. Ref
CreatAutoStartShell.py '' ''
./CreatAutoStartShell.py vncserverstart /home/qyang/startvncserver.sh
./CreatAutoStartShell.py startxcompmgr /home/qyang/startxcompmgr.sh
startvncserver.sh
#!/bin/bash
vncserver &
startxcompmgr.sh
#!/bin/bash
xcompmgr -n &
CreatAutoStartShell.py
#!/usr/bin/env python3
import os
import sys
home = os.environ["HOME"]

name = sys.argv[1]; command = sys.argv[2]

launcher = ["[Desktop Entry]", "Name=", "Exec=", "Type=Application", "X-GNOME-Autostart-enabled=true"]
dr = home+"/.config/autostart/"
if not os.path.exists(dr):
    os.makedirs(dr)
file = dr+name.lower()+".desktop"

if not os.path.exists(file):
    with open(file, "wt") as out:
        for l in launcher:
            l = l+name if l == "Name=" else l
            l = l+command if l == "Exec=" else l
            out.write(l+"\n")
else:
    print("file exists, choose another name")

Saturday, October 3, 2015

Key bindings

[1] https://help.ubuntu.com/community/Lubuntu/Keyboard
[2] http://cipricuslinux.blogspot.com.au/2012/11/edit-shortcuts-keybindings-in-lubuntu.html


Keybindings in Lubuntu   [1]
Modify keybindings in Lubuntu by changing its ~/.config/openbox/lubuntu-rc.xml [2]

System log in Linux

[1] https://ask.fedoraproject.org/en/question/9299/sticky-how-do-i-view-logs-on-fedora/




After fedora20, /var/log/messages no longer available.

$journalctl -n 100      show latest 100 lines of system log message

In debian/ubuntu it's in /var/log/syslog.

Wednesday, September 30, 2015

Filesystem Hierarchy Standard in Linux

[1] http://askubuntu.com/questions/138547/how-to-understand-the-ubuntu-file-system-layout/138551#138551
[2] https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard



Linux File System version is 2.3, announced on January 29, 2004. [1]




etc/    

Since the publication of early documentation, the directory name has been re-explained in various ways. Recent interpretations include backronyms such as "Editable Text Configuration" or "Extended Tool Chest". [2] 

Sunday, September 27, 2015

Install gcc / g++ man page manually on Debian.

[1] http://unix.stackexchange.com/questions/42474/find-and-install-man-file-manually


 Install gcc / g++ man page manually on Debian.

Edit /etc/apt/sources.list to include non-free repositories.

#apt-get update

#apt-get install gcc-doc

Wednesday, September 23, 2015

Linux package collection

[1] http://www.cyberciti.biz/tips/how-to-controlling-access-to-linux-services.html
[2] https://technicalsanctuary.wordpress.com/2016/05/28/installing-cisco-anyconnect-vpn-on-ubuntu-16-04/
[3] https://www.imagemagick.org/script/index.php

#apt-get autoremove                    clean up unused packages
#apt-get -f install                         fixing broken dependencies
#apt-get update                            update apt-get repository
#apt-get upgrade                          upgrade all apt packages
#apt-cache search keywordofpackage    search for an apt package in Ubuntu
#apt update
#add-apt-repository ppa:teatime/ppa
#apt install teatime-unity
#dpkg --list                                             list all installed package in Ubuntu
#dpkg -i xxxx.deb                       Install from downloaded package.


#yum search keywordofyumpackage     search for an yum package in Fedora

$systemctl daemon-reload



DEVELOPMENT
----------------------------
#apt-get install gcc-4.9
#apt-get install g++-4.9
#apt-get install gcc
#apt-get install g++
#yum install libstdc++-docs            libstdc++-docs.x86_64 0:4.8.3-7.fc20  man page for C++ lib
#apt-get install manpages-posix manpages-posix-dev
#yum install man-pages             man-pages.noarch 0:3.53-6.fc20  showing $man ldd $man pthread_mutex_lock after installation

#apt-get install libasio-dev           modern c++ library for network programming
#apt-get install libasio-doc
#apt-get install make

#apt-get install cmake
#apt-get install cmake-qt-gui         replacement for cmake -i wizard option

#apt-get install ipython
     Suggested packages:
     ipython-doc ipython-notebook ipython-qtconsole python-matplotlib
     python-numpy python-zmq python-pexpect-doc
     The following NEW packages will be installed:
     ipython python-decorator python-pexpect python-simplegeneric
#apt-get install python-matplotlib


sudo apt-get install qt4-designer --fix-missing

#apt-get install  vim-gnome
#sudo apt-get install ctags            then install tagsbar plug in
#sudo apt-get install exuberant-ctags    exuberant-ctags better than ctags which covers only c
#apt-get install cscope              

#apt-get install meld                  visual file comparison tool
#apt-get install subversion
#apt-get install git

#apt-get install kompare      similar like meld....visual file comparison

MISC-DEV
----------------
#apt-get install gawk                    to change from mawk to gawk to use --field-separater option in awk command line
#apt-get install ack-grep
#apt-get install screen                 screen/terminal logging tool
#apt-get install trace-route       to avoid modern firewall, u can use trace-route xxxx -T via tcp socket
#apt-get install dos2unix             convert dos format text file to unix format
#apt-get install nfs-common nfs-kernel-server            Then modify /etc/export and firewall settings to set up NFS server.

#apt-get install arp-scan           ip-scan for LAN

#dpkg -i ~/Downloads/pac-4.5.5.7-all.deb      PAC Manager, Perl/Gtk approach to sssh/telnet/rdp/... connections managing.




REMOTE ACCESS
------------------------------
#apt-get install openssh-server

#apt-get install freerdp-x11            to remote desktop From Linux to Windows
       qyang@lubuntu-laptop:~$ xfreerdp /u:UserName /p:Password /v:10.1.1.218 /f

#apt-get install tightvncserver       to remote desktop from Windows to Linux (faster than xrdp and x11vnc)
#apt-get install xtightvncviewer
#apt-get install autocutsel

$vino-preferences will bring ubuntu14.04.3 default installed desktop sharing options.


#apt-get install pptp-linux network-manager-pptp network-manager-pptp-gnome  for VPN connection to Microsoft VPN server

#apt-get install network-manager-vpnc                       for VPN connection using Cisco Compatible VPN (vpnc)
#apt-get install network-manager-vpnc-gnome           for VPN GUI integration with Gnome

#apt-get install lib32z1 lib32ncurses5                         required package for Cisco AnyConnect client installation
#apt-get install network-manager-openconnect-gnome    openconnect client
#./vpnsetup.sh                                                             for VPN connection using Cisco AnyConnect
                                                                                    Scripts downloaded when browsing https://vpn.dmglobal.com to install Cisco AnyConnect Client in Linux


run $systemctl daemon-reload if seeing error "Failed to start vpnagentd.service: Unit vpnagentd.service not found." [2]

#apt-get install ufw                                       ufw - program for managing a netfilter firewall





SYSTEM
-----------
#apt-get install sysv-rc-con          debian service config package installed on lubuntu-laptop
( #apt-get install rcconf                    service control)
( #apt-get install sysvconfig              chkconfig like service config on debian  [1] )
#yum install chkconfig                   fedora service control



MISC - MustHave
-----------------------
#apt-get install xpad                              sticky notes counterpart in Linux (others similar have knote,tomboy etc)
#apt-get install tree                                list folder structure
#apt-get install libreoffice
#apt-get install shutter                           screen shot tool, similar like snipping tool in win7. build-in pic annotation.
#apt-get install gnome-screenshot         gnome build-in screen shot tool shift+prtscn
                                                               $gnome-screenshot –file=[FILENAME]    
                                                               $gnome-screenshot -i  
                                                               $gnome-screenshot -a  
                                                               $gnome-screenshot -w
#sudo apt-get install file-roller              a tool to open and view *.tar *.tar.gz
#clock or teatimer                               a good tool for timer remind
#apt-get install imagemagick                a good tool to convert multiple images into one pdf file using 'convert' command line as part of imagemagick.

MISC
---------
#apt-get install docky
#apt-get install xcompmgr                      enable 3D effect for docky applicataion
#apt-get install seahorse             front-end to reset/change key ring password
#apt-get install gconf-editor            alt+f2 bring cmd prompt, type 'gconf-editor' config docky position
sudo apt-get install gtypist
sudo apt-get install dvorak7min
sudo apt-get install typespeed
sudo apt-get install transmission     default official BitTorrent client in ubuntu, transmission-gtk, transmission-common


MultiMedia
----------------
#sudo apt-get install ubuntu-restricted-extras
#sudo apt-get install libdvd-pkg  (> 15.04)
#sudo dpkg-reconfigure libdvd-pkg

Monday, September 21, 2015

Remote desktop from Windows to Linux

[1] http://www.linux.org/threads/rdp-into-your-linux-desktop.8/
[2] http://ubuntuwiki.net/index.php/Xrdp,_installing
[3] http://askubuntu.com/questions/235905/use-xrdp-to-connect-to-desktop-session

Through VNC as most people traditionally did.
Through RDP. [1]


 yum install xrdp -y
# chkconfig --levels 35 xrdp on
# service xrdp start

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm


Under debian using xrdp + vino [2] [3]
 vi /etc/xrdp/xrdp.ini
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1

# set empty username because VNC auth 
# doesn't actually use username, so no
# point in asking the user for one.

[xrdp1]
name=Active Local Login
lib=libvnc.so
username=
password=ask
ip=127.0.0.1
port=5900

[xrdp2]
name=Clean Session
lib=libvnc.so
username=
password=ask
ip=127.0.0.1 
port=5901 
 
 
$sudo vino-preferences