Sunday, 30 September 2012

Install and Configure Samba share in Ubuntu 12.04, 12.10 Quantal Quetzal | Howto

How to Samba...

One of the most asked features for Samba is a graphical user interface to help with configuration and management,  there are several GUI interfaces to Samba available, for me the most  simple and powerful one of these tools is samba server configuration tool. In this post, i will show you how to install and configure samba in Ubuntu 12.10 Quantal Quetzal, this work also for previous releases of Ubuntu.

Installing Samba on Ubuntu:

1- Install Samba files

First thing we need to do is to install samba, go to Software center in Ubuntu and search for samba then install the package. If you want to install it via terminal then copy this command :

sudo apt-get  install  samba samba-common

2- Install some dependencies for Configuration tools (don`t   forget to  install python-glade2)

sudo apt-get install python-glade2

3- Installing Samba Server configuration Tool :

Now install the graphical interface System-config samba

sudo apt-get install system-config-samba

4- Add a Linux/Unix user:

adduser   pirat9

5- Make  a Linux/Unix  password for  user  pirat9

passwd pirat9

6- Now open samba configuration tool.

7- Add the  folder you want to share and setup the permissions access.

- Setup the permissions access

8- Now before to connect to  the  share, you  have  to  create the  samba user  :

sudo smbpasswd -a  pirat9  New SMB password  retype New SMB Password

Now the configuration is done.

Tip: You can chose any  directory you want to share by  right click on the  folder directory and open the  share options

And activate share:

 

9- Now, let`s test if samba share is working from another Linux Machine, in my case will try to connect from LinuxMint12 machine to Ubuntu 12.04 machine where we just installed samba, from menu open connect to server and type the details of your Ubuntu machine

12- Connect  from  windows  (XP/Vista/7)




Useful commands for Linux normal users and administrators



For Linux/Unix administrators:

1- Compare a remote dir with a local dir

 $ diff -y <(ssh user@host find /boot|sort) <(find /boot|sort)

2- Trace and view network traffic

tcpdump -s 0 -w - port <port> | tcpdump -r - -A

3- Check if a machine is online

ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINE

PING
parameters
c 1 limits to 1 pinging attempt
q makes the command quiet (or silent mode)
/dev/null 2>&1 is to remove the display
&& echo ONLINE is executed if previous command is successful (return value 0)
|| echo OFFLINE is executed otherwise (return value of 1 if unreachable or 2 if you're offline yourself).
I personally use this command as an alias with a predefined machine name but there are at least 2 improvements that may be done.
Asking for the machine name or IP
Escaping the output so that it displays ONLINE in green and OFFLINE in red (for instance).

4-  Reverse SSH

ssh -f -N -R 8888:localhost:22 user@somedomain.org

Reverse SSH
this command from the source server and this follow in the destination server:

 ssh user@localhost -p 8888

5- Show mounted volumes in a table (Thanks to Shawn):

mount | column -t

6- The fastest way to kill tcp or udp port is to run the following command (Thanks to Sriram):

fuser -k PORT-NUMBER-HERE/tcp  fuser -k PORT-NUMBER-HERE/udp

7- edit a file on a remote server using vim from your Linux / Unix / OS X desktop:

vim scp://sriram@server1/etc/http/httpd.conf  

Commands for Both Normal users and Linux admins

8- Grep your command history (Thanks to Shawn)

history | grep /pattern/

9- Extract audio from Flash video (*.flv) as mp3 file

 ffmpeg -i video.flv -vn -ar 44100 -ac 2 -ab 192k -f mp3 audio.mp3

10- copy hybrid iso images to USB key for booting from it, progress bar and remaining time are displayed while copying

time (pv file.iso | dd bs=1M oflag=sync of=/dev/sdX 2>/dev/null)

11- what model of computer I'm using?

sudo dmidecode | grep Product



The latest Dream Studio OS release! ( DreamStudio )

Rock musician and software developer Dick MacInnis, announced a few days ago the availability of the new Dream Studio release which is based on Ubuntu 12.04.

Dream Studio is a GNU/Linux multimedia distribution, aiming to offer tools for graphic designers, photographers, music composers and video editors. The main reason to upgrade is that the latest release is based on an LTS version of Ubuntu, thus it is a lot more stable and for the specialized uses that such distributions have, stability is a serious matter. Another important reason to upgrade would be that all applications and tools are at their latest version.

Lets take a look at the available tools that Dream Studio offers out of the box.

Besides all that, there are of course more application that cover the daily desktop need like  Firefox, LibreOffice, Thunderbird and Tomboy. The only thing I have to notice before suggesting the download of this great distribution is that some users reported that while the system works perfectly in live mode, it doesn't work at all after the installation. Dick McInnis is already working on that, and I suppose there will be a bugfix minor version available soon.

Dream Studio




Sunday, 23 September 2012

Create custom notification on your Ubuntu desktop using python

You can easily create custom notifications for your applications on ubuntu. Ubuntu's current notification system is called NotifyOSD. It provides api for several languages. Using python-notify library it is really so easy than in any other.

Ubuntu by default have the python-notify installed. If don't install it using

1
sudo apt-get install python-notify

Sample notification program using python for notifyOSD

Now you open gedit or any other text editor, paste the following code and save it as notify.py


#!/usr/bin/python
import sys
import pynotify
 if __name__ == "__main__":
    if not pynotify.init("icon-summary-body"):
        sys.exit(1)
 
    n = pynotify.Notification(
        "Burhan Uddin",
        "What is life? Full of of care? We have no time to stand or stare!",
        "notification-message-im")
    n.show()

Now run this py file using terminal

1
python notify.py

And see the output ..




Run C, C++ Programs In Ubuntu Linux


If you are a developer you need C and C++ Compiler for your development work.In ubuntu you can install the build-essential for C and C++ compilers.

Install C and C++ Compilers in Ubuntu

#  sudo aptitude install build-essential

This will install all the required packages for C and C++ compilers

Testing C and C++ Programs

Compiling Your first C Programs

Now you need to open first.c file

sudo gedit first.c

add the following lines save and exit the file

Firstly compile the code using the following command

cc -c first.c

that would produce an object file you may need to add to the library.

then create an executable using the following command

cc -o first first.c

Now run this executable using the following command

./first

Output should show as follows

Hello, world

Compiling your first C++ program

If you want to run c++ program follow this procedure

g++ is the compiler that you must use.

you should use a .cpp file extension rather than a .c one

You need to create a file

sudo gedit first.cpp

add the following lines save and exit the file

Run your C++ Program using the following command

g++ first.cpp -o test

./test

Output should show as follows

Hello World!




Sunday, 16 September 2012

History of Linux operating system

Linux history, How Linux come into existence, When it started and what is the history of Linux. These questions are answered here.
  • What is Unix/Linux?
  • History of Linux
  • Features Supported Under Linux
  • The future of Linux

In 80's, Microsoft DOS was the dominated OS for PC
Apple MACINTOSH was better, but expensive
UNIX was much better, but much, much more expensive. Only for minicomputer for commercial applications
People was looking for a UNIX based system, which is cheaper and can run on PC
Both DOS, MAC and UNIX were proprietary, i.e., the source code of their kernel is protected
No modification is possible without paying high license fees

GNU foundation, established in 1984 by Richard Stallman, who believes that software should be free from restrictions against copying or modification in order to make better and efficient computer programs.

GNU is a recursive acronym for GNU's Not Unix.
Aim at developing a complete Unix-like operating system which is free for copying and modification
Companies make their money by maintaining and distributing the software, e.g. optimally packaging the software with different tools (Redhat, Slackware, Mandrake, SuSE, etc)
Stallman built the first free GNU C Compiler in 1991. But still, an OS was yet to be developed

A famous professor Andrew Tanenbaum developed Minix, a simplified version of UNIX that runs on PC
Minix is for class teaching only. No intention for commercial use
In Sept 1991, Linus Torvalds, a second year student of Computer Science at the University of Helsinki, developed the preliminary kernel of Linux, known as Linux version 0.0.1

Message from Professor Andrew Tanenbaum
" I still maintain the point that designing a monolithic kernel in 1991 is a fundamental error.  Be thankful you are not my student. You would not get a high grade for such a design."
                                                              (Andrew Tanenbaum to Linus Torvalds)


Soon more than a hundred people joined the Linux camp. Then thousands. Then hundreds of thousands
It was licensed under GNU General Public License, thus ensuring that the source codes will be free for all to copy, study and to change.
Linux has been used for many computing platforms
PC, PDA, Supercomputer.
Not only character user interface but graphical user interface is available
Commercial vendors moved in Linux itself to provide freely distributed code. They make their money by compiling up various software and gathering them in a distributable format
Red Hat, Slackware, etc

Recent estimates say about 29 million people use Linux worldwide. The effects of the dot-com bust, IT slowdown and global economic recession can be clearly seen.

Free software, as defined by the FSF (Free Software Foundation), is a "matter of liberty, not price." To qualify as free software by FSF standards, you must be able to:
Run the program for any purpose you want to, rather than be restricted in what you can use it for.
View the program's source code.
Study the program's source code and modify it if you need to.
Share the program with others.
Improve the program and release those improvements so that others can use them.




Saturday, 15 September 2012

Fire Wall: Firewall Builder

http://static.howtoforge.com/images/configuring_source_and_destination_nat_with_firewall_builder/fwbuilder_logo.png


Image of NAT rule

Firewall Builder is a firewall configuration and management GUI that supports configuring a wide range of firewalls from a single application. Supported firewalls include Linux iptables, BSD pf, Cisco ASA/PIX, Cisco router access lists and many more. The complete list of supported platforms along with downloadable binary packages and soure code can be found at http://www.fwbuilder.org.

In this tutorial we are going to cover how to use Firewall Builder to configure a NAT rule that translates both the source and destination IP addresses of the original packet. This type of NAT configuration can be useful in a variety of network configurations.

There are situations where both the source and destination IP addresses of a packet need to be NAT'ed. The diagram below shows just such a scenario where an internal server needs to be accessed remotely from the outside using the Remote Desktop Protocol (RDP).