A very important detail if you mount anything on /media

Categorized | Database, System, cli

Use locate across external devices in Linux

December 5th, 2010 by T4L

By default, updatedb indexes only your root partition when run. To be able to extend locate’s reach and get updatedb to index external devices such as USB harddisks and flash drives, edit the /etc/updatedb.conf file. Modify the following line:

PRUNEPATHS=”/tmp /var/spool /media”

so that it reads

PRUNEPATHS=”/tmp /var/spool”

This adds the devices mounted in the /media directory to the search path.

Author Profile

T4L ;

Other posts by T4L

Author’s web site

Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.

Hi, Be the first leave some reply

Leave A Reply

I keep my user folders on /media/ DATA which until now has meant that I haven’t been using the ‘locate’ command properly. Little wonder then, that this has frustrated me no end.

musicfetcher.py : A python script to fetch music from freemusicarchive.org

I've worked out how it would work, but I need to learn how to get Python to find the substrings in question.
Any advice would be appreciated:

#!/usr/bin/python
#findurl.py
#Released under a GPLv3 Licence by Clockwork PC

import os
H = os.getenv("HOME")

#Get the lines in the file that contain the URL substrings
for line in open("/home/clockworkpcasus/Music/freemusicarchive.org/index.html"):
    if "http://freemusicarchive.org/music/download" in line:
        print line
#Create a BASH script in ~/Documents/bin
os.system("cpcbash.sh")

#Move the newly created script into ~/Music/freemusicarchive.org
os.system("cd ~/Documents/bin && mv `ls -alt | grep sh | head -n 1 | awk '{print $8}'` ~/Music/freemusicarchive.org/musicfetcher.sh")

#Make musicfetcher.sh executable
os.system("chmod +x ~/Music/freemusicarchive.org/musicfetcher.sh")

#Copy the URL substrings into ~/Music/freemusicarchive.org/musicfetcher.sh

#Turn each URL substring into the following: gnome-terminal -x wget http://freemusicarchive.org/Download/Music... etc.

#Save ~/Music/freemusicarchive.org/musicfetcher.sh

#Execute the script
os.system("/bin/bash ~/Music/freemusicarchive.org/musicfetcher.sh"

The Clockwork PC BASH script generator

Here is a little BASH script I wrote to automate the process of writing a BASH script.

To use it, open a terminal and enter the following commands:

mkdir ~/Documents/bin
gedit ~/Documents/bin/cpcbash.sh

Then paste the following text into the text files.

#!/bin/bash
#cpcbash.sh
#Released under a GPLv3 Licence by Clockwork PC (2011)

#BASH script to generate BASH scripts

echo "What do you want to call your BASH script?"
read RESPONSE

echo "#!/bin/bash" | tee $RESPONSE.sh
echo "#Filename:$RESPONSE.sh" | tee -a $RESPONSE.sh
echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a $RESPONSE.sh

chmod +x $RESPONSE.sh

sudo ln -s ~/Documents/bin/$RESPONSE.sh /usr/local/bin/$RESPONSE.sh
sudo chmod +x /usr/local/bin/$RESPONSE.sh

gedit $RESPONSE.sh

Save the text file and return to the terminal:

chmod +x ~/Documents/bin/cpcbash.sh

Now, whenever you want to write a bash script, just enter the following command:

cpcbash.sh

And enter a name WITHOUT the .sh suffix.

Enjoy!

How to get the ultimate screenshot functionality in Ubuntu with Compiz, Pinta, and our old friend BASH

STEP ONE: Create a screenshot folder and sound effects folder.  Mine is /media/DATA/Screenshots but yours could be ~/Documents/Screenshots

Copy and paste into a terminal

mkdir ~/Documents/Screenshots
mkdir ~/Videos/Sound_effects

STEP TWO: Enable Compiz Screenshots and PNG

0screenshot_on_2011-03-24_thurs

STEP THREE: Install Pinta and Mplayer if you have not done so already

Copy and paste into a terminal:

sudo apt-get install pinta mplayer

STEP FOUR: Create a bin folder in Documents

Copy and paste into a terminal:

mkdir ~/Documents/bin

STEP FIVE: Create a BASH script in the bin folder

Copy and paste into a terminal:

gedit ~/Documents/bin/compiz-screenshot.sh

And paste the following text in:

#!/bin/bash
#compiz-screenshot.sh
#Released under a GPLv3 Licence by Clockwork PC http://www.clockworkpc.com.au

# Change into the Screenshots folder

cd /media/DATA/Screenshots

# Renaming the most recent PNG file in the directory

mv `ls -alt | grep png | head -n 1 | awk '{print $8}'` Screenshot_on_$(date +%F_%A_at_%H:%M:%S).png &

# Playing a camera click sound

mplayer $HOME/Videos/Sound_effects/camera1.wav &&

pinta `ls -alt | grep png | head -n 1 | awk '{print $8}'`

STEP 6: Make the script executable

Copy and paste into a terminal:

chmod +x ~/Documents/bin/compiz-screenshot.sh

STEP 7: Make a symlink in /usr/local/binCopy and paste into a terminal:

sudo ln -s ~/Documents/bin/compiz-screenshot.sh /usr/local/bin/compiz-screenshot.sh
sudo chmod +x ~/Documents/bin/compiz-screenshot.sh

STEP 8: Change settings in Compiz Screenshot according to this image

Screenshot_on_2011-03-24_thurs

STEP 9: Download you desired sound effect, and save it to ~/Videos/Sound_effects and rename it to camera1.wav
OR
Change line 13 in ~/Documents/bin/compiz-screenshot.sh to point to the correct file.

And when you hold down the Super/Windows key and select a portion of the screen you'll get a perfectly detailed file, a camera click, and Pinta will open with it ready for you to edit.