Feeds:
Posts
Comments

Posts Tagged ‘Windows’

If you’ve attached an external hard drive to your system, then decided to use your partitioner to format it to EXT4 for greater efficiency (or just to match your Ubuntu system), you may have been shocked to find that your empty drive seemed to be missing a few gigabytes when mounted afterwards. And this has nothing to do with the good old binary (base-8) vs decimal (base-10) situation which would see your “750Gb” drive be more like 700Gb (in Windows and earlier versions of Ubuntu – now Mac OS X and Ubuntu have followed hardware manufacturers and use decimal, so that’s more like 738Gb).

This is because Ubuntu (and other Linux distributions) reserve typically around 5% of the space for the root user and system services, so should you run out of hard drive space, the administrator can still log in, and system services continue to run.

However, this is only really needed for your Ubuntu partition, so if you have an external EXT4 drive, or have an EXT4 partition on your internal drive (other than the one your system is on), you are needlessly wasting space (40Gb of the drive in the example). But you can free up that disk space quite easily, without having to re-partition the drive or anything. All it takes is a couple of commands pasted into the terminal.

In the following example, an external hard-drive will have the reserve set to 0 (zero), since this is what most people will need this for. First, we have to determine the device name, as using its mounted name – /media/700Gb Ext4 – won’t suffice. To do so, enter the following into the terminal:

mount|grep ^'/dev'

Look for the line containing your device:

/dev/sdc1 on /media/700Gb Ext4 type ext4 (rw,nosuid,nodev,uhelper=udisks)

… and you can see what it is named (/dev/sdc1 in this case). To free up reserved space, enter the following (replacing /dev/sdc1 with whatever the appropriate device name is, if need be – just make sure you don’t do it to your main drive!):

sudo tune2fs -m 0 /dev/sdc1

You should then be presented with the following message:

Setting reserved blocks percentage to 0% (0 blocks)

To confirm all has gone well, you can right-click an empty area of the folder window for the device and choose Properties, then compare the free space from before and after, or run the following command (once again replacing the device name with the correct one in your case):

sudo tune2fs -l /dev/sdc1 | grep 'Reserved block count'

You should be greeted with the following:

Reserved block count: 0

That’s it – you now have all of your drive to use.

ΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘ

Note: if you receive the following error message:

tune2fs: Bad magic number in super-block while trying to open /dev/sdb1
Couldn’t find valid filesystem superblock.

… then the filesystem likely isn’t EXT4 – chances are the drive is actually formatted as NTFS or FAT for use on Windows systems (which would be the case if you’ve bought an external drive, and never did anything other than copy files to it). You would have needed to partition/format the drive to EXT4, so if you didn’t, then you actually don’t need this guide.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Whether you have a fresh Ubuntu 11.04 Natty Narwhal install or have upgraded, one thing you may have noticed is that the familiar Alt+Tab key combo for cycling between open programs and folder windows doesn’t work, which is even more of a pain if you’re using Unity.

 

Since there is no taskbar in the Unity desktop, and at this current early stage of development leaves a lot to be desired when it comes to accessing running applications, this can be a problem for those not wanting to waste a lot of time fiddling.

But you can actually rectify this, and that’s by enabling a Compiz-Fusion plugin. Go to System > Preferences > CompizConfig Settings Manager, and under Window Management enable Static Application Switcher (if prompted, click the Enable Compiz Library Toolbox button to proceed).

If that doesn’t work, click on that plugin, and set the desired binding (“Next window“) to Alt+Tab in the Bindings tab. Make sure you click the button opposite the “Next window” for keyboard, not mouse. After selecting to enable that combo you can click Grab key combination and hold Alt while you press Tab.

Alt+ Esc?

If you’re wondering whether the other related key combo can be restored, being Alt+Esc for cycling between windows without the popup, you’ll note further down in the Bindings tab that there is also “Next window (No popup)“. You can once again get it to grab the key combo, but after setting it to <Alt>Escape it unfortunately did not work. However, setting it to <Super>Tab did work, just not as it used to, in that it will only bring another window to the foreground once you’ve let go of the keys. Hitting the combo once just cycles between the last two windows repeatedly, but hitting more than once will bring others in the chain to the fore, so for now the Alt+Tab combo is preferable (unless you know the order of open windows).

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

While Ubuntu‘s new Unity interface has been designed for less clutter, and generally makes getting to common tasks a breeze, many have found navigating through the rest a bit of a nightmare. While everything is supposed to be more simplified, some would argue having all your launchers accessible via categories in the old Applications menu was actually simpler and quicker.

But you can actually have the best of both worlds, so if you’re avoiding Unity and using the Classic Desktop simply for access to the Applications and System (or Wine) menus, read ahead.

While you can’t actually add the old menu system to the Unity panel, since it is not gnome-panel that is running, there is actually an “indicator” available for Unity that will do the same thing. So while this new (or old?) menu won’t replace Unity‘s “Dash“, you will see an Ubuntu icon in your system tray’s notification area. Click that, and you will see the old familiar Applications menu, with all the categories you’re used to.

To install Classic Menu Indicator, enter the following commands in sequence in a terminal:

sudo add-apt-repository ppa:diesch/testing

sudo apt-get update

sudo apt-get install classicmenu-indicator

Once installed, hit Alt+F2 and enter classicmenu-indicator as the command to run.

Apart from easy access to all your launchers, you’ll find your old System menu is there too, split into the familiar Preferences and Administration sub-menus.

More importantly for many, you will also have your old Wine menu back for running Windows programs. Unity‘s Dash menu system does not currently show a Wine section, and finding those apps can be near-impossible, but classicmenu-indicator will rectify this.

If you find that this menu/indicator does not automatically run upon your next boot (which it should), simply add classicmenu-indicator to your Startup Applications, and it will be forced to load from then onwards (it should already be in there, so check it isn’t disabled).

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

If you upgraded to Ubuntu 11.04 (or installed a fresh Natty Narwhal system) and are running the Classic desktop, you may find something amiss with the ability to bring folder windows or programs to the foreground by holding an item over its taskbar button until it appears.

For example, you’re looking in a folder at a sound file you downloaded, and wish to play it in Banshee, which is already open but hidden from view. Normally, you would drag the file over the Banshee taskbar button in the bottom panel, wait till Banshee appears, then drop the file onto it.

A more common use is perhaps file management, when you’re dragging files and folders from one Nautilus window to another which is hidden from view. This is most handy, as it means you don’t need to carefully line up both source and destination folders before doing the drag-and-dropping.

But you may find something is preventing you from doing this, with the only thing happening is a + sign appearing, and if you finally let go on the panel instead of press the Esc key, a launcher will be created there, which you then have to remove. This is not some new setting you can change in Nautilus‘s preferences (which is evident if you try with another file manager like Thunar), but a Compiz bug. While that obviously needs to be ironed out, there is a way around this, which is to run the following command in a terminal:

compiz --replace

Note that the next time you restart, things will be back as before, but at least you can just run that command again (which you can easily do by hitting the up arrow when in the terminal, or pick from the menu in the Run dialogue via Alt+F2).

Also note that if you try adding that command to your startup programs, it will likely do nothing, but you can always make a launcher for your panel, which you can then click once everything has loaded, or when you go to drag stuff via the taskbar and remember you need to.

This bug will likely be fixed soon enough, but at least there is a way around it for now. If you’d like to add your voice to the bug report (since more voices mean quicker action), click here (note that if you haven’t already got a Launchpad account, it only takes a couple of minutes to join, and is worth the small effort, since you can then report your own bugs).

ΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘ

Can’t get the Run Application dialog to appear when you hit Alt+F2?

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Please note: this guide is for Ubuntu 10.10 backwards, as Emerald is no longer supported by Ubuntu. If you have upgraded to 11.04, Emerald will still the there, but the themes will be useless unless you uninstall Emerald and reinstall a version compatible with the latest Compiz-Fusion. If you have Emerald running successfully in 11.04 onwards, then this guide will still apply to you. Otherwise, read the guide for restoring window borders in 11.04 onwards.

ØØØØØØØØØØØØØØØØØØØØØØØØØØ

Once in a while, you might find that when you boot to your desktop, the title-bars to all your windows are missing, along with the control buttons (Minimize, Maximize and Close).

While many wouldn’t know any way around this situation other than a reboot, others will be aware of the fusion-icon package that lets you reload your window manager. Once installed, it can be found in Applications > System Tools > Compiz Fusion Icon, and when launched you’ll find its icon in the system tray. Simply right-click it and choose the Reload Window Manager option, and Compiz-Fusion will be forced to restart, and your title-bars will reappear with the Emerald theme currently in use.

But there is actually a much easier way to go about this, and it is as simple as pasting the following command into a terminal or via Alt+F2:

emerald --replace

This just reloads Emerald, which is all that is needed to get your title-bars back. As you can see, this is much quicker than using the Compiz Fusion Icon, and means you don’t have to worry about installing the fusion-icon package if it’s not already on your system.

But there is an even easier way to do this, and that is create a launcher for it. You can put it anywhere you like, like the desktop or on the panel, but if you’re worried about clicking it accidentally, or just want it out of the way until needed, you can add a drawer to your panel and stick it in that.

The command for the launcher is exactly the same as for the terminal, and you can name it something like Reload Emerald/Compiz. Then all you have to do from then onwards is click your launcher and watch your title-bars bounce back.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

AnyMeal is a recipe database program for Linux that is a great way to store and edit your recipes, and because it is compatible with the Mealmaster program for Windows, you can find thousands of recipes online to import. To install it, simply enter the following into a terminal:

sudo apt-get install anymeal

You’ll also need to make sure the packages mysql-server and mysql-client are installed, as the database won’t work without them. If not, you can open Synaptic and enter mysql-server in the Quick search bar, and when you select if for installation, it will automatically mark all the other packages it needs. Or you can install everything at once with:

sudo apt-get install anymeal mysql-server

This should install all the needed MySQL stuff, as well as some packages AnyMeal will need, like the KDE Wallet Manager (since AnyMeal is in fact a KDE program, but runs absolutely fine in Gnome once it has installed a few KDE packages).

Once installed, open AnyMeal (Applications > Accessories > anymeal), click the Connect button, and enter your normal password to open the KDE Wallet Manager.

You will then be presented with the “Connect To Datasource” dialogue, and you will notice the default Server is “Embedded“, with User being your username.

You’ll need to change the Server toNetwork“, which will be listed as “localhost“, and set the User toroot“. However, this will only work once you’ve created a user called “root“. If you have never created a password for the root user, you will be doing so shortly, so make sure you write it down somewhere, as it is something you don’t want to forget!

Click the New button at the bottom of the dialogue box, then Next when you get to the “Welcome to AnyMeal” message. You’ll see pretty much what you saw before, so change the Server to “Network“, and the User to “root“. Then click the Connect button beneath, then Next. In the next screen, you will be asked for a name for the database, which you can just leave as “anymeal“. Click the Create/Connect button, followed by Next.

In the “Setup MySQL Datasource” box, you can leave the Client as “localhost“, but change User to “root“. You will then need to enter the password for root, and confirm it, then click Create/Use, then Next.

You will then be told “You can import some recipes already, if you want to” (if you do, click the Import Recipes button), so click Finish.

You are now ready to start adding to your recipe database, which you can do via Edit > New Recipe (or the “Edit new recipe” toolbar button). You can also use File > Import > Mealmaster (or the “Import recipes from Mealmaster-file” toolbar button) to import recipes stored in the .mmf format for the popular Mealmaster program. Just do a Google search for “Mealmaster recipe” and you’ll find thousands online to choose from.

As an example, here is the seafood page from one of the more popular recipe sites:

Open a desired recipe in a new tab, then click the small “Display Recipe for Import” link at the bottom so it opens as text-only without all the banners and links.

Save the page, but make sure the extension is .mmf, not .txt or .html; it is very likely most recipes you will come across will be either plain text (.txt) or a web page (.html) – since the browser knows how to display these – so just rename the suffix to .mmf (and don’t forget to give it a descriptive name).

You will occasionally come across web pages with multiple recipes in Mealmaster formatting one after the other, so you will need to copy and paste each recipe into its own .mmf text file. Similarly, if you find a site that has one recipe per page, but has no plain text version to view (ie: the page also has images and links), you will need to copy the text and paste it into new .mmf files for importing.

In AnyMeal‘s “Batch Import Mealmaster” box, click Add and browse for and select a recipe you downloaded. You’ll notice the file has been added to the import list (which can feature multiple files), but the OK button is disabled. Next to Input Encoding you will need to select “UTF-8“, then under Handling Of Erroneous Recipes select either “Abort on error” or “Ignore errors“, then click OK.

When you return to AnyMeal, it will probably look empty, but if you go to Edit > Search (or click the “Search recipe by title and category” toolbar button) and click OK (no need to type anything), your imported recipes will appear. You might need to do this again if the list of recipes is not refreshed after adding more.

To view a recipe, simply double-click it. If it is maximised, you can use the Search button to get back to the recipe list, unless you have a Back button at the top of your keyboard, which should work fine. Of course, you can also just use the Restore button (between Minimise and Close) to restore it to a smaller window, and you’ll be able to see your list behind it. Just make sure you don’t use the Restore button in AnyMeal‘s titlebar, but the one in the row of buttons beneath.

To delete a recipe from the database, right-click it and choose Delete. You’ll notice while you’re in the context menu that you can also Export your recipes in a number of formats, so you can even share your own recipes with Mealmaster users.

Also, you can choose to Edit a recipe, and you’ll see just how well AnyMeal did with converting that plain text file you imported into useful and editable information. You can add your own ingredients, change quantities and amount of servings, etc, as well as change the title. The latter is useful as many imported recipes will contain recipe numbers, or be in upper-case (which you can be forgiven for finding annoying!), and even contain typos, all of which can be edited. It’s also the place to change ingredient names to those you use in your own country, like if you’re an Aussie you’ll probably prefer to see “prawn” instead of “shrimp” (especially since we call tiny prawns “shrimps“), and “chick peas” instead of “garbanzo beans“. And let’s not forget converting American measurings (ie: pounds and ounces) to the modern metric system the rest of the world uses (ie: kilos and grams)!

For some info on the recipes stored, like the total amount of ingredients for all recipes in the database, go to Database > Database info.

This should be all the info you need to get you started, so have fun saving your recipes, and of course browsing through all those recipes you’ll be importing!

Extra Notes:

» Note that if you disconnect from the database and then reconnect, you will be asked for your password again to open KDE Wallet Manager, but since it is already open, you can actually ignore it and click Cancel.

» If the fact that the launcher is all in lower-case (ie: “anymeal“) bugs you, just right-click the Applications menu, choose Edit Menus, select the Accessories folder, then select anymeal and click the Properties button to the right of it, enter the new name (ie: “AnyMeal“), and click Close.

» For command-line options, check out the manpage (you can pick your version of Ubuntu under the top banner, though it really shouldn’t make any difference).

» You can resize AnyMeal so that your list of recipes is accessible on one side while viewing recipes on the other.


☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

A Quick Intro to End-Of-Line Conventions

Most people don’t realise that when they hit the Enter key to create a new paragraph in a text file, something very different is going on behind the scenes in the three major operating systems: Windows, Macintosh and Linux. The “end-of-line delimiter” (often expressed as “End-Of-Line“, “End of Line“, or just “EOL“) – which some of you know as the “line break” or “newline” – is a special character used to designate the end of a line within a text file.

UNIX-based operating systems (like all Linux distros and BSD derivatives) use the line feed character (\n or <LF>), “classic” Mac OS uses a carriage return (\r or <CR>), while DOS/Windows uses a carriage return followed by a line feed (\r\n or <CR><LF>). Now that Mac OS X is based on FreeBSD‘s file system, it follows the UNIX convention.

Now, the reason most people don’t know about all this is because nobody really should have to. But while users of Linux distros and Mac OS can open Windows text files in basically any available editor and not even know the difference, the same can’t be said for Windows users opening files created in one of the other operating systems.

If you type up a simple text file in Ubuntu and save it in the default “Unix/Linux” format, in Windows it will appear as one continuous paragraph, with black squares where the line breaks (or new paragraphs) should be. While you can open the file in a more advanced text editor (or proper word processor) to view it as it should look, others you’ve sent it to are just likely to double-click it and let it open in Notepad (which can only handle MS-DOS EOL).

But you can save text files as Windows EOL easily with Gedit, as well as convert to that from UNIX via the terminal, so hopefully the following guide will be of use.

For more detailed info on End-Of-Line, go to the Wikipedia page.

And if you find the editor you’re using to display Windows files in Ubuntu shows ^M instead of a line break (not very likely with even the most lightweight text editors, but something you’ll probably come across if you display the text in a terminal), check out how to convert to Unix/Linux.

Saving Windows Text Files in Text Editor (Gedit)

It’s actually very easy to create text files with Windows EOL in Ubuntu using the default Text Editor, Gedit. When saving a file, go to Line Ending in the dialogue box and choose Windows instead of the default Unix/Linux. For files that were previously created, you can open them in Gedit and use Save As… to convert them (or save copies with the correct EOL).

As you can see, that’s pretty easy, but for more than one or two files, it is way too much work, so check out how to batch-convert multiple files via the terminal.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

A Quick Intro to End-Of-Line

Most people don’t realise that when they hit the Enter key to create a new paragraph in a text file, something very different is going on behind the scenes in the three major operating systems: Windows, Macintosh and Linux. The “end-of-line delimiter” (often expressed as “End-Of-Line“, “End of Line“, or just “EOL“) – which some of you know as the “line break” or “newline” – is a special character used to designate the end of a line within a text file.

UNIX-based operating systems (like all Linux distros and BSD derivatives) use the line feed character (\n or <LF>), “classic” Mac OS uses a carriage return (\r or <CR>), while DOS/Windows uses a carriage return followed by a line feed (\r\n or <CR><LF>). Now that Mac OS X is based on FreeBSD‘s file system, it follows the UNIX convention.

Now, the reason most people don’t know about all this is because nobody really should have to. But while users of Linux distros and Mac OS can open Windows text files in basically any available editor and not even know the difference, the same can’t be said for Windows users opening files created in one of the other operating systems.

If you type up a simple text file in Ubuntu and save it in the default “Unix/Linux” format, in Windows it will appear as one continuous paragraph, with black squares where the line breaks (or new paragraphs) should be. While you can open the file in a more advanced text editor (or proper word processor) to view it as it should look, others you’ve sent it to are just likely to double-click it and let it open in Notepad (which can only handle MS-DOS EOL).

But you can save text files as Windows EOL easily with Gedit, as well as convert to that from UNIX via the terminal, so hopefully the following guide will be of use.

For more detailed info on End-Of-Line, go to the Wikipedia page.

If you’d like a more WYSIWYG approach, check out how to save and convert via Gedit.

And if you find the editor you’re using to display Windows files in Ubuntu shows ^M instead of a line break (not very likely with even the most lightweight text editors, but something you’ll probably come across if you display the text in a terminal), check out how to convert to Unix/Linux.

Converting Linux EOL to Windows via the Terminal

It’s easy enough to create new text files with Windows EOL in Ubuntu using the default Text Editor (Gedit), but what if you’ve created a whole bunch with the default Unix/Linux EOL and need to convert them for Windows users? Well, you can actually open them in Gedit and use Save As… to save over them (or to create copies), but for more than a couple of files this would be the long, complicated solution.

By far the quickest and easiest approach is to convert the offending files via the command-line. This way, you could batch-convert hundreds of such files at once, not have to do them individually.
There are actually quite a few ways to do this, but we’ll look at a couple of tiny packages you can install, and the related commands to use.

The first – the tofrodos package – is undoubtedly the most widely-used, so we’ll look at that in detail – especially since many of the guides out there are outdated, since the commands it contains have been renamed.

The second is a little package called flip, and since it’s tiny and won’t cause any issues, it’s worth installing as a backup (just in case. I found it useful after trying to get tofrodos going on a new system, before I found out the commands were changed).

There is no actual command tofrodos, as it is just the package that contains the commands todos and fromdos. Currently, the vast majority of online guides will list the commands as unix2dos and dos2unix, but as the developer states:

With this release the symlinks “unix2dos” and “dos2unix” are dropped from the package. This will allow the introduction of the original dos2unix package, which also supports conversion to MacOS style files.

So now you can choose to use either todos (to convert to Windows) and fromdos (to convert to Linux), or just fromdos with options (fromdos -u to convert to DOS, and fromdos -d to convert to UNIX, though obviously the -d option really isn’t needed, as it is the default behaviour for the fromdos command).

We’ll use todos, as it is easier to remember, and show how to alter a single file, or all text files in a given folder. When you’re ready to proceed, open a terminal in the folder containing the text file(s) and use one of the following commands (note that for the purpose of illustration, the .txt suffix is used, but you can specify any other extension for your text files).

To convert to DOS/Windows format:

Single file (remember to replace filename.txt with the actual name of the file)

todos filename.txt

All text files in a folder (if the extension differs to .txt, simply replace it in the command)

todos *.txt

Similarly, flip is easy to use:

flip -m filename.txt (or flip -m *.txt for multiple files).

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

A Quick Intro to End-Of-Line

Most people don’t realise that when they hit the Enter key to create a new paragraph in a text file, something very different is going on behind the scenes in the three major operating systems: Windows, Macintosh and Linux. The “end-of-line delimiter” (often expressed as “End-Of-Line“, “End of Line“, or just “EOL“) – which some of you know as the “line break” or “newline” – is a special character used to designate the end of a line within a text file.

UNIX-based operating systems (like all Linux distros and BSD derivatives) use the line feed character (\n or <LF>), “classic” Mac OS uses a carriage return (\r or <CR>), while DOS/Windows uses a carriage return followed by a line feed (\r\n or <CR><LF>). Now that Mac OS X is based on FreeBSD‘s file system, it follows the UNIX convention.

Now, the reason most people don’t know about all this is because nobody really should have to. But while users of Linux distros and Mac OS can open Windows text files in basically any available editor and not even know the difference, the same can’t be said for Windows users opening files created in one of the other operating systems.

If you type up a simple text file in Ubuntu and save it in the default “Unix/Linux” format, in Windows it will appear as one continuous paragraph, with black squares where the line breaks (or new paragraphs) should be. While you can open the file in a more advanced text editor (or proper word processor) to view it as it should look, others you’ve sent it to are just likely to double-click it and let it open in Notepad (which can only handle MS-DOS EOL).

Occasionally, the reverse is the issue, but you can convert Windows text files to UNIX easily with Gedit, as well as convert them via the terminal, so hopefully the following guide will be of use.

For more detailed info on End-Of-Line, go to the Wikipedia page.

Or if you’re wanting to do the reverse, check out how to convert to Windows format via the terminal and with Save As… in Gedit.

Converting Windows EOL to Linux via the Terminal

If you find the text editor you’re using to display Windows files in Ubuntu shows ^M instead of a line break (not very likely with even the most lightweight text editors, but something you’ll probably come across if you display the text in a terminal), don’t worry – just convert them to Unix/Linux format.

While you can actually open them in Gedit and use Save As… to save over them (or to create copies) in the correct format, for more than a couple of files this would be the long, complicated solution.

By far the quickest and easiest approach is to convert the offending files via the command-line. This way, you could batch-convert hundreds of such files at once, not have to do them individually.
There are actually quite a few ways to do this, but we’ll look at a couple of tiny packages you can install, and the related commands to use.

The first – the tofrodos package – is undoubtedly the most widely-used, so we’ll look at that in detail – especially since many of the guides out there are outdated, since the commands it contains have been renamed.

The second is a little package called flip, and since it’s tiny and won’t cause any issues, it’s worth installing as a backup (just in case. I found it useful after trying to get tofrodos going on a new system, before I found out the commands were changed).

There is no actual command tofrodos, as it is just the package that contains the commands todos and fromdos. Currently, the vast majority of online guides will list the commands as unix2dos and dos2unix, but as the developer states:

With this release the symlinks “unix2dos” and “dos2unix” are dropped from the package. This will allow the introduction of the original dos2unix package, which also supports conversion to MacOS style files.

So now you can choose to use either todos (to convert to Windows) and fromdos (to convert to Linux), or just fromdos with options (fromdos -u to convert to DOS, and fromdos -d to convert to UNIX, though obviously the -d option really isn’t needed, as it is the default behaviour for the fromdos command).

We’ll use fromdos, as it is easier to remember, and show how to alter a single file, or all text files in a given folder. When you’re ready to proceed, open a terminal in the folder containing the text file(s) and use one of the following commands (note that for the purpose of illustration, the .txt suffix is used, but you can specify any other extension for your text files).

To Convert to UNIX/Linux via Terminal:

Single file (remember to replace filename.txt with the actual name of the file)

fromdos filename.txt

All text files in a folder (if the extension differs to .txt, simply replace it in the command)

fromdos *.txt

Similarly, flip is easy to use:

flip -u filename.txt (or flip -u *.txt for multiple files)

Converting Windows EOL to Linux with Gedit

It’s actually very easy to convert text files with Windows EOL to Unix/Linux in Ubuntu using the default Text Editor, Gedit. Simply open the files, choose Save As…, go to Line Ending in the dialogue box and choose Unix/Linux instead of Windows. While that is easy enough, for more than one or two you’d really want to save yourself some time and hassle and perform a batch-conversion via the terminal.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Older Posts »