sabato 2 maggio 2015

Edit a remote file via ssh

ssh is mainly used to securely remote login to another computer.
It can also be used to issue commands on a remote machine without actually logging in. Thus, you may as well edit a remote file using vi. The syntax would be

ssh user@host 'vi filename'

Unfortunately you'll get the following message

Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal

You can quickly resolve the problem adding -t option to ssh

ssh -t user@host 'vi filename'

Here's what man ssh tells about -t option

  • -t  Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

lunedì 24 novembre 2014

OS X, how to launch an application in a different language than your default system language

Sometimes it can be useful to launch a particular application in a language that is not the one you choose when you first set up your account.

In order to do that momentarily, let's say I want to execute Preview in English instead of Italian, open Terminal and type the following command (or copy and paste the line below)

/Applications/ -AppleLanguages '(en-US)' &

The ampersand at the end of the line puts the execution of Preview in background, returning to the Terminal's prompt immediately.

It is also possible to always launch an application in another language. For the purpose of this example, Spanish. Open Terminal and type (or copy and paste) the following line
defaults write AppleLanguages '("es")'

To revert back to the default language, the command to issue into Terminal is 

defaults delete AppleLanguages

giovedì 26 dicembre 2013

Prevent auto mount in OS X

I like experimenting, a lot, with my computers. To be honest, that is the funny part of owning a computer.

I am going to use the Terminal in order to edit the file /etc/fstab
As a matter of fact, this file does not exist by default in OS X 10.5, 10.8 and 10.9. It doesn't probably exist on other versions of OS X too, but those OSs are what I'm using.

To create and/or edit /etc/fstab use vifs. Do not simply edit fstab with a text editor like vi.

This is vifs' man page

The goal here is to insert into fstab the IDs of the volumes you don't want to mount when the system boots.
You have two options. Specify the UUID (universally unique identifier) of the volume, or the volume disk label.
The volume disk label is the easiest method, because you already know it. For example the internal Macintosh hard drive is labelled "Macintosh HD" or whatever you named it. So, the line to add, looks like this

LABEL=Macintosh\040HD none hfs rw,noauto

The \040 represents the space character (see ASCII table) in octal numeral system.

The other option is to put in the UUID of the volume you don't want to mount.
To know the UUID you must issue a couple of commands.

diskutil list

   #:            TYPE NAME                 SIZE       IDENTIFIER
   0:  GUID_partition_scheme              *500.1 GB   disk0
   1:            EFI                       209.7 MB   disk0s1
   2:            Apple_HFS MacOSX_SYS      499.2 GB   disk0s2
   3:            Apple_Boot Recovery HD    650.0 MB   disk0s3

Lists all the information about the disks connected to your Mac. You must search for a line with the name equivalent to the volume's name you want to exclude from auto mount and make note of its identifier.
In my example this is /dev/disk0s2.
The last command let you know the UUID associated to the volume

diskutil info /dev/disk0s2 | grep UUID

Volume UUID:         72B18CD5-ADD4-382E-A877-F67239F204B3

So, the line to add to fstab is

UUID=72B18CD5-ADD4-382E-A877-F67239F204B3 none hfs rw,noauto

Save the new fstab file and reboot.

lunedì 4 novembre 2013

Disable hibernation on Windows 7, 8, 8.1

By default hibernation is enabled, and uses the file named hiberfil.sys located on the root folder of the system disk. This file is as big as the total amount of RAM installed inside your computer.
To disable hibernation, the quickest way is running a Command Prompt session with Run as administrator

At the prompt type

powercfg.exe /hibernate off

To verify that hibernation is really gone issue the following command

dir /as %SystemDrive%\hiberfil.sys

if you get "File not found" then hibernation is disabled.

To revert the above command

powercfg.exe /hibernate on

sabato 19 ottobre 2013

EFI and SMC firmware updates for Intel-based Macs

Usually Software Update can detect autonomously if your computer needs firmware updates.
If you want to be sure that your Mac's EFI and SMC firmware are updated, especially before upgrading the operating system, check this Knowledge Base document HT1237.

domenica 16 dicembre 2012

FAT32 is not fat enough

FAT32 is making its days.

If you frequently exchange data between Windows and Mac you should be aware of a relatively new file system called exFAT that extends FAT32 features.
As many of you know, NTFS would be the best choice but OS X cannot natively write on NTFS formatted volumes.

Windows prerequisites: Windows Vista onwards

Windows XP with this update Update for Windows XP (KB955704)

Mac OS prerequisites: OS X 10.6.5 onwards

More in depth explanation and links on exFAT from Microsoft knowledge base

In OS X use Disk Utility to format an external drive as exFAT.

domenica 27 maggio 2012

IE8 misbehaves on virtualized Windows XP SP3 inside Virtual PC 7.0.2

A few months ago I subscribed to Microsoft TechNet Standard.

Today I installed Microsoft Virtual PC 7.0.2 onto my glorious PowerBook G4 1.67 GHz/1.5 GB, to test Windows XP Professional SP3.

The installation took quite a long time but in the end all went fine. Running XP on a PowerPC G4 is not the fastest experience, but acceptable anyway.

Next step, I updated Internet Explorer from version 6 to version 8.

I run IE8-WindowsXP-x86-ENU.exe, restarted the virtual machine, launched IE8, went along the first time run questionnaire. I don't like automatic updates, so I opted for not to let the system check for updates for IE.

Everything was in place. Time to test internet sites. I typed in the first URL that came to mind, hit return and waited for the page to load. I could see, on the status bar, the loading page progress, but I got nothing but a blank page. Tried a couple of other URLs. Same results.

What I discovered after some Google searches was that, I wasn't alone.
At first, the only resolutive suggestion I found was to uninstall IE8 and install IE7. I didn't like the idea. Tried harder and I came across this post.

Now I knew that an IE patch would have fixed the issue. But which one?
Back to Google search engine I entered "Cumulative IE8 updates" into the search box. As expected, I got in return a plethora of links. I went for the first one in the list 

and, YES, that did the trick :-)