Reading HTML e-mail with Mutt
Posted: 25 January 2012 Filed under: productivity, ubuntu | Tags: e-mail, mutt Leave a commentGlory be! It’s pretty easy to get nicely formatted output of those sneaky HTML e-mail messages (which all the young Internet kids are sending nowadays).
In your ~/.mailcap
, if you use w3m (as I do):
text/html; w3m %s -o display_link_number=1; nametemplate=%s.html
text/html; w3m -dump %s -o display_link_number=1; nametemplate=%s.html; copiousoutput
And in your ~/.muttrc
:
auto_view text/html
The Debian Administration site tells you how!
Ubuntu batch photo processing
Posted: 17 October 2011 Filed under: ubuntu | Tags: command line, photos, ubuntu Leave a commentWay-cool batch photo processing on Ubuntu, GNU/Linux, Windows, and Mac with Phatch.
http://photobatch.wikidot.com/getting-started
Enabling Apache’s PHP execution in User Directories on Ubuntu Lucid
Posted: 6 October 2011 Filed under: ubuntu | Tags: apache, drupal, php 7 CommentsUbuntu Lucid ships with PHP disabled for user directories. That’s a sensible security default, but it won’t allow your developers to get their work done. And if you’re working with Drupal, you’ll need all the steps listed here.
First, you’ll need to install Apache:
sudo apt-get install apache2
Then the compiled PHP binary (or “shared object” in Apache lingo):
sudo apt-get install php5
You may need to do sudo /etc/init.d/apache2 restart
or sudo service apache2 restart
to have it pick up the updated configuration file that loads the PHP5 module. Try visiting your own box at “localhost” to see if you get a nice “welcome” page. You can put an “info.php
” file in /var/www
to test if PHP is working (the contents of your info.php file are simply <?php phpinfo(); ?>
), and visit that in your browser.
Once you’ve gotten PHP running under Apache, edit /etc/apache2/mods-available/php5.conf
and comment out the lines as instructed:
<IfModule mod_php5.c> <FilesMatch "\.ph(p3?|tml)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> # To re-enable php in user directories comment the following lines # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it # prevents .htaccess files from disabling it. # <IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_value engine Off # </Directory> # </IfModule> </IfModule>
If you’re developing with Drupal, the following step may also be necessary: In /etc/apache2/mods-available/userdir.conf
, you should allow Drupal’s local .htaccess
file to override the Apache-wide configuration file, with:
(...) <Directory /home/*/public_html> AllowOverride All #AllowOverride FileInfo AuthConfig Limit Indexes #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec (...)
Restart Apache with sudo /etc/init.d/apache2 restart
and you might be done!
Ignoring Ubuntu Upstart for System V compatibility
Posted: 21 July 2011 Filed under: system administration, ubuntu 2 CommentsIf you’d like to start an Ubuntu service using the System V-compatible runlevels, use “update-rc.d.” For example:
# update-rc.d ssh defaults
update-rc.d: warning: ssh stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (none)
Adding system startup for /etc/init.d/ssh ...
/etc/rc0.d/K20ssh -> ../init.d/ssh
/etc/rc1.d/K20ssh -> ../init.d/ssh
/etc/rc6.d/K20ssh -> ../init.d/ssh
/etc/rc2.d/S20ssh -> ../init.d/ssh
/etc/rc3.d/S20ssh -> ../init.d/ssh
/etc/rc4.d/S20ssh -> ../init.d/ssh
/etc/rc5.d/S20ssh -> ../init.d/ssh
Split a file across multiple CDs or DVDs on Linux
Posted: 13 January 2011 Filed under: productivity, ubuntu | Tags: command line Leave a commentOkay, so you very likely have the ‘split’ utility installed (it’s in the GNU coreutils package, so… very likely). If you want to burn a file to multiple media, but you don’t have kdar installed on your desktop… don’t worry about it. Just open a terminal and do:
$ split --bytes=600MB --numeric-suffixes filename.zip filename_part_
In my case, I have a 2.8GB file, but I only have 700MB CDs on hand for my burner. So this command will ensure that I get several 600 “megabyte” (1000 bytes * 1000) pieces, named “filename_part_00,” “filename_part_01,” and “filename_part_02,” et cetera.
Remove user list from Ubuntu 9.10 Karmic Koala login screen
Posted: 28 February 2010 Filed under: ubuntu | Tags: command line Leave a commentProblem: You want to login to your Ubuntu laptop without letting others shoulder surf your full name. You’d like to introduce yourself to them personally instead.
Solution: In a terminal (Applications -> Accessories -> Terminal), enter
sudo -u gdm gconftool-2 --set --type boolean /apps/gdm/simple-greeter/disable_user_list true
Type in your password when requested. You’re done.
sftp chroot jail in Ubuntu
Posted: 11 January 2010 Filed under: system administration, ubuntu | Tags: command line, sftp, ssh, system administration, ubuntu 9 Comments(Update 16 Mar 2011: Since writing this post, I’ve learned of an easier way to create this chroot jail. Newer versions of OpenSSH enable the “ChrootDirectory” configuration directive. I recommend that you take a look at George Ornbo’s tutorial on chrooting sftp users in Intrepid for the details.)
(Updated 08 Feb 2011 to reflect xplicit’s experience on Ubuntu 10.04.)
I wanted to give a buddy access to a website hosted on my box. So I tried scponly
, since I only wanted to provide SFTP access to that particular directory, using a chroot
jail. The steps are as follows.
- Install the scponly package using Ubuntu’s APT package management system.
- Use the script provided to set up your first jail and your user’s home directory. For the location of the user’s jail, give the path of the directory you want to share.
- Provide a password for the new user.
- Ensure that the new user has permissions to read and write all the necessary directories in your Web site.
$ sudo apt-get install scponly
$ gzip -dc /usr/share/doc/scponly/setup_chroot/setup_chroot.sh.gz > /tmp/setup_chroot.sh
$ cp /usr/share/doc/scponly/setup_chroot/config.h /tmp
The previous step copies the “config.h” file to help things go more smoothly, as Luke found.
$ chmod +x /tmp/setup_chroot.sh
$ cd /tmp
$ sudo ./setup_chroot.sh
Next we need to set the home directory for this scponly user.
please note that the user's home directory MUST NOT be writeable
by the scponly user. this is important so that the scponly user
cannot subvert the .ssh configuration parameters.
For this reason, a writeable subdirectory will be created that
the scponly user can write into.
Note that I removed the /incoming subdirectory created by this script. There was no need for a separate directory for my buddy to upload files. He could have permissions over the whole site tree.
-en Username to install [scponly]
bob
-en home directory you wish to set for this user [/home/bob]
/var/www/sites/bobsite/htdocs
-en name of the writeable subdirectory [incoming]
-e
creating /var/www/sites/bobsite/htdocs/incoming directory for uploading files
Your platform (Linux) does not have a platform specific setup script.
This install script will attempt a best guess.
If you perform customizations, please consider sending me your changes.
Look to the templates in build_extras/arch.
- joe at sublimation dot org
please set the password for bob:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
if you experience a warning with winscp regarding groups, please install
the provided hacked out fake groups program into your chroot, like so:
cp groups /var/www/sites/bobsite/htdocs/bin/groups
This script added certain directories to the site root (/var/www/sites/bobsite/htdocs
). Every other directory needed to be writable by Bob. So let’s add Bob to a special group, and allow that group write access on all the website’s files.
$ sudo adduser bob www-data
We can ignore /bin
, /etc
, /lib
and other directories added to the chroot jail (the website filesystem):
$ sudo find . \! -user root -exec chgrp www-data \{\} \;
$ sudo find . \! -user root -exec chmod g+w \{\} \;
Good to go!
Set Debian or Ubuntu server timezone
Posted: 30 December 2009 Filed under: system administration, ubuntu | Tags: command line, debian, linux, system administration, ubuntu Leave a commentThis one’s an easy one, from the tzselect (1)
manpage:
sudo dpkg-reconfigure tzdata
Flush DNS cache in Ubuntu
Posted: 15 October 2009 Filed under: system administration, ubuntu | Tags: dns, linux, system administration, ubuntu Leave a commentInterested in flushing your Ubuntu DNS cache? Note: I’m running Jaunty Jackalope as of the date of this post.
Well, Ubuntu doesn’t cache DNS by default. Your cache rests within your router, or your assigned DNS servers. You could restart your router, if you have access to it. Or wait until the time-to-live has expired.
You can install a local resolver that will cache DNS addresses, if you like. It will speed up your Web access slightly, since your Web browser will check the local cache first. I imagine the time you save will be measured in milliseconds.
Do that with:
sudo apt-get update && sudo apt-get install nscd
And to clear your local cache, restart the service:
sudo /etc/init.d/nscd restart
Recursively find and list filesize and full path on the command line
Posted: 2 October 2009 Filed under: system administration, ubuntu | Tags: command line, linux, system administration 2 CommentsCan’t beat the command line for flexibility and power in accomplishing system administration tasks. Here’s one way to recursively list the filesizes and full paths of files with a particular extension from the command line:
nice find . -name "*.swf" -type f -print0 | xargs -0r ls -skS | less
This is a succinct way to say:
“Show me all Flash files in the current directory hierarchy, descending to unlimited depth. Print the full filename on standard output followed by a null character. Send each filename in turn to the ‘ls’ command, which will look up each file’s size and print that in 1K blocks followed by the filename. (If there aren’t any results from the first command, don’t even run the ‘ls’ command, since that will just give us a list of all the files in the current directory.) Finally, send all that output to the ‘less’ command, which will allow me to page through and view it easily.”
EDIT: Added -r
switch to xargs
command to ensure we don’t see a list of all files, if the first ‘find’ command doesn’t find any. That sort of thing could be confusing.