Adding a designer frame to an image using gimp in linx

We can add a designer frame to any photo using gimp by using following steps.

Open gimp and open the photo for which we need to add a frame by clicking on

file->open

We will use the following example image to add a frame to.

 photo linux.jpg

Now click on

FX-Foundry->Image effects->Add Frame

As shown below.

 photo add_frame_select.png

This will pop a window with options for the frame as shown below.

 photo add_frame_options.png

The various options are

Frame Width : The width of the frame to added
Frame Fill: We can choose the fill the frame with
Color of our choise or, the same color as the background, the same color as the foreground or we can select any of the patterns available in gimp.
Texture Frame: We can add a texture from the various options of texture available. Texture Bump Map and Bump interactively are advanced options which we can explore once we are comfortable with the basics.
Bevel Index: How much slope needs to be added to the frame
Inner Shadow width : Width of the shadow of the frame
Innter Shadow Opacity :Opacity of the inner shadow.
Use layers : To retain the layers gimp creates for adding the frame, if the box is not checked gimp merges all the layers and creates a single layered image.

Now click on ok and we can see gimp will uickly add the frame as selected by the various options. The following is the result of addition of a frame to the above image.

 photo linux_with_frame.jpg

Category: Linux | Comments Off on Adding a designer frame to an image using gimp in linx

To find if cpu is 32bit or 64 bit in linux

Here are two ways of finding out,using linux, whether a processor on a system is 32bit or 64 bit.

1. Using proc entry.

Run the command

$ cat /proc/cpuinfo | grep address\ sizes address sizes : 40 bits physical, 32 bits virtual

The above output clearly indicates that the address size of the cpu is 32 bits and hence does not support 64 bit.

2. Using the command cpuid.

For this we will have to install the package cpuid

$ sudo apt-get install cpuid

After the installation run the command

cpuid | grep address Maximum linear address: 32; maximum phys address 40

From the above output too we can conclude that the cpu is a 32bit architecture.

Category: Linux | Comments Off on To find if cpu is 32bit or 64 bit in linux

Binary clock on linux terminal

Here is how we can create a binary clock on the Linux terminal. We will need to install the package binclock which can be done in the debian based systems

$ sudo apt-get install binclock

Now launch a terminal and run the command

$ binclock

 photo binclock.png

To understand the output add the option “-n”

$ binclock -n

 photo binclock_2.png

The binary time is in the format HH:MM:SS. The first column represents the first number of HH the second column the second number of HH and so on.

binclock by default provides the output in color which can be turned of by adding the option –color=off

$ binclock –color=off

 photo binclock3.png

Category: Linux | Comments Off on Binary clock on linux terminal

Encrypting text files using VI editor

While creating text files using the “vi” editor we can make the files secure by encrypting the files with our own encryption key. Any encrypted file will be unreadable unless the coorect key is not known.

Let us say we have a file by the name temp:

$ cat temp This is test file to be used for encryption using vi editor in linux. We should not be able to read the contents of the file untill we do not know the encryption key.

To encrypt this file, so that no one with out the encryption keys is able to read or write from the file, open the file using vi editor

$ vi temp

Now go to command mode by typing “esc”

Then type :X and press enter.

Note the “X” is in upper case

VI will now prompt for an encryption key as shown below.

Enter any key, and press enter

It will prompt for confirmation of the key, enter the same key again .

To find out whether the file is encrypted or not we can use the command file

$file temp temp: Vim encrypted file data

Thus indicating that it is an encrypted file. If we try to read from the file using cat

$cat temp

The output will be junk value. If we try to open the file using “vi” editor, it will prompt us for the encryption key.

In case we entered the wrong key, the file will open but with garbage values in it, and it will be in read only mode.

Only on entering the correct key, the file be visible in the original form

To remove the encryption, open the file using “vi” editor by entering the correct key and go to the command mode. Use the command

set key

And press enter. It will prompt for a value of key, hit enter, do not enter any value for the key.

The encryption should have been removed now and we can edit the file as usual way.

Category: Linux | Comments Off on Encrypting text files using VI editor

10pt loadable: Metric (TFM) file not found

While using latex in debian 6.0 we might come across the following error.

10pt loadable: Metric (TFM) file not found

This is because the font the latex is trying to use is not installed in the system

The workaround for the problem is to install the package

texlive-fonts-recommended

In debian we can do it using the command

$ sudo apt-get install texlive-fonts-recommended

After installing the package the above error should not appear while using latex.

Category: Linux | Comments Off on 10pt loadable: Metric (TFM) file not found

searching in pdf files using grep : pdfgrep

Just as we use grep to search for patterns in a text file we can use pdfgrep to search for strings in a pdf file. In debian based systems we can install the package from the package manager or from the terminal using

sudo apt-get install pdfgrep

Once installed we can use this command from the terminal to search for the strings in pdf files. The syntax for use of the command is

$ pdfgrep [option]

Let us say we are searching for string “ioctl” in a pdf file name ch03.pdf (which is the third chapter from Linux device drivers book) .

$ pdfgrep ioctl ch03.pdf int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); The ioctl system call offers a way to issue device-specific commands (such as formatting a track of a floppy disk, which is which is neither reading nor writing). Additionally, a few ioctl commands are recognized by the kernel without referring to to the fops table. If the device doesn’t provide an ioctl method, the system call returns an error for any request that method, the system call returns an error for any request that isn’t predefined (-ENOTTY, “No such ioctl for device”). = scull_llseek, .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open = scull_open, .release = scull_release, .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open = scull_open, .release = scull_release, }; check this field for read/write permission in your open or ioctl function, but you don’t need to check permissions for read or by changing both the current and default values using ioctl at runtime. Using a macro and an integer value to allow both in ) here, and the rest in the section “Using the ioctl Argument” in Chapter 1; they use some special,

It lists out all the lines that contain the string “ioctl”. To make the output look more easier to read we can prefix each line with the page number on which it occurs using the option “-n”.

$ pdfgrep -n ioctl ch03.pdf 10: int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); 10: The ioctl system call offers a way to issue device-specific commands (such as formatting a track of a floppy disk, which 10: is neither reading nor writing). Additionally, a few ioctl commands are recognized by the kernel without referring to the 10: to the fops table. If the device doesn’t provide an ioctl method, the system call returns an error for any request that 10: the system call returns an error for any request that isn’t predefined (-ENOTTY, “No such ioctl for device”). 12: .llseek = scull_llseek, .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open = scull_open, .release = 12: .read = scull_read, .write = scull_write, .ioctl = scull_ioctl, .open = scull_open, .release = scull_release, }; 12: check this field for read/write permission in your open or ioctl function, but you don’t need to check permissions for 21: or by changing both the current and default values using ioctl at runtime. Using a macro and an integer value to allow 23: in ) here, and the rest in the section “Using the ioctl Argument” in Chapter 1; they use some special,

If we want to count the number of occurrences instead of viewing the lines on which they appear we can use the option “-c”

$ pdfgrep -c ioctl ch03.pdf 10

We can also prefix each line of output with the name of the file in which the line appears, which is useful when searching in multiple files, by using the option -H.

Category: Linux | Comments Off on searching in pdf files using grep : pdfgrep

djpeg to convert jpeg images to .gif,.bmp etc

djpeg(Decompress jpeg) command can be used to convert the jpg or jpeg format images into .bmp ,.gif and other formats.

For example let us say we have a jpg file by the name temp.jpg. We can find the size of the file using the command du.

$du temp.jpg 24K temp.jpg $

We can use the command djpeg on this file to convert it to a .gif file.

$djpeg -gif -outfile temp.gif temp.jpg

options

“-gif” : To specify the output the file to be of type .gif
“-outfilename” : To specify the output file name which is given above as temp.gif

After executing the command we can see the new temp.gif file in the same folder.

$ls temp.jpg temp.gif $du temp.* 288K temp.gif 24K temp.jpg

Thus we can see that the new file “temp.gif” has been created and it is bigger than the .jpg file as it is a decompressed file.

Insted of “-gif” we can pass the option “-bmp” to convert the image to .bmp format.

We can also remove the color from the image and make it a grayscale image from the .jpg image by passing the option “-grayscale”

$djpeg -bmp -grayscale -outfile temp.bmp temp.jpg

We can also scale images,make them smaller, using the option -scale, where the value of scale can be any number between 1 and 16, which is the scaling factor.

$ djpeg -gif -scale 2 -outfile temp2.gif temp.jpg

The file created above will be scaled by a factor 2/8, where 8 is the default DCT size.

$ du temp* 288K temp.gif 164K temp2.gif 24K temp.jpg

We can see above that temp2.gif is of smaller size than temp.gif as it has been scaled.

Category: Linux | Comments Off on djpeg to convert jpeg images to .gif,.bmp etc

Turning the screen blank from command line

Screensavers are used to cover the desktop with some images or graphics while we are away from the system.

Here is how we can enable the screen saver from the command line. The screen saver from the command line will basically turn the screen blank and turn it on again only on detecting a user activity or when the command to turn off the screen saver is sent.

The first step to activate screensaver from the command line is the start the screensaver using the command

$ gnome-screensaver

After the command has been executed we can activate the screensaver using the command

$ gnome-screensaver-command -a

As soon as the command is executed the screen turns blank and comes back to life on any press of key or mouse movement.
Note that after being activated it will prompt for the user password before displaying the desktop.

We can also simulate a user activity from command line by passing the option “-p” to the command gnome-screensaver-command, which is equivalent to poking the screensaver like a user.

Thus to make the screen blank for 5 minutes we do

$ gnome-screensaver;gnome-screensaver-command -a;sleep 5;gnome-screensaver-command -p

The above set of command will make the screen blank for 5 seconds and then reactivate the screen after 5 seconds.
To prevent from being prompted for password on activation of the screen, we can use the option -d instead of -p, which is to deactivate the screensaver.

We can create a script with the above commands, as required, and add it to the panel as a quick launcher, to give us the facility of quickly blanking the screen whenever required.

Category: Linux | Comments Off on Turning the screen blank from command line

Displaying calendar on linux terminal

We can use the cal command in the linux terminal to display the calendar of the month in the terminal itself.

Example :

$ cal

 photo cal.png

We can see the calendar of the month with the current date highlighted.

We can avoid highlighting of the current day using the the option -h $ cal -h

 photo cal_2.png

We can also display the calendar of any year we want by passing the option -y followed by the year.

Example:

$ cal -y 1980

 photo year_cal.png

We make the calendar weeks to appear in tow using the command ncal

$ ncal

 photo ncal.png

Category: Linux | Comments Off on Displaying calendar on linux terminal

Converting pdf to text in linux

The contents of a pdf file can be converted to a simple text file using the tool “pdftotext”. The format of using pdftotext is

$ pdftotext -f -l

Let us say we have a pdf file by the name temp.pdf, of which we want to convert to text the page numbers 1 to 4 and create a text file by the name output.txt .

$ pdftotext -f 1 -l 4 temp.pdf output.txt $ ls output.txt temp.pdf

The file output.txt will have all the text contents of the temp.pdf, pages 1 to 4 but will not contain the images. The formatting by default in not maintained in the text file.

To be able to maintain the formatting also we need to pass the option -layout.

$ pdftotext -f 1 -l 4 -layout temp.pdf output.txt

Now the text file will have almost the same format as the pdf file.

Category: Linux | Comments Off on Converting pdf to text in linux