2010年12月24日 星期五

linux下/dev/shm是什麼?



   默認系統就會載入/dev/shm ,它就是所謂的tmpfs,有人說跟ramdisk(虛擬磁片),但不一樣。象虛擬磁片一樣,tmpfs 可以使用您的 RAM,但它也可以使用您的交換分區來存儲。而且傳統的虛擬磁片是個塊設備,並需要一個 mkfs 之類的命令才能真正地使用它,tmpfs 是一個檔系統,而不是塊設備;您只是安裝它,它就可以使用了。

  tmpfs有以下優勢:
  1,動態檔系統的大小。

  2tmpfs 的另一個主要的好處是它閃電般的速度。因為典型的 tmpfs 檔系統會完全駐留在 RAM 中,讀寫幾乎可以是瞬間的。

  3tmpfs 資料在重新啟動之後不會保留,因為虛擬記憶體本質上就是易失的。所以有必要做一些腳本做諸如載入,綁定的操作。

  好了講了一些大道理,還是講講應用吧:

  首先在/dev/stm建個tmp檔夾,然後與實際/tmp綁定

  mkdir /dev/shm/tmp
  chmod 1777 /dev/shm/tmp
  mount --bind /dev/shm/tmp /tmp--bind

  在使用mount --bind olderdir newerdir命令來掛載一個目錄到另一個目錄後,newerdir的許可權和所有者等所有資訊會發生變化。掛載後的目錄繼承了被掛載目錄的所有屬性,除了名稱。

linux 安裝chrome和java plugin

這裡下載chrome
dpkg -i google-chrome-stable_current_i386.deb
然後安裝java plugin


sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-plugin
cd /opt/google/chrome/
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386/libnpjp2.so
這樣就ok了
可以到這裡測試你的java有沒有安裝成功

2010年12月22日 星期三

VT switching with Ctrl-Alt-Fn not working

VT switching with Ctrl-Alt-Fn not working


On upgrading the X installation on the only one of my boxes to actually have a keyboard attached to it - first from a woody backport of 4.3.0 to the sarge 4.3.0, then on to xorg 6.8.2 from sid (see here for details) - I was horrified to find that I could no longer switch from X to a text console by hitting Ctrl-Alt-Fn. I like my text consoles, so a solution was urgently required.

The solution turned out to be remarkably simple. My responses to the configuration questions posed by debconf during installation had resulted in the entry
    Option    "XkbLayout"    "uk"
in /etc/X11/xorg.conf. This appeared to work in the sense that there were no keyboard mapping errors reported in /var/log/Xorg.0.log and the punctuation characters including the pound sign all worked and were on the right keys. However, the VT switching didn't work... There were also no files named "uk" under /etc/X11/xkb/symbols/ which I found a little puzzling.

The solution was to change the entry in /etc/X11/xorg.conf to
    Option    "XkbLayout"    "gb"
The gb files under /etc/X11/xkb/symbols/ in my installation are here:
/etc/X11/xkb/symbols/gb
/etc/X11/xkb/symbols/pc/gb
/etc/X11/xkb/symbols/pc/pc
I am using a 102-key UK-layout keyboard. It may be significant that the other people who had been having this problem according to Google mostly seemed to have non-US keyboard layouts. Since I discovered the solution by fiddling about rather than by understanding how X keyboard mapping actually works, I'm not sure quite why it did work, but it may be useful for people with this problem to compare the files their X installation is using with the versions I'm using and see if there are any significant differences.

If anyone knows of any hook in X that may be used to execute an arbitrary file when switching to a text console, please contact me. At present I have to reset the framebuffer manually after switching to a text console otherwise the display screws up. A hook to enable me to do this automatically would be great, but AFAICT there's no way to do it without hacking the X source, and I can't be arsed to do that yet.

2010年12月21日 星期二

Xorg 設定硬體方式

http://mbetter.net.ru/node/16

Ubuntu Linux的SSH遠端連線

Ubuntu Linux的SSH遠端連線

SSH Server 遠端連線方式

透過 telnet 進行遠端登入是系統管理這最常使用的方式 ,
但是它有安全性上的缺點存在;因此,另一種方法則是透過ssh的方式進行遠端登入。
要進行SSH遠端登入,可以透過 Putty 或 Pietty 等遠端連線軟體連線進行連線。
但是前題是在 Ubuntu Linux Server 上必須支援 SSH Server。
而最方便的是安裝 OpenSSH Server。

裝openssh-server
如果你沒有安裝ubuntu時沒有安裝openssh,請以終端機介面輸入以下的指令來做安裝

sudo apt-get install openssh-server

接下來
輸入以下指令來檢查 ssh-server 是否有執行,
ps aux | grep ssh
啟動 ssh-server 的指令是,
sudo /etc/init.d/ssh start   
或重新啟動的指令是,
sudo /etc/init.d/ssh restart 

遠端 Client 端連線方式
遠端Client是Linux,則質借透過終端機下指令,
sudo ssh localhost -p 22 -l root
如果遠端Client是Windows,那就必須透過應用軟體,如 Putty Pietty

為了安全性考量,建議將預設的port 22改為port 22222
修改完成之後,請存檔並離開
sudo vim /etc/ssh/sshd_config 
再來找到
# What ports, IPs and protocols we listen for (約第4、5行)
Port 22 
可將預設的port改成系統未在使用的port,因為系統預設都會有一些連接port,例如:ftp是port21、web是port80、smtp是port25、ssh是port22、telnet是port23等等,那你要怎麼知道哪些被使用呢?鍵入下列的指令吧。
(port的內容相當多,在一個區段內找一個數字,只要在services當中沒出現的即可)

sudo less /etc/services

例如:22222這個port系統沒有使用,那你就將22改成22222,那這樣在連ssh時就必須將port改成22222,若維持22是連不進去的。
 修拐完成Port後,必須重新啟動OPENSSH Server
sudo /etc/init.d/ssh restart  
其他,


限制IP登入
再來,我們要修改可以登入這台主機的ip,否則任可一個ip都可以利用帳號登入,這是基本的防護。

sudo vim /etc/hosts.allow
在最下方加入
sshd:xxx.xxx.xxx.xxx :allow

xxx就是指你的ip位置,包含你遠端要登入的ip(一般ADSL浮動ip則不適用,此方法只適用固定IP)。

拒絕所有IP登入
當你允許了你指定的IP可以登入,那其他的浮動IP就不讓他們登入了,避免不必要的麻煩和攻擊,

sudo vim /etc/hosts.deny
加入 sshd:all:deny

如此一來,除了你允許的IP之外,其他的浮動IP就連不進來

sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
一樣修改完成後,要重新啟動喔!

2010年12月20日 星期一

busybox開發日記


配置busybox
[root@localhost busybox­1.1.3]#  make menuconfig
Busybox Settings  ­­­> 
General Configuration  ­­­>
[*] Support --install [-s] to install applet links at runtime /*init腳本中用到--install*/
[*] Support for devfs 
Build Options  ­­­> 
[*] Build BusyBox as a static binary (no shared libs)
/*  busybox 編譯為靜態連接,少了啟動時找動態庫的麻煩 ,但不能DNS了(即ping www位址時找不到服務了),故在此我選擇動態連接*/
[*] Do you want to build BusyBox with a Cross Compiler? 
(/opt/crosstool/arm-linux/gcc-3.4.4-glibc-2.3.5/arm-linux/bin/arm-linux-) Cross Compiler prefix
/* 指定交叉編譯工具路徑 */

Installation Options  --->
   [ ] Don't use /usr     //說明是否也按裝到usr目錄下,不選表也按裝到usr目錄下
      Applets links (as soft-links)  ---> 
(/home/wang/bak/source/arm-linux-2.6/target/busybox-1.1.3/rootfs_src) BusyBox installation prefix
/* 指定busybox編譯後按裝路徑 */

Init Utilities  ­­­>
[*] init
[*] Support reading an inittab file
    /* 支援 init 讀取/etc/inittab 配置檔,一定要選上 */
Shells  ­­­> 
Choose your default shell (ash)  ­­­>
  /* (X) ash 選中 ash,這樣生成的時候才會生成 bin/sh
   * 看看我們前頭的 linuxrc 腳本的頭一句:
   * #!/bin/sh 是由 bin/sh 來解釋執行的
*/
[*] ash   
[* ]   command line editing //shell中命令的自動補全和命令可編輯還是挺方便的。這些功能在busybox1.5以前shell'command line editing'項在shell的選項內,但是從1.5開始這個選項已經移到'Busybox Settings -> Busybox Library Tuning'中了,如果要在1.5以後的版本中修改相應的選項要在新的地方修改。
 Coreutils  ­­­>
[*] ls
[*] pwd 
Editors  ­­­>  [*] vi 
Linux System Utilities  ­­­> 
[*] mount 
[*] umount

2010年12月4日 星期六

電影裡的愛情故事

每個電影中都有個愛情故事

兩個人一起跟著某個目標努力

進而產生深厚的感情

只是有些結局是完美的  有些則是慘痛的

看電影體會著不同的人生  想想自己需要的人生

努力吧  ~~

Plurk