Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Sunday, November 27, 2016

Posted in My Programming Skill

OwnCloud 8 installation on Ubuntu 14.04


For the people who don't know, OwnCloud is a free and open-source software which enables you to create a private “file-hosting” cloud. Owncloud is made by PHP and backend database MySQL (MariaDB), SQLLite or PostgreSQL. OwnCloud also enables you to easily view and sync address book, calendar events, tasks and bookmarks. People access it via the easy web interface or install OwnCloud client on your machine.

Here step by step installation of OwnCloud 8 on Ubuntu 14.04.

To install OwnCloud on your system, go through following steps:

Step 1. First of all log in to your server as root and make sure that all packages are up to date.


# apt-get update
# apt-get upgrade
 
Step 2. Instal Apache web server on your Ubuntu 14.04 LTS if it is not already installed.

# apt-get install apache2

Step 3. Next, install PHP on your server.

# apt-get install php5 php5-mysql

Once the installation is done install the following PHP modules required by OwnCloud:

# apt-get install php5-gd php5-json php5-curl php5-intl php5-mcrypt php5-imag

Step 4. Install MySQL database server.

# apt-get install mysql-server

By default, MySQL is not very much secured. You can secure MySQL using the mysql_secure_installation script. you should read and follow each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL.

# mysql_secure_installation

Step 5. Create a new MySQL database for OwnCloud using the following commands.

#mysql -u root -p
Enter password:
mysql>
CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'YOURPASSWORD';
mysql> CREATE DATABASE ownclouddb;
mysql>
GRANT ALL ON ownclouddb.* TO 'ownclouduser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql>
exit

Step 6. Installing Owncloud 8.

To download the latest stable release of OwnCloud on your server (at the time of version 8.0.0).

# wget https://download.owncloud.org/community/owncloud-8.0.0.tar.bz2
# tar -xvf owncloud-8.0.0.tar.bz2 -C /var/www/html/

Set the directory permissions:

# chown www-data:www-data -R /var/www/html/owncloud/

Step 7. Configuring Apache for OwnCloud.

While configuring Apache web server, it is recommended that you to enable .htaccess to get a enhanced security features, by default .htaccess is disabled in Apache server. To enable it, open your virtual host file and make AllowOverride is set to All.For example, here i used external config file instead of modifying main file.

### nano /etc/apache2/sites-available/owncloud.conf

<IfModule mod_alias.c>
Alias /owncloud /var/www/html/owncloud
</IfModule>
<Directory “/var/www/html/owncloud”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>

Remember to restart all services related to Apache server.

# service apache2 restart

Step 8. Access OwnCloud application.

Navigate to http://your-domain.com/ and follow the easy instructions. Enter username and password for the administrator user account, click on the ‘Advanced options’ hyperlink and enter the data directory (or leave the default setting), then enter database username, database password, database name, host (localhost) and click ‘Finish setup’.


Saturday, November 26, 2016

Posted in My Programming Skill

Virtualization on Ubuntu using KVM

KVM is stand for  Kernel-based Virtual Machine which turns linux kernel into hypervisor. Hypervisor is nothing but the virtual machine manager program.

To create virtualization on Ubuntu using KVM use the following step

1) Check whether CPU has hardware virtualization support.

KVM only works if your CPU has hardware virtualization support – either Intel VT-x or AMD-V. To determine whether your CPU includes these features, run the following command:

#sudo grep -c "svm\|vmx" /proc/cpuinfo


A 0 indicates that your CPU doesn’t support hardware virtualization, while a 1 or more indicates that it does.

2) Install KVM and supporting packages.

Virt-Manager is a graphical application for managing your virtual machines.you can use the kvm command directly, but libvirt and Virt-Manager simplify the process.

#sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager

3) Create User.

Only the root user and users in the libvirtd group have permission to use KVM virtual machines. Run the following command to add your user account to the libvirtd group:

#sudo adduser tsec
#sudo adduser tsec libvirtd

After running this command, log out and log back in as tsec

4) Check whether everything is working correctly.

Run following command after logging back in as tsec and you should see an empty list of virtual machines. This indicates that everything is working correctly.

#virsh -c qemu:///system list


5)Open Virtual Machine Manager application and Create Virtual Machine

#virt-manager

6) Create and run Virtual Machines





7) # ls /var/lib/libvirt/images/
ubuntu-vm.img

8) # ls /var/lib/libvirt/quem
dump save snapshot ubuntu-vm.monitor


9) # apt-get install virt-viewer virt-top virt-what

10) # virsh list --all

Sunday, November 20, 2016

Posted in My Programming Skill

Introduction & Installation of NS2 on Ubuntu

Network Simulator-2:-

ns is a name for series of discrete event network simulators, specifically ns-1, ns-2 and ns-3. All of them are discrete-event event computer network simulators, primarily used in research and teaching. ns-3 is free software, publicly available under the GNU GPLv2 license for research, development, and use.

Ns began as a variant of the REAL network simulator in 1989 and has evolved substantially over the past few years. ns-2 is often criticized because modelling is a very complex and time-consuming task, since it has no GUI and one needs to learn scripting language, queuing theory and modelling techniques. Also, of late, there have been complaints that results are not consistent (probably because of continuous changes in the code base) and nd that certain protocols have unacceptable bugs.

if your ubuntu version is 12.04 lts or less follow these steps:

Step 1: Setting up the Prerequisites  or dependencies

1. First of all, download Network Simulator (NS-2.35), assume you have downloaded it into your '/home/user_name/Documents' directory.

2. [Optional].Now we have to update and run these commands:

sudo apt apt-get update
sudo apt apt-get dist-upgrade

3. Before installing the NS we have to install some essential packages required by the NS. So run the following commands:

sudo apt-get install build-essential autoconf automake
sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install perl xgraph libxt libxt-dev libx11-dev libxmu-dev
sudo apt-get install gcc-4.4

Step 2: Extract and Install NS

1.Extract the downloaded NS package either using the right click context menu "Extract here" or using the following commands from a terminal:

cd /home/user_name/Documents
tar -xvzf ns-allinone-2.35.tar.gz

2. After extracting the "ns-allinone-2.35" folder, open up the file "/ns-allinone-2.35/ns-2.35/linkstate/ls.h" in an editor. You can do it either from the terminal or from the file explorer Nautilus). We have to make some changes in the ls.h file else it will show an error while installing the NS. Once you have opened the file move to the line 137 and replace the erase (image 1) withhis—>erase (image 2) and save the file.

NOTE:If you don't make the above stated change then you will see an error while installing the NS

3. Now its time to finally install the NS. Open up a terminal and move to the directory where you have extracted the package, in our case its '/home/user_name
'/home/user_name/Documents' and install NS using the following commands

cd /home/user_name/Documents/ns-allinone-2.35
sudo ./install

It will take around 15 minutes so have patience.

Step 3: Set the Environment Variables

1.Assuming everything went well in the previous step and you have successfully installed your NS. Now that NS is installed, there are some environment variables that need to be added to your profile. This can be done by editing the .bashrc file. Open a new terminal and open the file using:

sudo gedit .bashrc

NOTE:You may want to create a backup of the .bashrc before editing, the easiest way is to copy the file to a different location. Later you can replace the edited .bashrc with the copied one in case something goes sideways or if you want to remove the NS.


2.Add the following lines AT THE END of the file. Be sure to change "/path_to" to the path of where you have extracted the NS (e.g. '/home/user_name/Documents').

Save the file and restart the system, alternatively you can just reload the .bashrc as:

source ~/.bashrc

Step 4: Validate the Installation

You need to validate NS to check if everything is OK but keep in mind that it will take a lot of time (about 1:30 hrs). Open up a terminal and move to the directory ‘/home/user_name/Documents/ns- allinone-2.35/ns-2.35/' and run:
./validate

And run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running.


if your ubuntu version is 14.04 lts or later, just do following simple steps:

1) apt-get install build-essential
2) apt-get install ns2
3) apt-get install nam
4) apt-get install xgraph

you have done with installing with ns2 on your system.
now run ns from a terminal window by executing: ns
If you received the "%" sign, it means that NS is running.
Posted in My Programming Skill

HTML Indentation in VIM editor

fig 1: HTML Text before indentation
        To indent html content follow the below steps:
1) type esc + :filetype
 it will show you like this....

filetype detection:OFF  plugin:OFF  indent:OFF 

2) To turn on these services, type following three commands

i) Esc + :filetype plugin on
ii) Esc + :filetype indent on

 after this if you  type first command again, you will get following result

filetype detection:ON  plugin:ON  indent:ON

3) Esc + :set filetype=html
4) Esc + :set tabstop=3 (to make the tab space to 3.. default tab space is 8)
5) Esc + v (for visual) + select all text (using up or down arrow) + =

after the above steps you should get your code indented as below

fig 2: HTML Text after indentation
 Note that after doing indentation, if closed your file and reopened it you may not see indentation. It just because, above steps perform indentation on temporary basis.

If you want to keep changes for long time do following steps before above steps.

1) open a file named .vimrc
2) .vimrc file present in /home/user((avinash) in my case)/.vimrc
3) Delete all content of its, if any present and put following lines in it

filetype plugin on
filetype indent on
set filetype=html
set tabstop=3

save and close the file

4) copy this file in /root/ directory also

now you will get your indented code back every time you opens the file.

    Translate

    Protected by Copyscape