리눅스마스터1급 : 삼바 실행과 테스트
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 2,374 조회
- 0 추천
- 목록
본문
리눅스마스터1급 : 삼바 실행과 테스트
① 삼바 실행과 종료
삼바 데몬을 실행하기 위해서는 /etc/rc.d/init.d 디렉토리에 있는 smb 스크립트를 이용한다.
|
|
|
| [root@sulinux ~]# /etc/rc.d/init.d/smb start SMB서비스를 시작 중: [ OK ] NMB서비스를 시작 중: [ OK ]
[root@sulinux ~]# /etc/rc.d/init.d/smb stop SMB 서비스를 종료 중: [ OK ] NMB 서비스를 종료 중: [ OK ] |
|
|
|
|
smb 스크립트의 내용
|
|
|
| #!/bin/sh # # chkconfig: - 91 35 # description: Starts and stops the Samba smbd and nmbd daemons \ # used to provide SMB network services. # # pidfile: /var/run/samba/smbd.pid # pidfile: /var/run/samba/nmbd.pid # config: /etc/samba/smb.conf
# Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 1 fi
# Avoid using root's TMPDIR unset TMPDIR
# Source networking configuration. . /etc/sysconfig/network
if [ -f /etc/sysconfig/samba ]; then . /etc/sysconfig/samba fi
# Check that networking is up. [ ${NETWORKING} = "no" ] && exit 1 # Check that smb.conf exists. [ -f /etc/samba/smb.conf ] || exit 6
RETVAL=0 start() { KIND="SMB" echo -n $"Starting $KIND services: " daemon smbd $SMBDOPTIONS RETVAL=$? echo KIND="NMB" echo -n $"Starting $KIND services: " daemon nmbd $NMBDOPTIONS RETVAL2=$? echo [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \ RETVAL=1 return $RETVAL }
stop() { KIND="SMB" echo -n $"Shutting down $KIND services: " killproc smbd RETVAL=$? echo KIND="NMB" echo -n $"Shutting down $KIND services: " killproc nmbd RETVAL2=$? [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb echo "" return $RETVAL }
restart() { stop start }
reload() { echo -n $"Reloading smb.conf file: " killproc smbd -HUP RETVAL=$? echo return $RETVAL } rhstatus() { status smbd RETVAL=$? status nmbd RETVAL2=$? if [ $RETVAL -ne 0 ] ; then return $RETVAL fi if [ $RETVAL2 -ne 0 ] ; then return $RETVAL2 fi } # Allow status as non-root. if [ "$1" = status ]; then rhstatus exit $? fi
# Check that we can write to it... so non-root users stop here [ -w /etc/samba/smb.conf ] || exit 4 case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; status) rhstatus ;; condrestart) [ -f /var/lock/subsys/smb ] && restart || : ;; *) echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}" exit 2 esac
exit $? |
|
|
|
|
② 삼바 사용자 추가
윈도우에서 리눅스 삼바 서버에 접속하려면 먼저 시스템계정을 추가하고 삼바 계정을 생성한다.
|
|
|
| [root@sulinux ~]# useradd sulinux [root@sulinux ~]# passwd sulinux Changing password for user sulinux. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully.
[root@sulinux ~]# smbpasswd -a sulinux New SMB password: Retype new SMB password: Added user sulinux. |
|
|
|
|
③ 삼바 서버 테스트 - testparm, smbstatus, smbclient
삼바 서버의 설정 파일에 이상이 없는지를 체크할 때 사용하는 도구로 testparm이 있다.
이 명령을 사용하여 설정한 파일에 오류 여부를 확인해 볼 수 있다.
이 명령은 어떠한 옵션도 없이 단독으로 실행하여 smb.conf 파일을 점검한다.
|
|
|
| [root@sulinux ~]# testparm Load smb config files from /etc/samba/smb.conf Processing section "[homes]" Processing section "[printers]" Processing section "[public]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions [printers] comment = All Printers path = /var/spool/samba printable = Yes browseable = No
[public] comment = Public Stuff path = /home/sulinux read only = No guest ok = Yes |
|
|
|
|
smb.conf 파일의 문법적인 오류를 검사하여 그 결과를 보여 주는데, 아무런 오류가 없다면 OK 메시지를 보여 주고, 커서는 키보드 입력을 대기하는 상태에 있게 된다.
여기서 ENTER키를 입력하면 공유 설정 항복들을 보여준다.
smbstatus는 현재 삼바 서버 상태를 확인할 수 있다.
|
|
|
| [root@sulinux ~]# smbstatus
Samba version 3.0.28-0.SUL2.9 PID Username Group Machine ------------------------------------------------------------------- 16380 sulinux sulinux suadmin-pc (192.168.0.224)
Service pid machine Connected at ------------------------------------------------------- public 16380 suadmin-pc Sun May 19 04:16:21 2013
Locked files: Pid Uid DenyMode Access R/W Oplock SharePath Name Time -------------------------------------------------------------------------------------------------- 16380 500 DENY_NONE 0x100001 RDONLY NONE /home/sulinux . Sun May 19 04:16:21 2013 |
|
|
|
|
sulinux 사용자가 192.168.0.224 아이피를 갖는 suadmin-pc 머신에서 접속하였음을 알 수 있다.
삼바 클라이언트 유틸리티인 smbclient를 이용하여 삼바 서버의 상태를 체크할 수도 있다.
smbclient는 삼바 서버를 체크하는 데 사용할 뿐만 아니라, 리눅스 클라이언트에서 MS 윈도우 삼바 서버에 접속하는데 사용되는 매우 유용한 유틸리티이다.
smbclient 명령어에 사용되는 옵션은 다음과 같다.
|
|
|
| Usage: smbclient service <password> -R, --name-resolve=NAME-RESOLVE-ORDER Use these name resolution services only -M, --message=HOST Send message -I, --ip-address=IP Use this IP to connect to -E, --stderr Write messages to stderr instead of stdout -L, --list=HOST Get a list of shares available on a host -t, --terminal=CODE Terminal I/O code {sjis|euc|jis7|jis8|junet|hex} -m, --max-protocol=LEVEL Set the max protocol level -T, --tar=<c|x>IXFqgbNan Command line tar -D, --directory=DIR Start from directory -c, --command=STRING Execute semicolon separated commands -b, --send-buffer=BYTES Changes the transmit/send buffer -p, --port=PORT Port to connect to -g, --grepable Produce grepable output
Help options: -?, --help Show this help message --usage Display brief usage message
Common samba options: -d, --debuglevel=DEBUGLEVEL Set debug level -s, --configfile=CONFIGFILE Use alternate configuration file -l, --log-basename=LOGFILEBASE Base name for log files -V, --version Print version
Connection options: -O, --socket-options=SOCKETOPTIONS socket options to use -n, --netbiosname=NETBIOSNAME Primary netbios name -W, --workgroup=WORKGROUP Set the workgroup name -i, --scope=SCOPE Use this Netbios scope
Authentication options: -U, --user=USERNAME Set the network username -N, --no-pass Don't ask for a password -k, --kerberos Use kerberos (active directory) authentication -A, --authentication-file=FILE Get the credentials from a file -S, --signing=on|off|required Set the client signing state -P, --machine-pass Use stored machine account password |
|
|
|
|
다음 예제는 현재 삼바 서버의 호스트 이름을 지정하여 삼바 서버의 상태를 확인한 결과를 보여주고 있다.
만약 삼바 서버에 암호를 지정했다면 암호를 입력해야 한다.
|
|
|
| [root@sulinux ~]# smbclient -L sulinux Password: Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.28-0.SUL2.9]
Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba Server Version 3.0.28-0.SUL2.9) public Disk Public Stuff Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.28-0.SUL2.9]
Server Comment --------- ------- SULINUX Samba Server Version 3.0.28-0.SUL2.9
Workgroup Master --------- ------- MYGROUP SULINUX SUPERUSER LOCALHOST WORKGROUP SUIDC |
|
|
|
|
관련자료
-
이전
-
다음