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)

Tuesday, December 3, 2013

How to hide web server version from appearing in http header

For apache, just add below lines into /etc/apache2/apache2.conf:

ServerTokens Prod

ServerSignature Off

where ServerTokens controls what kind of information being sent to the header. Options available for ServerTokens are(from apache docs):



ServerTokens Prod[uctOnly]
Server sends (e.g.): Server: Apache
ServerTokens Major
Server sends (e.g.): Server: Apache/2
ServerTokens Minor
Server sends (e.g.): Server: Apache/2.0
ServerTokens Min[imal]
Server sends (e.g.): Server: Apache/2.0.41
ServerTokens OS
Server sends (e.g.): Server: Apache/2.0.41 (Unix)
ServerTokens Full (or not specified)
Server sends (e.g.): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2


while ServerSignature is to allow configuration of a trailing footer line under server generated documents, such as error messages and mod_proxy ftp directory listings. Putting it to off will suppress the footer line.

Once added, restart or reload apache to activate the changes.
# /etc/init.d/apache2 restart

For nginx, add below line into your /etc/nginx/nginx.conf:


server_tokens off

where this line of config will hide your nginx version number. Do not forget to restart or reload nginx, for the change to take effect.
# /etc/init.t/nginx restart

To check for the header, you can use curl:


curl -I www.foo.net

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Server: Apache/2.2.15 (Red Hat)

where -I is for curl to grab just the http header.

Thursday, November 28, 2013

Manually manipulating iptables in CentOS and Redhat

The iptables rules in redhat based distro is being kept by default in /etc/sysconfig/iptables and /etc/sysconfig/ip6tables. To manipulate the firewall, just add or remove rules from this file, and restart iptables services. For example, we want to allow tftp port, which is port 69 udp:

  1. Edit /etc/sysconfig/iptables
    • # vi /etc/sysconfig/iptables
  2. Add the following lines, before the final LOG and DROP lines for INPUT chain:
    • -A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT
  3. Save and close the file
  4. Restart iptables service:
    • # /etc/init.d/iptables restart
  5. Check your new iptables rules, where -L is to list all rules in the selected chain, and -n is for printing port in numeric output:
    • # sudo iptables -L -n
  6. And you can see that
    "ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:69"
    line is in the iptables file.
  7. To save the new rules permanently, just run:
    • # /etc/init.d/iptables save 

To block any particular port, you just need to edit /etc/sysconfig/iptables, remove the ACCEPT line that contain that port, and restart iptables, and you are done :)

Easily open port and service on iptables using lokkit

Lokkit is an iptable manipulating tool, and it belongs to system-config-firewall-base rpm package. This tool has many usage, but in this article, I just want to share on how to open a port in iptables using lokkit. Let's say we want to open a tcp port 1234, below is the command to do it (you must be root, or using sudo do execute this):

# lokkit -q -p 1234:tcp

where -q is for quiet mode, where no message will appear once the operation is done, and -p is for the port and protocol, in this case port 1234 using tcp protocol.

If you want to open a common service like ssh, it can be done easily by using the -s flag
# lokkit -s ssh

To list all available services that lokkit can manage, use:
# lokkit --list-services

Predefined Services with Default Environment:

ipp-client: Network Printing Client (IPP)

    default: desktop

ipp: Network Printing Server (IPP)

mdns: Multicast DNS (mDNS)

    default: desktop

ipsec: IPsec

    default: desktop

ssh: SSH



    default: server

...

To see more verbose output, you can use -v flag, like below:
# lokkit -s tftp -v
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
ip6tables: Applying firewall rules:                        [  OK  ]