X11 Forwarding – SSH using XMING

After many years of working with PeopleSoft I try not to get to worried about the little things, because so much changes every day that you could lose your mind trying to keep track of it all.

I was doing an install of the Oracle Database software on a new RHEL 5.8 server the other day and I could not get my X11 forwarding working.  Now I don’t claim to be an expert in SSH and never will be, but I use the Bitvise Tunnelier and then use XMing for the SSH/X11 client software.  On this server I had setup the SSH Daemon to run X11 forward on using the default off-set 10.  This basically means that the communication for X11 will be on port 6010 instead of 6000. This means that your display variable will need to be set differently.  This is the export command I used:

export DISPLAY=localhost:10.0

In a lot of cases it will just show you 0.0, but because of the offset you need to change to 10.0 when using the off-set of 10. When setting up my SSH connection in Tunnelier, under the terminal tab, you need to enable X11 forwarding, and you will need to change your Display variable appropriately, in my case I was using the offset: 10, so I entered:

127.0.0.1:10.0

Lastly, I found that the XMing client defaults to NO offset, so when I launched XMING launch, on the first page it asks what the offset should be be.  Once I changed that to 10, everything started working great.

It should also be noted that if you are using a firewall (in my case iptables) you will want to make sure port 6010 is open correctly if using the ssh-offset 10.

The common error I got with this configuration being wrong as: Windows TCP error code 10061.

Redhat – Changing the Prompt

When working on SSH sessions, you run into some environments that have weird prompts and colors associated with the prompt. Often I find I can’t even see the prompt where it is a dark blue on black. Maybe that is just a sign that I am getting older but it is really difficult to see.

So to change the prompt here are a list of options:

  • \a : an ASCII bell character (07)
  • \d : the date (Format: “Tue May 26”)
  • \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
  • \e : an ASCII escape character (033)
  • \h : the hostname up to the first ‘.’
  • \H : the hostname
  • \j : the number of jobs currently managed by the shell
  • \l : the basename of the shell’s terminal device name
  • \n : newline
  • \r : carriage return
  • \s : the name of the shell, the basename of $0 (the portion following the final slash)
  • \t : the current time in 24-hour HH:MM:SS format
  • \T : the current time in 12-hour HH:MM:SS format
  • \@ : the current time in 12-hour am/pm format
  • \A : the current time in 24-hour HH:MM format
  • \u : the username of the current user
  • \v : the version of bash (e.g., 2.00)
  • \V : the release of bash, version + patch level (e.g., 2.00.0)
  • \w : the current working directory, with $HOME abbreviated with a tilde
  • \W : the basename of the current working directory, with $HOME abbreviated with a tilde
  • \! : the history number of this command
  • \# : the command number of this command
  • \$ : if the effective UID is 0, a #, otherwise a $
  • \nnn : the character corresponding to the octal number nnn
  • \\ : a backslash
  • \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  • \] : end a sequence of non-printing characters

In order to change the color you will need to add the escape sequence:  \e[x;ym where x = 0 or 1, zero is darker and one is lighter.

  • y = 30 – Black, 31 – Red, 32 – Green, 33 – Brown, 34 – Blue, 35 – Purple, 36 – Cyan

So to change your prompt to be Red with user @ machine short name showing the directory in brackets and a mode at the end you would do the following, note that the \e[m at the end of the string effectively ends the color change otherwise the color change will impact everything that isn’t color controlled:

export PS1=’\e[1;31m[\u@\h \W] \$ \e[m’

Unix – chmod – File Permissions

Every now and then I find that I am battling permission issues in the unix environment and it usually turns out to be the permissions that are set on the directory or file.  Unix has an interesting way of handling permissions.  If you do a list command “ls -l” you will see a box of information on the left that looks like:

———- (10 dashes) If you see this, the file has NO rights (pretty rare).

The first position you will commonly see a “d” or “l”, the “d” is for directory, and “l” is for a link.

Position 2 to 4 are the owner permissions “rwx”, where “r” is read, “w” is write, “x” is execute

Position 5 to 7 are the group permissions “rwx”, where “r” is read, “w” is write, “x” is execute

Position 8 to 10 are the world permissions “rwx”, where “r” is read, “w” is write, “x” is execute

You can change the permissions using the command: “chmod”

To grant the read permission you give a value of 4, write permission is 2, and execute is 1.  So if you want to grant read+write, you would do 4+2 = 6.  And when you issue the chmod you give it a number for each permission (owner, group and world), so if you wanted to give the owner, group and world read and write access to a file you would issue the command:

chmod 666 filenametochangepermissionsto

Another useful function is the chown function, which changes the owner and/or group permission.

chown user:group filenametochangeownershipto
chown -R user:group directorytochangeownershiptorecursivelyto


PeopleSoft – Redhat (RHEL5.7) – sysctl parameters

Just to drive the system administrator nuts, for some reason Redhat sysctl parameters by default are not robust enough to handle starting up even a small application server. There are several cases on My Oracle Support that explain how to set the variables but at a minimum I found this to a good starting point:

fs.file-max = 65536
kernel.msgmni = 512
kernel.msgmax = 1048576
kernel.msgmnb = 1048576
kernel.shmmni = 4096
kernel.shmmax = 33554432
kernel.sem = 250 256000 64 1024

You can add/modify these entries in the sysctl.conf file (/etc/sysctl.conf). Once they are modified you can put them into effect by issuing sysctl -p. If you want to do a change temporarily you can issue: sysctl -w parameter=value.