Roshan Book

My Tech Notebook

Category Archives: ubuntu

Improve battery life and reduce overheating in Ubuntu/Debian

Feeling the heat from your laptop? Overheating and reduced battery life is common ‘phenomenon’ in Linux Mint. Jupiter was the best tool to reduce overheating in Linux desktop but since its development has stopped, you can use TLP or CPUFREQ instead of Jupiter. Install TLP using the following command:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw
sudo tlp start

No configuration required for using TLP. Install it and forget about it. If you want to use CPUFREQ, read this article how to use CPUFREQ to reduce overheating in Ubuntu.

Advertisements

Howto Install Mysql Database Server with Phpmyadmin Frontend

Source:http://www.ubuntugeek.com/howto-install-mysql-database-server-with-phpmyadmin-frontend.html

MySQL is a widely used and fast SQL database server. It is a client/server implementation that consists of a server daemon (mysqld) and many different client programs/libraries.

Installing Mysql database in Ubuntu

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

This will complete the installation of mysql server 5.0.45 in ubuntu gutsy.

Configuring Mysql in ubuntu

MySQL initially only allows connections from the localhost (127.0.0.1). We’ll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf

sudo gedit /etc/mysql/my.cnf

Find the line bind-address = 127.0.0.1 and comment it out

#bind-address = 127.0.0.1

You can check your configuration using the following command

#netstat -tap

Output Looks like below

tcp 0 0 *:mysql *:* LISTEN 4997/mysqld

MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the computer you’re working on. For more information see here

sudo mysqladmin -u root password your-new-password

sudo mysqladmin -h root@local-machine-name -u root -p password your-new-password

sudo /etc/init.d/mysql restart

Manage Mysql using Phpmyadmin

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges,export data into various formats and is available in 54 languages. GPL License information.

Install phpmyadmin in ubuntu

sudo aptitude install phpmyadmin

This will complete the installation.

Now you need to goto http://serverip/phpmyadmin/

Login using your mysql root as username and password


 

FFmpeg cheat sheet

Source: http://www.webupd8.org/2009/08/ffmpeg-cheat-sheet-19-best-practices.html

ffmpeg is a multiplatform, open-source library for video and audio files. It is usualy available in your distribution repositories, so search for it and install it. For Ubuntu:

sudo apt-get install ffmpeg

Because certain codecs are not activated for FFmpeg in Ubuntu Jaunty, I suggest you download and install these ffmpeg fixed packages (unfortunately they are available for 32bit only).

Now that you have installed ffmpeg, you can start trying these commands which cover almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more:

Getting info from a video file

ffmpeg -i video.avi

Turn X images to a video sequence

ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images

ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also available : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone

ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 128kb/s
* Video codec : mpeg4
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Encode video for the PSP

ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 32kb/s
* Video codec : xvid
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Extracting sound from a video, and save it as Mp3

ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

* Source video : source_video.avi
* Audio bitrate : 192kb/s
* output format : mp3
* Generated sound : sound.mp3

Convert a wav file to Mp3

ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_song.mp3

Convert .avi video to .mpg

ffmpeg -i source_video.avi final_video.mpg

Convert .mpg to .avi

ffmpeg -i source_video.mpg final_video.avi

Convert .avi to animated gif (uncompressed)

ffmpeg -i source_video.avi animated_gif.gif

Mix a video with a sound file

ffmpeg -i song.wav -i source_video.avi final_video.mpg

Convert .avi to .flv

ffmpeg -i source_video.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv final_video.flv

Convert .avi to dv

ffmpeg -i source_video.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 final_video.dv

Or:

ffmpeg -i source_video.avi -target pal-dv final_video.dv

Convert .avi to mpeg for dvd players

ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 final_video.mpeg

Explanations :

* target pal-dvd : Output format
* ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
* aspect 16:9 : Widescreen

Compress .avi to divx

ffmpeg -i source_video.avi -s 320x240 -vcodec msmpeg4v2 final_video.avi

Compress Ogg Theora to Mpeg dvd

ffmpeg -i source_video.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 final_video.mpg

Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-svcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-svcd final_video.mpg

Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-vcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-vcd final_video.mpg

Multi-pass encoding with ffmpeg

ffmpeg -i source_file -pass 2 -passlogfile ffmpeg2pass final_file-2

19 ffmpeg commands for all needs

 

Source:http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

ffmpeg is a multiplatform, open-source library for video and audio files. I have compiled 19 useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.

 

 

Getting infos from a video file
ffmpeg -i video.avi
Turn X images to a video sequence
ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images
ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 128kb/s
  • Video codec : mpeg4
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Encode video for the PSP
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 32kb/s
  • Video codec : xvid
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Extracting sound from a video, and save it as Mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

  • Source video : source_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : sound.mp3
Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg
Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi
Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif
Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Convert .avi to dv
ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv

Or:

ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to mpeg for dvd players
ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

Explanations :

  • target pal-dvd : Output format
  • ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
  • aspect 16:9 : Widescreen
Compress .avi to divx
ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Compress Ogg Theora to Mpeg dvd
ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg
Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg
Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg
Multi-pass encoding with ffmpeg
ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2

Download Youtube playlist videos on ubuntu

Source:http://www.ubuntubuzz.com/2011/10/how-to-download-all-videos-of-youtube.html

Imagine you have a playlist on YouTube that contains hundreds of videos in it and you want to download them, what will you do? Do you really want to download them one by one? I think that’s not a good idea. So, in this my first post, I’d like to show you how download all videos of YouTube playlist by simply type a few commands.

Applications used:
In order to getting this trick done, we have to install two applications called umph and youtube-dl. Umph is such an application that can parse YouTube feeds, it can parse playlists, favourite lists, and user upload lists. Youtube-dl is well-known command line tool for downloading YouTube videos by giving their video links.

Installing applications:
Fortunately, I’ve created a PPA contains those two applications. Simply type the following command to install them:

  • sudo add-apt-repository ppa:tldm217/tahutek.net
  • sudo apt-get update
  • sudo apt-get install umph youtube-dl

Usage instructions:

  • umph playlist_ID | youtube-dl -l -a –

You can get playlist_ID from playlist URL, for example, we will download all videos in PHPAcademy 200 JQuery Tutorials, see the picture below for more details.

Take a look at part marked with red box, you will get the weird phrase “PL46408891B63317A4”. By removing the “PL” characters, now you have the playlist ID: 46408891B63317A4. You’re ready to go:

  • umph 46408891B63317A4 | youtube-dl -l -a –

By default, umph will parse 25 videos. So, by executing the above command you will download the first video until 25th video. If you want to download all videos (200 videos) you must add an argumen “-m 200”.

  • umph -m 200 46408891B63317A4 | youtube-dl -l -a –

The tricky part is in umph command line arguments, please take look at this documentation for further information.

Install unity 5.0 in ubuntu 11.10

Source

Unity 5.0 installed in Ubuntu 11.10

Unity 5.0 hit Ubuntu 12.04 last night, but Ubuntu 11.10 users don’t need to miss out: Unity 5.0 is also available to install in Oneiric.

The packages are housed in the Unity Team Staging PPA. As this is not a ‘Stable releases’ PPA you should expect things to break after upgrading – as such only those who feel confident enough in handling any bugs should upgrade.

Two apps that won’t work under Unity 5.0 on Ubuntu 11.10 are the Marlin file browser and the stable release of Nuvola Player. Nor will many of the third-party Lenses and Scopes we’ve featured over the last month.

On to the good stuff. Unity 5.0 feels every bit as snappy under Ubuntu 11.10 as it does under 12.04. All of the options and features we’ve previously mentioned are available including the menu discovery fading, support for custom Dash colouring, force-quit action, and the Bfb ‘Lenses Quicklist’.

And yes – you can also disable the ‘Apps for Download’ section using Unity 5.0.

Install Unity 5.0 in Ubuntu 11.10

Add the following PPA to your Software Sources per these instructions:

  • ppa:unity-team/staging

After adding, pen the Update Manager, click ‘Check for Updates’, and proceed to install those you’re prompted to do.

This can also be achieved via the Terminal by running: –

  • sudo add-apt-repository ppa:unity-team/staging
  • sudo apt-get update && sudo apt-get dist-upgrade

All done? Restart your computer then begin enjoying Unity 5.0.

Downgrade Unity 5.0

“It’s all gone wrong! Halp!”

Open a terminal and enter the following commands: –

  • sudo apt-get install ppa-purge
  • sudo ppa-purge ppa:unity-team/staging

Make .sh file executable in linux

Source: http://www.digimantra.com/linux/how-to-make-shell-or-sh-bin-file-executable-in-ubuntu/

Somehow somwhere or in most of the stuff you need to make your shell file .sh or .bin file as executable. So to do that simple open the terminal and write the following command

chmod +x filename.sh

Well that gonna make your file executable which can be run from terminal by simple command

sudo ./filename.sh

There is another way of doing it through GUI, when you right click on the file and goto permissions tab then you get an option to make the file executable show as below :

executable shell How to make shell or sh , bin file executable in ubuntu

Make ubuntu faster

Originally published at http://www.pelagodesign.com/blog/2009/07/21/how-to-make-ubuntu-linux-run-faster-on-a-laptop/

How to make Ubuntu Linux run faster on a laptop

If you google around on the web you will find there are several tutorials on how to make your Ubuntu Linux installation run faster — especially on older hardware. These tips are very useful and range from minor tweaks to major overhauls. Being an intermediate Linux user myself, I found some of the more difficult optimizations to be overwhelming and not something I would want to try at home — changes to how Linux writes to the hard drive, for example. While researching and implementing the optimizations I felt comfortable with on my older Dell laptop and my new Asus eeePC 901, I jotted down all of my notes for future reference. Below are some tips for the intermediate user on how to optimize your laptop (or desktop) running Ubuntu Linux.

 

Reduce Swappiness

Most laptops have enough RAM installed that the swap space on the hard disk shouldn’t really be used. Yet the default setting for swappiness in Ubuntu is 60. By lowering it to 10 we can reduce the number of read/writes the the hard disk. This is especially handy for netbooks with solid state drives in them. To reduce the swappiness, follow these steps:

  1. sudo sysctl -w vm.swappiness=10
  2. Add the following line to /etc/sysctl.conf
    vm.swappiness=10

 

Preload

Preload is an adaptive read-ahead daemon that monitors running applications and analyzes them for commonalities. It then uses this data to predict what applications you might run and preloads them into memory. The result is faster startup times for commonly used programs. Installing preload is as easy. Just run the following line in a terminal window:

sudo apt-get install preload

» For further explanation, read this article on loading applications quicker in Ubuntu using preload.

 

Boot-Up Manager

The Boot-Up Manager (BUM) is a useful utility for starting and stopping boot-up scripts. Once installed it will appear in the System -> Administration menu. You can use BUM disable unnecessary boot-up scripts that may be slowing down your boot time. For example, I disabled saned, an API library for scanners, because I know I’ll never be attaching a flatbed scanner to my laptop. To install BUM:

sudo apt-get install bum

» Read the documentation for Boot-Up Manager

 

Startup Applications

If you are using Gnome for your desktop manager there will be an option to select which applications are started when you login. Go to System -> Preferences -> Startup Applications and uncheck the programs you don’t need. For example, I disabled the Evolution Alarm Notifier because I don’t use Evolution for setting alarms. I also disabled the Remote Desktop server, UME Desktop Launcher, and UNR Launcher. Just be careful to uncheck them and not remove them. In the case that you’ve removed something critical, you’ll want to be able to get it back.

 

Replace Metacity with Openbox

Openbox is a minimalistic and lightweight window manager that is known to run much faster than metacity, its bulkier counterpart. And you can easily get it working while still using Gnome as your window manager / desktop environment. By running Openbox inside the Gnome environment your desktop will become cleaner and faster. To install it, follow these steps:

  1. Install openbox using:
    sudo apt-get install openbox obconf openbox-themes
  2. Setup openbox as the default window manager by adding an entry in Startup Applications.
    To do this, go to System -> Preferences -> Startup Applications and enter the following: 

    • Name: Openbox
    • Command: openbox ––replace

    Note: According to the Openbox documentation you can make it the default by choosing the GNOME/Openbox session when logging in and saving this as your default session. However, this functionality is broken in 9.04. The above steps are a workaround until this is fixed.

  3. Choosing the Openbox theme and other configuration settings
    Go to System -> Preferences -> Openbox Configuration Manager to choose a theme you like and to update other settings such as Appearance and Windows.
    Note: changing the Desktops setting doesn’t effect the Gnome applet controlling the number of desktops. To change the number of desktops, you will need to revert back to Metacity and change them, then re-enable Openbox

» More information, documentation and screenshots available at the Openbox web site

Setup Samba peer-to-peer with Windows

As many fellow Ubuntu users seem to have trouble setting up samba peer-to-peer with Windows I decided to write a small howto on this matter.

NOTE: I am aware that there’s a wiki-page as well as several other howto’s around – but by looking at the constant “how do I setup samba” posts that are floating around in the forum I simply see the need for a more thourough guide on this matter.

Feel free to contribute and suggest – it’ll only help to make this howto a better guide.

The goal of this howto is to have samba act like a Windows Workstation in the LAN. As a “value added bonus” we will use samba to do netbios name resolution so that you can use the names of the workstations for network drive mapping instead of their ip-addresses (i.e.: \MY_WINDOWS_BOX\SHARE) – but only for as long as your Linux box has an static ip-address and is up and running.

This guide is based on Ubuntu 6.06 LTS and intended for all architectures (i386, AMD64, …) – if you are still using Breezy it’s safe to follow this guide as there should be no differencies.

A second guide on how to setup samba as Primary Domain Controller along with several other services such as DHCP, DNS and NTP will follow later on as this topic will be a little more thourough.

1. Prerequisites

– Your Linux box should have an static ip-address.
In case you’re getting your ip from a router/server via DHCP make sure it’s configured to provide a fixed dhcp-lease. If that’s no valid option you cannot use WINS … more on this way down.

– You need to have samba installed.
If you haven’t done so already open a terminal and type:

Code:
sudo apt-get install samba

Don’t close the terminal upon installation – we still need the commandline to get several tasks done!

2. Getting samba configured

First, let us make sure samba isn’t running:

Code:
sudo /etc/init.d/samba stop

As a starting point I included an smb.conf below, and there are only a few simple things you may need to tweak.

Since the installation of samba just installed a rather useless template file we’re going to rename it – we keep the file just in case.

Code:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template

Next we create a new empty file

Code:
sudo touch /etc/samba/smb.conf

And finally we need to open the file inside an editor

Code:
sudo gedit /etc/samba/smb.conf

NOTE: If you’re on KDE replace “gedit” with “kate”

Copy / Paste the contents of the code-section below into your editor and read on …

Code:
[global]
    ; General server settings
    netbios name = YOUR_HOSTNAME
    server string =
    workgroup = YOUR_WORKGROUP
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192

    passdb backend = tdbsam
    security = user
    null passwords = true
    username map = /etc/samba/smbusers
    name resolve order = hosts wins bcast

    wins support = yes

    printing = CUPS
    printcap name = CUPS

    syslog = 1
    syslog only = yes

; NOTE: If you need access to the user home directories uncomment the
; lines below and adjust the settings to your hearts content.
;[homes]
    ;valid users = %S
    ;create mode = 0600
    ;directory mode = 0755
    ;browseable = no
    ;read only = no
    ;veto files = /*.{*}/.*/mail/bin/

; NOTE: Only needed if you run samba as a primary domain controller.
; Not needed as this config doesn't cover that matter.
;[netlogon]
    ;path = /var/lib/samba/netlogon
    ;admin users = Administrator
    ;valid users = %U
    ;read only = no

; NOTE: Again - only needed if you're running a primary domain controller.
;[Profiles]
    ;path = /var/lib/samba/profiles
    ;valid users = %U
    ;create mode = 0600
    ;directory mode = 0700
    ;writeable = yes
    ;browseable = no

; NOTE: Inside this place you may build a printer driver repository for
; Windows - I'll cover this topic in another HOWTO.
[print$]
    path = /var/lib/samba/printers
    browseable = yes
    guest ok = yes
    read only = yes
    write list = root
    create mask = 0664
    directory mask = 0775

[printers]
    path = /tmp
    printable = yes
    guest ok = yes
    browseable = no

; Uncomment if you need to share your CD-/DVD-ROM Drive
;[DVD-ROM Drive]
    ;path = /media/cdrom
    ;browseable = yes
    ;read only = yes
    ;guest ok = yes

[MyFiles]
    path = /media/samba/
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0644
    directory mask = 0755
    force user = YOUR_USERNAME
    force group = YOUR_USERGROUP

Ok, I already mentioned that there are a few simple things you may need to tweak; so here they are:

-> netbios name = YOUR_HOSTNAME

Replace “YOUR_HOSTNAME” with your desired hostname (don’t use spaces!). Best pratice would be to use the same name you configured upon installation.

Example:

netbios name = DAPPER

-> workgroup = YOUR_WORKGROUP

Replace “YOUR_WORKGROUP” with the name of your workgroup, but make sure you’re using the same as configured in Windows.

To find out the Workgroup name in Windows follow these steps:

– Click “START”
– Click “Control Panel”
– Click “System”
– Click the 2nd Tab entitled “Computername” and find the name of the Workgroup there.

Example:

workgroup = MSHOME

-> wins support = yes

If your box doesn’t have a static ip-address, or you cannot configure your router/server to provide you with a fixed dhcp-lease, change this configuration parameter to “no”.

In this case you cannot use the benefits of WINS.

-> [MyFiles]

This is the name of the share. Leave it as it is or adjust it to whatever you prefer. Don’t use more than 31 characters and try to avoid spaces!

-> path = /media/samba/

This suggests that you’ve mounted an hard drive or partition on /media/samba where all the shared files will be stored.

In case you don’t have an extra hard drive/partition you may also create folder.

I assume you’ve been wise enough to put /home onto a separate partition having an reasonable amount of storage space.

To create the folder type (inside a new terminal) …

Code:
sudo mkdir /home/samba

… and adjust “path =” to read …

path = /home/samba/

Remember that this is just an example – you are free to put things wherever you like.

-> force user = YOUR_USERNAME
-> force group = YOUR_USERNAME

Well, this should say it all. Replace “YOUR_USERNAME” with the name you use for login (no spaces!).

Example:

force user = stormbringer
force group = stormbringer

Now we completed the part of editing smb.conf

Save the file and close gedit.

Since we are going to share the folder with other users we should now make sure that the permissions are set. Type:

Code:
sudo chmod 0777 /media/samba

NOTE: Don’t forget to correct the path to the location you chose above!

That’s it – now we need to start samba …

1.1 Starting samba and setting up user accounts

Let us fire up samba for the first time. Type:

Code:
sudo /etc/init.d/samba start

There shouldn’t be any errors – if you are presented with an error message make sure everything is correct (search for typos and/or invalid paths).

Time to add yourself as an samba user.

NOTE: You will be asked for a password – make sure you use the same as you use for login!

Code:
sudo smbpasswd -L -a your_username
sudo smbpasswd -L -e your_username

In case you need other users to be able to access the share you need to add them to your system AND samba as well. Make sure you use the very same Windows usernames and passwords!

NOTE: Windows XP doesn’t set passwords for its useraccount per default. If you haven’t set a password on your XP box just press enter when prompted to enter a password for the user account you’re about to create!

In the following example we will add an user called “mark” …

Example:

Code:
sudo useradd -s /bin/true mark
sudo smbpasswd -L -a mark
sudo smbpasswd -L -e mark

The “-s /bin/true” in the first line prevents the users from being able to access the commandline of your linux box (“-s” stands for “shell”). I strongly advise you to follow this recommendation! Don’t change that setting to a valid login-shell unless you really know what you are doing!

Repeat this step until you configured all user accounts!

Now that we configured samba and created the user accounts we are done with the Linux-part – there’s one more thing to do in Windows.

2. Changing network settings in Windows

Now we should let Windows know that there’s a WINS server active in the network.

If you had to change “wins support” to “no” above skip this step!

– Click “START”
– Click “Control Panel”
– Click “Network Connections”
– Find your “LAN Connection”
– Right-click the icon and select “Properties”
– Select the “TCP/IP” Protocol and click the “Properties” button
– Click “Advanced”
– Select the third Tab entitled “WINS”
– Click “Add”
– Type in the ip-address of your Linux box
– Click “Add”
– Select “Use NetBIOS over TCP/IP”
– Click “OK”
– Click “OK”
– Click “OK”
– Reboot Windows

Upon reboot you may now map the network drive within Windows.

With WINS enabled:
– Click “START”
– Right-click “My Computer”
– Select “Map network drive”
– Choose the drive letter
– Type \\DAPPER\MyFiles
NOTE: Adjust this to the hostname and sharename you chose above!
– Click “Finish”

With WINS disabled:
– Click “START”
– Right-click “My Computer”
– Select “Map network drive”
– Choose the drive letter
– Type \\<ip-address>\MyFiles
NOTE: To find out the ip-address of your Linux box type “ifconfig” inside a terminal and find the ip for the correct interface (i.e. eth0). Don’t forget to adjust the sharename to the name you chose above.
– Click “Finish”

That’s it – samba is up and running now.

3. Security consideration

This is the right time to think about security right away.

In case your computer has more than one network connection (i.e. wired and wireless ethernet) you may want to restrict access to samba.

If not especially configured samba will bind its service to all available network interfaces.

So, let us assume you only want your wired network to have access and that the network card is called eth0.

Add the following lines to the [general] section of your smb.conf to achieve that goal:

Code:
interfaces = lo, eth0
bind interfaces only = true

If you did it correctly it should look similar to this:

Code:
[global]
    ; General server settings
    netbios name = YOUR_HOSTNAME
    server string =
    workgroup = YOUR_WORKGROUP
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
    interfaces = lo, eth0
    bind interfaces only = true

Now only the local loopback interface (dubbed “lo”) and eth0 are able to access samba – there’s no need to fear that someone might break into your system by wireless as the interface isn’t bound to the service.

4. Final words

If you happen to have any questions feel free to ask – I’ll try to help as soon as possible.

If you find any mistakes in this howto please let me know so that I can fix them.

Feel free to contribute and suggest – help to make this howto a better guide.

5. Addendum: Useful links

Here are some links you may find useful.

The onsite links refer to other samba-guides and to ubuntu_daemon’s “Important Links” thread.

– Onsite
Ubuntu Help: Windows Networkworking
Ubuntu Documentation: Setting up Samba

READ THIS FIRST prior to posting – IMPORTANT links (by ubuntu_daemon)

The offsite links refer to the offical Samba homepage and to a selected choice of their official documentation; these links are useful if you like to dig yourself into the mysteries of samba’s configuration and usage as well as troubleshooting problems.

– Offsite
Samba Homepage

Practical Exercises in Successful Samba Deployment
The Official Samba-3 HOWTO and Reference Guide
Using Samba, 2nd Edition

Installing NFS on ubuntu

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.

Some of the most notable benefits that NFS can provide are:

  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

Installation

At a terminal prompt enter the following command to install the NFS Server:

 

sudo apt-get install nfs-kernel-server

 

Configuration

You can configure the directories to be exported by adding them to the /etc/exports file. For example:

 

/ubuntu  *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)

 

You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.

To start the NFS server, you can run the following command at a terminal prompt:

 

sudo /etc/init.d/nfs-kernel-server start

 

NFS Client Configuration

Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt:

 

sudo mount example.hostname.com:/ubuntu /local/ubuntu

 

[Warning]
The mount point directory /local/ubuntu must exist. There should be no files or subdirectories in the/local/ubuntu directory.

An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted.

The general syntax for the line in /etc/fstab file is as follows:

 

example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

 

If you have trouble mounting an NFS share, make sure the nfs-common package is installed on your client. To install nfs-common enter the following command at the terminal prompt:

sudo apt-get install nfs-common

 

%d bloggers like this: