Check file usage using fuser

2010-06-24 1 min read Fedora Linux

There is a package called psmisc that provides a useful application fuser. The package provides the below (on fedora):

/sbin/fuser
/usr/bin/killall
/usr/bin/peekfd
/usr/bin/pstree
/usr/bin/pstree.x11

There are couple of options you can provide on the terminal to fuser. The main purpose of the binary is to check the process id of the process using the file. This can be useful if some file operation on a file is blocking something for you 🙂

Continue reading

email with templates (with variables) from the command line with sendmail or any other MTA.

2010-06-09 2 min read Bash Fedora Linux

I was trying to get templates to work on evolution and found that although templates are there in evolution mail client, its not that efficient to use. What I thus wanted was to have something that could allow me to send mails to (and cc and bcc) to specified people with predefined template, only some values changed, like changelog and so on. So I wrote a set of files and below files to achieve the same. Hope it helps you too 🙂

Continue reading

Logwatch for Linux Systems.

2010-06-02 2 min read Fedora Linux

On my personal <a class="zem_slink freebase/en/client" title="Client (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Client_%28computing%29">desktop at home, I like to see the <a class="zem_slink freebase/en/statistics" title="Statistics" rel="wikipedia" href="http://en.wikipedia.org/wiki/Statistics">statistics at least once a day, for what was installed, what was run with <a class="zem_slink freebase/en/sudo" title="Sudo" rel="homepage" href="http://www.sudo.ws/">sudo and other such details like <a class="zem_slink freebase/en/kernel" title="Kernel (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Kernel_%28computing%29">kernel errors.

Running this monotonously every day is quite boring, so comes to rescue is logwatch. I have <a class="zem_slink freebase/en/fedora" title="Fedora" rel="homepage" href="http://fedoraproject.org/">Fedora <a class="zem_slink freebase/en/installation" title="Installation (computer programs)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Installation_%28computer_programs%29">installation so I will talk about the location with respect to that so for your distribution it might be a little different.

Continue reading

Get the most favourite commands from commandlinefu

2010-05-12 1 min read Bash

For those of you who don&#8217;t know, commandlinefu should be one place you should watch to learn new things for command line. Everyday a lot of people post commands to better the previously posted commands. If you want to get the best voted commands from the archieves of commandlinefu then you can use the command:

curl -O &#8221;<a rel="nofollow" href="http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/%5B0-2400:25%5D">http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2400:25]&#8221;

Suggested by Dynetrekk ****<a href="http://www.commandlinefu.com/commands/view/2740/get-all-these-commands-in-a-text-file-with-description" target="_blank">here.

Download with browse with bash and wget

2010-05-09 1 min read Bash Fedora

Been pretty busy for last couple of days. Will be busy for another few days, but here&#8217;s something to munch in the meantime (Script may need changes depending on the type of file you want to download or the site you are browsing, but the chnages should be minimal):

file=&#8221;/tmp/temp.dir&#8221;
url=&#8221;URL Here&#8221;
IFS=&#8217;
&#8217;
cont=&#8221;y&#8221;
while [ $cont != &#8221;n&#8221; ]
do
name=&#8221;&#8221;
wget &#8221;$url&#8221; -O $file -o /dev/null
for i in $(grep href $file |grep -v Parent)
do
name=${i##href=&#8221;}
name=${name%%&#8221;>
}
echo $name
if [[ $name == *gz ]]
then
cont=&#8221;n&#8221;
fi
done
if [ ! $name ]
then
echo &#8221;No files here.. Exiting&#8221;
exit -1
fi
echo
if [ $cont == &#8221;n&#8221; ]
then
echo &#8221;Enter the filename for download :&#8221;
read file
fi
echo &#8221;Select one of the options:&#8221;
read product
url=&#8221;$url/$product&#8221;
echo &#8221;About to get $url&#8221;
done
wget &#8221;$url&#8221; -O $file -o /dev/null

Continue reading

unbound variable – bash completion not working and having issues with other stuff like command not found.

2010-03-23 1 min read Bash Learning Linux

I generally use vi/vim for all my practical purposes of working with text files. And I have all the vi/vim plugins required to work with the files. This causes the following to be in the skeleton for all the bash scripts that I create:

set -o nounset                              # Treat unset variables as an error

With this all the unbound variables as errors and was problem with all the shell scripts that was being sourced in the startup of bash. So all I had to do was remove this from all the startup scripts and then from the skeleton of the bash script in vim :).

Continue reading
Older posts