Main

unix Archives

July 16, 2001

echo if you don't have ls

don't have ls but you do have echo? try :

$ echo *

not entirely sure why that works though...

Update - Simple really, the shell expands the asterisk to everything in the current directory, and each one is passed to echo, with the result that you get a listing of all the files.

regex back references

nice explanation of regex backreferences, mentioned a few blog entries ago - here

du sorted on size

du sorted on size (largest first):

$ du -k | sort -nr | more

Origins of UNIX and C

very interesting paper written by Dennis Richie on the beginnings of UNIX (and C).

July 24, 2001

from mutt to pine

changed from mutt to pine as i couldn't find a good way of filtering incoming mail without faffing with procmail (can't the client do that?). also, mutt seems to behave a little weirdly against the IMAP server, messages marked for deletion keep re-appearing, sync problems etc. pine is also a little less fiddly to configure.

November 30, 2001

xf86cfg

note to self, new XFREE86 config tool is xf86cfg.

xf86cfg

note to self, new XFREE86 config tool is xf86cfg.

January 21, 2002

vi brackets

ahah! % toggles between parentheses in vi.

February 5, 2002

egrep OR

egrep '(expr1|expr2)' file to find occurances of expr1 OR expr2

February 12, 2002

List all open files

FreeBSD - lsof - list all open files - neat :)

February 15, 2002

ports collection update

updating ports collection :
cvsup /usr/share/examples/cvsup/ports-supfile -h cvsup2.de.freebsd.org
portversion
portupgrade {port}

gzip

neat gzip tip - cat blah | gzip > foo.gz

February 20, 2002

xwindows screen saver

to stop xwindows blanking the screen - xset s off

February 27, 2002

tip tip 2

when using tip on a serial connection to a solaris machine, ~# sends the equivalent of a STOP-A

February 28, 2002

params?

writing bourne shell scripts, want to check for existance of command line params. try [ -z $1 ] which should tell me if the first command line param is empty. however all i get is "test: argument expected" when the param is not there. no good. annoying. discover bourne shell has a reserved var for the number of arguments passed, looking much like perl's - $#. so accomplish it by a simple [ $# -ne 1]. simple when you know how.

March 12, 2002

mozilla email client

switched to the mozilla email client after i'd finally had enough of pine. pretty impressed so far, i like the quick and simple filter dialog, the screen format etc. nice :)

March 14, 2002

regex {n}

regex - match something n times {n}, match something at least n times {n,}, match something between n and m times {n,m}, eg find all words in dict 6 chars or longer - egrep '^.{6,}$' dict . bet it doesn't work in solaris though... pooey solaris.

March 19, 2002

regex back references

new regex discovery - backreferences, v nice. eg:
sed -E 's/([0-9]+):([0-9]+$)/1,2/' - match numbers colon numbers and replace the colon with a comma. the parentheses (brackets) remember and can then be used again with 1 2 etc

regex back references

new regex discovery - backreferences, v nice. eg:
sed -E 's/([0-9]+):([0-9]+$)/1,2/' - match numbers colon numbers and replace the colon with a comma. the parentheses (brackets) remember and can then be used again with 1 2 etc

March 22, 2002

spam

i hate spam

April 3, 2002

Xwindows to console

to switch to console after starting xwindows - CTRL-ALT-F2. to get back to xwindows - CTRL-ATL-F9

April 4, 2002

date

to set date on solaris eg 040218122002

April 12, 2002

ls mystery

why do i almost always do an ls immediately after cding into a newly made directory? i've seen other people do this too, so it's not just me. what the hell am i expecting to find there?

ls mystery

why do i almost always do an ls immediately after cding into a newly made directory? i've seen other people do this too, so it's not just me. what the hell am i expecting to find there?

May 2, 2002

big bang

Scientists were excited this week at having isolated a brief sound which occurred immediately before the Big Bang. Apparently, the sound was, 'uh oh'.

May 4, 2002

don't understand unix

'Those who do not understand Unix are condemned to reinvent it, poorly.' -- Henry Spencer

May 19, 2002

press 3

'For a list of the ways which technology has failed to improve our quality of life, press 3.'

May 20, 2002

mv

i didn't know you could do that - mv ${DIR1}/[qxs]${file} ${DIR2}/

June 14, 2002

all year

24/7/365? no! 24/7/52!

June 25, 2002

Bruno Munari

Progress means simplifying, not complicating - Bruno Munari

July 4, 2002

case change

to change case on the unix command line - tr '[:lower:]' '[:upper:]' (or the other way about)

July 19, 2002

ping

ping can return error codes, useful for scripting, as in:
#Solaris:
$ ping (ip)
#FreeBSD:
$ ping -c (ip)
$ echo $?

July 31, 2002

ftp-less file xfer hack

ok, so for whatever reason (firewall) you can telnet to a unix box but not ftp. however you need some files from it. they are reasonably large, and contain binary information. how do you get them?

client $ script
client $ telnet (host)
..login..
host $ uuencode (filename) (filename)
host $ CTRL-D
client $ CTRL-D

you should now have the result of the session in a file (probably called typescript). all you need to do is strip the ^Ms out of it, and uudecode it. hey presto. neat :)

August 6, 2002

awk vmstat

learning awk. neat :) produce an average idle time from captured output of a solaris vmstat:
grep -v swap vmstat.txt | grep -v memory | awk '{s += $22} END { print 'sum-',s,' avg-',s/NR}'

October 5, 2002

standards

'The nice thing about standards is that there are so many to choose from. And if you really don't like all the standards you just have to wait another year until the one arises you are looking for.'
A. Tanenbaum, 'Introduction to Computer Networks'

October 24, 2002

nurdz

found this picture linked to on slashdot, with the caption 'Run Linus Run, no really RUN!' doesn't it just sum up everything that is un-fashionable about computers? And what is the guy in the back doing?

October 25, 2002

disable nis

to disable NIS (ypbind) from starting on a Solaris machine, just rename -

/usr/lib/netsvc/yp/ypstart

to something else.

November 5, 2002

programming == art?

is programming art? i think so. Justin Erenkrantz also thinks so. thanks to Ben for the link.

regexpr case change

now there's something i've been wondering about for a while, how to change case with reg expressions, eg in vi :

:%s /./l&/g

will change all characters to lower case, and :

:%s /./u&/g

will change them all to upper

November 6, 2002

broken mail

the mail application on my ibook recently stopped working. i think it was a combination of moving it from the applications folder to a sub folder, and then upgrading it when i upgraded to OSX 10.2.1. when i tried to run it, the app just bounced a few times in the dock and then vanished. the console showed error messages reguarding a missing nib file. anyhoo, after a bit of poking around i discovered Pacifist, a util based around the unix pax util, something i'd been looking at recently for something else. using this i opened the essential packages package from my OSX install CD, and was able then to re-install the mail app.
and it works. i am now of course in the position of having most of 10.2.1 installed, but the mail app from 10.2.0. it seems to work ok though, so it's not something i'm particularly bothered about.

November 13, 2002

ray tracing

reading an article on /. about 3D packages, I remembered a package called Povray i used to mess about with years ago. it really has come a long way since then, stuff like this is stunning.

November 30, 2002

rm -

trying to rm that file with a '-' at the start of its name? :

rm -- -foo

where -foo is the filename. apparently -- tells rm not to treat the rest of the arguments as parameters. i'm also told that this works for other common UNIX commands, cp etc.

December 5, 2002

eclipse

read headline on the BBC news site this morning - Millions wonder at southern eclipse. my first thought was '14 year old science student explains all.'

mysql

making progress on a mySQL backend for this site. my first forrays into the world of mySQL a few years back never amounted to much, more for a lack of project than anything else. now i have something to use it with it all starts making sense. i already feel comfortable with the basics. also managed to install it on the iBook without too much hassle.

December 14, 2002

shell arguments

useful shell scripting trick:

$ set -- `uname -a`

then variables $1 through $n are set to the fields of the back ticked command, in this case:

$ echo $1
SunOS
$ echo $2
booger
$ echo $3
5.7

etc. neat. saves having to parse out the fields, or use awk or something.

December 18, 2002

sylpheed

changed my FreeBSD email client to Sylpheed from Mozilla's built in client. Although I like Mozilla's, there are a number of things that still irk me, the main one being that it is part of Mozilla when Mozilla should be a browser and nothing else. First impressions are good, it has the (now standard) Outlook layout, seems to do IMAP reasonably well against the company's expunge server, though I've yet to figure out how to fill my address book with minimum hassle. I'm hoping it does somthing similar to Mozilla by catching all the email addresses that go past, which I always thought such a great feature. Once I'm happy with Sylpheed I will have a go at Phoenix as a lighter replacement for Mozilla. Already converted to Chimera on the iBook which is much faster and lighter.

December 19, 2002

Stanislav Lem

good article in the Boston Globe on Stanislav Lem, the author of Solaris.

January 22, 2003

rip sylpheed

sorry Sylpheed but Mozilla's email client is back on the desktop. just a bit too klunky for my tastes, and the filtering didn't seem to work particularly well.

February 2, 2003

moveable type?

maybe i should just try movable type instead of trying to find time to attach the database to the back of this blog...

February 25, 2003

shell trick

very nice shell scripting trick:

df -k -F ufs -l | while read FILESYSTEM KBYTES USED AVAIL CAPACITY MOUNTED_ON
do
echo $FILESYSTEM
done

April 7, 2003

Friendly Fire

The Independent has a chilling report on John Simpson's almost fatal friendly fire experience. I find it very difficult to understand how so much money is ploughed in to building these weapons and yet such a high percentage of situations like this still happen. The US made a lot of noise about how much more advanced their technology is since '91. Really? I'm wondering what criteria they are using to make such a statement.

April 22, 2003

Nina Simone 1933-2003

Nina Simone died over the weekend. BBC report..

Regular Expression Library

Again an idea that comes to me in a blinding flash of genius, and someone has beaten me to it. Not that surprising this time though - a library of useful regular expressions. Not quite how I would have done it, but useful none the less.

April 29, 2003

Interview with core FreeBSD team

Interesting interview over at OS News with the FreeBSD core team and one of the lead programmers. good to see a long interview for once, instead of those single page things. ta to /. for the link.

May 9, 2003

one day i will know

one day i will know the crontab entry time fields off by heart without having to look them up in "Essential System Administration"

May 16, 2003

base conversion on the command

base conversion on the command line:

$ echo "ibase=10;obase=16;15" | bc
F

where in this case we want to know what base 10 15 is in base 16

June 24, 2003

Took a taxi back from

Took a taxi back from Tim O'Reilly's talk last night, amazed to find a TV built into the cab. After the novelty wore off, and the 5 minute long advert had finished I started getting a little annoyed with it. I was able to turn off the sound but not the picture, which is almost impossible not to watch. I hope this is not going to become the norm, spoiling what is normally a relaxing indulgence.

http://www.cabvision.com/

July 8, 2003

Middleman

Reading this interesting article about HTTP proxies, discovered Middleman, a small HTTP proxy. Apart from doing an excellent job of filtering out ads it does all sorts of fun stuff like show you HTTP headers, log HTTP traffic, and allow wonderful URL tricks. Also very configurable. It even fixes a weird probelm I've been seeing with Mozilla and IIS web sites, AND (and this is really cool) it properly makes links out of URLs that aren't. Everyone should have one.

August 7, 2003

Thinking about a new plan

Thinking about a new plan of attack for the spam wars - education. Educate the masses to stop replying to the bloody stuff, and eventually it really would become unfeasable to run a spam business. Infact you could take this a few steps further, instead of making it illegal to send spam, why not make it illegal to reply to spam? Make a big song and dance about it in the media, scare the average Joe Schmo who is replying to the stuff in the first place, and you reach the same result - spam businesses will find it no longer makes any money.

August 13, 2003

"This webpage contains information about

"This webpage contains information about Red Hand Gang as part of the Kids TV In The 70s section." It does? Oh yes, shoved into a tiny column in the corner after the ad which takes up most of the page, yes I can see it.

August 21, 2003

hacky-but-works bit of shell to

hacky-but-works bit of shell to grab the last 10 search terms people have entered at MetaCrawler:

lynx -dump http://www.metaspy.com/spymagic/Spy | grep "   \[[0-9]" \
| grep -v "Powered by InfoSpace" \
| grep -v "\[3\]MetaCrawler" | sed 's/ \[[0-9]*\]/ /g'
works nicely with things like the phosphor hack of XScreensaver.

August 22, 2003

Multiple text replace

A problem I've been faced with recently, and I know a fairly common question in the UNIX community : how to search and replace a given string in a number of files quickly and efficiently. Here is the answer I came up with walking home today. I was quite chuffed that it worked first time. This works in bash :

for file in *.txt
do
ed ${file} <<!
%s/foo/bar/g
wq
!
done

where *.txt selects the files, 'foo' the string to search for and 'bar' the replacement string. ex can be used instead of ed, but you need to add a colon before the %, ala vi.

I'd be interested in any other solutions to the problem.

September 24, 2003

Hypocracy

The Sun newspaper today launches a fund 'to help people with mental health problems like boxing hero Frank Bruno.' Strange turnaround from their stance yesterday when an early edition of the paper reported 'Bonkers Bruno Locked Up'.

October 3, 2003

cygwin

Read about it but never had the need for it until today. Cygwin does exactly what it says on the tin, ie "a Linux-like environment for Windows". I was most impressed with the X support, works wonderfully. My thankfully brief forrays into the world of Windows will now be slightly less troublesome.

October 13, 2003

Moffs

Me to hardware shop employee - "Do you have anything that will get rid of moths?"
Him, after much sucking of teeth - "Mmmmmmmm, no I don't think we do, but this Anti-Moth might help"

WTF?

October 24, 2003

Regex Coach

This looks very nice indeed. Can't wait to try it out. Needs to be ported to FreeBSD/OSX really.

Regex Coach

This looks very nice indeed. Can't wait to try it out. Needs to be ported to FreeBSD/OSX really.

November 4, 2003

Too much unix

You know you've been doing too much UNIX when you see the word 'goatherd' and immediately think of it as a daemon for some goather service.

February 13, 2004

shell

I found out what ${parameter:-word} means in shell. Cool. See the sh man page.

February 20, 2004

Dotfiles

Stumbled across dotfiles.com again today. Vastly useful site, particularly when trying to remember what the option is to get vim highlighting syntax. ( syn on ).

July 5, 2004

Linux Allocated Devices list

Very useful list of devices allocated under Linux - http://www.lanana.org/docs/device-list/devices.txt

July 8, 2004

Process each line in shell

This works nicely when a 'for' loop would split lines into fields :

cat /etc/passwd | while read line
do
echo $line
echo ------
done

August 3, 2004

UNIX

Once again someone has already beaten me to a cool idea. This time it's the UNIX equivalent chart at www.unixguide.net.

September 15, 2004

Sir Alfred

Interesting article in the Guardian about "Sir Alfred", or Merhan Karimi Nasseri, his real name. He has been living on a bench in terminal 1 of Charles de Gaulle Airport since 1988. Steven Spielberg's The Terminal is loosley based on him.

April 6, 2005

Gentoo

I did it! I have Gentoo booting! It was a long and sometimes confusing journey, but the login prompt is flashing at me as I type. One thing I had to do is change the Grub boot line to include :

gentoo=nodevfs udev

after I got problems errors with it not being able to find devfs. I'm using udev instead.

Gentoo

I did it! I have Gentoo booting! It was a long and sometimes confusing journey, but the login prompt is flashing at me as I type. One thing I had to do is change the Grub boot line to include :

gentoo=nodevfs udev

after I got problems errors with it not being able to find devfs. I'm using udev instead.

April 21, 2005

ftpd not working on Gentoo

Weird problem. Getting this message after installing ftpd under Gentoo and trying to ftp in for the first time :

Error loading /etc/ssl/certs/ftpd.pem

For some reason there are SSL certificates involved? I fixed this by taking the script:

cert-dummy.sh

from the source tarball of bsdftpd-ssl. Run it, then copy the resulting file cert-dummy.pem to ftpd.pem and plonk it in the appropriate place. Seems to do the trick.

July 20, 2005

Linux, VNC with GDM login

Took me a while to figure out how to do this. this page helped http://forums.teamphoenixrising.net/showthread.php?t=32325

November 23, 2005

x2vnc

x2vnc is a very neat little tool that gives you dual screen between two computers running different operating systems. So for instance I have a Gentoo machine as my main box at work, with the obligatory Windows machine next to it with it's own monitor. Running x2vnc on my Gentoo box I can just move the mouse cursor to the edge of the screen and hey presto it apears on the windows desktop. And the best thing is that the clipboard works between the two machines, so no more pasting stuff into temporary text files etc. Very nice. Give it a go, it's a bit spooky at first :)

November 24, 2005

Firefox error pages

Make Firefox give you a page of HTML instead of that annoying dialog box when you type an invalid URL - in about:config, change this :

browser.xul.error_pages.enabled = true

Nice.

November 30, 2005

Firefox - force new windows to be opened as tabs

I don't understand why this option isn't made the default for Firefox. There's nothing I hate more than links which insist on opening new windows. Bloody arogant if you ask me. Actually the feature should never have been allowed in the first place. It's my decision to open a new window or tab, not the site designer's. Rant, rant.

December 2, 2005

Meebo

Thanks to misterzeta for pointing me in the direction of Meebo, very nice web front end to Gtalk, Yahoo chat, ICQ and MSN Chat. Useful if you don't have a client handy, or are stuck behind a firewall.

December 28, 2005

PostgrSQL package for OSX

http://www.entropy.ch/software/macosx/postgresql/

April 2, 2006

Driftnet

Driftnet is a little toy that sniffs images from network traffic and displays them on the screen. Neat idea I came across a while back, but until recently I've always been on switched networks so it doesn't make much sense. There is even a FreeBSD port for it. Would make a nice screen saver. Now to try it out :)

April 26, 2006

Pimp my Snack

http://www.pimpmysnack.com/ - We take Snacks to their limit, and show what they're capable of with a little ingenuity, a little cash, and a lot of imagination. Madness in the kitchen. - Thanks to Nick for the url.

May 18, 2006

cssh

I've been looking for a way of multiplexing several ssh sessions. By that I mean the ability to type once, and the result happens in x ssh sessions. Thanks to someone on the FreeBSD UK user list I came across cssh (http://freshmeat.net/projects/cssh/). This does pretty much what I need, and so far I've had no problems with it.

What would be ideal though is functionality built into the window manager to do the same thing, so I 'tag' any number of windows, even varying applications, and my keyboard input, (maybe even mouse) is copied to all windows. For instance I could be typing into 3 ssh sessions and an instance of vi to record my typing.

May 23, 2006

Redhat up2date error

If you get the following while trying to run up2date:

RPM error.  The message was:
Could not determine what version of Red Hat Linux you are running.
If you get this error, try running 

rpm --rebuilddb

You may want to check to see if the redhat-release RPM is installed. Installing this fixed the problem for me.

May 26, 2006

Samba mounts from fstab in FreeBSD

For some reason it seems very difficult to get Samba mounts to work from FreeBSD's fstab. I think I've got the (a?) magic formula:

<fstab>
//bob@sambaserver/share        /the/local/mount/point  smbfs   rw,noauto,-I=10.11.12.13      0 0
</fstab>

where:

bob = username
sambaserver = netbios server name
share = share name
10.11.12.13 = IP address of sambaserver

and

<.nsmbrc>
[SAMBASERVER:BOB]
password=bobspassword
</.nsmbrc>

Put .nsmbrc in root's home directory and make sure it isn't readable by anyone else. The bit in square brakets needs to be in capitals.

June 1, 2006

Installing OpenBSD on an AR-B9637

I've written up a page on installing OpenBSD onto an AR-B9637 here.

July 23, 2006

Fix for Canon Camera Window and OSX 10.4.7

It seems that the recent update to OSX (10.4.7) broke Canon's Camera Window software. While there doesn't seem to be an official fix for this at the moment I've found a work around which is almost as good. Plug the CF card into a normal USB card reader, the Camera Window software seems to recognise it as if you had plugged in your camera. After all the camera is probably only acting as a USB storage device anyway.

Hopefully Canon will fix this soon, I don't think it's a problem with OSX as such.

August 14, 2006

Immediately delete mail in Thunderbird

Quite often I don't want deleted mail to go to my Trash bin first, especially if it is spam or if I'm having mailbox quota problems. Holding down SHIFT before pressing delete will bypass the trash folder and delete mail immediately.

November 12, 2006

.mp4 to .mpg

Converting films from my Samsung SGH-P300 to 'normal' mpeg (probably mpeg 2?):

ffmpeg -an -i foo.mp4 -r 25 bah.mpg

Haven't found a way of getting the sound across, hence the -an. orlando at numbersix.net if you have a solution.

January 5, 2007

centericq

Every so often you come across a piece of software that just seems right straight away. I've been using Gaim for my ICQing, and never been really happy with it. It seems to be too sensitive to network issues, popping up the reconnect dialog way too often. And generally it seems lacking in some way. So I was very please to discover Centericq recently, a text based chat client that supports all the usual protocols. Installed the FreeBSD port and had it configured and running in less than a minute. Very clean, unfussy layout.

A couple of things I need to either get used to or figure ways around though, I'm used to pressing return to send the message, Centericq uses ^X which isn't that intuitive. And being text based it isn't obvious that someone has called you when you're running it in a window on an other desktop, or hidden behind what you're doing. Maybe I can get it to beep?

Running it on my FreeBSD server it complements Pine very well as a text based tool. Maybe I'll even be converted to lynx soon.

November 16, 2007

sshd listen on multiple ports

I tried to ssh into my server the other day from behind a very restrictive firewall to read my mail. I found that it wouldn't allow outgoing connections to the standard ssh port (22).

Back at home later I started thinking about installing a web mail program on the server to get around such situations, but eventually solved the problem by doing something much simpler, I configured ssh to listen to more than one port, the second port is a much more commonly allowed port like 80 or 443.

You can do this by configuring multiple Port directives in sshd_config. Don't forget to HUP the ssh daemon once you've done this for the changes to take effect.

November 24, 2007

vim - turn off matching bracket highlight

vim highlights matching brackets which is nice until it starts becoming a pain. This in your .vimrc will turn it off:

let g:loaded_matchparen= 1

From here : http://groups.google.com/group/comp.editors/browse_thread/thread/42daad5f97aa6f13/9e140069098c7560?lnk=raot

You can still bounce between the matching brackets by pressing %.

January 5, 2008

"Console session already in use"

Sun machine, trying to connect to the RSC and you're getting the message "Console session already in use". You know the other connection is not important.

Some versions of RSC allow:

console -f

to force a connection. If this doesn't work, try:

resetrsc

February 28, 2008

Shell - Test for argument

I always forget this and spend ages finding out how to do it. How to test for an argument passed from the command line to a shell script, and not get "argument expected" error:

if [ -z "$1" ]; then
echo argument expected
exit 1
fi

The secret is the quotes around the $1.

May 2, 2008

smpatch access to remote servers

The more recent versions of Solaris come with an online patching utility smpatch. This requires access to various servers on the public Internet. I cannot find any definitive documentation on exactly which servers are accessed, the documentation only suggests updates.sun.com, but this is patently not the whole story. There seems to be a system of redirects and load balancers in place that mean a bunch of other servers might be queried as well. This makes creating outbound firewall rule sets difficult.

So far I have made up the following list. The /24 networks are not entirely necessary, but I'd rather be a little generous here than having to add IPs to my rule set every time I want to patch. Access does seem to be restricted to port 443.

72.5.124.61
80.231.19.70
80.231.19.71
195.176.255.0/24
198.232.168.0/24

July 24, 2008

vi - search replace with command

To search for a string, and then perform a vi command :

:g/string/command

for instance:

:%g/endofline$/join

will search for the string "endofline$" and then append the next line to any line that matches.

Vim documentation: http://vimdoc.sourceforge.net/htmldoc/

About unix

This page contains an archive of all entries posted to numbersix in the unix category. They are listed from oldest to newest.

tv is the previous category.

web is the next category.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33