Samba服務是一個用於Linux文件共享的服務,能夠理解爲「Linux的共享文件夾」。在Windows上可以直接訪問被共享的目錄。shell
例如訪問192.168.1.3的home目錄,能夠直接在Windows的文件管理器的路徑上輸入\\192.168.1.3\quantum
。固然,若是你不肯定該訪問哪個共享目錄,你能夠只輸入\\192.168.1.3
,查看全部的共享目錄安全
| 服務器IP | Samba帳號 | Samba密碼 |
| 192.168.1.3 | Linux帳號(例如whqt) | 123456 |
| | | |
| | | |bash
使用Samba的好處,拷貝日誌、拷貝編輯配置文件均可以直接在Windows下進行,甚至能夠直接在Windows下使用Visual Studio打開服務器上的代碼工程進行開發,即使服務器重啓,也不會形成影響。服務器
yum install samba
爲Samba添加用戶和密碼測試
#這裏添加的用戶必須是本機已有的Linux用戶 smbpasswd -a whqt
因爲CentOS7採用了比較嚴格的權限管理和訪問控制(iptable、SELinux),這些都會影響到Samba服務器的運行,考慮到服務器位於公司內網,相對比較安全,所以直接在開機階段就將這些服務禁掉rest
CentOS7採用chkconfig來管理服務日誌
每一個被chkconfig 管理的服務須要在腳本加上兩行或者更多行的註釋code
# chkconfig: 2345 55 25
服務腳本須要實現start
,stop
,restart
,status
參數的功能,簡單來講須要實現以下功能:ip
case $1 in start) do_start;; stop) do_stop;; restart) do_restart;; status) echo "Status of $DESC: " check_status exit "$?" ;; *)
#!/bin/bash # chkconfig: 2345 55 25 #description: the environment init script # useage manual # add to system config # chkconfig --add xyd_init.sh # chkconfig --level 345 xyd_init.sh on # start the service # service xyd_init.sh start # service xyd_init.sh stop # service xyd_init.sh restart # service xyd_init.sh status do_start_EX() { setenforce 0 service iptables stop service smb restart echo "sambda service start success" } do_start() { do_start_EX } do_stop_EX() { service smb stop echo "sambda servoce stopped" } do_stop() { do_stop_EX $i } do_restart() { do_stop do_start } check_status() { echo "do nothing" } case $1 in start) do_start;; stop) do_stop;; restart) do_restart;; status) echo "Status of $DESC: " check_status exit "$?" ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac
-開發
將腳本拷貝到/etc/init.d/
目錄下, 並添加可執行權限chmod +x 服務腳本
。
執行以下命令將服務腳本添加到chkconfig進行管理
chkconfig --add 服務腳本 chkconfig --level 2345 服務腳本 on
至此就完成了服務開機啓動的配置
就像啓動任何一個普通服務那樣
sudo service xyd_init.sh start
完畢