|
|
current directory: home / linux |
| [site tree] |
one of the nicest things about linux is that you can customize it out the wazzoo until it fits you like a glove and becomes ever easier to use because it works the way you want it to, not the way the company that made it wants it to work. you can set up your environment to make it ever more comfortable and useful to you.
so i thought i'd share with you some of the ways in which i mold my machine to match my way of working. if you have ideas of your own to share, send them along to me. i'm not looking for full-blown programs here; i'm talking small scripts, aliases, command line shortcuts, that kind of stuff.
ok, here we go:
[if you don't know how to use crontab, type "man 5 crontab".]
i've tried various kinds of organizers over the years, tried keeping lists, etc., but the problem is always getting myself to actually look at the lists. awhile back, i asked myself, "what do i look at compulsively; what is it that i'm surely not going to miss day in and day out?", and the answer was... email. i may forget to feed myself and the cat, i may forget that today's the day my car is being repossessed, but no matter what, i am going to check my email.
so now instead of writing notes to myself on paper, i email them using the "note" script below. for things i need to not forget to do regularly, i put entries like these in my crontab ("crontab -e", if you didn't know):
0 8 * * * /usr/games/fortune | Mail -s "pay bills" jeff 0 8 * * * /usr/games/fortune | Mail -s "take vitamin" jeff 0 8 * * * /usr/games/fortune | Mail -s "clean litter box" jeff 0 8 * * * /usr/games/fortune | Mail -s "water plants" jeff 30 9 * * * /usr/games/fortune | Mail -s "check voicemail" jeff 30 9 * * * /usr/games/fortune | Mail -s "return phone calls" jeff 0 4 * * 1,4 /usr/games/fortune | Mail -s "car on this side of street" jeff 0 4 * * 2,5 /usr/games/fortune | Mail -s "car on other side of street" jeff 0 9 * * 6 /usr/games/fortune | Mail -s "tape cartalk" jeff 0 0 1 * * /usr/games/fortune | Mail -s "post the umbcfaq" jeffso then they clutter up my inbox until i do them and delete them. i once lost my crontab for some reason, so in paranoia i occasionally do this:
$crontab -l > ~/crontab
#! /bin/bash # note /usr/games/fortune | Mail -s "$*" jeff
i use this all day long, typing things like "note buy a gallon of milk" to myself.
#! /bin/sh # repeat -- performs a task at repeated intervals while [ -d / ]; do $* ; sleep 3s done
for example, if you want to see how a download is progressing, you could do "repeat ls -l". if the condition in the while statement doesn't turn up true, you're in trouble. ;-)
#! /bin/bash
# px
if [ $# = 1 ]
then
{
ps aux | egrep -i $1 | egrep -v "egrep.-i.$1|bin/px";
}
else
{
ps aux;
}
fi;
finds all instances of a process for which you're looking, eg. "px bash".
#! /bin/sh
for dir in `find . -maxdepth 1 -type d` ; do
if [ $dir != "." ]; then
echo "-----------"
du $dir
fi
done
echo "-----------"
nicely formats a report of the space taken up by the files in each subdirectory of the current directory.
#!/usr/local/bin/perl -w
# tolower.pl by Mordechai T. Abzug, mabzug1@umbc.edu
# changes filenames to lowercase
foreach (@ARGV) {
$old=$_;
s{(\.[^\.]*)$}{\L$1};
if ($old ne $_) {
print "$old => $_ ";
system('/bin/mv', '-i', $old, $_) if ($old ne $_);
print "\n";
}
}
for when people from windows machines give you files named "picture.JPG" and the like.
alias ringme="play ~/sounds/village-jingle.wav"
just plays a sound. useful for something like:
$do-something-that-takes-awhile ; ringme
so that when it's done and i'm off on another screen busy with something else, it reminds me to come back to it.
alias ls-by-size="ls -a -c1 -s | sort +9.1b" alias ls-by-size-recursively="find . -type f | xargs ls -a -c1 -s | sort +9.1b"
list the current directory or the current and all subdirectories by file size. useful for "what the hell is taking up all that space in /home ?"
#from marc ewing via linux gazette:
c() {
if [ $# -ne 1 ]; then
echo "usage: c pattern"
return
fi
set "foo" `fgrep $1 $HOME/.dirs`
if [ $# -eq 1 ]; then
echo "No matches"
elif [ $# -eq 2 ]; then
cd $2
else
shift
for x in $@; do
echo $x
done | nl -n ln
echo -n "Number: "
read C
if [ "$C" = "0" -o -z "$C" ]; then
return
fi
eval D="\${$C}"
if [ -n "$D" ]; then
cd $D
fi
fi
}
cload() { find / -type d > $HOME/.dirs }
once you've run cload (it will take awhile to finish), you can type something like "c foobar", and if there's only one foobar directory on the system, it will take you there, otherwise it will give you a list of choices from which to pick.
doing backups with my zip drive is no problem, but remembering to do them would be a major drag, so i do this:
#! /bin/bash
# /etc/cron.daily/make-backups
/usr/local/sbin/mount-zip
if [ -f /zip/i-am-the-backup-zip-disk ]; then
cd /zip
for script in `ls *.sh` ; do
./$script
done
cd /tmp
else
/usr/games/fortune | /bin/mail -s \
"backup zip disk not found, no backup made" root
fi
/usr/local/sbin/umount-zip
the result is that i just leave one of the zip disks i use for backups in the drive, then while i'm sleeping, plaything mounts the disk and checks to see if it's a backup disk. if it is, it runs all the shell scripts on the disk to make the backups. if it isn't, it sends me an email to let me know it didn't make a backup, so i can do it by hand. makes making backups a no-brainer; just leave one of the backup disks in the drive.
the mount and unmount scripts look like this because i have the parallel port drive:
#!/bin/sh # mount-zip /sbin/modprobe -r lp /sbin/modprobe ppa /bin/mount /zip
#!/bin/sh # umount-zip /bin/umount /zip /sbin/modprobe -r ppa /sbin/modprobe lp
the backup scripts are along these lines:
#!/bin/sh # backup-config-files.sh /bin/rpm -qac | xargs tar Pzcvf config-files.tgz
backs up everything rpm considers to be a configuration file.
#!/bin/bash # backup-home.sh tar Pzcvf home.tgz /home
backs up /home. similar scripts for /etc and /usr/local. everything else i can restore from rpms. there may be a nicer way of doing this than just tar (suggestions welcome), but it works for me since it's just a small amount of data i'm backing up each night.
| contact me |
this page was last updated on: 2005-01-10 14:44:19 |
all of the original content on this website is available under the creative
commons attribution-sharealike
license.