Thursday, July 10, 2014

How to refresh your ldap name database in an ldap client

This is useful when, you have a server that is authenticated by ldap. After you have edited something in your ldap server, let's say you have edited a gid for a user, you would find out that it won't be reflected immediately on the client side. So in this case, how would you force your client to accept your newly changed settings? The answer is you need to restart nscd (name service cache daemon):

$ getent passwd pauld

pauld:x:1987:1987:Paul Daniels:/home/pauld:/bin/bash
So after you have made your changes in the server, let's say you want to change pauld's gid to 4000, run the above command again:

$ getent passwd pauld

pauld:x:1987:1987:Paul Daniels:/home/pauld:/bin/bash

Still the changes are not being reflected there. To solve this, simply restart nscd:

$ sudo /etc/init.d/nscd restart

Stopping nscd:                                             [  OK  ]

Starting nscd:                                             [  OK  ]

You should be seeing your change is now updated in the user database:

$ getent passwd pauld

pauld:x:1987:4000:Paul Daniels:/home/pauld:/bin/bash


PS: If for some reason you are still not seeing the new data, you can invalidate the nscd database by:
$ sudo nscd --invalidate=passwd 

where passwd is the name of the table name in nscd database. You can see all available table name in /var/db/nscd 

To look into what is the content of each table, please use strings command:
$ sudo strings /var/db/nscd/passwd




Tuesday, July 1, 2014

How to install custom upstart script

To install custom upstart script, please follow below steps (in this example, I'll be using a service call cat):

  1. Copy the script into /etc/init 
  2. To make upstart distinguish the new service, run: 
    • $ initctl reload-configuration 
  3. Check whether your script is already in upstart by running:
    • $ initctl list | grep cat 
      cat stop/waiting
  4. And you are done, you can check the status of your service by running:
    • $ service cat status 
      cat stop/waiting
  5. You can also do the same with start, stop and restart
    • $ service cat start
      * Starting cat .... [OK]
    • $ service cat stop
      * Stopping cat .... [OK]
    • $ service cat restart * Restarting cat .... [OK]

Thursday, June 5, 2014

How to check which package a file belongs to in Redhat or Centos

If the package is not installed, run below commands (in this example, i use mkpasswd as an example):
$ yum whatprovides "*/mkpasswd" 
OR
$ repoquery -q --file */mkpasswd


If the package is installed:
$ rpm -qf /usr/bin/mkpaswd 

Wednesday, May 28, 2014

How to install HP PSC 1410 printer on Precise Puppy Linux 5.7.1

After some hair pulling, I managed to get this printer installed. Below are the steps that I have taken:
  1. Turn on and connect the printer to the puppy machine
  2. Install hplip using puppy package manager. Run command "ppm" on terminal, and search for hplip.
  3. Make sure all dependencies are installed
  4. Launch cups by going to http://localhost:631
  5. Go to "Administration -> Printer -> Add printer" OR "Administration -> Printer -> Find new printer"
  6. Choose the printer with connection like "usb://HP/PSC%201400%20series?serial=CN5CDC60T004BM" with hplip in the name
  7. For Driver, choose "HP PSC 1400 Series, hpcups 3.12.9 (color, 2-sided printing)"
  8. Set default settings for the newly added printer by going to "Printer -> HP PSC 1410 -> Administration -> set default option". Print settings in application does not work.
  9. You are done..... Congratulation :)

Tuesday, May 13, 2014

The definition of ls column headers in long listing mode

Thanks to http://www.unix.com/unix-dummies-questions-answers/41832-ls-l-column-headings.html, I have managed to find out what is the meaning of all the column header in ls -l command. Below are the details:

# ls -l
total 52
drwxrwxrwx   2 root root    41 Jan 14  2013 archive
drwxr-xr-x   2 root root  3072 Aug  3  2013 bin
-rw-r--r--   1 root root   578 Jan 14  2013 README-archive.txt 
lrwxrwxrwx   1 root root     3 Feb 17  2013 run -> tmp


1st column is file type(d for DIR, - for Files, l for links) and access details for UGO (User Group Others aka file permission).

2nd column is Number of links (2,1), the number of names there are for the file. Generally an ordinary file will only have one link, but a directory will have more, because you can refer to it as ``dirname'', ``dirname/.'' where the dot means ``current directory'', and if it has a subdirectory named ``subdir'', ``dirname/subdir/..'' (the ``..'' means ``parent directory'').

3rd Column is File/directory owner (root)

4th Column is File/directory group (root)

5th Column is Size of the file and Dir (41, 3072)

6th Column is Date the file / DIR created. ( Jan 14  2013)

7th Column is File Directory name (archive, bin)