Skip to topic
|
Skip to bottom
Search:
Chris and Janet's website
Home
Historian
Archive
Tech
Amnesty
Home
Changes
Index
Search
Tools
Start of topic |
Skip to actions
Linux tcp tuning: [[http://www-didc.lbl.gov/TCP-tuning/linux.html]] --- Generate random numbers on linux: =dd if=/dev/urandom bs=1 count=128 | od -x= --- Solaris: =psrinfo -v= lists the processors on a box --- *Re-format external USB hard drive (Debian)* Motive: I wanted a backup solution that preserved file permissions when using rsync with the _-a_ option. My backup drive, a Western Digital usb hard drive, had a vfat file system - which I found didn't preserve file permissions. The following describes how to convert from vfat to an [[http://en.wikipedia.org/w/index.php?title=Ext3&oldid=28195254][ext3]] file system. *Remember*, if you follow these instructions all your existing data will be erased. Be sure, be very sure you want to re-format your existing drive. Here goes... When you plug the drive in check =dmesg= to find out which /dev device it's been mapped to. I found mine under /dev/sda1. Then you'll need to partition the disk: =fdisk /dev/sda1= This will give you a command prompt interface. Type =p= to get a list of the current partitions. I had 4 partitions, so I deleted them all using the =d= command. Then create your partition(s). I created one great big extended partition using the =n= command. It asks you a few questions about block sizes etc, I chose the defaults. Then I typed =w= to write the partition data to the disk. Then I quit fdisk. Then I created the filesystem: =mkfs.ext3 /dev/sda1= It asked me a few questions, I excepted all the defaults. Then you're ready to mount the device: =mount /dev/sda1 /mnt/usbdrive= You'll have to create the folder /mnt/usbdrive yourself. So that the disk gets mounted on reboot add the following line to /etc/fstab: =/dev/sda1 /mnt/usbdrive ext3 defaults 0 0= This also means you can simply type: =mount /dev/sda1= when mounting the disk from the command line. This [[http://www.thelinuxpimp.com/main/modules.php?op=modload&name=News&file=article&sid=561][link]] was useful. --- *Recovering a screwed NTFS disk* I created an image file from the corrupt disk using _dd_ -> dd if=/dev/hdd of=imagename.img conv=noerror I wanted to use an image file so that I could mess around without harming the data on the original corrupt disk. I used _testdisk_ to restore the image file's partition information (follow interactive menu system). I was then able to mount the disk: mount -t ntfs imagename.img /mnt/restoredntfs -o loop,offset=32256 Becasue I was mounting from an image file, I had to mount to a loop device. Thanks NASA, apparently. According to testdisk my partition was situated at the 63rd cylinder -> 63 * 512 (assuming 512 bytes per block) = 32256 bytes. --- *X11* How to run x windows apps using X11 forwarding. * Enable X11 forwarding on the client (in my case a debian distro). To do this reconfigure the sshd daemon, by changing the line =X11Forwarding no= in /etc/sshd_config to =X11Forwarding yes=. Then restart the sshd daemon: =/etc/init.d/ssh restart=. * From the server (in my case a Powerbook) login into the linux box (but make sure you do this from an xterm session), using ssh (don't forget the -X): =ssh -X linuxhostname=. From the client (debian ssh prompt) run an app: xcalc, ddd etc. The window should appear on the server (Powerbook). Note, no need to use =xhost +=. The above solution is much more secure, both for client and server. All communication is authenticated and encrypted. And you don't have to set/export your display on the client (debian)! --- *awk* To print a timestamp (UTC) in a locale readable string do the following: =echo "1136211843" | awk '{print strftime("%c", $1)}'= prints: =Mon Jan 2 09:24:03 2006= --- *RPM* To check the version of an installed rpm package, use the following command (this example looks at procps, which includes the ps command): =rpm -qa | grep procps= returns: =procps-2.0.7-11.21AS.4= To list the files in an uninstalled package: <pre>rpm -qpl _packagename.rpm_ </pre> --- *Vim* Setting a text file to unix format from DOS using vim: =:set ff=unix= To find out what format a file is: =:set ff?= --- *du* Lists the size of each directory/file in the current directory, and prints the sizes in human readable form: =du -h --max-depth=1= --- *Prolong the life of your external USB drive* I have an external usb powered hard drive (one of [[http://www.lacie.com/products/product.htm?pid=10833][these]]) connected to my server permanently, as part of my backup solution. To prolong the life of the disk, I spin it down after my overnight using the following command: =sdparm --command=stop /dev/sda= *Note:* your device might be mounted somewhere other than =/dev/sda=. --- *Renaming a large number of hidden files* The following command searches the current directory, recursively, for all hidden =mp3= files, appending a =.blah= suffix: =find . | egrep "/\..*mp3$" | while read e ; do mv "$e" "$e.blah"; done= Filenames *can* have spaces in them! --- *XEmacs* To get rid of that annoying flashing when making a mistake in XEmacs: =M-x= =set-variable= =visible-bell= Value: =nil=
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
More topic actions
Revisions: | r1.22 |
>
|
r1.21
|
>
|
r1.20
|
Total page history
|
Backlinks
You are here:
Home
>
UnixStuff
to top