Monday, February 9, 2015

Linux file-folder permission sticky bit

In UNIX like systems there are special permissions for folders and files. Sticky bit is one of the special permission.

The sticky bit is a user ownership access right flag that can be assigned to files and directories on Unix-like systems.

When a directory's sticky bit is set, the file system treats the files in such directories in a special way so only the file's owner, the directory's owner, or root user can rename or delete the file.

The sticky bit can be set using the chmod command and can be set using its octal mode 1000 or by its symbol t.

For example, to add the sticky bit on the directory /test one can type chmod +t /test
To clear it, use chmod -t /test


If the sticky-bit is set on a file or directory which doesn't have execution permission to others, it is indicated with a capital T


Thursday, February 5, 2015

X11 forwarding not working from putty and XMing on RHEL 6.x

X11 forwarding not working from putty and XMing on RHEL 6.x

X11 forwarding:

We can run graphical programs on Linux machines remotely and display them on your desktop computer running Windows. We can do this by using running two applications together on your Windows machine: Xming and PuTTY.

What is Xming:

Xming is a PC X Window Server. This enables programs being run remotely to be displayed on your desktop

About PuTTY: 

PuTTY is a free SSH client. Through PuTTY we connect to a remote machine via SSH protocol.

Install Xming and run Xming on task-bar.


Configuring PuTTY


  • Enter the hostname and port (ssh) of the server you want to connect.
  • Next scroll to Connection > SSH > X11. Check the box next to Enable X11 Forwarding. By default the X Display location is empty. You can enter localhost:0. The remote authentication should be set to MIT-Magic-Cookie-1

 


  • Click open to connect the session using X11 forwarding.
  • Try run your graphical applications.


X11 forwarding not working

In some of cases you might get stuck and don't get graphical interface coming in your local Windows Desktop.

  • Check X11 forwarding it setting $DISPLAY or not in your remote server first.


To resolve this problem you have to check and configure few things in your remote server.
  • To get X11 forwarding running you need following RHEL packages in your remote server.

                # yum install xauth -y

  •  If you use X-Forwarding: you don't need to directly use xauth or set a DISPLAY variable. Use PuTTY with SSH and X-Forwarding and enable it in the sshd server on the remote machine i.e. check its sshd_config file has following configurations


               X11Forwarding yes
               X11DisplayOffset 10
              X11UseLocalhost yes

  • Now try connect to remote server using X11 Forwarding enable in PuTTY. You will get result of $DISPLAY


Warning: I strongly recommend you do not alter DISPLAY on the remote server terminal, when using X11 Forwarding...you may end up with working graphical windows.

  • Now try run some graphical application from remote server and get the GUI in your Windows Desktop.
Thanks for reading.

Wednesday, February 4, 2015

OpenOffice as windows service

Running "OpenOffice headless" as a service in Windows

OpenOffice is a great third party tool used for Document preview generation. 
I have been using this tool in number of applications like Liferay, Alfresco, Drupal etc
In all these applications it have feature to show previews online on the portal. For generating preview we need OpenOffice to run in headless.

It is always be annoying to run OpenOffice headless manually. That is why we need a smooth running service of this application in the background.

You can easily configure OpenOffice headless as a windows service. 

How to begin

My environment detail:
Operating System - Windows Server 2008 
OpenOffice - 3.4.1

Follow the steps to create windows service.

  • Download srvany.exe and copy it in C:\Windows\system32 folder. You can also extract srvany.exe from Windows Server 2003 resource Kit 
  • Go to command prompt. You should have administrator privileges to perform this activity. 

    Command Syntax

    C:\Windows\system32>sc create "openoffice" binPath= "\"C:\Program Files (x86)\OpenOffice.org 3\program\soffice.exe\" -headless -nologo  -nocrashrep -norestore -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard" DisplayName= "OpenOffice 3.x Server" start= auto

    [SC] CreateService SUCCESS

  • Open Registry Editor (regedit) and Navigate to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\openoffice
  • Copy the value of the ImagePath to the clipboard.
  • Alter the value of ImagePath to "C:\Windows\System32\srvany.exe"
  • Add a new Key named "Parameters", this is essentially a folder.
  • Add a new String Value named "Application" and set the value to the clipboard contents copied from the ImagePath.

  • Start the service openoffice. 
  • Check if the open office service is started and running fine.

  • Command Syntax
    C:\windows\system32>netstat -nao |findstr -c ":8100"
    TCP       127.0.0.1:8100         0.0.0.0:0              LISTENING       7856