A few Terminal tips

A couple of days ago I found an interesting article called Lazy Linux: 10 essential tricks for admins, so I decided to try a couple of these on my Mac – I’m running Tiger, by the way.
  

1. Unmounting a stuck DVD (or disk image, for that matter)

I could not find the fuser command mentioned for linux on my Mac but we can always use lsof.

If you’re trying to eject a disk called Movies and are getting the old The disk “Movies” is in use and could not be ejected message you can open up the Terminal and run the following commands to find which app is at fault:

$ lsof | grep Movies
  

You should get something like this:

QuickTime 404  myuser  13r   REG   14,3 735825920   45186 /Volumes/Movies/My Movie.mov
  

This example tells you that QuickTime has a file called My Movie.mov open from the Movies disk. So just close the file in QuickTime and you should be able to eject your DVD/image file.
 

2. Collaboration with screen

This one worked exactly as it says in the article. Just do the following:

  • Open up the Terminal on your Mac. Let’s assume your username is myuser.
  • From another machine, open up an SSH connection to your Mac as myuser.
  • From the remote machine type the following:
  • $ screen -S myscreen 
      
  • Now, from the Mac Terminal type the following:
  • $ screen -x myscreen
     
  • Your Mac Terminal session and your SSH session should now be joined together. Anything you do on the Mac will be seen from the remote machine and viceversa. This is great for collaboration or troubleshooting.
  • To exit myscreen just type exit from either machine.

 

The linux article includes tips for:

  1. Unmounting the unresponsive DVD drive – works great.
  2. Getting your screen back when it is hosed.
  3. Collaboration with screen – I did not know about this, works great.
  4. Getting back the root password – I will probably try this one soon.
  5. SSH back door.
  6. Remote VNC session through an SSH tunnel.
  7. Checking your bandwidth.
  8. Command-line scripting and utilities.
  9. Spying on the console.
  10. Random system information collection.

 
So if you’re a linux user check them out. They could come in handy eventually.

Advertisements

Mail.app in Tiger hangs

So I was trying to check my email and all of a sudden Mail.app was not responding. I had to Force Quit the app because all I was getting was the spinning ball.

I tried again and the same thing happened.

What gives?

So after trying a few different things I decided to disable all my network connections and it finally opened. I just turned Airport back on and Mail.app was working fine again.

Strange.

By the way, I have Mac OS X 10.4.11.

MacPorts on Tiger

I decided to install MacPorts on Tiger. I basically had two options: to use the .pkg installer or to install it from source. Since I’m new to MacPorts I decided to take the easier road and use the package installer.

This is the description of what the package installer does on the MacPorts site:

This procedure will place a fully-functional and default MacPorts installation on your host system, ready for usage. If needed your shell configuration files will be adapted by the installer to include the necessary settings to run MacPorts and the programs it installs, but you may need to open a new shell for these changes to take effect.

Fair enough.

So I mounted the image, double-clicked on the .pkg file and installed the software. That was easy. Then I opened the terminal and decided to run the following:

$ sudo port -v selfupdate

I got the “command not found” error. What gives? I thought the installer was supposed to make the necessary changes to my environment. Anyway, I found no .profile file in my home directory so I had to add the following lines to the end of my .bash_profile file manually:

# For MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export DISPLAY=0.0

And that was it. Not a big deal I guess.