Turn your Debian Wheezy 7.2 system into a Samba Server.

Turn your Debian Wheezy 7.2 system into a Samba Server.

We’ve already installed our Debian Wheezy 7.2 system and now it runs a desktop environment. Our purpose is to run it as a Samba server.
We’ll deploy shared drives and print services to our Windows clients.
The most companies runs DFS ( Distributed File Services ) and Print Services deployed by their servers.
Samba server communicates using SMB ( Simple Message Block ) protocol which are supported in most systems.

In this tutorial we’ll install and test our Samba Server.
Each pc that connects to a network receives their ip addresses automatically assigned by DHCP ( Dynamic Host Configuration Protocol ).
A ip address assigned by dhcp is not optimal for servers so we’ll assign our machine a static one.
We can check our ip settings of our machine by executing ifconfig.
Type ifconfig + enter.

anne@Samba:~$ ifconfig
bash: ifconfig: command not found
anne@Samba:~$


Oops what’s went wrong inhere?

In the most Linux machines you’ll get your ip settings displayed but in Debian Wheezy you’ll see bash: ifconfig: command not found.
We’ve discussed in previous tutorials how to find locations of commando’s.
If you like you can review “Applications and commando’s locations Debian Wheezy 7″ article.
The location of ifconfig is /sbin directory.
Let’s continue revealing our machine’s ip settings.
Type /sbin/ifconfig + enter.
We have two interfaces displayed in our output, etho and a loopback 0 interface.

anne@Samba:~$ ifconfig
bash: ifconfig: command not found
anne@Samba:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:a8:9a:9a 
          inet addr:192.168.0.233  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea8:9a9a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5641 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3726 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5746232 (5.4 MiB)  TX bytes:635055 (620.1 KiB)

 lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

anne@Samba:~$


Our machine ip settings assigned by dhcp are:

ip: 192.168.0.233/24
subnetmask: 255.255.255.0
Our default gateway is missing at this moment but we’ll execute netstat command to reveal this.
Type netstat -r + enter.

anne@Samba:~$ netstat -r
Kernel IP routing table
Destination        Gateway           Genmask              Flags    MSS Window  irtt Iface
default                 192.168.0.1      0.0.0.0                 UG              0 0                  0 eth0
link-local             *                        255.255.0.0         U                 0 0                  0 eth0
192.168.0.0        *                         255.255.255.0     U                 0 0                  0 eth0
anne@Samba:~$


Now we know our important ip settings assigned by dhcp.

Complete machine ip settings are:
ip: 192.168.0.233/24
subnetmask: 255.255.255.0
default gateway: 192.168.0.1

The best practice is to write down your ip settings on a piece of paper because you’ll need it later on.
Our next task is important before proceeding by installing our samba server.
We need a static ip address instead a assigned one by dhcp.
First off all we’ve to shutdown some services like avahi-daemon and network-manager.
On a server they’re annoying because they startup by system boot with the purpose to give a ip address assigned by dhcp.
Don’t do this at desktops, laptops and other devices, they need this services to work properly while connecting to a network.
The services network-manager and avahi-daemon are located in the directory /etc/rc2.d.
Let’s take a look and type cd /etc/rc2.d + enter and than type ls -l + enter.
Now we’ll see all our services here including avahi-daemon and network-manager displayed below.
The links of our services are bold and underlined tekst displayed below.

anne@Samba:~$ cd /etc/rc2.d
anne@Samba:/etc/rc2.d$ ls -l
total 4
-rw-r–r– 1 root root 677 Jul 14 19:24 README
lrwxrwxrwx 1 root root  14 Oct 17 15:46 S01motd -> ../init.d/motd
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S13rpcbind -> ../init.d/rpcbind
lrwxrwxrwx 1 root root  20 Oct 17 16:14 S14nfs-common -> ../init.d/nfs-common
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S16acpi-fakekey -> ../init.d/acpi-fakekey
lrwxrwxrwx 1 root root  24 Oct 17 16:14 S16binfmt-support -> ../init.d/binfmt-support
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S16rsyslog -> ../init.d/rsyslog
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S16sudo -> ../init.d/sudo
lrwxrwxrwx 1 root root  32 Oct 17 16:14 S16virtualbox-guest-utils -> ../init.d/virtualbox-guest-utils
lrwxrwxrwx 1 root root  15 Oct 17 16:14 S17acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S17acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S17anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root  13 Oct 17 16:14 S17atd -> ../init.d/atd
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S17cron -> ../init.d/cron
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S17dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root  15 Oct 17 16:14 S17exim4 -> ../init.d/exim4
lrwxrwxrwx 1 root root  27 Oct 17 16:14 S17speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S18avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root  19 Oct 17 16:14 S18bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root  25 Oct 17 16:14 S18network-manager -> ../init.d/network-manager
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S19cups -> ../init.d/cups
lrwxrwxrwx 1 root root  14 Oct 17 16:15 S19gdm3 -> ../init.d/gdm3
lrwxrwxrwx 1 root root  20 Oct 17 16:14 S19pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx 1 root root  15 Oct 17 16:15 S19saned -> ../init.d/saned
lrwxrwxrwx 1 root root  18 Oct 17 16:15 S20bootlogs -> ../init.d/bootlogs
lrwxrwxrwx 1 root root  19 Oct 17 16:15 S21minissdpd -> ../init.d/minissdpd
lrwxrwxrwx 1 root root  18 Oct 17 16:15 S21rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root  19 Oct 17 16:15 S21rmnologin -> ../init.d/rmnologin
anne@Samba:/etc/rc2.d$


Ok we’ll remove the links of both services using the command rm. You must have high privileges on your system so you’ve to use your root user.

Type su + enter.
You’ll be asked to fill in your root password followed by enter.
The sign # represents that you’re logged in as user root.
Be aware when you’re changing things in here because you’ve full privileges on your system. This actions will affect your system’s behavior.
Let’s remove the links of our services by using mv command.

Type rm -v /etc/rc2.d/S18avahi-daemon + enter.
than,
Type rm -v /etc/rc2.d/S18network-manager + enter.
We’ve used the -v option to see what happens after our execution.

As you can see they’re successfully removed.

anne@Samba:/etc/rc2.d$ su
Password:
root@Samba:/etc/rc2.d#rm -v /etc/rc2.d/S18avahi-daemon
removed `/etc/rc2.d/S18avahi-daemon’
root@Samba:/etc/rc2.d# rm -v /etc/rc2.d/S18network-manager
removed `/etc/rc2.d/S18network-manager’
root@Samba:/etc/rc2.d#


We’ve no links to our services anymore so we’ll create a new one as followed.

Type ln -s /etc/init.d/networking /etc/rc2.d/S15networking + enter.
Now we’ve a new link that leads to our directory /etc/init.d/networking.

anne@Samba:/etc/rc2.d$ su
Password:
root@Samba:/etc/rc2.d#rm -v /etc/rc2.d/S18avahi-daemon
removed `/etc/rc2.d/S18avahi-daemon’
root@Samba:/etc/rc2.d# rm -v /etc/rc2.d/S18network-manager
removed `/etc/rc2.d/S18network-manager’
root@Samba:/etc/rc2.d# ln -s /etc/init.d/networking /etc/rc2.d/S15networking


Ok, we’re ready to stop our services avahi-deamon and network-manager as followed.

Type /etc/init.d/avahi-daemon stop + enter.
than,
Type /etc/init.d/network-manager stop + enter.
If you prefer you can just restart your machine. It’s causes the same results.

We can see in our output that our services are stopped successfully.

root@Samba:/etc/rc2.d# /etc/init.d/avahi-daemon stop
[ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon.
root@Samba:/etc/rc2.d# /etc/init.d/network-manager stop
[ ok ] Stopping network connection manager: NetworkManager.
root@Samba:/etc/rc2.d#


Hmm, alright, let’s continue by taking care of our ip settings.

We’ll give our machine a static ip address before being able to install our samba.
As you already know our system is built up of directories and files.
The configuration files we need are located at the directory /etc.
Type cd /etc + enter.
Our working directory /etc so we’re interested in the network files. Let’s take a look.
Type ls net* + enter.

anne@Samba:~$ cd /etc
anne@Samba:/etc$
ls net*
netconfig  networks

network:
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  run
anne@Samba:/etc$


We see the file interfaces located in our  sub directory network.

Go to that directory and type cd network + enter.
Now we’re in our working directory network which contains the file interfaces.

anne@Samba:/etc$ cd network
anne@Samba:/etc/network$
ls
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  run
anne@Samba:/etc/network$


Each file can be changed that affect our system’s behavior so pay attention while you’re changing files like this one.
Let’s take a look at the contents of the file interfaces by using our cat. If you have any doubts you can check it’s properties by executing command file.

Type file interfaces + enter.
Our file interfaces is a ASCII-tekst based file so we’re able to read it’s contents by performing the cat command.
Type cat interfaces + enter.
This file contains the available interfaces on your system and can be modified if it’s necessary to do so like assigning ip addresses.

anne@Samba:/etc/network$ file interfaces
interfaces: ASCII text
anne@Samba:/etc/network$ cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
anne@Samba:/etc/network$


Let’s check all our interfaces available in our machine by executing ls.

Type lspci + enter.
Here you discover your Ethernet Controller shown below.
Type lspci + enter.
Here you see our Ethernet Controller displayed below.
Everything seems to be alright so far.

root@Samba:/etc/network# lspci
00:00.0 Host bridge: Intel Corporation 440FX – 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service

00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC’97 Audio Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
root@Samba:/etc/network#


Let’s start our static ip configuration by opening our file interfaces using Pico.

We’re still root user with high privileges so we can carry on.
We hope you’ve written down your ip settings.
Type pico interfaces +  enter.
Your file may look like this.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


Write your ip settings you like to use as static ip.

We’ve chosen a /24 network 192.168.0.0
Our samba server will use ip 192.168.0.254
Subnetmask 255.255.255.0
Gateway 192.168.0.1
A little explanation about the file we’re modifying:
auto eth0 stands for startup ethernet interface 0 while system boots.
Iface eth0 inet static indicates a static assigned address at ethernet interface 0
These ip addresses displayed here are just examples so you can use your own settings you prefer.
Take note you can’t use a ip address twice and you must pay attention not to use addresses served by dhcp.
Navigate your cursor below using your arrow keys.
Write in our file the followed tekst:
auto eth0
iface eth0 init static
address 192.168.0.254
netmask 255.255.255.0
gateway 192.168.0.1

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.254
netmask 255.255.255.0
gateway 192.168.0.1


If it’s correct save your file without changing the name of it.

Press ctrl + x and type y to save your file.
Don’t change anything here but just press enter.
Your file is now saved and ready to use after restarting our network services as followed.

We do this so the system can write down the changes we’ve just made.
Type /etc/init.d/networking restart + enter.
This will restart the network services.
Leave your root by typing exit.
Your prompt shown the $ again that indicates the default user.

Check your ip settings by typing /sbin/ifconfig + enter.
We can see our static ip settings listed below.
ip 192.168.0.254
subnetmask 255.255.255.0
defaul gateway 192.168.0.1

anne@Samba:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:a8:9a:9a 
          inet addr:192.168.0.254  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea8:9a9a/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1595 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:251030 (245.1 KiB)  TX bytes:19119 (18.6 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

 anne@Samba:~$


We’ll test our connectivity by executing the ping command.

Type ping www.google.com + enter.
You’ll see a output like below if you’re connected successfully.
Notice we have transmitted 4 packets and received four. None of them were lost.
Stop you ping by pressing ctrl +c.

anne@Samba:~$ ping http://www.google.com
PING http://www.google.com (74.125.136.104) 56(84) bytes of data.
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=1 ttl=46 time=23.5 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=2 ttl=46 time=25.7 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=3 ttl=46 time=23.8 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=4 ttl=46 time=23.1 ms
^C
http://www.google.com ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 23.113/24.050/25.723/0.999 ms
anne@Samba:~$


Now we’re able to install our Samba server.

Login as user root by performing su + enter.
Type your root user password + enter.
Your prompt shows the #  sign instead the default $ sign.
Ok, let’s do it.
Typ apt-get install samba + enter.

anne@Samba:~$ su
Password:
root@Samba:/home/anne# apt-get install samba
Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following extra packages will be installed:
  libwbclient0 samba-common smbclient tdb-tools
Suggested packages:
  openbsd-inetd inet-superserver smbldap-tools ldb-tools ctdb cifs-utils
The following NEW packages will be installed:
  samba tdb-tools
The following packages will be upgraded:
  libwbclient0 samba-common smbclient
3 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 10.5 MB of archives.
After this operation, 23.8 MB of additional disk space will be used.
Do you want to continue [Y/n]?


Now you can make a decision here.

We can see what will happen during this installation and how much disk space will be used.
You can abort this by pressing n but we’ll proceed the installation by pressing y.
Type y + enter.
Our samba server will be installed and a long list will roll on our terminal.

root@Samba:/home/anne# apt-get install samba
Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following extra packages will be installed:
  libwbclient0 samba-common smbclient tdb-tools
Suggested packages:
  openbsd-inetd inet-superserver smbldap-tools ldb-tools ctdb cifs-utils
The following NEW packages will be installed:
  samba tdb-tools
The following packages will be upgraded:
  libwbclient0 samba-common smbclient
3 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 10.5 MB of archives.
After this operation, 23.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.belnet.be/debian/ wheezy/main tdb-tools amd64 1.2.10-2 [27.0 kB]
Get:2 http://security.debian.org/ wheezy/updates/main libwbclient0 amd64 2:3.6.6-6+deb7u2 [95.7 kB]
Get:3 http://security.debian.org/ wheezy/updates/main smbclient amd64 2:3.6.6-6+deb7u2 [5,891 kB]
Get:4 http://security.debian.org/ wheezy/updates/main samba-common all 2:3.6.6-6+deb7u2 [213 kB]
Get:5 http://security.debian.org/ wheezy/updates/main samba amd64 2:3.6.6-6+deb7u2 [4,322 kB]
Fetched 10.5 MB in 5s (2,059 kB/s)
Reading changelogs… Done
Preconfiguring packages …
(Reading database … 142221 files and directories currently installed.)
Preparing to replace libwbclient0:amd64 2:3.6.6-6+deb7u1 (using …/libwbclient0_2%3a3.6.6-6+deb7u2_amd64.deb) …
Unpacking replacement libwbclient0:amd64 …
Preparing to replace smbclient 2:3.6.6-6+deb7u1 (using …/smbclient_2%3a3.6.6-6+deb7u2_amd64.deb) …
Unpacking replacement smbclient …
Preparing to replace samba-common 2:3.6.6-6+deb7u1 (using …/samba-common_2%3a3.6.6-6+deb7u2_all.deb) …
Unpacking replacement samba-common …
Selecting previously unselected package samba.
Unpacking samba (from …/samba_2%3a3.6.6-6+deb7u2_amd64.deb) …
Selecting previously unselected package tdb-tools.
Unpacking tdb-tools (from …/tdb-tools_1.2.10-2_amd64.deb) …
Processing triggers for man-db …
Setting up libwbclient0:amd64 (2:3.6.6-6+deb7u2) …
Setting up samba-common (2:3.6.6-6+deb7u2) …
Setting up smbclient (2:3.6.6-6+deb7u2) …
Setting up samba (2:3.6.6-6+deb7u2) …
Generating /etc/default/samba…
Adding group `sambashare’ (GID 123) …
Done.
update-alternatives: using /usr/bin/smbstatus.samba3 to provide /usr/bin/smbstatus (smbstatus) in auto mode
[ ok ] Starting Samba daemons: nmbd smbd.
Setting up tdb-tools (1.2.10-2) …
update-alternatives: using /usr/bin/tdbbackup.tdbtools to provide /usr/bin/tdbbackup (tdbbackup) in auto mode
root@Samba:/home/anne#


We’ll configure and test our samba server.

Our fresh installed server uses configuration files located at /etc/samba directory.
We’ll copy this one in the same directory using mv command.
Type mv /etc/samba/smb/conf /etc/samba/smb.conf.testsamba.
You’re free in naming your smb.conf file you prefer.
Now we’ve copied our configuration file named smb.conf.testsamba.

root@Samba:/home/anne# mv /etc/samba/smb.conf /etc/samba/smb.conf.testsamba
root@Samba:/home/anne#


Now we’re able to configure our smb.conf file using Pico.

Let’s open this file, pico /etc/samba/smb.conf + enter.
You’ll see a empty file which contains nothing at this moment.

You’re free to use your own configuration instead of this example displayed below.
Type:
[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation

If you’re satisfied you can safe your file by pressing ctrl+x at once.
You’ll be asked what to do with this file, just press y.
Now press enter without changing it’s name.
Ok our smb.conf file is configured and saved in our directory /etc/samba.

At this time we’ve no shared drive yet in our samba server.
We need to create a directory in our directory /home.
Type mkdir /home/shareddrive + enter.

root@Samba:/# mkdir /home/shareddrive
root@Samba:/#


We’ve chosen shareddrive but you’re free to name it what you like.

Check this in your /home directory using ls command.
Type ls +enter.
Yes our directory shareddrive is pressent inhere.

root@Samba:/# ls /home
anne  shareddrive
root@Samba:/#


Everything is done so far so we’re ready to restart our samba server.

Every change we made needs to be written into our system by restarting our samba services.
Type /etc/init.d/samba restart + enter.

root@Samba:/# /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.
root@Samba:/#


Ok, we’ll now test our configuration we’ve made before.

Type testparm + enter.
You’ll be asked to see your dump of your service definitions.
Press y.
In this output we see our successfull deployment of our shared drive.

root@Samba:/# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[antwerp]“
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
     workgroup = GNUBIZZERS
     idmap config * : backend = tdb

[antwerp]
     comment = sambainstallation
     path = /home/shareddrive
root@Samba:/#


We’re not done yet.

We need a user which will use our samba server.
We have named our samba user sysadmin.
Let’s create our user by typing useradd + username you prefere + enter.
than

Type smbpasswd -a username you’ve chosen + enter.
You’ll see New SMB password:
Type password your prefer + enter.
You’ll see Retype new SMB password:
Retype your password + enter.
Now the user sysadmin is added.

root@Samba:/# useradd sysadmin
root@Samba:/#
smbpasswd -a sysadmin
New SMB password:
Retype new SMB password:
Added user sysadmin.
root@Samba:/#


Now we’ve done everything and ready for the ultimate test.

We’ll login as sysadmin in our samba server. In fact we’ll connect into our shareddrive we’ve created before.
Type smbclient //localhost/antwerp -U sysadmin. + enter.
You’ll see Enter sysadmain’s password:
Type your password  + enter.

root@Samba:~# smbclient //192.168.0.254/antwerp -U sysadmin
Enter sysadmin’s password:
Domain=[GNUBIZZERS] OS=[Unix] Server=[Samba 3.6.6]
smb: \>


We’ve a successful logged into our shareddrive antwerp.

Let’s take a look what’s stored on that drive.
Type ls + enter.
Now we’ve a few pictures inhere displayed below.

root@Samba:~# smbclient //192.168.0.254/antwerp -U sysadmin
Enter sysadmin’s password:
Domain=[GNUBIZZERS] OS=[Unix] Server=[Samba 3.6.6]
smb: \> ls
.                                                                 D                 0    Wed Dec 18 23:40:59 2013
..                                                                D                 0    Wed Dec 18 22:57:48 2013
fancy-debian.jpg                                           1101847    Wed Dec 18 23:38:28 2013
icons.png                                                          341553    Wed Dec 18 23:36:56 2013
terminal.png                                                     79743     Wed Dec 18 23:37:40 2013
38577 blocks of size 524288. 28649 blocks available
smb: \>

If you’ve seen enough you can disconnect by typing quit + enter.


Our second test will be done using a Windows 7 based system.

Click start and type cmd than click cmd and your prompt will open.
Your CMD prompt looks like this below.
The numbers which are divided between dots repressents our samba-server’s ip address.
We’ll accomplish a connection to our samba server’s shared drive.
Type NET USE L: \\192.168.0.254\antwerp /USER:sysadmin + enter.
Type sysadmin’s password + enter.
We’re connected successfully but we’re still in our C:\ directory of Windows so w’ll change our working directory.
In Windows our shared drive is given the drive letter L.
Type L: + enter.
Our cmd prompt shows L:\ instead the default C:\
Now we’re able to see the contents by executing dir + enter.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Anne-Marie>NET USE L: \\192.168.0.254\antwerp /USER:sysadmin
Enter the password for ‘sysadmin’ to connect to ’192.168.0.254′:
The command completed susscessfully.

C:\Users\Anne-Marie>L:

L:\dir
 Volume in drive L is antwerp
 Vomume Serial Number is 622C-D244

 Directory of L:\


Picture displayed below how our real CMD look like.

You’ll see we’ve some pictures stored in our shared drive antwerp.

Samba



In our Windows system graphical user interface you’ll discover your network drive displayed on the left side below computer.

You can just click on network drive and you’ll be asked to insert sysadmin’s password to connect.

samba.gui


The contents of your drive is now accessible to explore.
Ok in our example there’s not that much stored inhere.

Samba_gui_access_shareddrive

We like to use our CMD instead of our graphical user interface.
It’s more accurate when creating directories and files.
Let’s use our cmd again and navigate to your shared drive L.
Type L: + enter.
Our purpose is to make a directory into our shared drive antwerp.
We’ll make a folder named Samba_Lessons + enter.
Type mkdir Samba-Lessons + enter.
Hmm, we’ll face a Access is denied.

L:\>mkdir Samba-Lessons
Access is denied.

L:\>

Oops it’s seems we’ve a problem here.
We’ve not write permissions here so we’ve to change it in our Samba system.

Samba_access_is_denied


Let’s go back into our configuration file smb.conf located at /etc/samba.
We’ll give us write permissions so we’ll be able to make our directories and files we like.
First you’ve to be root to perform this action.
Type su + enter.
than
Insert your password followed by enter.

anne@Samba:~$ su
Password:
root@Samba:/home/anne#


Open your configuration file using Pico.
Type pico /etc/samba/smb.conf + enter.
The file look like below.

[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation


Now we’ll insert one more argument that will give us write permissions.

Move your cursor downwards by using your arrow keys.
Type writable=yes.
Safe your file by pressing ctrl+x
than
Enter without changing it’s name.

[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation
writable=yes


Our changes must be written by our server and must be restarted to take affect.

Type /etc/init.d/samba restart + enter.

root@Samba:/home/anne# /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.
root@Samba:/home/anne#


Ok, let’s test it.

Open your cmd one more time and navigate to L drive.
Make a directory named Samba-Lessons.
Type one more time mkdir Samba-Lessons + enter.
We face the same issue again.
We still have no write permissions after our file mocification so we need to go furter.

L:\>mkdir Samba-Lessons
Access is denied.

L:\>


Open your terminal in your Samba server.

We need to change our permissions on the shared drive itself.
Let’s take a look.
Type ls -l /home + enter.
Shareddrive is owned by user root and only this user can do everything.

anne@Samba:~$ ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Dec 19 14:09 anne

drwxr-xr-x 
2 root root 4096 Dec 18 23:40 shareddrive
anne@Samba:~$


Login as user root by executing su + enter. Fill in your password followed by enter.
Type chmod 777 shareddrive + enter.
Check your permissions using ls -l command.
Now we must be able to write on that shared drive.

anne@Samba:~$ su
Password:
root@Samba:/home/anne# cd ..
root@Samba:/home# ls -l
total 8
drwxr-xr-x 25 anne anne 4096 Dec 24 11:43 anne
drwxr-xr-x  2 root root 4096 Dec 18 23:40 shareddrive
root@Samba:/home# chmod 777 shareddrive
root@Samba:/home# ls -l
total 8
drwxr-xr-x 25 anne anne 4096 Dec 24 11:43 anne
drwxrwxrwx  2 root root 4096 Dec 18 23:40 shareddrive
root@Samba:/home#


Let’s check this out in our Windows based machine using cmd.

Open your cmd and navigate to your L drive.
Type mkdir Samba-Lessons + enter and check this by using dir + enter.
We see here our newly created folder Samba-Lessons displayed below.

Samba_mkdir_Samba-Lessons


Now we’re able to create, change, safe and delete directories and files on the shared drive at the Samba server  from any machine connected to that drive.

When we perform such a configuration we’ll face a security breach that will affect the whole company.
The best practice is a permission management based on groups instead of users.
How to do that will be spoken in a later chapter.
We hope you’ve enjoyed this part of the servey. ;-)

About these ads

One Response to Turn your Debian Wheezy 7.2 system into a Samba Server.

  1. anne0001 says:

    Hmm, have you not made ​​a mistake in reading our articles.
    You show how to crack Sony Vegas 12 Pro which not open source software. There are “free” film editing software packages available like Pitivi, Kdenlive, OpenShotVideoEditor you can run on your linux machine.
    Our core business is discuss different open source distributions like Linux, Debian, Redhat and so on.
    But, feel free and leave your comments about open source software.
    Have a nice time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: