樹心幽徑

20180530解決acer電腦win10休眠後無法開機問題
2018/05/30,14:53

20180530acer電腦win10休眠後無法開機,拔掉CMOS水銀電池,重開機就可進入BIOS設定開機碟,然後就可正常開機了。

20180526在ubuntu1604裝KVM
2018/05/26,13:35

REF:http://blog.sina.com.cn/s/blog_820478da0100zvo6.html

(1)treehrt@treehrt-fire:~$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo

(2)

treehrt@treehrt-fire:~$ sudo apt-get install kvm qemu

Processing triggers for ureadahead (0.100.0-19) ...

treehrt@treehrt-fire:~$ qemu-img create hda.img 10G
Formatting 'hda.img', fmt=raw size=10737418240
treehrt@treehrt-fire:~$

treehrt@treehrt-fire:~$ ls -l|grep hda
-rw-r--r--  1 treehrt treehrt 10737418240  5月 26 13:47 hda.img
treehrt@treehrt-fire:~$ pwd
/home/treehrt
treehrt@treehrt-fire:~$

(3)

treehrt@treehrt-fire:~$ sudo adduser treehrt kvm
正將 `treehrt' 使用者新增至 `kvm' 群組 ...
正在將使用者“treehrt”加入到“kvm”群組中
完成。
treehrt@treehrt-fire:~$

(4)

treehrt@treehrt-fire:~$ sudo adduser treehrt disk
正將 `treehrt' 使用者新增至 `disk' 群組 ...
正在將使用者“treehrt”加入到“disk”群組中
完成。
treehrt@treehrt-fire:~$

(5)

treehrt@treehrt-fire:~$ sudo apt-get install bridge-utils

(6)

@treehrt-fire:~$ sudo invoke-rc.d networking stop
treehrt@treehrt-fire:~$ sudo vim /etc/network/interfaces
treehrt@treehrt-fire:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

 

(7)

treehrt@treehrt-fire:~$ sudo invoke-rc.d networking restart
treehrt@treehrt-fire:~$ ifconfig
br0       Link encap:Ethernet  HWaddr 6e:ba:b7:88:87:91 
          inet6 addr: fe80::6cba:b7ff:fe88:8791/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:6779 (6.7 KB)

enp0s31f6 Link encap:Ethernet  HWaddr b0:6e:bf:60:9d:23 
          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::4224:7ec4:579f:744e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41984 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25431 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:56149346 (56.1 MB)  TX bytes:2322221 (2.3 MB)
          Interrupt:16 Memory:df100000-df120000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1380 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1380 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:127858 (127.8 KB)  TX bytes:127858 (127.8 KB)

treehrt@treehrt-fire:~$

 

20180525在ubuntu1604裝GTK2.0 examples
2018/05/26,00:40

treehrt@treehrt-fire:~/mysqlc$ sudo apt-get install gtk2.0-examples; /usr/bin/gtk-demo

20180525在ubuntu1604裝GTK3.0並編寫一個gtk範例程式
2018/05/25,21:54

(1)

treehrt@treehrt-fire:~$ sudo apt-get install build-essential
[sudo] password for treehrt:
正在讀取套件清單... 完成
正在重建相依關係         
正在讀取狀態資料... 完成
build-essential is already the newest version (12.1ubuntu2).

 

(2)

treehrt@treehrt-fire:~$ sudo apt-get install libgtk-3-dev

:

Processing triggers for libc-bin (2.23-0ubuntu10) ...

 

(3)

treehrt@treehrt-fire:~$ sudo apt-get install pkg-config
正在讀取套件清單... 完成
正在重建相依關係         
正在讀取狀態資料... 完成
pkg-config is already the newest version (0.29.1-0ubuntu1).

 

(4)

treehrt@treehrt-fire:~$ sudo apt-get install devhelp

:

設定 devhelp-common (3.18.1-1ubuntu5) ...
設定 libdevhelp-3-2 (3.18.1-1ubuntu5) ...
設定 devhelp (3.18.1-1ubuntu5) ...
設定 libatk1.0-doc (2.18.0-1) ...
設定 libglib2.0-doc (2.48.2-0ubuntu1) ...
設定 libgtk-3-doc (3.18.9-1ubuntu3.3) ...
設定 libpango1.0-doc (1.38.1-1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

(5)

treehrt@treehrt-fire:~$ pkg-config --cflags --libs gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircore -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
treehrt@treehrt-fire:~$

(6)

treehrt@treehrt-fire:~$ pkg-config --cflags gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircore -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
treehrt@treehrt-fire:~$

 

(7)

treehrt@treehrt-fire:~$ pkg-config --libs gtk+-3.0
-lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
treehrt@treehrt-fire:~$

 

(8) 編寫gtk範例程式:參考https://developer.gnome.org/gtk3/stable/gtk-getting-started.html

treehrt@treehrt-fire:~/mysqlc$ vi gtk1.c

treehrt@treehrt-fire:~/mysqlc$ cat gtk1.c
#include <gtk/gtk.h>

static void
activate (GtkApplication* app,
          gpointer        user_data)
{
  GtkWidget *window;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
  gtk_widget_show_all (window);
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}


(9)編繹並執行成功:

treehrt@treehrt-fire:~/mysqlc$ gcc `pkg-config --cflags gtk+-3.0` gtk1.c `pkg-config --libs gtk+-3.0`

treehrt@treehrt-fire:~/mysqlc$ ./a.out

 

 

20180519在ubuntu建ilvssell資料庫及連線用戶treehrt並新增一個資料表new_cust及二筆資料
2018/05/19,09:28

(1)用c程式碼(t2)建立DATABASE ilvssell (可支援中文字欄位內容)

  if (mysql_query(con, "CREATE DATABASE ilvssell  default character set utf8"))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }

(2)用mysql指令建立ilvssell的連線用戶treehrt

treehrt@treehrt-fire:~/mysqlc$ mysql -p -uroot
Enter password:
:
mysql> CREATE USER treehrt@localhost IDENTIFIED BY 'abc123abc123';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL ON ilvssell.* to treehrt@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

(3)用c程式碼(t3)建立第一個資料表 new_cust 顧客基本資料表

  if (mysql_query(con, "DROP TABLE IF EXISTS new_cust"))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }
  printf("DROP TABLE new_cust ok!\n");

 

 char st[]="CREATE TABLE new_cust (uid char(10) default 'x', remain float default 0, inyear char(5) default '2018', dept char(10) default 'x', grade char(10) default '1' , class  char(10)  default 'x', cardid  char(10) primary key, uname  char(10)  default 'x', pid char(10)  default 'x', addr    varchar(80)  default 'x', tel  char(15)  default 'x', oldclass char(10)  default 'x', sno   char(2)  default 'x', lostc int default 0 , gen_code char(1) default '0'  , in_use char(1) default '1', cid4   char(4)  default 'x' )" ;

  if (mysql_query(con, st))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }
  printf("Execute ok!  %s\n", st);

(4)用mysql指令顯示新建立ilvssell.new_cust資料表的欄位結構

mysql> desc ilvssell.new_cust;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| uid      | char(10)    | YES  |     | x       |       |
| remain   | float       | YES  |     | 0       |       |
| inyear   | char(5)     | YES  |     | 2018    |       |
| dept     | char(10)    | YES  |     | x       |       |
| grade    | char(10)    | YES  |     | 1       |       |
| class    | char(10)    | YES  |     | x       |       |
| cardid   | char(10)    | NO   | PRI | NULL    |       |
| uname    | char(10)    | YES  |     | x       |       |
| pid      | char(10)    | YES  |     | x       |       |
| addr     | varchar(80) | YES  |     | x       |       |
| tel      | char(15)    | YES  |     | x       |       |
| oldclass | char(10)    | YES  |     | x       |       |
| sno      | char(2)     | YES  |     | x       |       |
| lostc    | int(11)     | YES  |     | 0       |       |
| gen_code | char(1)     | YES  |     | 0       |       |
| in_use   | char(1)     | YES  |     | 1       |       |
| cid4     | char(4)     | YES  |     | x       |       |
+----------+-------------+------+-----+---------+-------+
17 rows in set (0.00 sec)

mysql>

mysql> select column_name from information_schema.columns where table_name='new_cust';
+-------------+
| column_name |
+-------------+
| uid         |
| remain      |
| inyear      |
| dept        |
| grade       |
| class       |
| cardid      |
| uname       |
| pid         |
| addr        |
| tel         |
| oldclass    |
| sno         |
| lostc       |
| gen_code    |
| in_use      |
| cid4        |
+-------------+
17 rows in set (0.00 sec)

mysql>

(5)用c程式碼(t4)建立為第一個資料表 new_cust 顧客基本資料表新增一筆資料

 mysql_query(con, "set names utf8");

 char st[]="insert into new_cust (inyear,cardid,uname,cid4,remain) values (107,712003,'王一志' ,'B301',1000)" ;

  if (mysql_query(con, st))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }

(6)用mysql指令顯示新加入ilvssell.new_cust資料表的所有紀錄

mysql> use ilvssell;
mysql> insert into new_cust (inyear,cardid,uname,cid4,remain)  values (105,312005,'蕃茄' ,'B301',1000);

mysql> select inyear,cardid,uname,cid4,remain from ilvssell.new_cust;
+--------+--------+-----------------------+------+--------+
| inyear | cardid | uname                 | cid4 | remain |
+--------+--------+-----------------------+------+--------+
| 105    | 312005 | 蕃茄                  | B301 |   1000 |
| 107    | 812001 | 王一志                | B301 |   1000 |
+--------+--------+-----------------------+------+--------+
2 rows in set (0.00 sec)

mysql>

 

20180518在ubuntu裝PHP
2018/05/18,21:39

treehrt@treehrt-fire:~$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

:

設定 php7.0 (7.0.30-0ubuntu0.16.04.1) ...
設定 php (1:7.0+35ubuntu6.1) ...
設定 php7.0-mcrypt (7.0.30-0ubuntu0.16.04.1) ...

Creating config file /etc/php/7.0/mods-available/mcrypt.ini with new version
設定 php-mcrypt (1:7.0+35ubuntu6.1) ...
設定 php7.0-mysql (7.0.30-0ubuntu0.16.04.1) ...

Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version

Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version

Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version
設定 php-mysql (1:7.0+35ubuntu6.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for libapache2-mod-php7.0 (7.0.30-0ubuntu0.16.04.1) ...

20180518在ubuntu裝mysql-server
2018/05/18,12:32

treehrt@hrt:~/mysqlc$ sudo apt install mysql-server

:
:
設定 mysql-client-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
設定 mysql-client-5.7 (5.7.22-0ubuntu0.16.04.1) ...
設定 mysql-server-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
設定 libevent-core-2.0-5:i386 (2.0.21-stable-2ubuntu0.16.04.1) ...
設定 mysql-server-5.7 (5.7.22-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
設定 libhtml-template-perl (2.95-2) ...
設定 mysql-server (5.7.22-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
treehrt@hrt:~/mysqlc$ whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
treehrt@hrt:~/mysqlc$ mysql -p -uroot
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

20180517安裝ubuntu mysql c connector並設計一個顯示mysql版本的程式
2018/05/17,14:02

treehrt@hrt:~$ sudo apt-get install libmysqlcppconn-dev
[sudo] password for treehrt:
:

設定 libmysqlclient20:i386 (5.7.22-0ubuntu0.16.04.1) ...
設定 libmysqlcppconn7v5 (1.1.7-0ubuntu1) ...
設定 libmysqlcppconn-dev (1.1.7-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
treehrt@hrt:~$

 

treehrt@hrt:~$ sudo apt-get install libmysql++-dev

:
設定 libmysql++3v5 (3.2.2+pristine-1ubuntu1) ...
設定 zlib1g-dev:i386 (1:1.2.8.dfsg-2ubuntu4.1) ...
設定 libmysqlclient-dev (5.7.22-0ubuntu0.16.04.1) ...
設定 libmysql++-dev (3.2.2+pristine-1ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
treehrt@hrt:~$

 

treehrt@hrt:~/mysqlc$ sudo apt-get install libmysqlclient-dev

:

libmysqlclient-dev is already the newest version (5.7.22-0ubuntu0.16.04.1).
libmysqlclient-dev 被設定為手動安裝。

treehrt@hrt:~/mysqlc$ cat t1.c
#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
  printf("MySQL client version: %s\n", mysql_get_client_info());

  exit(0);
}
treehrt@hrt:~/mysqlc$

 

treehrt@hrt:~/mysqlc$ gcc t1.c `mysql_config --cflags --libs`

 
treehrt@hrt:~/mysqlc$ ./a.out
MySQL client version: 5.7.22

 

20180505在Ubuntu裝VMware tools
2018/05/05,21:52

treehrt@treehrt-fire:~$ sudo apt-get update

treehrt@treehrt-fire:~$ sudo apt-get install open-vm-tools

treehrt@treehrt-fire:~$ sudo apt-get install open-vm-tools-desktop

20180503在Ubutun安裝vsftpd伺服程式並上傳一張手繪的dog.png圖檔用pietty連線編寫一個能顯示dog的網頁
2018/05/03,16:22

(一)下載pietty並解開在桌面並連10.10.10.125,用firep帳號登入,密碼abc123

登入後,設定pietty的「選項/編碼/UTF8」

(二)執行sudo apt-get install vsftpd 來安裝ftp伺服程式

(三)執行ftp localhost來登入本機

用firep帳號登入,密碼abc123成功

(四)下載filezilla檔案傳輸用戶端程式(在官方網站上)

FileZilla_3.32.0_win32-setup_bundled.exe並執行之。

(五)在自動啟動的filezilla用戶端程式/按CTRL+S站台管理員/新增站台/輸入站台名稱:125,主機:10.10.10.125,使用者:firep,登入型式:一般/連線/成功

但無法在遠端新增一個目錄,也無法上傳檔案。

(六)執行 sudo vi /etc/vsftpd.conf 來修改設定檔

:

anon_upload_enable=YES

:

(七)執行 sudo vi /etc/vsftpd.chroot_list 來修改可登入的用戶列表設定檔,加入如下一行即可

firep

(八)執行  sudo service vsftpd restart 來重新啟動vsftp以讓設定生效

(九)用桌面的filezilla用戶端連上主機:10.10.10.125,以firep登入

仍無法在遠端新增一個目錄,也無法上傳檔案

(十)執行 sudo vi /etc/vsftpd.conf 來修改設定檔將下列最前端的註解#拿掉

#write_enable=YES

(十一)再執行  sudo service vsftpd restart

(十二)再用filezilla連上主機:10.10.10.125,以firep登入成功

(1)在遠端新增一個你的座號目錄(例如77),也並上傳你的dog.png圖檔到該目錄中

(十三)用pietty以firep登入10.10.10.125

(1) cd /var/www/html 切換到網頁主目錄

(2) ls -l 查看目前目錄的檔案列表

(3) mkdir 座號 來建立你的座號目錄

(4) cp ~firep/座號/dog.png   座號

將你上傳的dog.png 拷到你的網頁目錄下的座號目錄(資料夾)中

(5) cd 座號

切換工作目錄到「網頁主目錄的座號目錄」

(6) 用 firefox 連 http://10.10.10.125/座號/dog.png

無法觀看,

(7) chmod +r 座號/dog.png

修改dog.png為可讀,以firefox 重連後真的可讀。

(8) vi index.html 來為你的座號目錄編寫一個預設網頁,內容如下

按i進入編輯模式

<body bgcolor=yellow>

<img src=dog.png width=300>

<img src=dog.png width=200>

<img src=dog.png width=100>

</body>

按ESC:wq來存檔並結束vi編輯器

(9)用firefox 連

http://10.10.10.125/77/index.html

真的成功看到三隻狗

 

 

 

 

 

 

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType