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 Thunderbird 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 Thunderbird. Given below are a few simple steps that let you take a back-up of e-mails manually. 1. Check for your Thunderbird e-mail and profile folder. If you have not changed it, it should be at / home/<username>/.thunderbird/<alphanumeric_ named >.default_folder/ For example, the alphanumeric folder name on my system is vx3vg9j2. default 2. Copy the whole alphanumeric folder and place it in some other computer or storage device as an e-mail backup. Do remember to close Thunderbird before doing this. 3. After reinstalling your PC with any Linux-based OS, install the Thunderbird e-mail client and configure your e-mail credentials before closing the Thunderbird client. 4. Go to your Thunderbird folder in the new installation /home/<username>/.thunderbird/<alphanumeric_ named> folder. The alphanumeric named folder will be a different one now. For example: /home/guest/.thunderbird/jx3gv9k2. default
5. Copy the contents of the old alphanumeric 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 Thunderbird client and you will find that all the e-mail credentials, e-mails, e-mail rules and address book will be available as they were before re-installation. —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, narendrakangralkar@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, imrannsheikh@gmail.com
Comment out hashes in large configuration files
Here is a small tip for systems administrators, who need to tackle large configuration files, which include lots of commented lines (marked by #). With this tip, you can remove all those hashes and provide only an uncommented configuration view for faster lookup into the file.
If you want to check the configuration 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 configuration parameter that is being used in the current set-up.
—Yogesh Upadhyay, yogeshupadhya@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 distribution:
#chsh -l
To change your login shell, use the following command:
# chsh —Chandralekha Balachandran,
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 descriptors opened by all the processes. A very useful command when a process fails to close any file descriptors.
To know more details, you can view the manual pages of each command mentioned above.
—Prasanna Mohanasundaram, prasanna.mohanasundaram@gmail.com