2017年11月19日 星期日

add crontab list with command

Add a command
crontab -l | { /bin/echo "* 3 * * * aplay /home/ubuntu/321.wav;" } | crontab -
Multiple commands
crontab -l | { /bin/cat; /bin/echo "* 3 * * * aplay /home/ubuntu/321.wav; ls -alh"; } | crontab -
Add more commands
crontab -l | { crontab -l; /bin/echo "* 3 * * * aplay /home/ubuntu/321.wav ;"} | crontab -
Add more commands with index
crontab -l | { crontab -l; /bin/echo "* 3 * * * aplay /home/ubuntu/321.wav #index_1;"} | crontab -
Remove specific command
crontab -u mobman -l | grep -v 'index_1'  | crontab -u mobman -
Remove all
crontab -r
ref:
stackoverflow
stackoverflow

2017年11月15日 星期三

wifi hotspot / AP

環境: ubuntu 14.04
DHCP Server
1. sudo aptigude install isc-dhcp-server
2. sudo vim /etc/default/isc-dhcp-server
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth0"
/etc/dhcp/dhcpd.conf
ddns-update-style none;

#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

log-facility local7;

subnet 192.168.1.0 netmask 255.255.255.0 {
  range dynamic-bootp 192.168.1.192 192.168.1.240;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.1.255;
#  option routers 10.5.5.1;
}
reboot, use ifconfig to check eth0 after booting
Hostapd
1. download hostapd2.6
2. sudo aptitude install libnl-dev, libssl-dev
3. cd hostapd and make
4. sudo ./hostapd hsot.conf
host.conf - no security
(refer usr/share/doc/hostapd/examples/hostapd.conf.gz)
interface=wlan1
driver=nl80211

logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2

ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=test
hw_mode=g
channel=6
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0
own_ip_addr=127.0.0.1

2017年10月22日 星期日

設定音效卡的輸出輸入(Sound and Micphone)

因為Sound和Micphone有多個可以選,所以需要設定一下:
Sound:
    $ pacmd list-sinks | grep -e 'name:' -e 'index'
Micphone:
    $ pacmd list-sources | grep -e 'name:' -e 'index'
ex:
    index: 0
 name: <alsa_output .pci-0000_00_03.0.hdmi-stereo.monitor>
    index: 1
 name: <alsa_output .pci-0000_00_1b.0.analog-stereo.monitor>
  * index: 2
 name: <alsa_input .pci-0000_00_1b.0.analog-stereo=>
有 "*" 代表目前的設定值
用 pacmd 來改選擇設定
Sound:
    $ pacmd set-default-sinks "device_info"
Micphone:
    $ pacmd set-default-sources "device_info"
ex:
$ pacmd set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo
寫入系統設定:
$ vim /etc/pulse/default.pa
...
...
最後兩行, 在這裡設定以後開機就可以了
#set-default-sink output
#set-default-source input
但,麻煩的事,如果設定好後,
系統開機時抓不到該硬體,設定就會跑掉,需要再次手重設定

ref : Archlinux - pulseaudio