{"id":46,"date":"2008-11-08T14:28:55","date_gmt":"2008-11-08T19:28:55","guid":{"rendered":"http:\/\/xux.in\/blog\/?p=46"},"modified":"2008-11-08T14:28:55","modified_gmt":"2008-11-08T19:28:55","slug":"install-and-setup-samba-in-linux","status":"publish","type":"post","link":"http:\/\/xux.in\/blog\/post\/install-and-setup-samba-in-linux\/","title":{"rendered":"Install and setup Samba in Linux"},"content":{"rendered":"<p>What is <a href=\"http:\/\/us1.samba.org\/samba\/what_is_samba.html\">Samba<\/a>? If you don&#8217;t know what it is then you shouldn&#8217;t be reading this \ud83d\ude09 Samba can do a lot of things and we are only cover a basic configuration that will allow you to share specific folders on a Linux machine in the same way you share forlder in a Windows machine.<\/p>\n<p>This will cover a very quick installation and setup of Samba on any Linux flavor, however in this particular case I&#8217;ll cover CentOS 5.2<\/p>\n<p>First you need to install Samba&#8217;s binaries using yum \ud83d\ude42 (you can use apt-get or up2date if you want)<\/p>\n<pre lang=\"sh\">yum install samba samba-common<\/pre>\n<p>Installation stage has been covered, that was fast \ud83d\ude09 Now we need to do a basic configuration in order to start using it and we need to design a structure&#8230; let&#8217;s say I want to setup a Linux machine to share a specific folder to everyone with read-only access and a specific folder for only local user with read\/write access, so here we go:<\/p>\n<pre lang=\"sh\">cd \/etc\/samba\r\nmv smb.conf smb.conf.backup\r\nnano smb.conf<\/pre>\n<p>And paste the following configuration on the new smb.conf<\/p>\n<pre lang=\"ini\">[global]\r\nnetbios name = sambaserver\r\nload printers = no\r\npath = \/home\r\ndefault service = global\r\nsecurity = share\r\navailable = no\r\n\r\n[share]\r\npath = \/var\/ftp\/pub\r\nguest ok = yes\r\nread only = yes\r\ncomment = Public Access\r\navailable = yes\r\n\r\n[sambademo]\r\npath = \/home\/demo\r\nguest ok = no\r\nwritable = yes\r\nvalid users = demo\r\ncomment = User demo home\r\navailable = yes<\/pre>\n<p>So far we have setup a basic global configuration, a public access area and a restricted area for a local user called &#8220;demo&#8221;. Before we continue you need to make sure the folder \/var\/ftp\/pub exists. Now, before we start our new Samba server, we need to setup the &#8220;demo&#8221; account and it can be done in 2 ways:<\/p>\n<pre lang=\"sh\">useradd -s \/sbin\/nologin demo\r\nsmbpaswd -a demo<\/pre>\n<p> If we don&#8217;t want to give this user shell access, or&#8230;<\/p>\n<pre lang=\"sh\">useradd -s \/bin\/bash demo\r\npasswd demo\r\nsmbpasswd -a demo<\/pre>\n<p> If we want to give this user access to shell and of course we need to set the same password for the system and Samba.<br \/>\nIt is time to start our Samba server:<\/p>\n<pre lang=\"sh\">\/etc\/init.d\/smb start<\/pre>\n<p>Now let&#8217;s try it, on Windows do the following: Start -> Run -> cmd<\/p>\n<pre lang=\"sh\">net use y:\\\\samba_server_ip\\share\r\nnet use z:\\\\samba_server_ip\\demo \/user:demo thepasswordyouset<\/pre>\n<p>Hopefully you will see you have 2 new units on your Windows File Explorer, Y which is a read-only folder and Z which is a read\/write folder \ud83d\ude42 that&#8217;s all!<\/p>\n<p>If you want to do more things with Samba and you are lazy you can always get <a href=\"http:\/\/www.webmin.com\">Webmin<\/a> and use its module to configure Samba and use its advanced options.<\/p>\n<p><strong>NOTE:<\/strong> This article is for educational purposes and should be treated as it is.<\/p>\n<p><strong>Troubleshooting:<\/strong><\/p>\n<ul>\n<li><em>The network name cannot be found<\/em>: Check your computer&#8217;s firewall or if your ADSL\/DSL modem, sometimes by default they block all outgoing connections to Netbios port which is 139.<\/li>\n<li>Anything else check your log files \/var\/log\/samba\/smb.log \ud83d\ude42\n<\/ul>\n<p><strong>Literature:<\/strong> (Thanks to them, this tutorial exists)<br \/>\n<a href=\"http:\/\/crazytoon.com\/2007\/05\/22\/samba-how-do-you-install-and-set-up-samba-in-linux-redhat-enterpriserhel-centos-fedora\/\">Sunny Walia<\/a><br \/>\n<a href=\"http:\/\/www.linuxparatodos.net\/portal\/staticpages\/index.php?page=13-como-samba\">Joel Barrios Due\u00f1as<\/a><br \/>\n<a href=\"http:\/\/www.samba.org\">Samba<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Samba? If you don&#8217;t know what it is then you shouldn&#8217;t be reading this \ud83d\ude09 Samba can do a lot of things and we are only cover a basic configuration that will allow you to share specific folders on a Linux machine in the same way you share forlder in a Windows machine. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,8,1,5,9],"tags":[25,13,33,20,26],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-ensim","category-linux","category-lostfound","category-software","category-windows","tag-backup","tag-centos","tag-linux","tag-rhel","tag-samba"],"_links":{"self":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":1,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":47,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/posts\/46\/revisions\/47"}],"wp:attachment":[{"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xux.in\/blog\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}