read my CV Curriculum Vitae see all of my publications and conference talks Publications learn about my work in optics research Research learn how to make your computer into a video recorder Mythtv guides How I installed linux on my Compaq Rpictures of friends, family, research, etc. pictures links to my friends, where I work, linux sites, and more links contact back to the beginning home |
A few tips for shortcuts and other conveniences in ubuntu. backing up To backup the entire computer do the following: tar cpzf /ubuntu_backup_`date +%m_%d_%Y`.tgz --exclude=/proc --exclude=/lost+found --exclude=/ubuntu_backup_`date +%m_%d_%Y`.tgz --exclude=/mnt --exclude=/sys --exclude=/var/lib/mythtv / you might need to split the file if you're storing it on a FAT32 partition. This will do 2GB pieces: split -a 1 -b 2000000000 ubuntu_backup_`date +%m_%d_%Y`.tgz ubuntu_backup_`date +%m_%d_%Y`_ If you're using an ext3 partition or similar filesystem you won't need to do the split command. To restore an old backup do the following: tar -xvpzf /mnt/usbdrive/ubuntu_backup_<date>.tgz -C / mkdir /proc /lost+found /mnt /sys /var/lib/mythtv mkdir /mnt/usbdrive If you previously split the file you'll need to recombine it first, of course, and then do the restore commands above: cat ubuntu_backup_<date>* > ubuntu_backup_<date>.tgz you can set up a crontab to regularly backup your system by doing crontab -e as root. edit the file to look like the following: 59 4 15,30 * * /root/autobackup.sh autobackup.sh should be located in either the /root directory or in /usr/bin You can optionally add a line at the top of that script to delete old files before starting a new backup: rm `/usr/bin/find /mnt/usbdrive/ubuntu_backup* -type f -mtime +60` This will delete any backup files more than 60 days old mount a usb drive so that all users can access it despite linux and root This is one of those things that can make me angry. VERY ANGRY. On Ubuntu 8.04, a 2008 OS, I cannot mount my usb hard drive automatically. Why? I don't know. It just won't. Sometimes linux mounts some drives and sometimes it doesn't. I suspect it comes down to my use of a USB hub, which it doesn't like since it's connecting a usb drive to the same port as a number of other peripherals. Anyway, you can make linux mount it using the mount command, but you'll quickly find that only root can do anything to the mounted directories, making mounting the thing essentially useless and allowing you to bang your head against the wall. So, to get around this, you need umask=0 in your options in fstab for the device. Here's the line I adde to mount my usb hard drive so that I can freely read/write to it: /dev/sdc1 /mnt/auxdrive vfat rw,users,noauto,umask=0 0 0 Run a webserver in spite of ISP blocking port 80 To set up apache to use a different port in order to avoid having your webserver blocked by your isp: In /etc/apache2 edit the file ports.conf (create it if it doesn't exist): add or change the line to read the following: Listen <port#> where "<port#>" can be any number you want apache to listen on for http requests. Now when checking your hostname, you need to add the port to the end of the name in your browser. i.e. got to "myhost:<port#>" instead of just "myhost" to see your web page in your browser Deter constant attack away from your ssh server Chances are in your auth.og are tons of denied access attempts to your ssh server. It's because you're using port 22, the default port, and people and bots are probably trying to log into your ssh server from time to time. Stop these pesky attempts by changing your ssh port to something unusual. edit /etc/ssh/sshd_config and find the line that starts with the word "Port" replace the number "22" with whatever port you want to use. At the same time it might be a good idea to deny certain users from logging in: add the lines: DenyUsers mythtv AllowUsers <user> where <user> is a list of users who are allowed to use ssh. Note that you'll need to forward your new port from your router if you want to access the server from outside. sharing files: in order to share files with samba you need to su to become root, and then run shares-admin su shares-admin then you add folders to share there add the following lines to the end of /etc/samba/smb.conf [drive name] path = <path of share> available = yes browsable = yes public = yes writable = yes and now the drive should be visible from windows. Don't forget to set a password with smbpasswd, and set the samba user to the same one you log onto windows with. Not all shares are writable by default, so making the above change in smb.conf will help if you want to write to the directory from windows. sudoers To edit the sudoers file using anything but vi, do the following: sudo env EDITOR=gedit visudo temp monitors to get an applet on the panel that tells your processor temperature: sudo apt-get install sensors-applet also install a hard drive monitor: sudo apt-get install hddtemp Then add the applet to the panel. You may need to run sensors-detect to detect your motherboard's sensors to use in the sensors applet. dyndns install dynamic dns updater sudo apt-get install ddclient afterwards, enter web for interface during the config. Then edit the file /etc/ddclient.conf and replace the line use=if, if=web with use=web Then you can update your dynamic dns from the command line with sudo ddclient I put mine in cron to update once every ten days reload programs set up a hotkey program so that mythtv can be restarted using a hotkey on the remote control: sudo apt-get install hotkeys then use the config files I have placed in ~/.hotkeys/ I wrote a script that kills and reloads the frontend in case it crashes (rare but useful if it happens). I simply has two lines killall mythfrontend killall mythfrontend.real mythfrontend Move a Windows XP partition from one hard drive to another Connect the new hard drive to your current windows machine. First, set up your new hard drive with whatever partitions you want. You can use the disk management function in windows XP for this if you wish. Alternatively you can use gpartd in linux or some other partition manager. Make sure to save one partition for windows, or leave empty space which you'll partition later. Copy over all your old data (pics, mp3s, etc.) to the new paritions. Leave the windows partition untouched for now. If you have only one paritition on the old drive, which is the case for many people, just skip the data copying above. All your data will be copied in the next few steps. Next, you need to delete all the entries in your windows registry key under HKLM/system/MountedDevices. Simply delete everything except "default". This actually will not affect your old windows parition. It simply tells the machine to forget where the info about mounted drives is, so that windows does not reserve a single drive to be the C partition. Without doing this step, your new windows parition would mount with a different drive letter and look for the old C drive to continue booting. Next, turn off your machine and disconnect your old windows hard drive. Insert the Windows XP install CD and reboot from the CD drive. Go through the windows setup, and when it asks you to select a partition to install windows on, choose the new partition or empty space where you intend for your old windows installation to be copied to. Allow it to create / format the partition and then copy its setup files to it. Allow it continue on until it asks to reboot. Do not reboot. Instead, remove the Windows XP CD (we won't need it anymore), turn off the machine, and reconnect your old hard drive. Now, put a Linux Live CD into your drive; I prefer to use the Ubuntu 8.04 install CD - it worked perfectly for this. Reboot from the CD drive. In your Linux environment, do not choose to install Linux. Instead, use it as a Live CD or "demo" mode where you're able to use it as if it was a normal Linux box. This is where Ubuntu 8.04 comes in handy; it has a fully featured linux desktop with gnome straight from the CD. Once in your desktop, go to the command line and make two directories: sudo mkdir /mnt/new sudo mkdir /mnt/old Once that's done, mount both hard drives, putting the old one in "old" and the new one in "new": sudo mount -t ntfs /dev/sda1 /mnt/new sudo mount -t ntfs /dev/sdb1 /mnt/old Note you need to replace sda1 and sdb1 with whatever your partitions are. Here, sda1 is my new partition that I just ran the windows setup CD on. Now, finally we'll copy all of the files from /mnt/old into /mnt/new. sudo cp -r /mnt/old/* /mnt/new/. Check that both directories now look identical. If you used to store your pagefile.sys on a different partition, then the new directory will have a pagefile.sys while the old one will not. Simply delete the new pagefile.sys from the new directory. The directories should now look exactly alike. Finally, power off the machine. Disconnect your old windows drive, and reboot your machine. It should now reboot to the same familiar windows desktop you had before, just now from a different hard drive! That's it, all done. Don't chuck your old windows XP hard drive. You can use it as a failsafe backup in case things go pear-shaped later on in your new system. |