Archive for 2004

Processes and grep, the pgrep command

Thursday, August 19th, 2004

The pgrep command looks at the active processes on your system and displays information matching the criteria you specified.

Let’s see some sample usage.

List all the processes owned by root as long as process names:

pgrep -l -u root

In the same way list all the processes owned by snort and apache users and use “, ” (comma+white space) as field delimiter:

pgrep -l -u snort,apache -d”, “

List the processes whose controlling terminal is pts/0:

pgrep -l -t pts/0

List the processes whose controlling terminal is NOT pts/0:

pgrep -l -t pts/0 -v

References:

Starting squid with a clean cache

Friday, July 30th, 2004

Squid is an open source web proxy cache designed to run on Unix machines. Squid caches repeated requests thus increasing performance. But in some situations you will want to start Squid with an entirely clean cache. This tip will show you how.

First of all stop Squid and then…

echo ” ” > /path/to/squid/caches/swap.state

Now restart Squid and your done!

Note that you should repeat the above for every directory defined in the cache_dir option within squid.conf.

Happy System Administrator Appreciation Day!

Wednesday, July 28th, 2004

It’s here! SysAdmin appreciation day! Friday July 30th 2004!

Take a look at this site.

Gentoo Linux 2004.2 released

Wednesday, July 28th, 2004

Gentoo Linux has announced the new 2004.2 release. According to Gentoo the improvements include:

  • LiveCD compatibility with SMP machines
  • x86 laptop PCMCIA support
  • SATA support
  • And more

Links

Signals for kill

Friday, July 16th, 2004

Here goes a list of kill signals:


SIGHUP 1 Exit Hangup
SIGINT 2 Exit Interrupt
SIGQUIT 3 Core Quit
SIGILL 4 Core Illegal Instruction
SIGTRAP 5 Core Trace or Breakpoint Trap
SIGABRT 6 Core Abort
SIGEMT 7 Core Emulation Trap
SIGFPE 8 Core Arithmetic Exception
SIGKILL 9 Exit Killed
SIGBUS 10 Core Bus Error
SIGSEGV 11 Core Segmentation Fault
SIGSYS 12 Core Bad System Call
SIGPIPE 13 Exit Broken Pipe
SIGALRM 14 Exit Alarm Clock
SIGTERM 15 Exit Terminated
SIGUSR1 16 Exit User Signal 1
SIGUSR2 17 Exit User Signal 2
SIGCHLD 18 Ignore Child Status Changed
SIGPWR 19 Ignore Power Fail or Restart
SIGWINCH 20 Ignore Window Size Change
SIGURG 21 Ignore Urgent Socket Condition
SIGPOLL 22 Exit Pollable Event
SIGSTOP 23 Stop Stopped (signal)
SIGTSTP 24 Stop Stopped (user)
SIGCONT 25 Ignore Continued
SIGTTIN 26 Stop Stopped (tty input)
SIGTTOU 27 Stop Stopped (tty output)
SIGVTALRM 28 Exit Virtual Timer Expired
SIGPROF 29 Exit Profiling Timer Expired
SIGXCPU 30 Core CPU time limit exceeded
SIGXFSZ 31 Core File size limit exceeded
SIGWAITING 32 Ignore Concurrency signal reserved by threads library
SIGLWP 33 Ignore Inter-LWP signal reserved by threads library
SIGFREEZE 34 Ignore Check point Freeze
SIGTHAW 35 Ignore Check point Thaw

Memory allocation DOS

Monday, July 12th, 2004

A bug in Apache 2.0.49 may allow a remote attacker to perform a Denial of Service attack by exhausting memory. It seems that 1.3.x releases are safe.

For more information:

Adding static routes to Solaris

Monday, July 12th, 2004

From the Sun FAQ on routing:

Static routes are usually only used in conjunction with a /etc/defaultrouter. You might do so if you had a couple of networks which you did not want to go through your defaultrouter. In that case, you will probably want to make the routes permanent, by adding the route commands to the /etc/init.d/inetinit file.

You can not use the above method to add static routes if you are running in.routed, as in.routed will automatically remove them after 90 seconds. If you are using in.routed, but want to include a few static routes, you can do this with the /etc/gateways file.

A simpler approach to this question would be to create an init script and add your routes:

vi /etc/rc2.d/S76static-routes

route add net 192.168.10.0 netmask 255.255.255.0 192.168.10.1 1

Protecting configuration files

Wednesday, June 30th, 2004

When you update packages in your Gentoo Linux system you should be careful to avoid the configuration files to be overriden by new ones during the emerge process. To protect the configuration files in your system portage provides a feature called config file protection.

Take a look at /etc/make.globals and find out the CONFIG_PROTECT variable. This variable contains a list of protected directories and it will look something like:

CONFIG_PROTECT=”/etc /usr/share/config”

Simply add your protected directories separated by white spaces. Now new files will not override existing files installed in a protected directory, instead they will be renamed as ._cfg0000_blah. In addition etc-update is available to assist you while merging these files.

Note that portage will not delete files in protected directories when a package is unmerged.

References:

  • emerge -h config
  • man etc-update

Gracefully restarting Apache

Monday, June 14th, 2004

When you restart your Apache by issuing…

apachectl restart

or

/etc/init.d/apache restart

the httpd daemon is stopped and started again closing currently open connections.

There is a way to restart Apache’s http daemon keeping current connections opened. Simply type:

apachectl graceful

This is useful if you changed the httpd.conf configuration file and want Apache to re-read it keeping connections.

OpenSSH: port forwarding during active sessions

Tuesday, June 8th, 2004

Imagine you are logged into a remote system and want to forward a local port to the remote system without logging out and logging in again. This little trick will tell you how to do this.

According to OpenSSH man pages:

Escape Characters
When a pseudo terminal has been requested, ssh supports a number of
functions through the use of an escape character.
....

The supported escapes (assuming the default `~') are:
.....

~C Open command line (only useful for adding port forwardings using
the -L and -R options)

.....

So, to add a local forward after logging into the remote system procede as follows:

ssh user@remote_host

Once logged in…

CR~C

Hit carriage return then ~ and the C and you’ll get a prompt where you could type something like this:

ssh> -L 8022:127.0.0.1:22
Forwarding port