星期四, 4月 11, 2019

ubuntu init.d runlevel update-rc.d

Ubuntu startup script
http://felix-lin.com/linux/debianubuntu-%E6%96%B0%E5%A2%9E%E9%96%8B%E6%A9%9F%E8%87%AA%E5%8B%95%E5%9F%B7%E8%A1%8C%E7%A8%8B%E5%BC%8F/

/etc/init.d/blah
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/sh
# /etc/init.d/blah
#
 
# Some things that run always
touch /var/lock/blah
 
# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting script blah "
    echo "Could do more here"
    ;;
  stop)
    echo "Stopping script blah"
    echo "Could do more here"
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac
 
exit 0


update-rc.d blah defaults
update-rc.d blah start 20 2 3 4 . stop 80 0 1 6 .
start 20th in 2/3/4 runlevel
update-rc.d -f blah remove

星期三, 4月 10, 2019

key: nginx remove 405 html php7.0-fpm



https://segmentfault.com/a/1190000014027697delete ini file or directory will cause this issue
solution:
purge remove then install again

key: nginx remove 405 html php7.0-fpm

dpkg --get-selections | grep nginx
sudo apt-get --purge remove nginx-common

星期二, 4月 09, 2019

星期五, 3月 29, 2019

sudo , wifi connect command



  • To see list of saved connections, use (<SavedWiFiConn>)
    nmcli c
    
  • To see list of available WiFi hotspots (<WiFiSSID>)
    nmcli d wifi list

sudo nmcli d wifi connect iSSA_ASUS_50_2.4G password 54098542 iface wlan0

Reference:


www-data        ALL=(ALL) NOPASSWD: /usr/bin/amixer

PHP system call system/exec/shell_exec difference and sudo

PHP system call system/exec/shell_exec difference

  • system()
    • $last_line = system('ls', $return_var);
    • system() 會將輸出內容直接印出, 所以若於網頁, 會將所有回傳內容都顯示於頁面上.
    • $last_line: 只能取得最後一行的內容
    • $return_var: 取得系統狀態回傳碼
  • exec()
    • exec('ls', $output, $return_var);
    • $output: 回傳內容都會存於此變數中(儲存成陣列), 不會直接秀在頁面上.
    • $return_var: 取得系統狀態回傳碼
  • shell_exec()
    • $output = shell_exec('ls');
    • $output: 回傳內容都會存於此變數中(儲存成純文字內容), 不會直接秀在頁面上.

www-data        ALL=(ALL) NOPASSWD: /usr/bin/amixer


Reference:

nginx dependent file


        sudo apt-get install nginx nginx-common nginx-core fcgiwrap php7.0 apache2-utils
        sudo systemctl restart php7.0-fpm nginx
        #systemctl status nginx.service

.htpasswd add script


        sudo htpasswd -cb /etc/nginx/cam.htpasswd root pass