1. 程式人生 > >從零開始學Ubuntu心得

從零開始學Ubuntu心得

從零開始學ubuntu(學習心得) 2011-09-09 17:03:17

標籤:ubuntu 學習心得 從零開始

    2011.8.1開始至今,對著ubuntu,玩機、學習基本命令。看了兩本書後,大概到8月底就開始玩開發板。開發板是友善的mini2440,將開發板與電腦相關起來就幾乎花了一個星期。

    一 、由於對作業系統的超級終端之前一點概念都沒有,在ubuntu下查詢資料才知道,有三個選擇:minicom、kermit、gtkterm。我選擇了minicom。根據手冊配置好。安裝了lrzsz軟體包:

$sudo apt-get install lrzsz

通過串列埠用xmodem協議寫核心時會提示沒有xmodem協議。

    到這裡,在終端也只可以看到:

$minicom

welcom to minicom 2.4

options:I18n

compiled on Jan 25 2010,06:49:09

port/dev/ttyusb0

press ctrlA Z for help on special keys

    央求男友幫忙檢查,才發現串列埠(我是用usb轉串列埠+兩頭都是母頭的串列埠線連結)根本沒有連通,測試之後才知道我用的是交叉線(即線內部已經交叉連線了)。更改之後,開發板開機,在minicom終端下,有顯示系列資訊了!!

    二、 搭建交叉編譯環境arm-linux-gcc

2011.9.5

    1.將arm-linux-gcc-4.3.2.tgz複製到 /tmp路徑下

   2.在終端安裝標準C開發環境,

    sudo apt-get install build-essential libncurses5-dev

  3.進入/usr/local/arm/4.3.2 目錄,先將該目錄許可權修改為“777”,再

sudo tar -zxvf arm-linux-gcc-4.3.2.tgz -C /(c是大寫,空格再反斜槓)

這樣會自動解壓到/usr/local/4.3.2目錄下。

PS:我就是沒有修改許可權,繞了一點彎路。解壓的時候,報錯!

4.修改環境變數

1) sudo gedit /root/.bashrc 文末新增

export PATH=$PATH:/usr.local/arm/4.3.2/bin

儲存退出。

2********)sudo vi /etc/bash.bashrc

文末加:

if [空格-d空格/usr/local/arm/空格];then

   PATH=/usr/local/arm/bin:"${PATH}"

fi

3)修改profile:

sudo vi /etc/profile

文末加:

export PATH=$PATH:/usr.local/arm/4.3.2/bin

使其生效:

source /etc/profile

驗證:

echo $PATH

回顯:/usr/local/arm/bin;......

到此,執行arm-linux-gcc -v

顯示:arm-linux-gcc的第3行:exec:arm-none-linux-gnueabi-gcc未 找到。

煩!!!這個時候就要回過去找問題了。網上搜索的人們也有遇到此問題的,但沒有直接的答案。我看他們的執行命令,這個我自認不如人家。發現,在/usr/local/arm/4.3.2/bin下面真的有個arm-none-linux-gnueabi-gcc,也有arm-linux-gcc等 檔案,可是它幹嘛說找不到呢?我就 開啟 arm-linux-gcc

cat /usr/local/arm/4.3.2/bin/arm-linux-gcc

內容為: exec:arm-none-linux-gnueabi-gcc -march=armv4t $*

修改為: exec: /usr/local/arm/bin/arm-none-linux-gnueabi-gcc -march=armv4t $*

執行: arm-linux-gcc

錯誤還在!!

以下兩種方式都不報錯:

1) $ /usr/local/arm/bin/arm-none-linux-gnueabi-gcc -v

2) $ /usr/local/arm/bin/arm-linux-gcc -v

細心的 親們,一定已經發現了問題所在了吧。在檢視$PATH時返回的資訊,路徑為/usr/local/arm/bin,而在此路徑是沒有/bin的。修改為/usr/local/arm/4.3.2/bin的PATH問題就解決了!!!

三、這是最讓我頭疼的,配置NFS服務

環境:ubuntu10.4

ifconfig:

inet addr:192.168.0.2 bcast:192.168.0.255 mask:255.255.255.0

1)設定共享目錄

  $sudo gedit /etc/exports

第一次開啟為空白,如下新增內容:

/opt/FriendlyARM/mini2440/root_qtopia/  *(rw,sync,no_root_squash)



修改許可權:
chmod 777 -R

/opt/FriendlyARM/mini2440/root_qtopia/

2)安裝NFS

sudo apt-get install nfs-kernel-server (apt同時也安裝了nfs-common portmap)

3)配置nfs

 a. sudo gedit /etc/default/portmap

將末行“-i 127.0.0.1”去掉-i 127.0.0.1為“”。

b. sudo dpkg-reconfigure portmap

對should portmap be bound to the loopback address?

選N

c. 配置/etc/hosts.deny

sudo gedit /etc/hosts.deny(禁止任何主機host與你的nfs伺服器進行nfs連結)

末行新增:

###NFS DAEMONS

ALL:ALL

配置/etc/hosts.allow

sudo gedit /etc/hosts.allow

文末新增:

###NFS DAEMONS

portmap:192.168.0.

lockd:192.168.0.

mountd:192.168.0.

rquotad:192.168.0.

statd:192.168.0.

nfsd:192.168.0.



$ sudo /etc/init.d/portmap restart 重啟portmap daemon.
顯示如下
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restart portmap
portmap start/running, process   XXXX



$ sudo showmount -e
顯示 clnt-create : RPC : Program not registered

$ sudo   exportfs -r 更新

$ sudo  showmount 192.168.0.2 -e
顯示
Export list for 192.168.0.2:

/opt/FriendlyARM/mini2440/root_qtopia/

*

六 啟用
   $ sudo /etc/init.d/nfs-kernel-server restart 重啟nfs服務
顯示如下
* Stopping NFS kernel daemon                                                      [ OK ]
* Unexporting directories for NFS kernel daemon...                   [ OK ]
* Exporting directories for NFS kernel daemon...                           
   exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:
/opt/FriendlyARM/mini2440/root_qtopia/

".
   Assuming default behaviour ('no_subtree_check').
   NOTE: this default has changed since nfs-utils version 1.0.x
                                                                        

* Starting NFS kernel daemon                                                          [ OK ]

掛載
mount -t nfs 192.168.0.2:
/opt/FriendlyARM/mini2440/root_qtopia/   /nfsmnt
mount -t nfs 192.168.0.2:
/opt/FriendlyARM/mini2440/root_qtopia/    /nfsmnt   -o nolock

雖然還不知道能不能在開發板上用,今天終於初見端倪,在主資料夾下/nfsmnt找到了想要的內容!!

明天就是教師節啦,祝老師們節日快樂!

2011年的中秋節前夕寫一篇博文,以勉勵 吾輩。中秋快樂!


有一絕好的配置NFS的網址推薦:

http://mostlylinux.wordpress.com/network/nfshowto/#step01

ps:有關ping實用命令 (以下為轉載)

舉例說明
ping就是對一個網址傳送測試資料包,看對方網址是否有響應並統計響應時間,以此測試網路。   
具體方式是,開始--執行--cmd,在調出的dos視窗下輸入 ping 空格 + 你要ping的網址,回車。   
比如 “ ping XXX網址” 之後螢幕會顯示類似資訊   
Pinging XXX 網址 [61.135.169.105] with 32 bytes of data:   
Reply from 61.135.169.105: bytes=32 time=1244ms TTL=46   
Reply from 61.135.169.105: bytes=32 time=1150ms TTL=46   
Reply from 61.135.169.105: bytes=32 time=960ms TTL=46   
Reply from 61.135.169.105: bytes=32 time=1091ms TTL=46   
後面的time=1244ms 是響應時間,這個時間越小,說明你連線這個地址速度越快。
本段PING測試
  
1.Ping本機IP   
例如本機IP地址為:172.168.200.2。則執行命令Ping 172.168.200.2。如果網絡卡安裝配置沒有問題,則應有類似下列顯示:   
Reply from 172.168.200.2 bytes=32 time<10ms   
Ping statistics for 172.168.200.2   
Packets Sent=4 Received=4 Lost=0 0% loss   
Approximate round trip times in milli-seconds   
Minimum=0ms Maxiumu=1ms Average=0ms   
如果在MS-DOS方式下執行此命令顯示內容為:Request timed out,則表明網絡卡安裝或配置有問題。將網線斷開再次執行此命令,如果顯示正常,則說明本機使用的IP地址可能與另一臺正在使用的機器IP地址重複了。如果仍然不正常,則表明本機網絡卡安裝或配置有問題,需繼續檢查相關網路配置。   
2.Ping閘道器IP   
假定閘道器IP為:172.168.6.1,則執行命令Ping 172.168.6.1。在MS-DOS方式下執行此命令,如果顯示類似以下資訊:   
Reply from 172.168.6.1 bytes=32 time=9ms TTL=255   
Ping statistics for 172.168.6.1   
Packets Sent=4 Received=4 Lost=0   
Approximate round trip times in milli-seconds   
Minimum=1ms Maximum=9ms Average=5ms   
則表明區域網中的閘道器路由器正在正常執行。反之,則說明閘道器有問題。   
3.Ping遠端IP   
這一命令可以檢測本機能否正常訪問Internet。比如本地電信運營商的IP地址為:202.102.48.141。在MS-DOS方式下執行命令:Ping 202.102.48.141,如果螢幕顯示:   Reply from 202.102.48.141 bytes=32 time=33ms TTL=252   
Reply from 202.102.48.141 bytes=32 time=21ms TTL=252   
Reply from 202.102.48.141 bytes=32 time=5ms TTL=252   
Reply from 202.102.48.141 bytes=32 time=6ms TTL=252   
Ping statistics for 202.102.48.141   
Packets Sent=4 Received=4 Lost=0 0% loss   
Approximate round trip times in milli-seconds   
Minimum=5ms Maximum=33ms Average=16ms   
則表明執行正常,能夠正常接入網際網路。反之,則表明主機檔案(windows/host)存在問題。