DæmonNews: News and views for the BSD community

Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

Aliasing is important for any-size networks

by Jonathon McKitrick <j_mckitrick@bigfoot.com>

If you run FreeBSD on a box of your own, you are a system administrator. The same applies to Windows, but the fact is, you can never have the amount of control over Windows as you can have over FreeBSD and other Unix-like operating systems. What does this involve? Well, most system administrators would tell you they maintain software packages, add and remove accounts, and manage printer and file sharing. And of course they deal with occasional problems. Many of these duties apply to installations with only one primary user. Let's consider some examples of how we can perform some of the same duties as a system administrator on our little (or not so little) FreeBSD boxes at home, and how we can use operating system features to make our job easier.

Simply put, most home users don't need to worry about adding and removing accounts. But, they can apply the other principles of system administration. First, let's consider a few shortcuts that can make day-to-day operations easier.

Here is my alias list, in part:

alias mc="midc"
alias x="startx"
alias v="vim"
alias la="ls -a"
alias ll="ls -al"
alias cp="cp -ip"
alias rm="rm -i"
alias mv="mv -i"
alias al="alias|more"
alias prof="vim ~/.zshrc"
alias conf="vim ~/admin/MERCURY"
alias o="shutdown -p now"

alias dogs="ssh -l jcm -c blowfish dogma.freebsd-uk.eu.org"

alias pon="ppp -ddial nerc"
alias poff="/etc/ppp/ppp-off"

alias z="mount /dev/da0 /mnt/z"
alias uz="umount /mnt/z"
alias dz="mount -t msdos /dev/da0s4 /mnt/z"
alias flp="mount -t msdos /dev/fd0 /mnt/a"
alias uflp="umount /mnt/a"
alias plist="make_pkg_list"

Like I said in my last column (my first?), I use Midnight Commander for some file managament. In linux, it is called 'mc', but under FreeBSD it is midc, so I just alias it as 'mc' for brevity. I also have aliases for vim, my editor, startx, three types of 'ls' with different arguments, and even 'al' to list my aliases to a pager. I also took some well-known advice for even the most sure-handed of system administrators: alias rm, cp, and mv to contain '-i', which requests confirmation for each file. If I need to delete a large number of files, I either use Midnight Commander, or you can specify the path as /bin/rm and the alias is sidestepped. I also include an alias 'o' to power down and turn off my laptop. Last in this group are two aliases, 'prof' and 'conf', which call vim to edit my z-shell shartup settings and my kernel config, respectively. There are also aliases for all my telnet/ssh connections and to connect to and disconnect from my ISP dialup account.

That leaves several aliases for mounting and unmounting filesystems. Filesystem management is very important in both large and small installations. Here I have aliases for mounting my zip drive on /mnt/z in either DOS mode ('dz') or UFS mode ('z'). To unmount, I use 'uz'. Floppies are mounted on /mnt/a with 'flp' and unmounted with 'uflp'. That brings us to an important point: unless you want to 'su' to root for these filesystem mount commands, you need to take an extra step in your system startup. In /etc/rc.local, I added the following lines:

sysctl -w vfs.usermount=1

This line allows non-root users to mount/unmount filesystems. But first, you have to own, or rather 'chown' them:

chown jcm /dev/da0
chown jcm /dev/da0s4
chown jcm /mnt/z
chown jcm /mnt/a

Lastly, the 'plist' alias comes in very handy. The command is actually:

pkg_info > /home/jcm/admin/pkg_list

When I start wondering where all my drive space is going, I can run this command and then peruse 'pkg_list' to see what I have installed. And then I start playing the Grim Reaper of ports. With this list in one Xterm, I open another and use Midnight Commander to peruse /var/db/pkg. For each package that I might not want anymore, I go into the directory bearing its name, and read 'REQUIRED_BY,' if there is one. This file obviously lists other packages that depend on this one. So, I either have to leave it, or I can delete the parent port that uses it, then come back and delete this one. To delete a package quickly, I back out to /var/db, place my cursor on the package name, and type 'pkg_delete ' (don't forget the space) and then ESC-enter to copy the package name onto the command line. Hit return, if there are no dependency issues, the package is removed. Sometimes there are warning messages, but this often occurs if part of the port has already been removed, and some of its directories or files no longer exist for this reason. There is a command to force removal even if there ARE dependency issues, but I'll wait until I am more advanced before I start making assumptions about which commands I should force and which I should not.

Remember: If you install ports rather than packages, you need to 'make clean' in /usr/ports to clean up the work directories. There can be a good deal of space hiding in those work directories. This also applies to /usr/src after 'make buildworld' as well. What are some tips for making world and cvsup'ping? What other tools and tricks can we use? Well, let's leave those questions for next time.

Google
Web daemonnews.org

More Articles
  • Interview with Jan Schaumann
  • Interview with Theo de Raadt
  • Book Review: Virtualization with VMware ESX Server
  • Editorial: Not Quite Dead Yet
  • The Design of OpenBGPd
  • Interview with der Mouse
  • Letter to Steve Jobs
  • Interview with Manuel Bouyer on Xen
  • Apple and Open Source
  • BSDCan 2006
  • BSD Certification Survey Results
  • Lab in a Box
  • Ike Notes on BSDCan 2005
  • BSDCan 2005 Photos
  • FreeBSD Developer Summit Pictures

  • Advertisements




    Author maintains all copyrights on this article.
    Images and layout Copyright © 1998-2006 Dæmon News. All Rights Reserved.