Tuesday, April 29, 2014

Source Insight 使用注意事項

除了一開始建project外
打開發現找不到symbol不能trace code的主要原因
應該是.......

Synchronize Files...    (Alt + Shift +S)

切記啊啊啊!!!

Wednesday, April 23, 2014

VIM用滑鼠複製貼上

複製:
  • 在任何模式下,用滑鼠先框選欲複製之目標文字,按Shift+Ctrl+C
貼上:
  • 進入編輯模式(鍵盤按i, a,o ...),在按Shift+Ctrl+V,即可貼上

ps. 如果複製完離開VIM,直接按Ctrl+V即可貼上(與VIM環境不同唷!!!)


Friday, April 18, 2014

用軟連結(ln -s)來分享Linux資料到Windows的samba上

相信有很多用了samba的人都會有這個小問題,想要不移動檔案但是讓Windows可以參照到Linux下的檔案,經過研究後,其實步驟很簡單,方法如下:

請參考連結
http://blog.ixxoo.me/samba.html

Thursday, April 17, 2014

簡單避免Linux被入侵的方法

設定不許登入的電腦(/etc/hosts.deny):
======================================
正常的情況下
Linux 會先判斷 hosts.allow
檔案中的電腦如果設定為可連線的話
則 hosts.deny 就不會被使用
因此,設定好了 hosts.allow 之後
將 /etc/hosts.deny 設定為『所有電腦都不許登入』

$ sudo nano /etc/hosts.deny
in.telnetd: ALL : Deny
sshd: All: Deny
sendmail: All: Deny

存檔
 禁止 root 帳號透過 ssh 登入
======================================
sshd_config 內的 PermitRootLogin 設成 no
$ sudo nano /etc/ssh/sshd_config
PermitRootLogin no

存檔
重開機

Important information for Linux

The system file /etc/passwd contains a database dealing with user accounts. It consists of lines, one per user, that contain the username, encrypted password, user identifier (UID), group identifier (GID), full name, home directory, and default shell. Here’s an example line:

neil:zBqxfqedfpk:500:100:Neil Matthew:/home/neil:/bin/bash

If you write a program that determines the UID of the user who started it, you could extend it to look in the password file to find out the user’s login name and full name. We don’t recommend this because modern UNIX-like systems have moved away from using simple password files to improve system security. Many systems, including Linux, have the option to use shadow password files that don’t contain any useful encrypted password information at all (this is often held in /etc/shadow, a file that ordinary users cannot read).

Additionally, I also suggest that reader can refer to [2] to comprehend the details of shadow file.

Reference:

  1. Neil Matthew and Richard Stones, Beginning Linux Programming, 4/e, Wiley Publishing, Inc, 2007, page 191.
  2. /etc/shadow檔案結構. [Online]. Available: http://linux.vbird.org/linux_basic/0410accountmanager.php#shadow_file

Tuesday, April 8, 2014

Ubuntu 網路IP的設定方式

要如何在Ubuntu改成固定的ip設定呢?

請先用指令看網路的編號
ifconfig

接著請用指令開啟
sudo vim /etc/network/interfaces

然後把原本加入以下的內容 (下面的eth3請依照ifconfig使用的ethernet port修正)
auto eth3
iface eth3 inet static
address 172.24.80.1xx
netmask 255.255.255.0
gateway 172.24.80.253
dns-nameservers 172.24.80.253


ps. 如果是用虛擬機器(如VirtualBox),請依照以下的方法修改

1)先按"設定值"
 2)再修正NAT為網接介面卡(Bridge Interface),並在名稱(N)中選擇正確可以對外連線的網卡



--------
除此之外,如果要設定成內網的話,可以使用以下的方式:
然後把原本加入以下的內容 (下面的eth3請依照ifconfig使用的ethernet port修正,Getway跟DNS可以不用設定)
auto eth3
iface eth3 inet static
address 192.168.1.1
netmask 255.255.255.0

--------
關於DHCP的設定方式
auto eth1
iface eth1 inet dhcp
netmask 255.255.255.0
gateway 172.24.80.254

dns-nameservers 172.24.80.253 172.24.80.254

Wednesday, April 2, 2014

紀錄一下最近很常用到的一些縮寫名詞(常忘=.=)


  1. CAWAP: Control And Provisioning of Wireless Access Points
    http://en.wikipedia.org/wiki/CAPWAP
  2. IPC Socket: Inter-Process Communication Socket, also called "Domain Socket"
    http://en.wikipedia.org/wiki/Unix_domain_socket
  3. DCS: Dynamic Channel Selection

Tuesday, April 1, 2014

上高斯(ceiling function) in C programming

假設有一可變大小的封包(packet),會被MAC切成固定48 bytes大小的訊框(frame),如何計算這個封包需要多少個訊框來裝載呢?

答案 :

可以運用int的特性,以兩個極端的例子來說 packet_size #1=96 bytes, packet_size #2=97bytes
依照判斷pkt #1是切成2個訊框,pkt #2是切成3個訊框,應該怎麼寫呢?

C語言寫法如下:
    frame_number = (int) (packet_size + 47)/48
即可得到上面所需的答案囉!!

另外,也可以把它寫成函數的方式來呈現
#define PKT_SIZE 48 /* the maximum packet size */ 

/* calculate the number of packets */
int cal_pkt_number(int packet_size)
{
    return (int) (packet_size+PKT_SIZE-1)/PKT_SIZE
}

int main(void)
{
    int curr_pkt_size = 47;
    int pkt_no;
    
    pkt_no = cal_pkt_number(curr_pkt_size);
    printf("The number of packets is %d\n", pkt_no);
}