May 11, 2005

How to upgrade the Ports tree?

Filed under: FreeBSD — Administrator @ 12:13 pm

Once in a while (or maybe regularly) you may want to upgrade the Ports tree (/usr/ports collection). The easiest way to do this is to use cvsup. Here’s the command:

/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile

After upgrading you *_MUST_* update the ports index file and the database file (INDEX.db) by issuing this command:

/usr/local/sbin/portsdb -Uu

May 7, 2005

Kexec - FAST reboot!

Filed under: Linux, Advanced — Administrator @ 5:27 pm

Ever got frustrated thinking “why does it take so long for Linux to reboot?”. Me too. Specially, when the server is a production server.

Well, there’s some hope. OSDL is developing a new tool that will reduce the time to reboot linux. It’s called ‘kexec‘. It’s still in development stage. But, it’s a good time to start playing with it. If you want to know more about it then check out the white paper.

May 1, 2005

How to search for a specific package in FreeBSD ports collection?

Filed under: FreeBSD — Administrator @ 8:02 pm

There are several ways to search for a package in FreeBSD ports collection. I will list each one of them one by one here.

1. From the FreeBSD ports website.

2. Using the make search method:

cd /usr/ports
make search name=program-name

For a keyword search use:

make search key=string

3. Using the plain old find command:

cd /usr/ports
find . -name "*program-name/keyword*"

Ever wanted to run Linux Apps. in another Windows/Non-windows machine accross the network?

Filed under: Linux, Fedora — Administrator @ 5:40 pm

Yup it’s possible. What’s possible? Here’s a list:

1. Run GIMP in a windows machine across an ADSL line where GIMP is actually installed in a Linux server somewhere else.
2. Run OpenOffice in windows or linux client machine over LAN or ADSL or even dial-up (just try it) when you don’t even have any X Windows packages intalled in your machine.
3. Even better, run the whole linux desktop remotely!

What’s the solution? NoMachine NX.

Here’s a how to:

http://www.linux-tip.net/cms/content/view/177/6/

You can also download a PDF from

tips.zunix.org or here.

You can even test drive this at NoMachine’s website:

http://www.nomachine.com/testdrive.php

Restricitng output to a specific colunm width.

Filed under: Linux, *NIX, Bash, Other tools in *NIX, Command Line — Administrator @ 3:53 pm

Lets say we have a file where the items in it are space separated. And we have around 5000 items in it. A simple sample looks like this:

item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 item11 item12 item13 item14 item15 item16 item17 item18 item19 item20 item21 item22 item23 item24 item25 item26 item27 item28 item29 item30

Now, what we want to achieve is show only 10 items in a line or show 10 columns at a time. Unix “findutils” has a very nifty utility called “xargs” to achieve this in a blink.

Here it goes:

cat /path/to/infile | xargs -n10 echo

Yes, its that easy. :)

The output will look something like:

item1 item2 item3 item4 item5 item6 item7 item8 item9 item10
item11 item12 item13 item14 item15 item16 item17 item18 item19 item20
item21 item22 item23 item24 item25 item26 item27 item28 item29 item30

Converting newline terminated items to space separted items.

Filed under: Linux, *NIX, Bash, Other tools in *NIX, Command Line — Administrator @ 3:19 pm

If you have some items/fields in a file in this format:

item1
item2
item3
item4

and you want to convert it to

item1 item2 item3 item4

then you can use

tr '\n' ' ' </path/to/infile >/path/to/outfile

Example:

awk -F: '{print $1'} /etc/passwd | tr '\n' ' '

Quick math.

Filed under: Linux, *NIX, Bash, Command Line — Administrator @ 4:55 am

Have to do some quick math or calculate something complicated and don’t have the calculator handy? Try this:

echo '(1 + sqrt(5))/2' | bc -l

or

echo '(65536 / 1024)' | bc -l

or

echo '(2 ^ 16)' | bc -l

Voila!

Ref: http://www.iol.ie/~padraiga/cmdline.html

Finding processes w/o using ‘ps’ command.

Filed under: Linux, *NIX, Bash, Command Line — Administrator @ 4:24 am

‘ps’ is one of the most important commands in the *nix world. But, what if someone wants to find out the processes running in a system without using the command ‘ps’. Why? There could be many reasons, one of them being “what if one wants to find out hidden processes in the system supposing the system was compromised…”.

So here it is:

cd /proc
for n in [0-9]* ; do echo -n "pid: "$n" "; cat $n/cmdline; echo; done

Ref: found in a post of Robert Mognet.

Redirecting output of a list of command to a file.

Filed under: Linux, *NIX, Bash, Command Line — Administrator @ 12:09 am

It is possible to redirect the output of a list of commands to a single file with a dash of style.

Here it is:

{ comand1; command2; command3 ; } > outputfile

Replace “command1″, “command2″ and “command3″ with your commands.

To append to a file instead of overwriting use “>>” instead of “>”.

Proudly powered by wordpress - Theme by neuro