Archive for the 'docs' Category

16 GB encrypted candy file

Update: as far as cryptoloop is vulnerable and is not maintained I don’t recommend using below approach for creating encrypted for for those of you who require strong security. Use truecrypt to create encrypted filesystem within a file instead.

passwords.txtToday it came to my mind that it is time to make sensitive information stored on my usb flash drive encrypted but still transportable and easy to use. But I don’t want to have whole my 32 GB usb drive fully encrypted using truecrypt or something similar. It is just toooo slow. I also don’t want to use GPG for uncompressing files and directories every time I would like to read them and then create new GPG compressed file every time I save changes. This eats too much of my time and system resources. At the same time it is necessary to be able to use that usb drive under windows, mac, linux whatever (read/write files) but still have my directory structure with sensitive files encrypted. Here is the solution: create encrypted filesystem within a file named, say, 16GB.candy.bin that could be stored on regular windows formatted usb flash drive and then mounted under Linux using the password.

When it becomes necessary I can mount that 16GB.candy.bin as the regular ext3 filesystem with all those stuff like permissions, ownership etc. that is available on ext3 but not in FAT or NTFS. On my windows formatted flash drive candy takes only 16 GB so I can use the rest of space to store not so sensitive information like mp3, movies or photos. Moreover I on windows or linux to read it.

Let’s create that 16GB.candy.bin file with encrypted ext3 filesystem (read below explanations below carefully before just to copy/paste commands into CLI):

[root@artemn root]# cd /path/to/candy/

[root@artemn root]# modprobe cryptoloop

[root@artemn root]# modprobe aes

[root@artemn root]# dd if=/dev/urandom of=16GB.candy.bin bs=1048576 count=16000

[root@artemn root]# losetup -e aes /dev/loop0 16GB.candy.bin

[root@artemn root]# mkfs.ext3 /dev/loop0

[root@artemn root]# tune2fs -i 0 -c 0 /dev/loop0

Here are some points: using above commands we create encrypted file of 16 GB so if you need to have more or less just change “count=16000″ in dd line. “count=16000″ means 16GB so “count=20″ means 20MB. Path ‘/path/to/candy/’ is for example only so you should change it to real directory that is able to host encrypted file (16 GB in above example). Command losetup is present in most Linux distributions (btw I recommend Ubuntu especially newly released Lucid Lynx) but if it is not use your disro’s packet manager to install it or compile from sources (for super geeks only, Mr. Stallman if you read this article — Hello). Reader, you can replace “/dev/urandom” in dd line with “/dev/zero” that will make that command to finish faster but will lower security level of resulting file (read about AES for better understanding). You will need to enter the password when running losetup command so make sure it safe and long enough like ‘6U2sAsR37Hn8122dGsaPrew1twt’ but not ‘abc123′ or ‘iloveyou’.

Once commands are done you will get 16GB.candy.bin containing encrypted ext3 filesystem. You can store this file where ever you want, say, on a flash drive. If you loose it nobody won’t be able to open it until he (or she!) cracked AES encryption (use long passwords to prevent this). As the next step it is required to mount filesystem and store some files/directories in it:

[root@artemn root]# mkdir -p /mnt/candy

[root@artemn root]# cd /path/to/candy/

[root@artemn root]# mount -t ext3 -o loop,encryption=aes 16GB.candy.bin /mnt/candy

[root@artemn root]# cd /mnt/candy

[root@artemn root]# #save files, edit them, view or anything you want

[root@artemn root]# cd /

[root@artemn root]# umount /mnt/candy

When you unmount 16GB.candy.bin the changes are already saved there so it’s not required to compress and encrypt anything unlike with GPG.

P.S. This post is inspired by Loopback tricks article. Thanks to the author. Good luck!

Sort CLI output by line length

Want to sort file contents by each line’s lenght? No problems:

artemn@artemn-laptop:~$ cat /etc/passwd | awk '{print length, $0}' | sort -n | awk '{$1=""; print $0 }'

Continue reading…

Watching HD Media on Linux made easy

h1_camcorder_1

This article is presented to you by LaptopLogic.com. Go there to read the latest info on the top rated laptops and the best laptop accessories.

The High Definition (HD) content is everywhere these days, from HD and Blue Ray Discs to streaming HD media. Although HD content gives best picture quality, it also uses a lot of computational power to decode and play.

This was made easy for Windows by the introduction of new drivers from graphics card manufacturers, Nvidia and ATI, which allowed the whole media to be decoded on the dedicated graphics card, saving cost in computational power, and the need to have a stronger processor.

nvidia graphicsNvidia recently released a new set of drivers for Linux supporting PureVideo technology for its line of graphics hardware, enabling full hardware HD-decoding, and giving smooth HD content playback, even on less powerful computers. The 180 series supports PureVideo decode acceleration. These drivers adds a new VDPAU API, which provides PureVideo like features on Linux, adds CUDA support, X Render optimizations, new workstation performance optimizations and some other improvements. The new versions offer optimizations and support for a wide range of Nvidia hardware, and is expected to improve with future releases.

Linux uses X-Video (Xv) as output extensions, where as X-Video MotionCompensation (XvMC) is an X-Video extension which offers some video decoding on GPU. With the new drivers, Nvidia implements VDPAU (Video Decode and Presentation API for UNIX).

VDAPU is capable of hardware acceleration and the decoding of MPEG-1, MPEG-2, VC-1 and H.264 bit streams. It also provides an API for post-processing of decoded video in order to apply operations such as noise reduction and temporal and spatial de-interlacing, timestamp-based presentation of final video frames, and compositing of sub-picture elements.

amd-4800-series-graphic-cardAMD also supports hardware acceleration through X-Video Bit stream Acceleration or XvBA API. The recent drivers can take advantage of Unified Video Decoder (UVD2).

These new technologies are also supported by new video playback softwares, which can fully utilize the Graphics Hardware for video playback, providing smooth frames in HD and Blue-Ray movies. The VDPAU supported players include libavcodec, mplayer and ffmpeg.

CUDA support is also provided with 180 series drivers for Linux, and it can also be used to accelerate videos, and also to do any processing involved, like CoreAVC 1.9.0 is the first media player to offer this decoding.

The video acceleration on Linux came late, but certainly, with these new advancements by Graphics chips manufacturers, Linux users will be able to experience HD media playback, even on less powerful systems.

Mount remote filesystem via ssh protocol using sshfs and fuse [Fedora/RedHat/Debian/Ubuntu way]

sshfs

Imagine the following situation: you have to compile some Linux/Unix application or kernel module that requires kernel source present at your hard drive, say, in /usr/src/kernels/kernel-2.6.21-i386/ or elsewhere. But there is not enough disk space to copy these sources or install kernel-devel or linux-source packages (in Fedora/RedHat or Ubuntu/Debian distros respectively)… Sounds familiar? Believe me, sometimes it happens :)

As a solution you can mount the directory of some remote PC that contains needed kernel source. It can be done via several protocols like smb, ftp etc. In this article we will mount remote directory using ssh protocol that is one the most popular for remote and secure access to Linux boxes over the network.

Below are the steps which should be taken to get the ball rolling. We need two packages: sshfs and fuse-utils.

ssh1. Install necessary packages:

a. Ubuntu/Debian:

sudo aptitude install fuse-utils sshfs

b. Fedora/Centos/RedHat:

yum install fuse-sshfs fuse fuse-libs

c. Other Linux: download and compile sshfs/fuse from sources

2. Check that kernel module fuse is loaded:

lsmod | grep fuse

There should be the line containing “fuse” in the output (of not try modprobe fuse).

3. Mount remote filesystem using something like this (two commands):

mkdir -p /mnt/sshfs/
sshfs remote-user@remote-machine:/some/directory /mnt/sshfs

where remote-user is the username allowed to login remote-machine via ssh protocol. It will ask you to type the password so just type it and press return :)

4. That’s it. Good luck!

Open .docx documents in Linux (OpenOffice)

Well, as for now it is not a problem anymore to open Microsoft Office 2007 .docx documents in any Linux distribution coming with OpenOffice suit. It may be Ubuntu (Feisty, Gutsy, Interpid whatever), almost any version of Fedora/RedHat/Centos, *SUSE, Mandriva and of course Debian (as per my personal opinion it’s the best one).

What is .docx actually? It’s Microsoft’s file format representing word processor documents and named OpenXML (as an attempt to create open and free international standard). Today .docx is default format for Microsoft’s word processor Word.

There are myriads of online converters between OpenXML and OpenOffice formats including .docx, .xlsx, .odt and many etc but sometimes it’s much more better to just open received .docx file in Linux offline (if there is temporarily no Internet connection or for security/private reasons etc).

So, just download the following package to certain directory like /usr/src, here are the commands to do it:

1. cd /usr/src
2. sudo wget http://blog.mypapit.net/imej/odf_filter.tar.bz2

The next step is to unpack the contents of the archive (.tar.bz2 is definitely well compressed file) and copy 3 files to OpenOffice’s system directories:

3. sudo tar -xvjf odf_filter.tar.bz2
4. sudo cp OdfConverter /usr/lib/openoffice/program/

5. sudo cp MOOXTypeDetection.xcu /usr/lib/openoffice/share/registry/modules/org/openoffice/TypeDetection/Types/
6. sudo cp MOOXFilter_cpp.xcu /usr/lib/openoffice/share/registry/modules/org/openoffice/TypeDetection/Filter/

As you can see from picture below now it’s possible to natively open .docx files in openoffice under Linux. Of course such “native” support may imply some artefacts in opened files due to file formats incompatibility so it’s also a good option to ask your friends to convert .docs into .pdf before sending you :)

openoffice openxml .docx

P.S. Thanks to guys from mypapit.

P.S. Here are several online converters .doc(x) <-> .odf <-> .pdf:

1. ZAMZAR (possibly the best converter), 2. http://docx-converter.com/.




Pages: 1 2 3 4 5 6 7 Next
Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
Linux HOWTOs, Tutorials & Projects with Adam Palmer | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››