OpenSource For You

TIPS & TRICKS

-

Encrypt an image using the command line

First, get a PNG image file and run the following command:

$echo p4ssw0rd| convert vizay.png -encipher - hidden.png

…where p4ssw0rd is our secret key for encryption and hidden.png is the encrypted image.

Now, to confirm the encryption, check whether or not the image can be seen as earlier by running the following command:

$display hidden.png

This should display the scrambled image and not the actual one if everything is fine.

Now, let’s decrypt the image by running the following command:

$echo p4ssw0rd| convert hidden.png -decipher - new.png Here new.png is our decrypted image. Running the command below will display the original image:

$display new.png

The new.png will be same as the original image, vizay. png

—Vizay Soni, vs4vijay@googlemail.com

Back-up and restore Thunderbir­d e-mails

In Linux, when you want to reinstall your system for any reason, you need to take a back-up of your data along with your e-mails in Thunderbir­d. Given below are a few simple steps that let you take a back-up of e-mails manually. 1. Check for your Thunderbir­d e-mail and profile folder. If you have not changed it, it should be at / home/<username>/.thunderbir­d/<alphanumer­ic_ named >.default_folder/ For example, the alphanumer­ic folder name on my system is vx3vg9j2. default 2. Copy the whole alphanumer­ic folder and place it in some other computer or storage device as an e-mail backup. Do remember to close Thunderbir­d before doing this. 3. After reinstalli­ng your PC with any Linux-based OS, install the Thunderbir­d e-mail client and configure your e-mail credential­s before closing the Thunderbir­d client. 4. Go to your Thunderbir­d folder in the new installati­on /home/<username>/.thunderbir­d/<alphanumer­ic_ named> folder. The alphanumer­ic named folder will be a different one now. For example: /home/guest/.thunderbir­d/jx3gv9k2. default

5. Copy the contents of the old alphanumer­ic folder that is kept as a backup to the above location. That is, you need to copy the contents of vx3vg9j2. default to jx3gv9k2. default 6. Now, open the Thunderbir­d client and you will find that all the e-mail credential­s, e-mails, e-mail rules and address book will be available as they were before re-installati­on. —Sobhanadri Agnihotram,

sobhanadri.a@gmail.com

Execute commands on a remote Linux machine

If you want to execute any command or script on a remote Linux machine, you can use ssh. Shown below are a few examples.

The syntax for running a command or script on a remote server is:

ssh [USER]@[IP] [command or script]

Let us look at how this can be done. Suppose you want to display the directory contents of /root of a remote host, you can run the following command: [narendra@ubunu]$ ssh root@172.16.223.128 ls -l /root root@172.16.223.128’s password: total 12

drwxr-xr-x. 2 root root 4096 Mar 12 00:05 device_drivers

drwxr-xr-x. 2 root root 4096 Mar 12 01:31 pthreads

drwxr-xr-x. 2 root root 4096 Mar 12 01:32 python

[narendra@ubunu]$

The same can be done to run any script on the remote computer.

—Narendra Kangralkar, narendraka­ngralkar@gmail.com

Run a Linux command after every reboot

This tip allows you to run any Linux command or script just after system reboot. You can use the @reboot cron keyword.

If you have a script in your /home directory and it needs to be run on every boot, open the cron file in editable mode and add the following:

$crontab -e

@reboot /home/xyz/myscript.sh Do remember to enable crond on boot.

—Imran Sheikh, imrannshei­kh@gmail.com

Comment out hashes in large configurat­ion files

Here is a small tip for systems administra­tors, who need to tackle large configurat­ion files, which include lots of commented lines (marked by #). With this tip, you can remove all those hashes and provide only an uncommente­d configurat­ion view for faster lookup into the file.

If you want to check the configurat­ion file of the Squid proxy server, run the following command:

#cat squid.conf | egrep -v ^#

This will show only lines that do not start with a hash mark, thus giving the configurat­ion parameter that is being used in the current set-up.

—Yogesh Upadhyay, yogeshupad­hya@gmail.com

Replacing ‘\n’ with ‘space’ in each line of a file

You can use the awk statement given below to remove the ‘\n’ from each line and replace it with a blank space:

awk ‘$1=$1’ ORS=’ ‘ /etc/passwd

—Rajeev N Sambhu, rajnellaya@gmail.com

Know your shells

Here is a command that will let you know about the available shells on your Linux distributi­on:

#chsh -l

To change your login shell, use the following command:

# chsh —Chandralek­ha Balachandr­an,

reachlekha@gmail.com

Advanced ls commands

The following commands are very useful to know your system better. lspci – Lists all PCI devices. Use -v for verbose output. lsusb – Lists all USB devices. Use -v for verbose output. lsmod – Lists the status of modules in the Linux kernel. lsattr – Lists file attributes on a second extended Linux file system.

lsof – Lists the file descriptor­s opened by all the processes. A very useful command when a process fails to close any file descriptor­s.

To know more details, you can view the manual pages of each command mentioned above.

—Prasanna Mohanasund­aram, prasanna.mohanasund­aram@gmail.com

 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from India