Turning off the smbclient mget prompt
Problem:
Just tried to use mget to get all the files in a remote directory and it prompted me to accept each file with a y/n. This is because by default smbclient prompts to accept each file when using the mget command.
smb: \> cd PDFs smb: \PDFs\> mget * Get file 20100615135815.pdf? # to get out of this you have to CTRL + C and then re-login using smbclient
The Fix:
When in an mget session turn off prompting by entering prompt before running the mget command
smb: \> prompt smb: \> cd PDFs smb: \PDFs\> mget * getting file \PDFs\20100615135815.pdf of size 68489 as 20100615135815.pdf (412.9 kb/s) (average 412.9 kb/s)
Wonderbah!
Using Google Maps to Roughly Determine Your Distance from the Local Telephone Exchange
ADSL performance is predicated on a number of factors. Of primary importance to the potential speed of ADSL is the distance of your house from your local Telephone Exchange.
Using Google maps you can roughly calculate your distance from the exchange:
- You need to know your home address. If you don’t know your address seek help! No seriously.
- Discover the location of your Local Telephone Exchange
- go to google maps for your country e.g. http://maps.google.com.au
- Click the Get Directions link and enter your home address and the exchange address. Then click the “Get Directions” button
You should see something like this. The distance will be on the left. I have highlighted it in yellow.
This is a guestimate only. Telephone cabling generally follows the local roads. However the Telephone cable could take a different path from the one google maps autopicks. But it’s enough to get a rough idea.
The Linux `at’ command
Cron does repeating jobs at runs one off jobs. So can be handy
You need the `at’ package
yum install atThe at daemon must be running
ps -ef | grep atd root 2496 1 0 Mar18 ? 00:00:00 /usr/sbin/atd
If not. Use chkconfig (redhatian) or update-rc.d (debian) to set it to start automatically
# add it (This is how you would get it running with a Redhat based system such as Fedora) chkconfig atd --add chkconfig atd on chkconfig --list atd atd 0:off 1:off 2:off 3:on 4:on 5:off 6:off # then as root start it service atd start
Using the at command add the job. The thing about this, to my mind is that you can’t specify a command with arguments as far as I am aware so you have to wrap all the commands in a script and point at to it using the -f parameter
at -f /usr/local/bin/service-start 7am tomorrow at -f /usr/local/bin/service-stop 2pm tomorrow
Use atq to check to see if the job was added correctly
atq 2 2010-06-10 14:00 a root 1 2010-06-10 07:00 a root
You can list the contents of the at job using at <jobNum> -c
at 1 -c
This is what at 1 -c spits out on my CentOS 5.x system
#!/bin/sh # atrun uid=0 gid=0 # mail myuser 0 umask 22 HOSTNAME=myhostname.domain.local; export HOSTNAME SHELL=/bin/bash; export SHELL HISTSIZE=1000; export HISTSIZE USER=root; export USER LS_COLORS=no=00:fi=00:di=00\;34:ln=00\;36:pi=40\;33:so=00\;35:bd=40\;33\;01:cd=40\;33\;01:or=01\;05\;37\;41:mi=01\;05\;37\;41:ex=00\;32:\*.cmd=00\;32:\*.exe=00\;32:\*.com=00\;32:\*.btm=00\;32:\*.bat=00\;32:\*.sh=00\;32:\*.csh=00\;32:\*.tar=00\;31:\*.tgz=00\;31:\*.arj=00\;31:\*.taz=00\;31:\*.lzh=00\;31:\*.zip=00\;31:\*.z=00\;31:\*.Z=00\;31:\*.gz=00\;31:\*.bz2=00\;31:\*.bz=00\;31:\*.tz=00\;31:\*.rpm=00\;31:\*.cpio=00\;31:\*.jpg=00\;35:\*.gif=00\;35:\*.bmp=00\;35:\*.xbm=00\;35:\*.xpm=00\;35:\*.png=00\;35:\*.tif=00\;35:; export LS_COLORS MAIL=/var/spool/mail/root; export MAIL PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin; export PATH INPUTRC=/etc/inputrc; export INPUTRC PWD=/usr/local/bin; export PWD LANG=en_US.UTF-8; export LANG SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass; export SSH_ASKPASS SHLVL=1; export SHLVL HOME=/root; export HOME LOGNAME=root; export LOGNAME LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN G_BROKEN_FILENAMES=1; export G_BROKEN_FILENAMES OLDPWD=/root; export OLDPWD cd /usr/local/bin || { echo 'Execution directory inaccessible' >&2 exit 1 } ${SHELL:-/bin/sh} << `(dd if=/dev/urandom count=200 bs=1 2>/dev/null|LC_ALL=C tr -d -c '[:alnum:]')` #!/bin/sh /usr/local/bin/servicerun start
Apple.com Trailers for Linux
Just installed Fedora 13 and was getting a “Get QuickTime” prompt when trying to view trailers at www.apple.com/trailers:
The Fix:
yum install gecko-mediaplayer mozilla-vlcCaveats:
Works with Firefox.
Google Chrome, although it looks at /usr/lib/mozilla/plugins doesn’t pickup and use the Gecko MPlayer plugins for some reason.
Update: Google Chrome (version 5.0.375.55) Seems to work for me now… Here is my plugin list I have added VLC recently and it’s seems to be using Totem. But the video controls don’t show when you do a mouseover on the lower part of the video screen.
Google Chrome Totem Plugin that mostly works for Apple.com
List of all plugins in Google Chrome…
On my machine which is an old P4 I have to adjust the audio volume down a little in order for the sound to start playing. I also have to right click in an area of the screen to start displaying the video.
My current F13 plugins list:
ls /usr/lib/mozilla/plugins gecko-mediaplayer-dvx.so librhythmbox-itms-detection-plugin.so gecko-mediaplayer-qt.so libtotem-cone-plugin.so gecko-mediaplayer-rm.so libtotem-gmp-plugin.so gecko-mediaplayer.so libtotem-mully-plugin.so gecko-mediaplayer-wmp.so libtotem-narrowspace-plugin.so libflashplayer.so libvlcplugin.so libjavaplugin.so
Facebook – The data persistence specialists
So tonight my better, no I mean much better half, goes to log into facebook and it prompts her to register her computer. Huh? Seeing as you can pretty much individually identify a computer simply by examining the default information that the browser passes over when you connect. I would say this wonderful new feature is yet again another Facebook privacy debacle.
Anyway a while ago I de-activated my Facebook account… and have become concerned that de-activating the account doesn’t actually delete the content… Meaning FB is doing who knows what with my pictures of LOL Catz.
So I Googled and attempted to delete it last night…
But don’t you know Facebooks version of delete, doesn’t actually mean delete, it means we’ll give you a 14 day cooling off period and if you accidentally login to your Facebook account, say for example on another computer which has your FB username and password cached (it’s easy to do), it get’s re-activated. Nice huh!
So as soon as Facebook starts offering an online backup service I’m going to apply for it, because you know with Facebook, even when you want to delete something it will be nigh on impossible to make it happen… Exactly what you want from a backup service.
Viv-la Social Media!
F13 Installer – Oh what a wonderful mess
So Ubuntu 10.04 is a thing of beauty and typically I use it above other distributions…. However my spiritual Linux home is Redhat/Fedora I started out with it and even bought the Sybex RHCE book. I even think that the Redhat style of system-config-blah provides a better way of admining a box than the Debian style of randomizing the name of all the config utils.
So every new release of Fedora I install it to see how it’s going. Which brings us to F13.
I have two hard disks and in my BIOS they are listed as follows
200GB /dev/sda
500GB /dev/sdb
Ubuntu detects them as the BIOS lists them.
Anaconda, The Fedora installer suffers from inverted myopia it can’t seem to get them straight no matter what options I chose. So F13 installs the boot loader in the wrong place and on restart gives me a GRUB> prompt nothing more….
Don’t get me wrong Fedora 13 installs fine it’s disk detection routine is retarded.
I finally got it to install on the second partition of /dev/sdb but still I couldn’t boot it. The Ubuntu GRUB 2 boot loader was in the root of /dev/sda and the Fedora 13 installer just couldn’t figure what was where in order to get me a bootable Fedora installation…
However once I booted into the Ubuntu install on /dev/sda I then ran
sudo update-grub2
and amazingly it detected the Fedora install and added it to the GRUB 2 boot loader…
This allows a successful boot of the Fedora install.
But at every kernel upgrade (which happens fairly regularly) you then have to boot to Ubuntu and get it to add the latest kernel version. Who wants to do that?
OK so here is the answer as far as my setup was concerned:
Install the Fedora grub to the same partition as it’s root dir:
grub-install /dev/sdb2
Open the Ubuntu version of /etc/grub.d/40_custom and add:
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. # add this bit the above is what is there by default echo "Chain Load GRUB 1 Fedora 13 from Ubuntu GRUB 2" cat << EOF menuentry "Chainload Fedora Grub" { set root=(hd1,2) chainloader (hd1,2)+1 } EOF } EOF
So this worked but because Anaconda is retarded it thinks that /dev/sdb is actually hd0 which is a total lie. So you also have to go into the /boot/grub/device.map file in Fedora and get it to think straight by adding all the harddisks as they really are thusly:
# this device map was generated by anaconda (hd0) /dev/sda (hd1) /dev/sdb
Which is far different from the confused pustule that Fedora serves up by default. Since when is sdb hd0.
# this device map was generated by anaconda (hd0) /dev/sdb
If the peoples creating the distributions are scratching their heads wondering why Ubuntu has gained supremacy, perhaps they should look at these sorts of duh duh oops sort of things.
Backup Linux to a Windows Box
Been having a look on the web for options that allow backing up a Linux box to a Windows box without first having to create a massive file on the Linux box.
Found a good FTP option at http://www.squidoo.com/linux_backup namely under point 4:
# login ftp TheFTPServersIPAddressHere # set the transfer mode to binary binary # tar straight to the remote server # the tar options are # -c create an archive # -v be verbose about it # -l restrict creation to local disk # -O pipe the archive to standard out # -o make an old style archive put |"sudo tar -cvlOo /usr" myusr.tar # the quotes around the "sudo tar -cvlOo /usr" are critical # as is there being no space between # the "|" pipe and the begining of the `sudo tar'
Which with sufficient automation would be one good backup solution.
But I would prefer to use windows networking because then I don’t have to a. Install a copy of the IIS FTP Server or FileZilla Server and b. send an unencrypted FTP password.
At that point I struck trouble… Google failed to dish up a good example of what I was trying to achieve.
So I have come up with something that seems to work OK as follows.
How to Backup Linux to Windows using Tar and Smbclient
On your Linux Box – You know! The one you want to backup
Create a file in your home directory named .smbclient with the following contents.
# Enter your windows network credentials here username=yourwindowsusername password=yourwindowspassword domain=YOURDOMAIN
Make sure you change the permissions of the .smbclient file to stop others (other than root) perusing your windows password
chmod 400 .smbclient
Create a file in your home directory named excludes.txt or whatever you want to call it with the patterns of what you want to avoid (check out the tar documentation on how these patterns work i’m a n00b when it comes to tar so you can probably do something more sophisticated).
# put anything in here that you don't want to backup home/user/excludes.txt home/user/.smbclient home/user/backup.log /dev /proc
Create a group and edit the /etc/sudoers file to allow you to perform a tar operation with superuser permissions without password authentication. Note: You may have to log out and back in to pick up the changes.
sudo groupadd smbclient # add your self to the group sudo usermod -a -G smbclient yourlinuxusername # add the group to your sudoers file to allow it # to perform the backup as superuser sudo visudo # add this line to the sudoers file %smbclient ALL=NOPASSWD:/bin/tar # in english the above line means... # anyone in the smbclient group on any host... # can use sudo to run /bin/tar with root privileges
Now for the work to get done using tar and smbclient. Create a file named backup.sh and make it excuteable
touch ./backup.sh chmod +x ./backup.sh
Add the following as contents of backup.sh edit it to taste:
#!/bin/bash cd # everything is relative to the user user's home dir so go there # you can backup as much `/' or as little `/path/to/one/dir/or/file' as you like TOP_DIR=/home/username # nice way to timestamp your backups with a YYMMDD stamp MYDATE=`date +%y%m%d` TARGET_DIR=$MYDATE MYFILE=`hostname -s`-$MYDATE.tar WINHOST=yourwindowsbox SHARE=C$ LOG=backup.log EXCLUDES=excludes.txt AUTH=.smbclient # now the work get's done # the tar args -c create an archive, -v verbosely, -O pipe it to STDOUT # -p preserve the permissions, # -X get the list of what not to back up from excludes.txt # using `2>' pipe STDERR (the verbose output of the -v switch) to backup.log sudo /bin/tar -cvOp $TOP_DIR -X $EXCLUDES 2>$LOG \ | smbclient //$WINHOST/$SHARE -A $AUTH -c "mkdir $TARGET_DIR; \ cd $TARGET_DIR;put - $MYFILE;exit"
Finally you can add this to your user crontab using
crontab -e # Plonk this content into the crontab # m h dom mon dow command # at 1/4 past 2 every morning run the backup 15 2 * * * /home/user/backup.sh
Caveat’s and Gotcha’s:
- Some files on a Linux installation have filenames incompatible with Windows for example the “:” character is acceptible in Linux but a no-no in Windows. So trying to untar an archive on Windows can be an excercise in futilty.
- Until you have taken a complete backup and successfully restored it then assume your backup strategy isn’t complete yet. A complete successful restore is really the only 100% reliable way of making sure you have captured everything you need to restore successfully. Remember what they say “In theory, theory is the same a practical. In practise it isn’t”
The above seems to work on a Ubuntu 9.04 VM that I am running and copying up to a Windows XP Pro SP3 share. I managed to backup the entire / sans /dev and /proc to a 4GB tar file on the Windows box successfully.
The process cannot access the file because it is being used by another process
Annoying problem “The process cannot access the file because it is being used by another process” trying to delete a directory.
Didn’t want to reboot because I was running a VMWare VM at the time and well real operating systems don’t make you reboot every time something untoward happens.
Tried filemon from sysinternals.com and couldn’t see any activity in the directory I was trying to delete.
so couldn’t figure out how to find which process was holding a lock on the directory I was trying to delete
Ended up Opening task manager and killing explorer.exe and then restarting by clicking File ==> New Task ==> explorer.exe {ENTER}.
Directory then deleted fine.
OS: Windows XP Professional SP3
Windows 7zip Fails to Extract a Tar Archive created on Linux
Just had an error in Windows 7-Zip 4.6.5 trying to extract a Linux tar archive. A reasonably large tar archive of 3.76 GB.
Got this error:
So fell back to using Cygwin
Using tar -tf archive.tar allowed me to list the contents of the archive just fine.
But attempting to extract the archive threw up errors such as this:
tar: usr/share/man/fr/man3/Defoma\:\:Font.3pm.gz: Cannot open: Invalid argument
The problem was the `:’ characters windows won’t allow them.
Australian Online Computer Component Sellers
http://www.staticice.com.au/
http://www.megabuy.com.au/
http://www.auspcmarket.com.au/
www.onlinecomputer.com.au
http://www.eyo.com.au/ – Based at chipping norton. Reasonably easy to navigate their website. I have purchased 2 or three boxes from them. Found them reliable.
http://www.computermemoryupgrades.com.au/ – I have used these guys. Easy to select the RAM and pay via CC. Usually arrives next day.



