Tuesday, February 27, 2018

如何在Ubuntu 16.04 desktop 透過PXE安裝Ubuntu?

在開始之前,請先準備與安裝相關的service在Ubuntu desktop 16.04 LTS:

1. Download Ubuntu desktop ISO
2. Download PXE bootloader

1. DHCP Server
# sudo apt-get install isc-dhcp-server
2. TFTP Server
# sudo apt-get install tftpd-hpa inetutils-inetd
3. NFS Server
# sudo apt-get install nfs-kernel-server
1. DHCP Server:
# sudo vi /etc/dhcp/dhcpd.conf
 subnet netmask {
 option domain-name-servers;
 option routers;
 option broadcast-address;
 default-lease-time 600;
 max-lease-time 7200;
 filename "pxelinux.0";

#sudo systemctl restart isc-dhcp-server
 2. TFTP Server:
# sudo vi /etc/default/tftpd-hpa
OPTIONS="-l -s /var/lib/tftpboot"

# sudo vi /etc/inetd.conf
  tftp    dgram   udp    wait    root    /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
#sudo systemctl restart tftpd-hpa 
3. PXE bootloader:
# tar -xJf syslinux-6.03.tar.xz
# cd syslinux-6.03
# sudo cp bios/core/pxelinux.0 /var/lib/tftpboot
# sudo cp bios/com32/lib/libcom32.c32 /var/lib/tftpboot
# sudo cp bios/com32/libutil/libutil.c32 /var/lib/tftpboot
# sudo cp bios/com32/elflink/ldlinux/ldlinux.c32 /var/lib/tftpboot
# sudo cp bios/com32/menu/vesamenu.c32 /var/lib/tftpboot
# mkdir /var/lib/tftpboot/pxelinux.cfg
# sudo vi /var/lib/tftpboot/default
DEFAULT vesamenu.c32
MENU TITLE Network boot
LABEL ubuntu-mate-16.04.2-desktop-amd64
  MENU LABEL ubuntu-mate-16.04.2-desktop-amd64
  KERNEL vmlinuz.efi
  APPEND initrd=initrd.lz root=/dev/nfs boot=casper netboot=nfs nfsroot= splash --
4. NFS file Server:
# sudo mount -o loop ubuntu-16.04.3-desktop-amd64.iso /mnt/
# sudo mkdir -p /var/nfs/ubuntu_desktop
# sudo cp -rf /mnt/* /var/nfs/ubuntu_desktop/
# sudo vi /etc/exports

/var/nfs/ubuntu_desktop *(ro,sync)
# sudo systemctl restart nfs-kernel-server
# showmount -e localhost 
Export list for localhost:
/var/nfs/ubuntu_desktop *

Boot from Network boot:


Tuesday, February 13, 2018

How can I move Launcher from left to the buttom on Ubuntu 16.04?

It's very simple, and it works for me even if I reboot or re-login the system b/c Ubuntu will remember it.

1. Open a terminal

2. To execute "gsettings set com.canonical.Unity.Launcher launcher-position Bottom"


Sunday, February 04, 2018

How can I get detail information of USB device?

The command lsusb, which able to list all USB devices of machine below:
lawrence@Lawrence-ThinkPad-X200:~$ lsusb
Bus 002 Device 004: ID 7392:7711 Edimax Technology Co., Ltd EW-7711UTn nLite Wireless Adapter [Ralink RT2870]
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 17ef:480c Lenovo Integrated Webcam
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 08ff:2810 AuthenTec, Inc. AES2810
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

However, I would like to know more informations. For example, speed, vendor, manufacturer......, etc. And there is a command usb-devices, which can help me.

lawrence@Lawrence-ThinkPad-X200:~$ usb-devices 
T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  4 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=7392 ProdID=7711 Rev=01.01
S:  Manufacturer=RalinkS:  Product=802.11 n WLAN
S:  SerialNumber=1.0
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=450mA
I:  If#= 0 Alt= 0 #EPs= 7 Cls=ff(vend.) Sub=ff Prot=ff Driver=rt2800usb
T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 2
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=04.13
S:  Manufacturer=Linux 4.13.0-32-generic xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:0d:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

Above you can see the Spd=480/USB 2.0, and Spd=5000/USB 3.0.

Sunday, January 28, 2018

[Shell script] Find user in system

The first way:


if [ $# -eq 0 ]
 echo "Usage: $0 lawrence"
  grep "\<$1\>" /etc/passwd > /dev/null
  if [ $RETVAL -eq 0 ]
   echo "Username $1 was found in the system"
   echo "Cannot find username $1"

The second way:

[ $# -eq 0 ] &&  { echo "Usage: $0 lawrence" ; exit 1; }

grep "\<$1\>" /etc/passwd > /dev/null

[ $RETVAL -eq 0 ] && echo "Username $1 was found in the system" || echo "Cannot find username $1"

Thursday, January 04, 2018

How can I add EPEL reop on CentOS 7.x?

It's quite simple, just two commands below:

# yum install epel-release

# yum repolist

Sample output:

Friday, September 29, 2017

How can I disable dnsmasq listen port 53 on the Ubuntu 16.04 LTS?

By default the DNS Server of Ubuntu 16.04 LTS will be, i.e., localhost.

Therefore, system will forward DNS query to the localhost first, and forward to the DNS server which obtained from the DHCP server afterward.

Actually, I didn't prefer this method, so that I would like to turn off  this mechanism via steps were listed below:

1. Open /etc/NetworkManager/NetworkManager.conf

2. To disable dnsmasq

3. Restart NetworkManager

4. Examine /etc/resolv.conf


Friday, September 22, 2017

How can I switch multi-user or graphical mode via one command? (Systemd)

To switch multi-user to graphical mode (runlevel 3 to runlevel 5)

# systemctl set-default graphical && reboot

To switch graphical to multi-user mode (runlevel 5 to runlevel 3)

# systemctl set-default multi-user && reboot