顯示具有 FreeBSD 標籤的文章。 顯示所有文章
顯示具有 FreeBSD 標籤的文章。 顯示所有文章

2011年8月28日 星期日

Ubuntu上使用Dropbox

X86.tar.gz   X64.tar.gz   Deb or Rpm

最近Dropbox非常熱門,用來儲存文件非常方便,將來非常有可能取代隨身碟,而且適用於多種平台,特別是使用在手機上非常方便。

Deb或RPM安裝就不介紹了,點了就可以安裝,以下介紹的是用壓縮檔安裝。

1.開啟終端機 下載壓縮檔

$ wget http://www.dropbox.com/download/?plat=lnx.x86

 

2. 解壓縮同目錄 下載後的 tar.gz

$ tar zxvf dropbox-lnx.x86-1.1.43.tar.gz

 

3.執行同目錄下的 dropboxd

$ ./.dropbox-dist/dropboxd

 

4.出現下列訊息 並登入

Please visit https://www.dropbox.com/cli_link?host_id=f58c94b1bca468309bb218c04dc706ac&cl=en_US to link this machine.

 

5.終端機會出現 代表成功了...

Client successfully linked, Welcome Bohan!

 

註:預設Dropbox在使用者目錄下 ~/Dropbox,進去就可以看到目錄下有你的資料了。

2011年4月24日 星期日

如何在 Linux 架設 Samba 網路芳鄰分享檔案

Linux : Ubuntu、Ubuntu Server

Windows : Windows 7

 

1.安裝Samba

# sudo apt-get install samba

 

2.備份smb.conf

# cp /etc/samba/smb.conf /etc/samba/smb.conf-bak

 

3.新增使用者(有兩種)

使用舊的版本

# smbpasswd –a user

完成後密碼檔在/etc/samba/smbpasswd

smbpasswd –h 可以查看更多參數

使用新的版本

# pdbedit –a user

完成後可用pdbedit –L 看目前使用者

pdbedit –x 刪除使用者

 

4.編輯smb.conf

# vim /etc/samba/smb.conf

 

1 [global]

2 workgroup = BohanSamba

3 netbios name = BohanPC

4 security = user

5

6 [share]

7 path = /home/download/

8 valid users = download

9 read only = no

10 browseable = yes

11 create mask = 0755
12 directory mask = 0755

 

5.重新啟動samba(有兩種)

使用舊的版本

# /etc/init.d/samba restart

使用新的版本

# sudo service smbd restart

# sudo service nmbd restart

 

6. 輸入IP 帳號 密碼

\\ yourip

windows7samba

7.刪除連線

開啟命令提示字元輸入

net use * /delete

2011年4月4日 星期一

rsync 資料同步 Linux->Linux Linux->Windows Windows->Linux Windows–>Windows

Linux : Ubuntu

Windows : Win7

Linux->Linux

1.安裝rsync套件

$ sudo apt-get install rsync

2.Linux來源 (source) –> Linux目的 (destination)

$ rsync -avzHS –delete --stats --ignore-errors --progress download@IP:/home/download/data/ /home/bohan/data/

3.Linux目的 (destination) –> Linux來源 (source)

$ rsync -avzHS –delete --stats --ignore-errors --progress /home/bohan/data/ download@IP:/home/download/data/

4.自定義rsync.sh方便資料同步、備份

rsync.sh內容

1 #!/bin/bash

2 sourcedir=/home/download/data/

3 destinationdir=/home/bohan/data/

4 host=ip

5 id=download

6 rsync -avzHS --delete --stats --ignore-errors --progress ${id}@${host}:${sourcedir} ${destinationdir}

Linux->Windows

1.Linuxrsync套件
$ sudo apt-get install rsync
2.Windowscwrsync
到這個頁面下載cwrsync.exe安裝
3.Linux來源 (source) -> Linux目的 (destination)
打開Windows命令提示字元,貼上下列命令
"C:\Program Files\cwRsync\bin\rsync.exe" -avzHS --delete --ignore-errors --progress --stats --rsh='"C:\Program Files\cwRsync\bin\ssh" -p 22'  download@IP:/home/download/data/ /cygdrive/c/Users/bohan/Desktop/data/
4.Linux目的 (destination) –> Linux來源 (source)
"C:\Program Files\cwRsync\bin\rsync.exe" -avzHS –delete --ignore-errors --progress --stats --rsh='"C:\Program Files\cwRsync\bin\ssh" -p 22' /cygdrive/c/Users/bohan/Desktop/data/ download@IP:/home/download/data/

Windows->Linux

Linux->Windows步驟相反即可

Windows->Windows

1.開啟命令提示字元

"C:\Program Files\cwRsync\bin\rsync.exe" -avzHS --delete --ignore-errors –progress --stats /cygdrive/c/source /cygdrive/d/destination

 

/cygdrive/c/ 代表Windows作業系統的C槽,D槽可用/cygdrive/d/,以此類

--delete 刪除傳送端已經不存在,而目的端存在的檔案,怕檔案被複寫可改成

--ignore-existing 忽略目的端已經存在的檔案(也就是不更新)。

※ 更多參數可以用 man rsync、rsync –h這裡

2011年1月18日 星期二

Ubuntu上安裝Squid Proxy Server

1.開啟終端機,安裝Squid

 

# sudo apt-get install squid

 

2. 備份Squid設定檔,改失敗了可以回復

 

# cp /etc/squid/squid.conf /etc/squid/squid.conf.bak

 

3.修改squid.conf

 

加入visible_hostname

visible_hostname spyker729-desktop

 

加入webmaster 管理者mail

cache_mgr spyker729@gmail.com

 

將去除下列設定 前面的井號

# cache_mem 8 MB

# cache_swap_low 90

# cache_swap_high 95

# maximum_object_size_in_memory 1024 KB (容量自訂)

# ipcache_size 1024

# ipcache_low 90

# ipcache_high 95

# fqdncache_size 1024

 

4.重新啟動Squid

 

# sudo /etc/init.d/squid restart

到這裡即可在瀏覽器使用 proxy,IP為架設機器的 IP,port為3128 (squid.conf可更改)

 

5.加入htpasswd認證,需要照號密碼才能使用proxy

 

更改squid.conf,加入下列命令存檔

77          auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

570        acl password proxy_auth REQUIRED

571         http_access allow password

 

6.設定帳號密碼

 

# htpasswd –c /etc/squid/passwd 帳號

 

謝謝收看!

2011年1月17日 星期一

用Webmin管理Linux系統

1.安裝webmin

到這裡下載 rpm,tar,deb http://www.webmin.com/download.html

2.安裝成功 (用deb安裝)
Screenshot-gdebi-gtk

3.進入Webmin

瀏覽器上輸入http://YourIP:10000

點選藍色連結

webmin
憑證不用理會它
webmin2
root的帳號密碼為登入帳密
webmin3
登入畫面與語言介面修改
webmin4
webmin5webmin6webmin7
謝謝收看 !

2010年11月20日 星期六

如何在FreeBSD上安裝MySQL?

1.先參考前一篇寫的如何在FreeBSD上安裝Apache+Php?

2.安裝MySQL-Server

# cd /usr/ports/databases/mysql51-server

# make WITH_CHARSET=utf8 WITH_XCHARSET=all

# make install

安裝成功

You already have a group "mysql", so I will use it.

mysql:*:88:88::0:0:MySQL Daemon:/nonexistent:/sbin/nologin

You already have a user "mysql", so I will use it.

************************************************************************

Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)

the first time you start the MySQL server after an upgrade from an

earlier version.

************************************************************************

install-info --quiet /usr/local/info/mysql.info /usr/local/info/dir

===> Installing rc.d startup script(s)

===> Compressing manual pages for mysql-server-5.1.33

===> Registering installation for mysql-server-5.1.33

===> SECURITY REPORT:

This port has installed the following files which may act as network

servers and may therefore pose a remote security risk to the system.

/usr/local/libexec/mysqld

This port has installed the following startup scripts which may cause

these network services to be started at boot time.

/usr/local/etc/rc.d/mysql-server

If there are vulnerabilities in these programs there may be a security

risk to the system. FreeBSD makes no guarantee about the security of

ports included in the Ports Collection. Please type 'make deinstall'

to deinstall the port if this is a concern.

For more information, and contact details about the security

status of this software, see the following webpage:

http://www.mysql.com/

2.安裝Php5-MySQL

# cd /usr/ports/databases/php5-mysql

# make

# make install

安裝成功

===> Installing for php5-mysql-5.2.9
===> php5-mysql-5.2.9 depends on file: /usr/local/include/php/main/php.h - found
===> php5-mysql-5.2.9 depends on shared library: mysqlclient.14 - found
===> Generating temporary packing list
===> Checking if databases/php5-mysql already installed
===> Registering installation for php5-mysql-5.2.9
****************************************************************************
The following line has been added to your /usr/local/etc/php/extensions.ini
configuration file to automatically load the installed extension:
extension=mysql.so
****************************************************************************

3.讓開機啟動MySQL

# vi /etc/rc.conf

加入mysql_enable=”yes”

4.匯入資料庫 與 設定MySQL密碼

參考之前的文章

(1) Ubuntu 如何用指令匯出 MySQL 的資料庫?

(2) Ubuntu 裡重新設定 MySQL root 密碼

“FreeBSD 停止/啟動 MySQL服務路徑為 /usr/local/etc/rc.d/mysql-server”

5.安裝phpmyadmin

# cd /usr/ports/databases/phpmyadmin

# make

# make install

"建議去官網下載 並解壓到 /usr/local/www/apache22/data/ 會比較快"

6.測試畫面

MySQLphpmyadmin

如何在FreeBSD上安裝Apache+Php?

FreeBSD Version : 7.2
1.切換成 root 權限
# su
2.安裝 Apache
# cd /usr/ports/www/apache22
# make config (想要什麼功能在這裡選擇 Mysql記得勾選 方便日後升級)
# make
# make install (建議make install分開做)
 
成功安裝訊息
Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch typically DNS or /etc/hosts or apache might
have issues starting depending on the modules you are using.
===> Installing rc.d startup script(s)
===> Compressing manual pages for apache-2.2.11_4
===> Running ldconfig
/sbin/ldconfig -m /usr/local/lib
===> Registering installation for apache-2.2.11_4
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/lib/libapr-1.so.3
This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/apache22
/usr/local/etc/rc.d/htcacheclean
If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.
For more information, and contact details about the security
status of this software, see the following webpage:
http://httpd.apache.org/
 
3.安裝 Php (php5 & php5-extension)
# cd /usr/ports/lang/php5
# make config (想要什麼功能在這裡選擇)
# make
# make install
 
成功安裝訊息
***************************************************************
Make sure index.php is part of your DirectoryIndex.
You should add the following to your Apache configuration file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
***************************************************************
===> Compressing manual pages for php5-5.2.9
===> Registering installation for php5-5.2.9
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/apache22/libphp5.so
/usr/local/bin/php
/usr/local/bin/php-cgi
If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.
For more information, and contact details about the security
status of this software, see the following webpage:
http://www.php.net/
 
# cd /usr/ports/lang/php5-extensions
# make config
# make
# make install
 
成功安裝訊息
===> Returning to build of php5-extensions-1.3
===> Configuring for php5-extensions-1.3
===> Installing for php5-extensions-1.3
===> php5-extensions-1.3 depends on file: /usr/local/include/php/main/php.h - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/bz2.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/ctype.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/dom.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/filter.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/ftp.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/hash.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/iconv.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/json.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/mssql.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/mysql.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/mysqli.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/ncurses.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/odbc.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/pcre.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/pdo.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/pdo_sqlite.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/posix.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/session.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/simplexml.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/snmp.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/sockets.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/spl.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/sqlite.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/tokenizer.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/xml.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/xmlreader.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/xmlwriter.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/zip.so - found
===> php5-extensions-1.3 depends on file: /usr/local/lib/php/20060613/zlib.so - found
===> Generating temporary packing list
===> Checking if lang/php5-extensions already installed
===> Registering installation for php5-extensions-1.3
 
4.Apache 基本設定
# vi /usr/local/etc/apache22/httpd.conf
 
<IfModule dir_module>
    DirectoryIndex index.html index.php (為了支援php格式)
</IfModule>
 
將下列兩列加到最後一行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
 
5.開機時啟動 Apache
# vi /etc/rc.conf
加入 apache22_enable=”YES”
 
6.測試畫面 (預設目錄在/usr/local/www/apache22/data/)



 

2010年9月6日 星期一

Rsync 指令參數

Rsync 可用於主機資料同步 也可以用於異地備份

使用方法,可以參考這裡


-h , --help 顯示rsync求助資訊.

--version 顯示rsync版本.

-v , --verbose 複雜的輸出訊息.

-q , --quiet 安靜模式,幾乎沒有訊息產生.常用在以cron執行rsync.

-I, --ignore-times 通常rsync為了加快速度會忽略同樣檔案大小且同樣存取時間點的檔案.
可以透過此參數關閉此快速檢查.

--size-only rsync只檢查檔案大小是否改變,不管時間存取點是否改變.
通常用在mirror,且對方時間不太正確時.

-c, --checksum 在傳送之前透過128bit的md4檢查碼來檢查所有要傳送的檔案.(會拖慢速度.)

-a, --archive archive mode 權限保存模式,相當於 -rlptgoD 參數.
很快速的保存幾乎所有的權限設定,除了硬式連結(透過-H設定).

-r, --recursive 複製所有下層的資料(遞迴)

-R, --relative 使用相對路徑.
如: rsync foo/bar/foo.c remote:/tmp/ 在遠端產生/tmp/foo.c檔案
rsync -R foo/bar/foo.c remote:/tmp/ 在遠端產生/tmp/foo/bar/foo.c 檔案

-R, --no-relative 不使用相對路徑.

-b, --backup 目的地端先前已經存在的檔案在傳輸或刪除前會被備份.
--backup-dir=DIR 設定備份的資料夾.
--suffix=SUFFIX 指定備份的檔案名稱字尾形式(預設為~).

-K, --keep-dirlinks 接收方將連結到資料夾的檔案視為資料夾處理

-l, --links 複製所有的連結

-H, --hard-links 保留硬式連結

-p, --perms 保留檔案權限

-o, --owner 保留檔案擁有者(root only)

-g, --group 保留檔案群組

-D, --devices 保留device資訊(root only)

-t, --times 保留時間點

-n, --dry-run 不實際執行傳送,只顯示將會有的傳輸動作

-S, --sparse 嘗試去處理稀疏的檔案,讓這些檔案在目的端佔去較少的磁碟空間.

-W, --whole-file 複製所有的檔案,不額外作檢查.
--no-whole-file 關閉 --whole-file 參數

-x, --one-file-system 不要跨越檔案系統分界(只在一個檔案系統處理)

-B, --block-size=SIZE 強制透過rsync程式去比對修復block-sizeforce

-e --rsh=COMMAND 定義所使用的remote shell

--rsync-path=PATH 定義rsync在遠端機器存放資料的路徑

--existing 只比對更新目的端已經存在的檔案

--ignore-existing 忽略目的端已經存在的檔案(也就是不更新)

--delete 刪除傳送端已經不存在,而目的端存在的檔案

--delete-excluded 除了把傳送端已經不存在,而目的端存在的檔案刪除之外,
也刪除 --exclude 參數所包含的檔案.

--delete-after rsync預設會在檔案傳送前進行相關刪除動作確保接收端有足夠的檔案空間,
但可以透過 --delete-after 讓刪除動作在檔案傳送後再行刪除.

--ignore-errors 忽略任何錯誤既使是I/O error 也進行 --delete 刪除動作.

--max-delete=NUM 定義rsync不要刪除超過 NUM 個檔案.

--partial rsync若遇到傳輸過程中斷時,會把那些已經傳輸的檔案刪除.
在某種狀況下保留那些部分傳送的檔案是令人高興的. 你可以透過 --partial 參數達到這個目的.

--partial-dir=DIR 在 --partial 參數啟動時,你還可以定義rsync把那些部分傳送的檔案
寫入定義的資料夾,而非直接寫入目的端.需要注意的是, 此資料夾不應該被其他使用者可以寫入.(如:/tmp)

--force 當目的端資料夾被傳送端非資料夾名稱覆蓋時,強制rsync刪除資料夾,
即使該資料夾不是空的.

--numeric-ids 不將傳送端檔案的uid及gid值,與目的端的使用者/群組進行配對.
若傳送端並沒有uid及gid的對應名稱(如:原帳號群組被刪除的遺留檔案),
或目的端沒有相對應的帳號/群組,保留數字型態的uid/gid

--timeout=TIMEOUT 設定 I/O 逾時的時間(秒). 超過這個秒數而沒有資料傳送,rsync將會結束.
預設為0,也就是沒有定義逾時時間.

-T, --temp-dir=DIR 定義rsync在接收端產生暫時性的複製檔案時使用資料夾暫存.
預設是直接在接收端資料夾直接產生暫存檔案.

--compare-dest=DIR 定義rsync在目的端建立資料夾來比對傳送過來的檔案.

--link-dest=DIR 與 --compare-dest 相同,但同時會針對無法改變的檔案建立硬式連結.

-z, --compress 壓縮模式,當資料在傳送到目的端進行檔案壓縮.

-P -P參數和 --partial --progress 相同.只是為了把參數簡單化.

-C, --cvs-exclude 排除那些通常不希望傳送的檔案.定義的方式與CVS傳送相同:
RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state
.nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej
.del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/
符合以上條件的都會被忽略而不傳送.

--exclude=PATTER 符合PATTERN(規則表示式)樣式的檔案不進行傳送

--exclude-from=FILE 和--exclude參數相同,不過是把不進行傳送的檔案事先寫入某一檔案.
執行時,透過此參數讓rsync讀取.
(; #開頭的行列或空白行會被rsync忽略)

--include=PATTERN 定義rsync不要排除符合pattern樣式的檔案.

--include-from=FILE 和--include參數相同,只不過把要包含的檔案寫到某一檔案.

--files-from=FILE 把要傳送的檔案名稱都精確的寫入某一檔案,讓rsync讀取.
如: rsync -a --files-from=/tmp/foo /usr remote:/backup

-0 --from0 定義檔案所要讀取的檔案是null字元結尾.

--version 顯示版本訊息.

--daemon 定義rsync以daemon型態執行.

--no-detach 當以daemon型態執行時,不要進行分裂且變成背景程序.

--address=ADDRESS 定義所要連結(bind)的ip位址或是host名稱(daemon限定)

--config=FILE 定義所要讀取的設定檔rsyncd.conf位置(daemon限定)
預設值為 /usr/local/etc/rsyncd.conf

--port=PORT 定義rsyncd(daemon)要執行的port(預設為tcp 873)

--blocking-io 使用blocking I/O連結遠端的shell,如rsh , remsh

--no-blocking-io 使用non-blocking連結遠端的shell,如ssh (預設值)

--stats 顯示檔案傳送時的資訊狀態

--progress 顯示傳送的進度.(給檔案傳送時,怕無聊的人用的..)

--log-format=FORMAT 定義log的格式(在rsyncd.conf設定)

--password-file=FILE 從檔案讀取與遠端rsync伺服器連結的密碼

--bwlimit=KBPS 定義傳輸頻寬的大小(KBytes/秒)

--write-batch=FILE 把紀錄資料寫入一個檔案(給其他相同環境且相同需求的機器使用)

--read-batch=FILE 透過讀取紀錄檔案來進行傳輸.(檔案由 --write-batch 參數產生)

--checksum-seed=NUM 定義檔案 checksum-seed 的大小(byte)

-4 --ipv4 使用IPv4協定

-6 --ipv6 使用IPv6協定


不習慣使用指令備份的話 網路上也有GUI介面的軟體