Posts Tagged Ubuntu

Installing AjaXplorer on Ubuntu Server

Instructions are here, reposted for my own convenience:

This is for Ubuntu Server 12.04 64-bit.

edit /etc/apt/sources.list and add to the bottom:

deb http://dl.ajaxplorer.info/repos/apt/ stable main
deb-src http://dl.ajaxplorer.info/repos/apt/ stable main

Then, install the gpg key

wget -O - http://dl.ajaxplorer.info/repos/charles@ajaxplorer.info.gpg.key | sudo apt-key add -

Lastly:

sudo apt-get update
sudo apt-get install ajaxplorer

A few more steps to get it working…

copy the sample config file over (and make it readable by the web server):

cp /usr/share/doc/ajaxplorer/apache2.sample.conf /etc/apache2/sites-enabled/ajaxplorer.conf
chown www-data:www-data /etc/apache2/sites-enabled/ajaxplorer.conf

Restart apache…

service apache2 restart

…or…

/etc/init.d/apache2 restart

Make AjaXplorer redirect to HTTPS… (this is displayed during the initial page visit anyway)

edit /usr/share/ajaxplorer/conf/bootstrap_conf.php and uncomment the following line (or add it to the bottom)

define("AJXP_FORCE_SSL_REDIRECT", true);

If HTTPS doesn’t load, it’s probably because apache isn’t configured for SSL. That’s in the next section.

If you get a warning about Server charset encoding, uncomment this line in /usr/share/ajaxplorer/conf/bootstrap_conf.php

define("AJXP_LOCALE", "en_US.UTF-8");

Lastly, since I have /srv on a separate partition, I want ajaxplorer data stored there. By default it’s stored in /usr/share/ajaxplorer/data, which is actually a symlink to /var/lib/ajaxplorer/data.

mkdir /srv/ajaxplorer
cp -r /var/lib/ajaxplorer/data/* /srv/ajaxplorer
chown -R www-data:www-data /srv/ajaxplorer
rm /usr/share/ajaxplorer/data
ln -s /srv/ajaxplorer /usr/share/ajaxplorer/data

Warning: AjaXplorer will start acting odd if /srv isn’t mounted at boot time. Keep that in mind.

By default, PHP max file upload is 2M, and this setting will carry over to AjaXplorer. In order to increase it, you have to change it in three places.  The AjaXplorer documentation says that this is set by php’s upload_max_filesize, but I’ve found that you also have to change php’s post_max_size to match. (/etc/php5/apache2/php.ini). After which, go into AjaXplorer settings repository, then Global Configurations > Core Configs > Common ‘uploader’ core configs. Expand Limitations, then set File Size to 0 to inherit the PHP setting. (Note: It won’t stay 0, it will auto-set to php’s setting. Keep this in mind if you want to change it later.)

More later…

About these ads

, ,

10 Comments

Installing webmin on Ubuntu Server

Same disclaimer as last post: This is mostly for my memory, but you’re welcome to the comments section below.

This is for Ubuntu Server 12.04 64-bit.

In order to install webmin from apt, follow these instructions, reposted here for my own convenience:

edit /etc/apt/sources.list and add to the bottom:

deb http://download.webmin.com/download/repository/ sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository/ sarge contrib

then, to add the gpg signature, run:

sudo wget http://www.webmin.com/jcameron-key.asc -O - | sudo apt-key add -

lastly, install:

sudo apt-get update
sudo apt-get install webmin

If it complains about missing dependencies, first edit /etc/apt/sources.list and uncomment any lines for universe. Then, install these:

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

Coming up…even more…

, ,

1 Comment

Installing Ubuntu Server 12.04 LTS x64 on the HP MicroServer N40L

I’m mostly documenting this as a way for me to remember it, but anyone is free to learn from my doings or leave their own comments.

Configuration is 3x2TB hard drives in bays 0, 1, 2. Bay 3 is empty. (I’m considering adding a 4th 2TB drive and reshaping to RAID-6 at some point in the future.)

Partitioned as follows (MBR):

  1. 50GB as RAID
  2. 4GB as RAID
  3. 1.9TB (max) as RAID

RAID setup (mdadm) as follows:

  • md0: partition 1 (50GB) RAID-5, 3 units, 0 spares. EXT4, bootable, mounted at / [Total 100GB+parity]
  • md1: partition 2 (4GB) RAID-5, 3 units, 0 spares. swap [Total 8GB+parity]
  • md2: partition 3 (1.9TB) RAID-5, 3 units, 0 spares. EXT4, mounted at /srv [Total 3.8TB+parity]

Packages installed during installation:

  • OpenSSH
  • LAMP
  • Samba

GRUB installed to MBR

The very first thing to do after installation is to update. SSH in and run the following:

sudo apt-get update
sudo apt-get upgrade

May get the following complaint about kernel updates being held back:

The following packages have been kept back:
 linux-headers-generic-lts-quantal linux-image-generic-lts-quantal
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

This is the fix:

sudo apt-get dist-upgrade

Coming up… more installations…

, , , , , , ,

Leave a comment

Build and install Mozilla Spider Monkey (spidermonkey-bin) on Ubuntu Linux

Here’s how to quickly and easily build spidermonkey-bin from source on Ubuntu Linux.

sudo apt-get install mercurial autoconf2.13
hg clone http://hg.mozilla.org/mozilla-central spidermonkey
cd spidermonkey/js/src
autoconf2.13
./configure
make
sudo make install

Enjoy!

, , , ,

Leave a comment

How to retrieve EXIF data from the command line in Ubuntu Linux

If you want to make use of the EXIF data stored in a JPEG (.jpg or .jpeg) or TIFF (.tif or .tiff) file from the command line in Ubuntu Linux — or most other Linux variants — here’s how.

This was tested on Ubuntu 11.10 (Oneiric Ocelot).

First, you will need to have imagemagick installed to provide the identify command.

sudo apt-get install imagemagick

Next, you can retrieve the data on an image with the following example:

identify -verbose /usr/share/backgrounds/WildWheat_by_Brian_Burt.jpg

If you want just the EXIF data, you can use something like the following:

identify -verbose /usr/share/backgrounds/WildWheat_by_Brian_Burt.jpg | grep "exif:"

, , ,

2 Comments

Bash script to automatically sort photos into folders based on EXIF data for Ubuntu Linux

If you — like me — take a lot of digital pictures, you probably have a hundred folders full of images on your hard drive or external drives, and not nearly as sorted as you would like them to be. you have probably gotten to the point that you don’t know what’s in them or can’t find an image when you’re looking. I had around 10,000 images in over a dozen folders spanning 5+ years, and I had no intention of even trying to sort them manually :) So I wrote this script.

The following script was written in bash on Ubuntu Linux and automatically sorts your images into directories based on the date and time the photo was taken. How does it do this? By making use of the EXIF data your digital camera stores inside the image. The date and time the photo was taken is stored in that EXIF data. When an image doesn’t have EXIF data (such as when it was downloaded from the Internet, or taken from a camera that doesn’t support adding EXIF data), it will use the files last-modified time.

First, this should be run in the top-most directory of wherever your pictures are stored. If you have pictures/foldername/somepics/ and pictures/anotherfolder/morepics, run it from your pictures/ directory.

There are quite a few opportunities to improve this script — and some cautionary notes as well — marked within the script with FIXME tags. I’m already finished sorting my images, but anyone is welcome to contribute suggestions and improvements, which I’ll look into incorporating the next time I’m using this. You are welcome to include any suggestions or code improvements in the comments below using <code> and/or <pre> tags.
Usage: Copy the script into a file, editing options where appropriate, and save it. Make it executable and run it from the command line or window, from the directory where your pictures are stored. No command-line arguments. Back up your stuff first :)

Here is the script:

#!/bin/bash
#
###############################################################################
# Photo sorting program by Mike Beach
# For usage and instructions, and to leave feedback, see
# http://mikebeach.org/?p=4729
#
# Last update: 20-May-2013
###############################################################################
#
# The following are the only settings you should need to change:
#
# TS_AS_FILENAME: This can help eliminate duplicate images during sorting.
# WARNING: Any two files with the same filename are automatically overwritten when
# this is on. FIXME: Handle filename collisions.
# TRUE: File will be renamed to the Unix timestamp and its extension.
# FALSE (any non-TRUE value): Filename is unchanged.
TS_AS_FILENAME=TRUE
#
# USE_LMDATE: If this is TRUE, images without EXIF data will have their Last Modified file
# timestamp used as a fallback. If FALSE, images without EXIF data are put in noexif/ for
# manual sorting.
# WARNING: Filename collisions are NOT handled when this is off. Files are automatically
# overwritten.
# FIXME: Handle collisions when this is off.
# Valid options are "TRUE" or anything else (assumes FALSE). FIXME: Restrict to TRUE/FALSE
#
USE_LMDATE=TRUE
#
# USE_FILE_EXT: The following option is here as a compatibility option as well as a bugfix.
# If this is set to TRUE, files are identified using FILE's magic, and the extension
# is set accordingly. If FALSE (or any other value), file extension is left as-is.
# CAUTION: If set to TRUE, extensions may be changed to values you do not expect.
# See the manual page for file(1) to understand how this works.
# NOTE: This option is only honored if TS_AS_FILENAME is TRUE.
#
USE_FILE_EXT=TRUE
#
# JPEG_TO_JPG: The following option is here for personal preference. If TRUE, this will
# cause .jpg to be used instead of .jpeg as the file extension. If FALSE (or any other
# value) .jpeg is used instead. This is only used if USE_FILE_EXT is TRUE and used.
#
JPEG_TO_JPG=FALSE
#
#
# The following is an array of filetypes that we intend to locate using find.
# Any imagemagick-supported filetype can be used, but EXIF data is only present in
# jpeg and tiff. Script will optionally use the last-modified time for sorting (see above)
# Extensions are matched case-insensitive. *.jpg is treated the same as *.JPG, etc.
# Can handle any file type; not just EXIF-enabled file types. See USE_LMDATE above.
#
FILETYPES=("*.jpg" "*.jpeg" "*.png" "*.tif" "*.tiff" "*.gif" "*.xcf")
#
# Optional: Prefix of new top-level directory to move sorted photos to.
# if you use MOVETO, it MUST have a trailing slash! Can be a relative pathspec, but an
# absolute pathspec is recommended.
# FIXME: Gracefully handle unavailable destinations, non-trailing slash, etc.
#
MOVETO=""
#
###############################################################################
# End of settings. If you feel the need to modify anything below here, please share
# your edits at the URL above so that improvements can be made to the script. Thanks!
#
#
# Assume find, grep, stat, awk, sed, tr, etc.. are already here, valid, and working.
# This may be an issue for environments which use gawk instead of awk, etc.
# Please report your environment and adjustments at the URL above.
#
###############################################################################
# Nested execution (action) call
# This is invoked when the programs calls itself with
# $1 = "doAction"
# $2 = <file to handle>
# This is NOT expected to be run by the user in this matter, but can be for single image
# sorting. Minor output issue when run in this manner. Related to find -print0 below.
#
# Are we supposed to run an action? If not, skip this entire section.
if [[ "$1" == "doAction" && "$2" != "" ]]; then
 # Check for EXIF and process it
 echo -n ": Checking EXIF... "
 DATETIME=`identify -verbose "$2" | grep "exif:DateTime:" | awk -F  '{print $2" "$3}'`
 if [[ "$DATETIME" == "" ]]; then
 echo "not found."
 if [[ $USE_LMDATE == "TRUE" ]]; then
 # I am deliberately not using %Y here because of the desire to display the date/time
 # to the user, though I could avoid a lot of post-processing by using it.
 DATETIME=`stat --printf='%y' "$2" | awk -F. '{print $1}' | sed y/-/:/`
 echo " Using LMDATE: $DATETIME"
 else
 echo " Moving to ./noexif/"
 mkdir -p "${MOVETO}noexif" && mv -f "$2" "${MOVETO}noexif"
 exit
 fi;
 else
 echo "found: $DATETIME"
 fi;
 # The previous iteration of this script had a major bug which involved handling the
 # renaming of the file when using TS_AS_FILENAME. The following sections have been
 # rewritten to handle the action correctly as well as fix previously mangled filenames.
 # FIXME: Collisions are not handled.
 #
 EDATE=`echo $DATETIME | awk -F  '{print $1}'`
 # Evaluate the file extension
 if [ "$USE_FILE_EXT" == "TRUE" ]; then
 # Get the FILE type and lowercase it for use as the extension
 EXT=`file -b $2 | awk -F  '{print $1}' | tr '[:upper:]' '[:lower:]'`
 if [[ "${EXT}" == "jpeg" && "${JPEG_TO_JPG}" == "TRUE" ]]; then EXT="jpg"; fi;
 else
 # Lowercase and use the current extension as-is
 EXT=`echo $2 | awk -F. '{print $NF}' | tr '[:upper:]' '[:lower:]'`
 fi;
 # Evaluate the file name
 if [ "$TS_AS_FILENAME" == "TRUE" ]; then
 # Get date and times from EXIF stamp
 ETIME=`echo $DATETIME | awk -F  '{print $2}'`
 # Unix Formatted DATE and TIME - For feeding to date()
 UFDATE=`echo $EDATE | sed y/:/-/`
 # Unix DateSTAMP
 UDSTAMP=`date -d "$UFDATE $ETIME" +%s`
 echo " Will rename to $UDSTAMP.$EXT"
 MVCMD="/$UDSTAMP.$EXT"
 fi;
 # DIRectory NAME for the file move
 # sed issue for y command fix provided by thomas
 DIRNAME=`echo $EDATE | sed y-:-/-`
 echo -n " Moving to ${MOVETO}${DIRNAME}${MVCMD} ... "
 mkdir -p "${MOVETO}${DIRNAME}" && mv -f "$2" "${MOVETO}${DIRNAME}${MVCMD}"
 echo "done."
 echo ""
 exit
fi;
#
###############################################################################
# Scanning (find) loop
# This is the normal loop that is run when the program is executed by the user.
# This runs find for the recursive searching, then find invokes this program with the two
# parameters required to trigger the above loop to do the heavy lifting of the sorting.
# Could probably be optimized into a function instead, but I don't think there's an
# advantage performance-wise. Suggestions are welcome at the URL at the top.
for x in "${FILETYPES[@]}"; do
 # Check for the presence of imagemagick and the identify command.
 # Assuming its valid and working if found.
 I=`which identify`
 if [ "$I" == "" ]; then
 echo "The 'identify' command is missing or not available."
 echo "Is imagemagick installed?"
 exit 1
 fi;
 echo "Scanning for $x..."
 # FIXME: Eliminate problems with unusual characters in filenames.
 # Currently the exec call will fail and they will be skipped.
 find . -iname "$x" -print0 -exec sh -c "$0 doAction '{}'" ;
 echo "... end of $x"
done;
# clean up empty directories. Find can do this easily.
# Remove Thumbs.db first because of thumbnail caching
echo -n "Removing Thumbs.db files ... "
find . -name Thumbs.db -delete
echo "done."
echo -n "Cleaning up empty directories ... "
find . -empty -delete
echo "done."

Questions, comments, or feedback can be left in the comments below. Thank you!

, , , ,

53 Comments

Basic Ubuntu VPS server backup via FTP or SSH SFTP

In my quest for the perfect “in my dreams” backup solution for my Ubuntu VPS, I created this very simple script which can be run as a cron job and can be easily modified to backup any amount of data to any remote FTP or SFTP server.

You could very easily include a database backup by running mysqldump beforehand, but I’m not including it in this script.

This required yafc to be installed, but Ubuntu installations can easily install it by running

sudo apt-get install yafc

And now, for the script:

#!/bin/bash
# format of the open command is proto://username:password@HOSTorIP/
# proto is either ftp or ssh
# special characters in the username or password are not well tolerated
# anything in the EOF tags are direct commands to yafc. Test if unsure
DIR=`date +%F`
yafc <<EOF
open ftp://username:password@ftp.example.com/
cd backup-dir
mkdir $DIR
cd $DIR
put -p -r *
close
exit
EOF

Enjoy! Questions, comments, and feedback are welcome and appreciated. Thank you!

, , , , , , , , ,

1 Comment

How to run a game or other program in a new X session in Ubuntu Linux

To do this, CTRL-ALT-F1 to an open terminal, log in, and run:

xinit ./program -- :1

where program is the program file you want to start in a new X session. Assuming your normal X session is on :0 and appears when you CTRL-ALT-F7, your new one will spawn on CTRL-ALT-F8.

Questions, comments? Please feel free to leave them in the comments section below. Thank you.

,

Leave a comment

Easy Ubuntu data usage monitor

If you’re lucky enough to have a broadband card that works under Linux, your plan probably includes an “allowance” or data usage quota per month. You might be thinking how nice it would be to have a utility that tracks your data usage for the month (or other period) and gives you an easy-to-read report. You might also want said monitoring utility to have pre-built packages for Ubuntu / Debian.

NTM (Network Traffic Monitor) is what you want. As of this post the latest version is NTM 1.2.4.

Start by going to the NTM download site and downloading ntm-1.2.4.deb. Then double-click on it to install it using Ubuntu Software Center.

Once installed, you will find NTM at Applications > Internet.

Upon starting, it minimizes to the tray (next to the clock). You can open the interface by left-clicking the icon, and open the menu to access preferences by right-clicking the icon.

By default NTM monitors ppp0, which is the most likely interface that your broadband card will use. If you want to monitor a different interface, change that under the General tab. If you’re not sure what interface to use, run the following command:

ifconfig -a

This lists all interfaces and will help you locate your desired connection by IP / MAC and other info.

Also by default, NTM is configured with some other settings, such as auto-disconnecting after a data threshold has been reached (98MB by default), and disconnecting after a certain number of usage hours (30). These are likely too low for most mobile broadband users. Be sure to change these settings, under the Traffic, Time Slot, and Time tabs, to prevent unexpected disconnections.

Questions, comments, or other feedback? Please comment below. Thanks!

, ,

Leave a comment

How to tell if your CPU supports virtualization under Ubuntu Linux

If you’re thinking of running a virtual machine, you should check first to see if your processor supports the VT extension. To do so, run the following command in a terminal.

cat /proc/cpuinfo | egrep '(vmx|svm)'

Having the VT extension allows improved virtual machine performance, as well as the ability to run 64-bit virtual machines. Note that some manufacturers have an option to enable/disable VT in the BIOS (which is usually set to disabled), so if you have VT extensions, you may want to check to make sure it’s enabled.

Further Reading: Linux Tip: How to Tell if Your Processor Supports VT

Sorry for the brief post, but it’s late and I’m just making a quick note of this. Note that this works in just about any Linux distro, not just Ubuntu.

,

1 Comment

Follow

Get every new post delivered to your Inbox.

Join 110 other followers

%d bloggers like this: