Pages

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, January 28, 2016

Reset default superuser password of PostgreSQL database

If you forgot the password of the PostgreSQL database, you can reset it by following below steps:

Start PSQL terminal with following command
$sudo -u postgres psql postgres

Then run following command and will ask to enter new password:
# \password postgres

Enter new password:
 

This method is tested with PostgreSQL 9.1.12

Wednesday, January 13, 2016

Mount Windows shared file in Linux

This post mainly focus on how to mount windows shared file in Linux.

"mount" command [1] is used to attach file systems  (located on an attached device or in network) to the file system tree at specified node.

To mount network shared file, the format of the command with most basic options as follows:

mount -t <type> //<hostname>/<shared_name> <path_to_mount_point>

type: File-system type. In this case cifs (Common Internet File System is variation of SMB protocol developed by Microsoft and native file sharing protocol used in Windows for more information refer [2])
hostname: Host name of the server (or ip address)
shared_name : Name of the shared directory/file
path_to_mount_point : path to the directory that shared file system should be mounted to file system tree

eg:
sudo mount -t cifs //10.100.5.92/TempShareDoc ~/Documents/share/ -v

If you need to mount password protected shared file, you can add those information as options username and password as follows
mount -t <type> -o username=<user_name>,password=<password> //<hostname>/<shared_name> <path_to_mount_point>

Also we can set the permissions of the mounted file system using dir_mode (directory permissions) and file_mode (directory permissions) options, as follows
mount -t <type> -o dir_mode=<permissions>,file_mode=<permissions> //<hostname>/<shared_name> <path_to_mount_point>

eg: 
sudo mount -t cifs -o dir_mode=0755,file_mode=0755  //10.100.5.92/TempShareDoc ~/Documents/share/ -v


[1] http://linux.die.net/man/8/mount
[2] https://technet.microsoft.com/en-us/library/cc939973.aspx

Saturday, July 26, 2014

How to create desktop file in linux

If we install software in linux (in this case consider Ubuntu) manually, which is without using package management software like "Ubuntu Software Center", we are unable to launch them from the launcher or main menu (we need to launch software from the terminal).

Let's see how we can list our application on the menu ......

To add applications to the menu we have to create a desktop file which is a text file with ".desktop" extension with a unique name which contain meta-data about the application.

Before creating a desktop file, we'll see how applications installed via Ubuntu Software Center appeared in main menu.

If I install "myPaint" application using software center, the desktop file is look like this:



Let's see how we can create a desktop file.

The primary functions of desktop file is to inform desktop environment, how to handle file such as menu placement, and how to display.

Format of .desktop file

The desktop file consists set of key-value pairs.

[Desktop Entry] Header to recognize key value pairs associated with desktop
Type [required] Type of desktop entry
Encoding [optional] Encoding of the entries in the file
Name [required] Name of the application / directory. This is the display name in the menu or launcher
GenericName [optional] Can used to state the generic name of the application.
eg.: "Text Editor" for "GEdit"
Comment Comment which can be used as a tooltip. Can include any useful information
Exec [required] The actual command to execute the target application from a shell. We also can add additional arguments if needed.
Icon [optional] Icon to be used
Terminal [optional] Boolean entry to specify whether the application requires terminal to execute

There are more optional entries refer Recognized desktop entry keys

Now let's test .......

 here are steps to follow to add eclipse IDE to the main menu in Ubuntu

  • Extract eclipse distribution to the target installation directory.
  • Create the desktop file
       Create the desktop file at:
           /usr/share/applications/ directory if it is globally available application
          ~/.local/share/applications if only for specific user 

[Desktop Entry]
  Version=1.0
  Name=Eclipse

  Exec=eclipse
  Terminal=false
  Icon=/opt/eclipse/icon.xpm
  Type=Application
  Categories=IDE;Development
  X-Ayatana-Desktop-Shortcuts=NewWindow

  [NewWindow Shortcut Group]
  Name=New Window
  Exec=eclipse
  TargetEnvironment=Unity
  • Restart the PC or logout  

Now the you can invoke eclipse from main menu....

Cheers ..