Main menu

Tag Archives: linux

If you have a printer connected to a Linux box that is being shared via CUPS, the following command at the command line in Mac OS X will tell CUPS on your Mac to look for printers on other CUPS servers.

cupsctl BrowseProtocols='"cups dnssd"'

Now when you go to Printers in System Preferences, your shared Linux printer should show up automagically.

To quickly change UNIX/Linux file permissions (this applies to Mac OS X also), one can use the find command, combined with the -exec flag.

For example, suppose you want all directories nested beneath (and including) the current directory to have 755 permissions:

find . -type d -exec chmod 755 ‘{}’ ;

Explanation: ‘.’ refers to the current directory, ‘-type d’ indicates file type of directory, the command executed is chmod 755, where ‘{}’ is a cookie — the directory name will be inserted here. The exec command ends with a semicolon ‘;’, which must be escaped with a backslash so that your shell doesn’t interpret it.

To change file permissions to 644 (leaving the directories as is):

find . -type r -exec chmod 644 ‘{}’ ;

Note the type of ‘r’ to indicate a regular file.

Using these two find commands together, one can quickly change permissions on directories and files to 755 and 644 respectively to make them globally accessible, or 700 and 600 respectively to secure the files.

Windows decided to overwrite my MBR and clobber grub. I was successful at restoring grub by taking the following actions. While this may be a self-serving reminder for the next time it happens, others may find it useful.

It’s worth noting that grub2, which ships with Ubuntu 10.04, has made some changes — mostly notably, /boot/grub/menu.lst has been replaced with /boot/grub/grub.cfg. Following restoration instructions for previous versions of grub will likely fail.

1. Boot from Ubuntu Live CD (Install disc)

2. Open terminal

3. Look at partitions to get device name

sudo fdisk -l

4. If your Linux partition is not marked as bootable, go to System->Administration->Disk Utility and mark the partition as bootable.

5. Create a mount point

sudo mkdir /mnt/linux

6. Mount the partition by device name found in step 3 (for example, /dev/sda1)

sudo mount /dev/sdXY /mnt/linux

7. Run grub-install, which will rewrite the MBR. Note that here you want to specify the device (ie, hard disk) but not the partition. So for /dev/sda1, you’d use /dev/sda.

sudo grub-install --root-directory=/mnt/linux/ /dev/sdX

8. Reboot and grub should load. You may wish to run sudo update-grub after rebooting to update /boot/grub/grub.cfg with any partition or OS changes.