How to list installed packages on RedHat

How to list installed packages on RedHat/CentOS

Basic listing

rpm –qa

or
yum list installed

 

Detailled and sorted by installation date

rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -n

 

Tackle X11 remote display issue

We attempt to export a X11 display of a server to a remote computer. However the display does not appear on the remote host.
We need to identify where it fails.

Check the client firewall

Obvious… but so necessary….
– Check (and temporary deactivate if possible) the firewall of the client.

Check that display is well exported on the server

Yes this is evident but has to be checked first…

Verify that the client is listening

  • Check on the client that MOBAXterm or Exceed or another X server is effectively listening to port 6000
  • Use netstat command to see if something is listening on port netstat –ano

Traceroute from server to the client

This could show an intermediate firewall or netxork equipment that may filter the traffic
traceroute -p 6000 target_ip

Test connectivity with Nmap X11 script

Nmap provides X11 testing scripts to ease debug.
I did some tests to compare script results with 2 known working machines on the same subnet (that work) and the real server->client setup.
Results show differences. In the second attempt, Nmap indicates that X11 traffic may be filtered and X11 session cannot be started.

Attempt connection between working LAN machines:

nmap -Pn -p6000 --script x11-access target_IP_address_that_works

Starting Nmap 5.51 ( http://nmap.org ) at 2015-02-19 16:37 CET
Nmap scan report for target_host_that_works (target_IP_address_that_works)
Host is up (0.0011s latency).
PORT     STATE SERVICE
6000/tcp open  X11
|_x11-access: X server access is granted

Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds

Attempt connection to the real client computer

nmap -Pn -p6000 --script x11-access target_IP_address

Note the filtered X11 words in result. Chances are high that a firewall is blocking our destination port.

Starting Nmap 5.51 ( http://nmap.org ) at 2015-02-19 16:37 CET
Nmap scan report for target_computer.corp (target_IP_address)
Host is up.
PORT     STATE    SERVICE
6000/tcp filtered X11

Nmap done: 1 IP address (1 host up) scanned in 2.08 seconds

Re-check the client firewall

Yes, yes, already said…. but the gap between theory and practice ….just redo it….

JSF JMeter SiteMinder

Quick notes on how to configure a JMeter test scenario for a JSF application protected by SiteMinder.

 

For this example, we consider that the URL of our application is http://serverName.corp/AppContext

 

General setup

 

Under thread group use HTTP request default :

 

  • server name: servername.corp

  • path: /AppContext/

  • and very important tick follow redirect !!

 

Authenticate against SiteMinder

 

We need the thread group to record SiteMinder related authentication and submit it with each request.

 

Add an HTTP Header manager

  • all set to default

 

Add an HTTP cookie manager

  • policy: default

  • implementation: HC4CookieHandler. This is important, the default does not work.

 

Add an HTTP Authorization manager

 

               

Add a basic HTTP request to application root

This request allows to authenticate to SiteMinder prior to running the scenario. Nothing to configure in this request because root is the default target of our thread group.

 

Tick the option follow redirect in this first request.

 

 

Extract and re-inject JSF session-related content

 

By default, when recording the scenario, the values of JSF session are hardcoded in the script.

This will lead to errors in subsequent run because the Session ID and related session may have expired.

 

We need to add an extractor to get the JSF session data out of server response and re-inject it in the following requests as a browser would do.

 

If you forget this step, you are likely to encounter an error like “cannot restore view”

 

Extract view state using an expression extractor

 

Under first recorded request, add a JSF Regular Expression Extractor

  • Reference name (i.e. the name of the variable where state will be stored): jsfViewState

  • Regular expression: <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="(.+?)" autocomplete="off" />

  • template: $1$

  • default value (will be used if value cannot be extracted): wrong_value_easily_identifiable

 

Substitute value in subsequent requests

 

Modify subsequent request to replace recorded (hardcoded) value of javax.faces.ViewState by ${jsfViewState}

 

Save full workbench

When using workbench, tick save workbench to embed it to the saved file.

Validate xml against local schema in eclipse

When an XML file references his schema (xsd) url, editing is easier in Eclipse. We can validate the xml file against this schema and use eclipse content assist which suggest possible values of tags.

An invalid reference to the schema.

In my current work, I have to edit XML files whose schema reference are invalid.

In the example below the xsd definition is not only commented out but also malformed. However I want the document to validate against modelSchema.xsd but I am not allowed to modify the header.
This is not the first time I see this on production environments. I suspect this is a quick and dirty workaround to avoid a parsing error when the server is not well configured to reach the Internet (or the schema is not deployed locally on the server).

<!--?xml version="1.0" encoding="UTF-8"?-->
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="my:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <description>Custom Model</description>
    <author>odm</author>
    <version>1.0</version>
</model>

Workaround: force eclipse to validate localy

Copy the xsd file localy and configure eclipse XML catalog to use the local schema to validate and provide content-assist.

Under Global preferences/XML/XML catalog, add a new entry:

location myEclipseProject/modelSchema.xsd
key type: namespace entry
key: http://www.alfresco.org/model/dictionary/1.0

Right click on the xml file, launch “validate”.

 

Automate wordpress backup (with BackWPup)

A set-up and forget scenario

I used to backup wordpress sites via FTP and export of the database. But it takes a lot of time. And with an increasing number of sites to maintain, I often skip this essential practice.

I just discovered BackWPup, a very configurable plugin for wordpress. It does everything I used to do… and can be scheduled !

What I need to backup

  • wordpress files
  • custom themes
  • plugins
  • database export
  • uploaded content

I store the backup on my laptop and on an external service (Dropbox).

Backup with one click

BackWPup builds a ZIP archive that contains the whole wordpress directory as well as  the SQL file that can be used to regenerate the tables.

The archive is sent by email or stored on a folder of the site. Even better : support for Dropbox or  amazon S3 is native and configured in a minute.

I made it push an archive of the site directly to a /fieldnotes folder of my dropbox account.

  • install the plugin
  • add a new backup job via the admin interface (settings are fine by default)
  • indicates where to store the backup
  • … that’s all !

Trigger the backup manually from the admin interface to ensure the setup is correct.

Schedule it !

You can now add scheduling via the admin panel (only pitfall: remember to tick the Activate scheduling checkbox) and enjoy receiving regulars backups in your dropbox !

 

 

Disable firefox offline mode

When Firefox 3.6 detects a network connection issue, it switches to offline mode.

I find it rather annoying as it forces me to manually switch to “online”  mode via the file menu each time I replug my laptop.

This behavior can be disabled via a hidden preference.

Type about:config in Firefox address bar, right click to add a new Boolean key and create

network.manage-offline-status

set it to false

Alternatively you may add an extension for this: https://addons.mozilla.org/en-US/firefox/addon/13152/

Bash syntax highlighting for eclipse

ShellEd adds syntax highlighting for bash to Eclipse (tested under  3.5.1 Windows).

The project page and installation instructions.

I couldn’t install it by downloading the zipped plugin, it only worked using the update site.

Cancel a scheduled task in javascript

More than often, the application UI consists in one master table that is used to refresh a slave one (item-details view).

When the user selects one record of the item list, the detail frame is refreshed with the fields related to this item. We use AJAX request to refresh the detail view.

However, multiple useless requests may occur when the user scrolls quickly through the master table. This can be avoided if we decide to refresh the detail view only if the user selection remains the same for a certain time.

The example below presents such mechanism.

The showDetails() function is called by a UI event such as onMouseOut().  The trick consist in delaying the refresh (by one second here), via a setTimeout() function. We keep track of the scheduled call in a global variable. This allow us to cancel the request in case another item in selected in the meantime.

var reqID = null; // Global var to avoid multiple requests when scrolling through the Item table
 
function showDetails(selectedItem) {
    if (reqID){
         // If an delayed AJAX call was already scheduled , we cancel it
        clearTimeout(reqID);
        reqID=null;
     }
 // Schedule a delayed ajax call (1s)
 reqID = setTimeout( function() { myMagicAjaxCall(selectedItem);}, 1000);
}

Thanks to StackOverflow article for the initial suggestion

An easier search with vim

Use incremental (search as you type) and case insensitive search in vim.

Edit ~.vimrc to add:

:set incsearch
:set ignorecase
:set smartcase
:set nu

ignorecase allow a case-insensitive search.  When smartcase is also used, it makes the search case-sensitive if the searched term contains an uppercase.

Thanks to Linux Magazine for the original article:

http://www.linux-magazine.com/w3/issue/85/Vim_Tricks.pdf