GNU/Linux Tips
This page lists some GNU/Linux tips helpful to me.
[1] How to enable php support in Apache
[2] How to set Sun java as default in Linux
[3] How to view and edit the tcp parameters
[4] How to remove lock on apt
[5] How to turn off monitor
[6] How to enable syntax highlighting option in Vim
[7] How to download all the links from a site automatically
[8] How to clear System Logs
[9] How to create a bootable USB from ISO
[10] How to clear shell history
[11] Debian Wheezy power off button missing
[12] How to convert color image to gray scale from command line
[13] How to get progress bar in apt
[14] How to reduce size of all images in a directory
[15] Command to reduce the size of a large pdf file
[16] How to install Canon LBP6030w printer under Debian
[1] How to enable php support in Apache
When we install APACHE and PHP, it does not by default give php support. We have to add following line to the end of /etc/apache2/apache2.conf to get it working.
AddType application/x-httpd-php .php
Then restart apache by giving the following command.
Note: Some time you have to restart the computer for this to come into effect.
/etc/init.d/apache2 restart
[2] How to set Sun java as default in Linux
Most of the time even if we install Sun Java gcj is used as the default. Sun java could be set as the deafult in Linux by the following simple command.
update-java-alternatives -l
java-6-sun 63 /usr/lib/jvm/java-6-sun
java-gcj 1042 /usr/lib/jvm/java-gcj
The above command lists all the available Java.
update-java-alternatives -s java-6-sun
java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
Note:Here my Sun Java is Version 6.
[3] How to view and edit the tcp parameters
The TCP options could easily be viewed from the /proc filesystem. It is located at /proc/sys/net/ipv4/. For example if the available congestion window mechanisms should be find.
cat /proc/sys/net/ipv4/tcp_available_congestion_control
cubic reno
ls /proc/sys/net/ipv4/
This gives the whole list of options. The values could be edited by echoing the needed values the options. Pittsbusrg Super Computing Site has more info about how to set various options in Linux/Mac OS/Windows/Sun Solaris... TCP man page has clear explanation of all the available options.
[4] How to remove lock on apt
Sometimes when using apt ( apt-get) we get the following errors even if no other instances are running
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
OR
E: Could not get lock /var/cache/apt/archives/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the download directory
This can be solved by removing the lock.
rm /var/lib/dpkg/lock
OR
rm /var/cache/apt/archives/lock
[5] How to turn off monitor
xset dpms force off
[6] How to enable syntax highlighting option in Vim
Most Ubuntu users will be getting this error when trying "syntax on" in Vim.
E319: Sorry, the command is not available in this version: syntax on
This is because most of the time Ubuntu comes with a minimal vim version called "vim-tiny", which doesn't have syntax highlighting option built into it by default. You can check whether the option is there or not with the following command:
apt-get install vim
[7] How to download all the links from a site automatically
Most of the time we would like to download all the links from a specific page. This usually occurs when one tries to download course materials from a univ site. Most often they didnt provide a single file to download. Rather they give links to download. But the task is easy with wget
wget -r <site_name>
This does a breadth first search up to 4 level depth. If i want to limit the depth I can use -l <level> option. For example if i want to download all files from the GDB tutorial here. I can use:
wget -r -l 1 http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html
[8] How to clear System Logs
System maintains several logs to keep track of various information. They can easily be cleared by
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/messages
dmesg -c
[9] How to create a bootable USB from ISO
Since most systems now comes without DVD drives, we need to to make a bootable USB from the iso. The easiest way is to use the dd command
dd if=<source> of=<destination>
For example if the source is image.iso and destination is /dev/sdb, you can give the command as
dd if=image.iso of=/dev/sdc
Note: In MAC OSX first disk needs to be unmounted using the command diskutil unmountDisk /dev/disk2 before running dd.
[10] How to clear shell history
history -c && history -w
[11] Debian Wheezy power off button missing
Type gnome-tweak-tool in terminal. Select shell extensions and in that select Alternative status menu extension.
[12] How to convert color image to gray scale from command line
Linux convert command can be used to convert color image grayscale from commandline. The command is
convert new.png -colorspace Gray destination.jpg
This will create grayscale image destination.jpg
[13] How to get progress bar in apt
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
[14] How to reduce size of all images in a directory
find . -iname "*.jpg" | xargs -l -i convert -quality 75 {} /tmp/output/{}
[15] Command to reduce the size of a large pdf file
convert -density 200x200 -quality 60 -compress jpeg input.pdf output.pdf
[16] How to install Canon LBP6030w printer under Debian
https://www.linuxquestions.org/questions/linux-hardware-18/installation-problem-of-canon-lbp6030w-printer-on-debian-4175615877/