User:Drue
From Devpit
test some more - this is a rubot test
Contents
Homebrew
Links
xterm
- FreeBSD: "xterm -j -s +sb -sl 1000 -ls -geom 80x25 -bg black -fg green -cr orange -ms orange -hc darkblue -fa "clean*" -fs 11"
- Linux: Use -fs 9
Changing a user's UID
- manually change the UID using vipw (note the old UID)
- change the user's GID to match in /etc/group (note the old GID)
The tricky part, then, is changing a user's files. This ought to do the trick:
find / -user oldUID -print | xargs chown newUID find / -group oldGID -print | xargs chgrp newGID
FreeBSD Ports Index
- When you need to rebuild FreeBSD's Ports Index
cd /usr/ports make fetchindex portsdb -u
Find Commands
- Basic Syntax
find / -name \*.fo\? -exec ls -l {} \;
- Chmod has a +X option which will give dirs x but not files. I wanted the same thing for read, like a +R - here's a command that will do it. It will give directories read access but not any files.
find . -type d -print0 | xargs -0 chmod a+r
scp script
- Scp with sh example
#!/bin/sh
for file in `ls *.jpg`
do
scp $file tiger:~/bleh/ && rm $file
done
Bash
- To rename all files in current dir without .dist extension (i think this only works in bash):
for foo in *.dist; do cp $foo `basename $foo .dist`; done
- More complicated example
for z in *; do echo -n $z | sed 's/_/ /g' | perl -e '$_ = <>; chomp; print;' | xargs -0 mv $z; done
Serial
- To connect to a serial device.
cu -s 9600 -l /dev/cuaa0 (or 38400) ## OR ## screen /dev/cuaa0 9600 vt100
- Or using kermit:
drue@thermite:~$ cat .kermrc set line /dev/cua00 set speed 9600 set flow-control none connect drue@thermite:~$ kermit
Postfix + FreeBSD
- Aliases with postfix in freebsd:
In main.cf:
alias_maps = hash:/etc/mail/aliases alias_database = hash:/etc/mail/aliases
Then, newaliases to regenerate alias db.
Command Line Perl
- To make a change to all files in a dir
perl -pi -e 's/one/two/g' *.html
- recursively
find . | grep php | grep -v svn | xargs perl -pi -e 's/\$DOCUMENT_ROOT/\$\{_SERVER\[\"DOCUMENT_ROOT\"\]\}/g;'
- Or how about setting the contents of everythign to lowercase
perl -pi -e 's/[a-z]/[A-Z]/' *
- This sets filenames in current directory to lowercase
for x in *; do echo -n $x | tr A-Z a-z | xargs mv $x; done
FreeBSD Commands
- What's listening?
sockstat -4
Apache Tips
- Apache truncating dir listings fix:
12:43PM <bilbo_work> Guys, patch this in all your httpd.conf's... Search for
"IndexOptions FancyIndexing" and add a line after it that reads:
12:43PM <bilbo_work> IndexOptions NameWidth=*
Cron Tips (freebsd)
- Cron doesn't have a year option, nor is it possible to do, for instance, "first wednesday of the month". But, using date, you can do this:
-
0 0 * 9 * if [ `date "+\%Y"` != 2007 ]; then exit; fi; echo "This will execute every day of september in 2007."
-
Using Screen
Labeling Screens: In screen, ctrl-a :sessionname foobar Or start screen using -S and/or -t.