Current Reading:
JSP, Servlets, and MySQL
Switch to SpeakEasy.net DSL
Unix Tips
- Motif Window Manager
- Want to tell MWM to keep the root menu sticky?
- Want to run my retro MWM desktop like you see in the newest screenshots?
- NetBSD
- Debian GNU/Linux
- Want to tell tcsh to autocomplete apt-get, apt-cache, and dpkg? - Applies to Conectiva/etc as well
- Solaris
- What's with /usr/ucb?
- Want to make Solaris more BSD-like?
- Commands
- Search and Replace in a Directory: grep -r -l SearchTerm /Directory | xargs -l sed -i "s/SearchTerm/ReplaceTerm/g"
- Backup Partition to 10GB Multi-Tape Archive: find / -xdev | pax -w -B 10240m -x ustar -f /dev/tape
- Extract Above Multi-Tape Archive: cd /somewhere; tar xMvf /dev/tape
- Copy Data to new Drive: find /path | cpio -pudvm /newpath
- Find software packages in Debian: apt-cache search ftp
- Find 30 Biggest Files [in /tmp]: find /tmp -ls | sort -n +6 | tail -n 30
- Find 20 Biggest Directories: du -Sm | sort -n | tail -n 20
- Indent Modified K&R C Source Files: indent -kr -br -nce -nut -st *.c *.h
- Obtain a list of IPs showing repetitive (>=2) ssh attacks (root or unknown users): zcat -c -f /var/log/messages* | grep 'sshd\[' | egrep "(Failed password for root|Illegal user)" | awk '{print $10 $11}' | sed 's/[[:alpha:] :]//g' | sort | uniq -d
- Get list of next 7 days (BSD): setenv start `date +%s`; seq -f %f $start 86400 `echo $start + 86400\*7 | bc` | xargs -n 1 date -r
- Change permissions of certain file type: find /path -name "*.jpg" | xargs -l chmod 640
Motif Window Manager
Want to tell MWM to keep the root menu sticky?
Edit your ~/.mwmrc file and change the mouse event that does the root
menu from Btn3Down to Btn3Up.
Want to run my retro MWM desktop like you see in the newest screenshots?
You will need OpenMotif MWM, Gkrellm, osd_clock, xtoolwait, chameleon, xscreensaver. I am also using pterm as my terminal emulator. I have packaged all the relevant files (xsession, xdefaults, wallpaper, etc..) available here. Be sure to move the tzosdclock file that is extracted to the appropriate place (like /usr/local/bin).
Debian GNU/Linux
Want to tell tcsh to autocomplete apt-get, apt-cache, and dpkg?
You should install sudo or modify this for root to use it. If you'd like to run this on Conectiva, comment out the three lines dealing with dpkg. Put this in your ~/.tcshrc file:
## debian
if ( -f /etc/debian_version ) then
alias apt-get "sudo apt-get"
alias dpkg "sudo dpkg"
alias alien "sudo alien"
set ipackages = `dpkg --get-selections | awk '{print $1}'`
set apackages = `apt-cache search '' | awk '{print $1}'`
complete dpkg 'n/-L/$ipackages/'
complete apt-cache 'n/{show,search,depends}/$apackages/' 'p/*/(show search pkgnames depends)/'
complete apt-get 'n/{install,remove}/$apackages/' 'p/*/(update install remove upgrade dist-upgrade clean)/'
endif
Solaris
What's with /usr/ucb?
You will find /usr/ucb on many SysV-compatible systems as a generic directory for duplicate programs that are compatible with the syntax of BSD commands. Just think of it as "/usr/university of california at berkeley" if you have trouble . Interesting fact: on Tru64, /usr/ucb is a symlink to /usr/bin. Tru64's commands can automatically tell which syntax they've been run under. It's sad to see the last real commercial UNIX die.
Solaris/BSD
- Disable Sun Print Server
- Install a current NetBSD pkgsrc tree and bootstrap it
- `scp user@netbsd:/etc/rc.subr /etc` on the host, change first line to #!/bin/bash. Solaris sh/ksh have issue with some NetBSD scripts.
- touch /etc/rc.conf
- mkdir /etc/rc.d
cat > /etc/init.d/netbsdrc <<EOF
#!/bin/ksh
cd /usr/pkg
if [ "$1" != "start" -a "$1" != "stop" ]; then
echo Usage: $0 start \| stop
exit
fi
for each in /etc/rc.d/*; do
$each $1
done
EOF
- chmod 755 /etc/init.d/netbsdrc
- ln -s ../init.d/netbsdrc /etc/rc3.d/S10netbsdrc
- ln -s ../init.d/netbsdrc /etc/rc3.d/K60netbsdrc
- Manage rc.conf and rc.d as usual, but you may need to modify rc.d scripts to use /bin/bash as well
- Install print/LPRng, misc/watch, etc.. from /usr/pkgsrc
- Modify user and system shell PATHs to include /usr/pkg/bin, etc..
- Alias ps, df, du and others to /usr/ucb equivilant just for your interactive shells
|