Search

Just Another Tech Blog

A mind is like a parachute. It doesn't work if it is not open.

Category

Ubuntu

How To Add Robot Framework Syntax in Sublime Text and VIM editor


By default, files for the Robot Framework do not show any syntax on Sublime Text or VIM, with some tweaks we can add Robot Framework syntax.

For Sublime Text 2:

Open Sublime Text 2 and click Preferences -> Browse Packages to open the packages directory. Then create a directory named Robot Framework containing the contents of the following repository:

https://github.com/seeamkhan/sublime-robot-plugin

Note: The contents of the repository should be directly under the Robot Framework directory.

Now close the Sublime Text 2 editor if it’s already been opened and then open a file with Robot Framework syntax, the syntax should be now visible like below:

Selection_012

For VIM Text Editor:

Clone the git repository in any place:

git clone https://github.com/seeamkhan/robotframework-vim

Go to the content directory:

cd robotframework-vim

Make sure the directory ~/.vim/ already exist for the current user, if not then create the directory:

mkdir ~/.vim

Now copy all the contents to ~/.vim/ location:

cp -R * ~/.vim/

Now open any files with Robot Framework syntax in the VIM editor, the syntax should be visible like below:

Selection_014

LAMP and Virtual Host


Every time I set-up a new Linux PC, I need to install LAMP and Virtual Hosts etc etc. Definitely, there are a lot of resources about how to do all those stuff but I have to spend a lot of time for finding those. Because, most of the time the site which I bookmarked last time does not found. Therefore, I am creating this post with collection of commands which will help for set-up LAMP and Virtual Host very quickly.

Setup LAMP:

Step 1: Install Apache

sudo apt-get update
sudo apt-get install apache2

When apache2 installation is done, try hitting http://localhost URL in the browser. It should show Apache2 Ubuntu default page.

Step 2: Install MySQL

sudo apt-get install mysql-server

sudo mysql_secure_installation

Answer y for yes, or anything else to continue without enabling.

You’ll be asked to select a level of password validation. Keep in mind that if you enter 2, for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words.

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

For the rest of the questions, you should press Y and hit the Enter key at each prompt.

Step 3: Install PHP

sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

To do this, type this command to open the dir.conf file in a text editor with root privileges:

sudo nano /etc/apache2/mods-enabled/dir.conf

It will look like this:

/etc/apache2/mods-enabled/dir.conf

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

We want to move the PHP index file highlighted above to the first position after the DirectoryIndexspecification, like this:

/etc/apache2/mods-enabled/dir.conf

DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

sudo systemctl restart apache2

Step 4: Test PHP Processing on your Web Server

sudo nano /var/www/html/info.php

This will open a blank file. We want to put the following text, which is valid PHP code, inside the file:

info.php

<?php phpinfo();
?>

Now visit: http://your_server_IP_address/info.php

sudo rm /var/www/html/info.php

Now the LAMP installation is done!

Now we need to create some virtual hosts. I have found a script which worked great for me, I have forked the script in my GIT, so here is the script: https://github.com/seeamkhan/virtualhost

Download as Zip,  then extract it.

You will find a directory named ‘virtualhost-master’. Open it and add exe permission for the ‘virtualhost.sh’ file:

$ chmod +x /path/to/virtualhost.sh

Now create virtual host by typing this command:

sudo virtualhost.sh create mysite.com

Now browse http://mysite.com

Install phpMyAdmin:

To get started, we can simply install phpMyAdmin from the default Ubuntu repositories.

sudo apt-get update
sudo apt-get install phpmyadmin php-mbstring php-gettext
  • For the server selection, choose apache2.
  • Select yes when asked whether to use dbconfig-common to set up the database
  • You will be prompted for your database administrator’s password
  • You will then be asked to choose and confirm a password for the phpMyAdmin application itself

The installation process actually adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is automatically read.

The only thing we need to do is explicitly enable the PHP mcrypt and mbstring extensions, which we can do by typing:

sudo phpenmod mcrypt

sudo phpenmod mbstring

Afterwards, you’ll need to restart Apache for your changes to be recognized:

sudo systemctl restart apache2

You can now access the web interface by visiting your server’s domain name or public IP address followed by /phpmyadmin:

https://domain_name_or_IP/phpmyadmin

If you get a 404 error upon visiting http://localhost/phpmyadmin:You will need to configure apache2.conf to work with Phpmyadmin.

$ gksudo gedit /etc/apache2/apache2.conf

Include the following line at the bottom of the file, save and quit.

Include /etc/phpmyadmin/apache.conf

Now Restart the apache server and try again to phpmyadmin:

sudo systemctl restart apache2

Decorate Terminal


Everyone loves to decorate their PC. Specially when you are working in a Linux OS there are lots of opportunity to customize and decorate. Here’s a simple one, about how to change user and host name color in terminal:

This is very simple, just open the terminal and type this to edit the .bashrc file:

sudo leafpad ~/.bashrc

Now uncomment the following line:

#force_color_prompt=yes

Then go to the following lines:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Pay attention at the part \u@\h it is saying “user@host” and the number before it \[\033[01;32m\] indicates the color. This is what you have to change. For example, lets change the “user” for red, the “@host” for white, edit the line to looks like:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;37m\]@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Now save the file.

Close the terminal and open it again.

Bingo!!

Shutter Plugin for Simple Border


Shutter is a feature-rich screenshot program for Linux based operating systems such as Ubuntu. You can take a screenshot of a specific area, window, your whole screen, or even of a website – apply different effects to it, draw on it to highlight points, and then upload to an image hosting site, all within one window. Shutter is free, open-source, and licensed under GPL v3.

Official website: http://shutter-project.org/

I have made a simple plugin using shell scripting for Shutter to add a simple 1 pixel black border on the image.

Install shutter

Open terminal and run the following command one by one.

sudo apt-get update
sudo apt-get install shutter

It should install shutter in your ubuntu.

Now from Dashboard search “shutter” and confirm that it has installed.

Configure Shutter

Open shutter and press Alt+P or go to Preferences from menu.

Now click Action tab from left and make the following changes:

  • Check Open wiht Built-in Editor
  • Check Border and make it 1 pixels and color black.

Selection_047
Now click on Behaviour tab and confirm the settings are same as the bellow image:

Selection_048

Now Close the Preferences.

Keyboard Short-cut Settings for Shutter

In Ubuntu dashboard type keyboard and press enter or go to Keyboard settings manually.

After opening Keyboard settings window click “Shortcuts” tab then click “+” icon bellow.

Selection_049

A pop-up will appear type “Shutter” in the Name field and “shutter -s” in Command field then click Apply.

Selection_050

A warning pop-up will appear click Reassign.

Selection_051

Now add another short-cut by clicking “+” icon.

Here the Name should “Shutter full” and Command should “shutter -f”.

Now Apply and click Reassign.

Selection_052

Now close the Keyboard setting.

Now Pressing the Print Screen button on keyboard will appear the screen capture window
with selection area option.

And Cltr+Print Screen button will capture the full screen.

Adding border after editing

If after editing any image the pre-selected border got cut off you can add another using Simple Border Plugin. Simple Border plugin Download.

Please see the Readme.txt file for detail instruction.

Now Quit shutter and run it again.

Now open any image in shutter, press Cltr+Shift+P or right click on the image and click “Run a Plugin”,

select ”Plain Border” and Run.

It will add a border on the image.

Selection_057

How to Create Lan/Samba sharing from Ubuntu


  1. install Samba
    sudo apt-get update
    sudo apt-get install samba
  2. Set a password for your user in Samba
    • sudo smbpasswd -a <user_name>
      • Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...

         

        Tip1: Use the password for your own user to facilitate.

         

        Tip2: Remember that your user must have permission to write and edit the folder you want to share.
        Eg.:
        sudo chown <user_name> /var/opt/blah/blahblah
        sudo chown :<user_name> /var/opt/blah/blahblah

         

        Tip3: If you're using another user than your own, it needs to exist in your system beforehand, you can create it without a shell access using the following command :
        sudo useradd USERNAME --shell /bin/false
        
        You can also hide the user on the login screen by adjusting lightdm's configuration, in /etc/lightdm/users.conf add the newly created user to the line :
        hidden-users=

         

  3. Create a directory to be shared [optional]
    mkdir /home/<user_name>/<folder_name>
  4. Make a safe backup copy of the original smb.conf file to your home folder, in case you make an error
    sudo cp /etc/samba/smb.conf ~
  5. Edit the file “/etc/samba/smb.conf”
    sudo nano /etc/samba/smb.conf
    • Once "smb.conf" has loaded, add this to the very end of the file:
      
      [<folder_name>]
      path = /home/<user_name>/<folder_name>
      available = yes
      valid users = <user_name>
      read only = no
      browseable = yes
      public = yes
      writable = yes

       

      Tip: There Should be in the spaces between the lines, and note que also there should be a single space both before and after each of the equal signs.

       

  6. Restart the samba:
    sudo service smbd restart
  7. Once Samba has restarted, use this command to check your smb.conf for any syntax errors
    testparm
  8. To access your network share

    To access your network share use your username (<user_name>) and password through the path “smb://<HOST_IP_OR_NAME>/<folder_name>/” (Linux users) or “\\<HOST_IP_OR_NAME>\<folder_name>\” (Windows users). Note that “<folder_name>” value is passed in “[<folder_name>]”, in other words, the share name you entered in “/etc/samba/smb.conf”.

    • Note: The default user group of samba is "WORKGROUP".
  9. Now from GUI go to any directory.
  10. Right click on it > go to Properties.
  11. Click “Local Network Share” > Click “Share this folder” > click “Create share” at the right bottom.
  12. Now it is done.
  13. Go from any network PC and hit the ip address.
  14. Use user/pass (samba) and happy Browsing!! 🙂

Source

Create a free website or blog at WordPress.com.

Up ↑