HowTo Copy a Folder in Linux/Unix

So, I got this question recently from a new Linux user, but I’m pretty sure even people who’ve been using Linux for some time will have a question or two regarding copying files on the command line.

Happy penguins

Unix, and by extension, Linux isn’t known to be very chatty. Most commands are two or at the most three characters long with a hundred options, so a lot of people who’ve come to Linux by way of easy to use distributions such as Ubuntu or Mint have never really used the command line to get done work. I, on the other hand, am an old Linux hand and, frankly, am the most comfortable on the command line.

Continue reading “HowTo Copy a Folder in Linux/Unix”

How To Password Protect Files in Linux

The USP of Linux has always been the strong security and stability it offers. Per user/group permissions and ACLs (access control lists) take care of almost all the security needs of a home users as well as an enterprise customer. If there is a need for even more fine grained control, there are various flavors of Linux available that are specifically designed with industrial grade security in mind and certified by organisations such as the NSA.

If you’re a home user, though, all this doesn’t really matter to you. Sure, it helps to have seperate permissions for different users on the system, if you’re sharing your computer with, say, your sibling, but configuring ACLs for home a user is a little overkill, if you ask me.

If all you need is a way to password protect certain important files from the prying eyes of your siblings, kids or pesky neighbors, Linux doesn’t offer anything *out of the box*. Fear not, though, we have just the right tool for you.

Password Protect Files

mcrypt is a utility designed to encrypt/decrypt a file using standard encryption techniques. If you don’t have mcrypt installed, you can install it with the following command.

apt-get install mcrypt

To password protect a file execute the following command

mcrypt <filename>

The above command will output something like this.

khera@khera:~$ mcrypt test1
Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase: Enter password here
Enter passphrase: Repeat password here

File test1 was encrypted.
khera@home:~$

By default, mcrypt creates a new encrypted file with the extension .nc added to the original filename and leaves the original file intact. If this is not what you want, and you’d rather not have any traces of the original file, use mcrypt with the “-u” option.

mcrypt -u <filename>

This will ask you for a password as usual and the only difference will be that when the command finishes executing, the original file, test1 in the above case, will be deleted.

Decrypting a Password Protected File

So, now you know how to password protect file but what about decrypting it.

Turns out mcrypt does that too. Just use mcrypt with the “-d” option and it will decrypt the file for you after confirming the password with you.

mcrypt -d <encrypted filename>

The output should look something like this

khera@khera:~$ mcrypt -d test1.nc
Enter passphrase: Enter password here
File test1.nc was decrypted.

Like, in the encryption phase, mcrypt doesn’t delete the original file by default and if that is what you want, use mcrypt with the -u switch.

mcrypt -u -d <encrypted filename>

This will decrypt the file and delete the original encrypted file leaving no traces of it on your computer.

How was that for an easy encryption/decryption utility?

WinFF – a media convertor for (almost) any format

WinFFHow many times have you come across a movie or a video clip and wished that you could put it on your iPod and watch it on the go ? Or came across a DivX encoded video and wished that you could burn it to a DVD and play it on an old style DVD player ?

With the increasingly fast broadband connections that most of us have these days, videos are becoming as much a part of our daily internet consumption as text is. But, unlike text, videos are not portable – You can’t just take a video from one source and play it anywhere you want. Of course, with media players like VLC, this is less of a problem but even VLC can’t help you if you want videos from a random site to work on, say, your iPod.

If converting videos and juggling between the different file formats is becoming too much for you to handle, you should give WinFF a try.

Continue reading “WinFF – a media convertor for (almost) any format”

Download youtube videos to your computer on Linux

YouTubeYoutube is by far the most popular site for sharing videos. The only problem with uploading your videos to youtube is that there really is no easy way to download those videos back to your computer. Your only option than is to view them online. There are also times when you watch a video so hilarious/interesting that you want to keep a copy for your own use.

To get over these restrictions, a lot of people have written really neat utilities which let the user download videos directly from the site. In this post, we’ll be talking about one such utility for Linux.

Youtube-dl

Youtube-dl is a console only application which is the simplest utility I’ve found till now for downloading videos from youtube.

To install youtube-dl, if you’re using Ubuntu, use apt-get.

apt-get install youtube-dl

Now, using a browser, browse to the video that you want to download. Copy the URL of the video page.

Now, at the console, give the following command.

youtube-dl <URL of the video>

Youtube-dl

That’s all. youtube-dl will now download the video to your computer and save it in the default .flv format which Youtube uses to save it’s videos. FLV files can be easily played back on Linux using the excellent VLC media player.

How to create a secure and private network

hamachiPicture this – You’re out on the road for work or pleasure and have this sudden urge to listen to that one song from your collection which is stored on your desktop back at home. Or you’re a freelancer and need access the draft proposal you made for a client which is again on your desktop sitting in your home office.

You can’t keep your desktop or other machines at home exposed to the outside world over the Internet, because, franklt speaking, it’s a dangerous world out there. But you still need safe and easy (and secure) access to all your data. How do you do that ? Did someone say – “Create a VPN!”

Enter Hamachi.

Continue reading “How to create a secure and private network”

How to schedule tasks in GNOME using gnome-schedule

gnomeMost Linux/Unix veterans use cron to schedule tasks on their machines and it is a very powerful utility for what it does.

The problem with cron is the cryptic syntax which tends to scare away most new users and the fact that a user has to use the terminal to create a new job.

In this tutorial we will explain how to use a graphical front end to cron, called gnome-schedule.

Continue reading “How to schedule tasks in GNOME using gnome-schedule”

Elisa – Open Source Cross platform Media center

Elisa media center Ellisa is an open source media center that can play DVDs, VCDs, video files and even display your photos. The support for video files is extensive and the player can handle almost any video that you might throw at it.

Elisa is extensible and is based on a very neat plugin architecture, which means that if there are features that you miss from the default install, they’re usually just a plugin away.

In the true spirit of open source, Elisa is available for both Linux and Windows with a Mac OS X port on the way.

Continue reading “Elisa – Open Source Cross platform Media center”

Play Space Invaders in Openoffice Calc

OpenOffice LogoWho said open source developers were a boring bunch of people. I’m quite sure that person hasn’t met the developers of Calc.

For those of you who’ve been living under a rock until now, Calc is the Spreadsheet part of the OpenOffice.org suite and today we are going to unearth a very cool easter egg game programmed within Calc by the developers.

Open a Calc Spreadsheet and type =GAME(“StarWars”) into any cell. The text should be typed exactly as written.

Continue reading “Play Space Invaders in Openoffice Calc”

How to install *.rpm files in Ubuntu

UbuntuUbuntu (and all Debian based) distributions use the .deb format for application packages and these days most developers writing applications for Linux provide a .deb package.

But, even then there might be times when you want to install an application which is available only in the .rpm format. If you use Ubuntu or any other Debian distribution, Alien might be able to help you.

Alien is a program that converts between the rpm, dep, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it.

Alien is available in the Ubuntu repository so you can install it by using the following command

$ sudo apt-get install alien

To convert an rpm file to deb, use the following command

$ alien -d -k package.rpm

Where package.rpm is the rpm package that you want to convert. The ‘-k’ option is to tell alien to keep the same version number on the resulting .deb as the rpm file.

Alien can also convert .deb packages to .rpm and the command to do that is

$ alien -r package.deb

Where package.deb is the deb package that you want to convert.

Disable spatial mode in GNOME’s Nautilus file browser

gnomeI’m a big GNOME fan and have been using it ever since it was first released.

Ofcourse, like all software, not all is good with the GNOME project also and some of the decisions made by the developers are just plain absurd to me. One such decision was making the Spatial mode on Nautilus as the default.

Nautilus, for those not familiar with it, is the default file browser/manager bundled with GNOME and the spatial mode basically means that each folder or file opens in a window of its own. There are other advantages to the spatial mode, I agree, but this is the one that I found the most irritating.

Nautilus Spatial mode

To make Nautilus behave and get rid of the spatial mode, open the gconf-editor application from the run menu and browse to the following key: apps -> Nautilus -> Preferences

Now, check the always_user_browser property.

gconf editor

That’s all. Now, go ahead and enjoy Nautilus and GNOME the way they’re meant to be.

Nautilus