Category: Tips

Dec 26 2008

Quick way to discover who your computer is talking to

If you have Linux, here is a quick way to determine what programs are listening for incoming network connections as well as who your computer is currently connected to.

sudo netstat -plateu
Nov 26 2008

Send a test fax for FREE

I recently setup a FAX service for someone and needed a way to test if the system was receiving FAXes OK. I could have tracked down a friend with a FAX machine and have him send a test FAX. How much easier though to plug in the FAX numbher and have an automated system send you a FAX. Follow this link to send a test FAX.

Interpage Network Services Inc.TM Free Web to Fax and EMail OutFax Service.

Nov 15 2008

Speed Up Multiple SSH Connections to the Same Server

If you run a lot of terminal tabs or scripts that all need to make OpenSSH connections to the same server, you can speed them all up with multiplexing: making the first one act as the master and letting the others share its TCP connection to the server.

If you don’t already have a config file in the .ssh directory in your home directory, create it with permissions 600: readable and writeable only by you.

Then add these lines:

Host *
   ControlMaster auto
   ControlPath ~/.ssh/master-%r@%h:%p

ControlMaster auto tells ssh to try to start a master if none is running, or to use an existing master otherwise.

ControlPath is the location of a socket for the ssh process to communicate among themselves. The %r, %h and %p are replaced with your user name, the host to which you’re connecting and the port number - only ssh sessions from the same user to the same host on the same port can or should share a TCP connection, so each group of multiplexed ssh process needs a separate socket.

To make sure it worked, start one ssh session and keep it running. Then, in another window, open another connection with the -v option:

~ ssh -v example.com echo "hi"

And, instead of the long verbose messages of a normal ssh session, you’ll see a few lines, ending with:

debug1: auto-mux: Trying existing master
hi

Pretty fast. If you have to connect to an old ssh implementation that doesn’t support multiplexed connections, you can make a separate Host section:

Host antique.example.com
   ControlMaster no

For more info, see man ssh and man ssh_config.

Oct 28 2008

HOWTO: Copying a Filesystem between Computers

If you need to transfer an entire filesystem from one machine to another, for example, when you get a new computer, do the following steps.

1) Boot both PCs with any Linux live CD (for example, Knoppix), and make sure they can access each other via the network.

2) On the source machine, mount the partition containing the filesystem to be copied, and start the transfer using netcat and tar:

cd /mnt/sda1
tar -czpsf - . | pv -b | nc -l 3333

3) On the destination machine, mount the partition to receive the filesystem, and start the process:

cd /mnt/sda1
nc 192.168.10.101 3333 | pv -b | tar -xzpsf -

The nc (netcat) command is used for any kind of TCP connections between two hosts. The pv (progress viewer) command is used to display the progress of the transfer. tar is used to archive the files on the source machine and un-archive them on the destination.

Oct 05 2008

A complete zenity dialog examples 1 » Linux by Examples

Have you ever needed to display information or get information from the user from within one of your scripts? There is a slick little utility for Gnome systems called ‘zenity‘ that will do the trick. (zenity for gnome, kdialog for KDE, xmessage for other windows managers) Here is a link to a site that has some zenity examples for you to try.

We have introduce how to make use of GUI dialog box in Using GUI dialog box, where we give an example of how zenity create a question dialog box. Besides question dialog box, zenity can create more than that, such as calendar, entry, error, info, file selection, list, notification, progress, warning, scale and text info. In this tutorial, we would like to illustrate how to create every single zenity dialog by examples.

A complete zenity dialog examples 1 » Linux by Examples.

Oct 02 2008

Helpful Tips

Here are some non IT related tips. I can’t vouch for the validity of any of these - your mileage may vary.

Read more »

Sep 30 2008

My Ubuntu

Here are the packages from Ubuntu’s repositories that I like to install on my Ubuntu box:


Intrepid Ibex

sudo apt-get install amarok audacity beagle beagle-backend-evolution build-essential compizconfig-settings-manager cream exiv2 fdupes festival festvox-kallpc16k gnome-commander gnome-ppp gnucash gparted grsync hplip-gui imagemagick jpilot jpilot-plugins k3b lame libimage-exiftool-perl libk3b2-extracodecs libmp3lame0 libsox-fmt-all libvcdinfo0 libxine1-ffmpeg lm-sensors mail-notification mailutils msttcorefonts nautilus-actions nautilus-gksu nautilus-open-terminal ntfsprogs openssh-server pdfedit sensors-applet secpanel smbfs sox sshmenu-gnome ssmtp thunderbird thunderbird-beagle thunderbird-gnome-support ubuntu-restricted-extras vlc wine wipe

acidrip emerald libvlc0 mozilla-plugin-gnash pitivi seahorse


Hardy

sudo apt-get install acidrip amarok audacity beagle beagle-backend-evolution build-essential compizconfig-settings-manager cream emerald exiv2 fdupes festival festvox-kallpc16k gnome-commander gnome-ppp gnucash gparted grsync hplip-gui imagemagick jpilot jpilot-plugins k3b lame libimage-exiftool-perl libk3b2-extracodecs liblame0 libsox-fmt-all libvcdinfo0 libvlc0 lm-sensors mail-notification mailutils mozilla-plugin-gnash msttcorefonts nautilus-actions nautilus-gksu nautilus-open-terminal ntfsprogs openssh-server pdfedit pitivi seahorse sensors-applet secpanel smbfs sox sshmenu-gnome ssmtp thunderbird thunderbird-gnome-support ubuntu-restricted-extras vlc wine wipe

Here are the programs that I install or build from source on my Ubuntu box:

http://earth.google.com/
http://picasa.google.com/linux/
http://www.virtualbox.org/wiki/Downloads
http://www.aczoom.com/tools/cdinsert/#download
   then build http://sourceforge.net/projects/gtkcdlabel/
http://kornelix.squarespace.com/fotox/

Here are the applets that I enable or add to my gnome panel on my Ubuntu box:

Applications/Accessories/Terminal
Applications/Internet/Pidgin
Applications/Internet/Thunderbird
Applications/Office/GnuCash
Applications/Office/Jpilot
Applications/Office/OpenOffice.org Word Processor
Applications/Sound & Video/Amarok
Custom Launcher: secpanel
Hardware Sensors Applet
System Monitor Applet
Weather Applet
Sep 12 2008

Share a Keyboard/Mouse Between Multiple Computers With x2x

Here is a great article from Linux Journal.

If you have multiple computers on your desktop there are a number of scenarios for using them:

* The brute force way: get a big desk and a swivel chair and spin back and forth between keyboards/mice
* Use VNC or rdesktop to control secondary computers from your primary computer. The main problem with this is that you lose all the screen real estate on your secondary computers and end up with their desktops showing in a window on your primary computer.
* Get a KVM to allow you to switch one keyboard/mouse between multiple computers.
The normal usage of a KVM is to switch your monitor as well as your keyboard and mouse, but that’s not required. KVM’s often seem like a great solution for many peripheral sharing problems, but they’re a bit of a hit-or-miss. They often have switching problems, system boot problems, video quality problems, and if you use multiple monitors a KVM to switch multiple monitors between systems gets pretty expensive.
* Use x2x, the solution we’ll examine here, to share the keyboard and mouse between systems.

There are two ways to run x2x on Linux, the easiest is to use ssh with X forwarding enabled and ssh from the primary system to the secondary system and run x2x on the secondary system:

primary $ ssh -X secondary x2x -east -to :0

The -X option tells ssh to enable X forwarding. The “x2x …” tells ssh to run x2x on the remote system (secondary) rather than running the shell. The “-east” option tells x2x where one system is relative to the other: to the east or west (-west).

The primary system is the system whose keyboard and mouse you are actually using. The secondary system is the one that is going to share the primary system’s keyboard and mouse.

Now, if you move the mouse on the primary system over to the edge where the secondary system is the mouse pointer should move from the primary screen to the secondary screen and from now on any mouse movement should be passed to the secondary system and anything you type on the keyboard should be sent to the secondary system. If this doesn’t work try moving the mouse to the other side of the screen, if that works then restart the command using “-west” rather than “-east”.

The other method of running x2x on a Linux system is to run it directly on the primary system and tell it to connect to the X server on the secondary system:

primary $ x2x -to secondary:0.0 -east

The reason this is not the easy method is that you also need to enable remote X access on the secondary system using xhost:

secondary $ xhost primary

and you also need to open TCP port 6000 on both systems. The easiest way of doing this is going to depend on your distro.

The main advantage of the second method is that copy/paste will now work between systems.

Getting x2x to work on a Windoze system takes a bit more work, mostly because first you have to install Cygwin. Although, if you’re a Linux fan you should already have it installed, it’s the only way to make Windoze bearable. When you’re installing Cygwin make sure x2x is selected in the list of available packages.

Using x2x with Cygwin has a couple of restrictions/problems:

* You can’t use the ssh connection method.
* You have to use the Windoze system as the primary system (i.e. you have to use the keyboard and mouse on the Windoze system).
* If you have multiple displays on your Windoze system you’ll probably experience mouse problems when you return the mouse from a secondary display. The only workaround is to move the mouse very very slowly when you’re about to move off a secondary display onto the primary display.

When using x2x on Windoze run the following command from a shell prompt:

windoze $ x2x -fromwin -to secondary:0.0 -east

Generally speaking x2x works very well both on Linux and on Windoze. Every once in a while you may get a bit of mouse flakiness when you move a window on a secondary display. Also once in a while, when using the shift key you may get the unshifted character on the secondary system if you type too fast. But in most instances you won’t notice any difference between typing/mousing on the primary system and on the secondary system.

p.s. If you have a problem where you get a “>” when you type “< " you need to find a newer version of x2x. This is long-standing bug that was recently fixed.

Aug 14 2008

Unix ‘ln’ tip

Links are commonly used to point from one filesystem location to another. They also have a more surprising use: to make a program that does several things, deciding what to do by checking the name it was called with. Here’s an example: a single program in /usr/bin that sets, shows, and removes at jobs:

$ ls -l at*
-rwsr-sr-x 1 ... at
lrwxrwxrwx 1 ... atq -> at
lrwxrwxrwx 1 ... atrm -> at

These are simple to write as shell scripts. The script simply needs to test its name:

myname=${0##*/}  # Program name without path
case "$myname" in
at) ... ;;
atq) ... ;;
atrm) ... ;;
*) echo "$0 ERROR: ..." 1>&2; exit 1 ;;
esac
Jul 29 2008

HOWTO: Convert Filenames to Lowercase

Back in the good old days, there was an operating system that didn’t seem to think NAME and name were different. The result was that sometimes when you transfered files from a floppy disk (remember them?) created on that Dumb Old System, you would clutter your directory with uppercase filenames. As us UNIX old-timers learned a nifty trick to get directory names to sort before filenames in the output of the ls command (namely, start directory names with an uppercase letter), having filenames with uppercase letters was irritating.
After using the mv command all too many times and typing things like mv FILE.TXT file.txt, I wrote this script. I was thinking I could put a new coat of paint on it but, in reality, it does the job and is easy to understand. (The line numbers are there, of course, just for reference.)

.
    1   #!/bin/sh
    2   # lowerit
    3   # convert all file names in the current directory to lower case
    4   # only operates on plain files--does not change the name of directories
    5   # will ask for verification before overwriting an existing file
    6   for x in `ls`
    7     do
    8     if [ ! -f $x ]; then
    9       continue
   10       fi
   11     lc=`echo $x  | tr '[A-Z]' '[a-z]'`
   12     if [ $lc != $x ]; then
   13       mv -i $x $lc
   14     fi
   15     done

Line 6 starts a loop (which ends with line 15). The ls command returns a list of filenames which are sequentially assigned to the shell variable x. The if test (lines 8 through 10) checks to see if the current filename is that of a plain file. If not, the remainder of the statements in the current loop iteration are skipped.

If line 11 is to be executed we know that we have an ordinary file. Using tr we convert the filename to lowercase and assign the new name to the shell variable lc. Line 12 then checks to see if the lowercase version of the name differs from the original. If it does, line 13 is executed to change the name of the original file to the new lowercase name. The -i option causes the mv to prompt for confirmation if executing the command would overwrite an existing filename.

Dec 06 2007

HOWTO: Create a Linux RAM disk in Ubuntu

Remember the old days of RAM disks? Well. Linux has them too! If you’ve never tried them, a RAM disk is a virtual file system that runs entirely from your PC’s main memory, which means it’s lightning fast to read and write anything you want. How much space you choose to allocate to your RAM disk is down to how much RAM you have and how much you plan to use it - if you have 1GB of RAM, you can easily spare 64MB for a ramdisk; if you have 2GB you can probably spare 256MB, and if your are fortunate enough to have 4GB then you can easily stretch your RAM disk legs with 1GB. Here’s how to setup a 64MB disk - just change the 65536 for the size you want:

sudo mkfs -t ext3 -q /dev/ram1 65536
sudo mkdir -p /ramdisk
sudo mount /dev/ram1 /ramdisk -o defaults,rw

Remember: If your PC gets switched off accidentally it all gets wiped!

Dec 06 2007

HOWTO: Stop disk thrashing in Linux

If you want your disks to run at their full potential, make sure and enable the noatime option in /etc/fstab.

Every time your disk does a read (eg reading a file), it also does a write, to store the information pertaining to when the file was last read. This process is incredibly slow, and you can get a sizable speed boost - usually around 10 percent - with just one simple tweak.

Switch to root, then open up /etc/fstab in your favorite text editor. Look for where your root file system is, and make sure that it uses defaults,noatime for its settings, then save, reboot and let your poor overworked PC perform to its full potential.

Dec 06 2007

HOWTO: Add more functions to Nautilus

Nautilus (file manager in Ubuntu linux) has a surprising amount of power with its extensions, but none are installed by default leaving it looking somewhat bare. That’s easily fixed, though, particularly if you’re using Ubuntu - just apt-get the nautilus-gksu and nautilus-open-terminal extensions, restart Nautilus, enjoy the upgrade.

sudo apt-get install nautilus-gksu nautilus-open-terminal

This will give you a right click option to open a terminal, and if you right click on a file there is an option to open it as an administrator.

Dec 05 2007

APT: Advanced User Tricks

APT is a front end for the Debian and Ubuntu package manager. If you have used debian for any length of time you probably have run the command ‘apt-get install somepackage’ to install some package. If that is all you have used apt for then look at this list for some of the other things you can do with apt.
Read more »

Oct 27 2007

HOWTO: Securely delete files/folders in Ubuntu

Use the ’shred’ command to securely delete files from the command line like this:

shred -z -u filename

Here is an easy way to securely delete files and folders from within the Ubuntu Nautilus file manager. You first need to download and install two packages; wipe and nautilus-actions like this from a terminal prompt:

sudo apt-get install wipe nautilus-actions
  • Now copy and paste the schema text below into a text file on your desktop.
  • Click on the new preferences menu “/System/Preferences/Nautilus Actions configuration”.
  • Click the Import/Export button.
  • Import the schema file you just created.
  • Log off and back on.

You should now have a “Wipe Selected” option when you right click on a file, folder, or selected files/folders in the Nautilus file manager. Be careful since files that are wiped are not recoverable in any way.

Read more »

Oct 09 2007

Simple date and time calulation in BASH

From within a BASH script I needed to determine the date from one month ago. I new there had to be an easy way to do this. This web site, Simple date and time calulation in BASH - The UNIX Forums, had the answer plus several other goodies.

# Other standard goodies from GNU date not too well documented in the man pages 
# assign a value to the variable dte for the examples below 
 dte="2006-10-01 06:55:55" 
 echo $dte 

# add 2 days, one hour and 5 sec to any date 
 date --date "$dte 2 days 1 hour 5 sec" 

# substract from any date 
 date --date "$dte 3 days 5 hours 10 sec ago" 
 date --date "$dte -3 days -5 hours -10 sec" 

# or any mix of  /-. What will be the date in 3 months less 5 days 
 date --date "now  3 months -5 days" 

# time conversions into ISO-8601 format RFC-3339 internet recommended format 
 date --date "sun oct 1 5:45:02PM"  %FT%T%z 
 date --iso-8601=seconds --date "sun oct 1 5:45:02PM" 
 date --iso-8601=minutes 

# time conversions into RFC-822 format 
 date --rfc-822 --date "sun oct 1 5:45:02PM"
Jun 29 2007

Convert to Upper / Lower case in Linux

Here is a simple shell command to convert everything to uppercase. Reverse it to convert to lowercase. Just redirect your output through the ‘tr’ command like this:

echo "Convert this sentence to uppercase." | tr [:lower:] [:upper:]
Jun 28 2007

Strip all non printable characters

This example would take the file myfile1 and strip all non printable characters and output the results to myfile2.
tr -cd '\11\12\40-\176' < myfile1 > myfile2

May 15 2007

HOWTO: Map local Linux drive resource to Windows terminal server

Here is the problem: You are connected to a remote machine via a Windows Terminal Server. You want to copy files from your local Linux machine to the remote machine (or vice versa).

The answer is to map the local disk resource through to the terminal server. This command will take any mounted drive on your local linux box and make it appear in your drive list of Terminal Server…

rdesktop -a 16 -g 85% -r disk:Liunx=/ ts.example.com
  • Where - a (sets the color to 16 bit & -g sets the window to be 85% of your full screen size)
  • Where -r disk: redirects mounted drives
  • Where Linux = is your pick you could say ‘yo momma’ & it would work fine :)
  • Where =/ (directory location you want mounted)
  • Where ts.example.com (location of redirection)

Thanks to Micah J for this tip!

Feb 24 2007

HOWTO: Fix Gnome-panel from crashing

I experienced a problem today where every time I login to Ubuntu, gnome-panel immediately crashes and the bug report tool pops up as usual and then gnome-panel automatically restarts or attempts to and then continues to keep crashing until I restart X.

Fortunately this was an easy fix in my case. Login using a console terminal [CTRL] [ALT] [F1] and delete the file .recently-used.xbel

rm .recently-used.xbel
Feb 16 2007

HOWTO: Manually releasing / renewing a DHCP lease on Linux

At times I need to manually renew my DHCP IP address. Here is an easy way to do it from the command line.

sudo ifdown eth0

followed by a

sudo ifup eth0

That’s it.

Nov 14 2006

pstree - Show running processes as a tree

I found and interesting command today, pstree, that will show your running processes as a tree. Here is an example:

     ├─kswapd0
     ├─kthread─┬─aio/0
     │         ├─kacpi_notify
     │         ├─kacpid
     │         ├─kblockd/0
     │         ├─kgameportd
     │         ├─khubd
     │         ├─kjournald
     │         ├─kpsmoused
     │         ├─kseriod
     │         ├─2*[pdflush]
     │         └─shpchpd
     ├─logd
 
Nov 14 2006

lsof -i List open Internet files

I found an interesting command today to list out what programs have open Internet connections. From a terminal, issue the command:

lsof -i

lsof - list open files

-i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no
address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.

Sep 05 2006

cut - select portions of each line of a file

If you need to separate a delimited file and extract certain fields, use cut. For example, to extract users’ login names and shells from the system password file, /etc/password, use…

$ cut -d : -f 1,7 /etc/passwd
Aug 21 2006

Netsh Tricks

Netsh Tricks

During the development of Windows NT 5.0— which later became Windows 2000—Microsoft worked briefly with Cisco Systems to try to incorporate some of that company’s ideas into the new OS and to help Cisco incorporate some NT 5.0 ideology into Cisco’s products. (You can see evidence of the effort today in the Cisco Voice over IP solution, which requires an Active Directory—AD—implementation.) That fleeting flirtation ultimately cooled, but it left behind a framework for Netsh, an extremely useful commandline networking tool.

Read more »

Aug 17 2006

If you need to run find on files with peculiar names

If you need to run find on files with peculiar names — for example, file names that contain spaces — use the -print0 option.

$ find /home/joe -type f -name '*.txt' -print0 | xargs -0 grep -l "Monthly Report"

-print0 terminates each line with zero and xargs -0 splits the records on the zero byte. This allows all file names to be processed properly.

Aug 17 2006

Send mail directly from the command-line

Although you’re likely to read mail via a client such as Evolution or perhaps even pine, don’t forget that you can send mail directly from the command-line. For example…

$ echo "Hello, World" | mail -s "Some simple mail" joe@example.com

… sends the message “Hello, World” with subject (-s) “Some simple mail” to joe@example.com. You can list more recipients on the command-line or place a similar command in a loop in script to customize the outgoing message, for example.

Aug 17 2006

ls is full of tricks

ls is full of tricks. -m prints filenames separated by commas. -r reverses the order of several options. For example, ls -tr prints oldest files first. ls -Sr lists smallest files first. ls -r used by itself lists files in reverse lexicographic order.

Aug 17 2006

Make a quick copy of a local or remote MySQL database

You can make a quick copy of a local or remote MySQL database right from the command-line. Just use mysqldump and mysql. For example:

$ mysqldump --add-drop-table -h example.com -u dbuser -ppassword database | /usr/bin/mysql -u localdbuser -plocaldbpassword database
Aug 14 2006

Thunderbird: ‘Mark all messages as read’ when exiting a newsgroup

In OE there’s an option to ‘mark all messages as read’ when exiting a newsgroup. Is there a way to do this with TB?

Go to Tools > Options > Advanced > General and click “Config Editor”
Right-click in an empty area and select New > Boolean
Enter one of the following hidden prefs (you want the first one):

mailnews.mark_message_read.nntp for Newsgroups
mailnews.mark_message_read.pop3 for POP3 email folders
mailnews.mark_message_read.imap for IMAP email folders
mailnews.mark_message_read.rss for RSS folders
mailnews.mark_message_read.none for folders in “Local Folders”

Set the value to “True”
Close the Config Editor and click “OK” in the Options panel

Aug 01 2006

Ten tips for new Ubuntu users

Linux.com has a good article on getting started with Ubuntu. The best tip is to switch the kernel from the default 386. The 386 kernel runs on almost anything but does not use any of the newer features of more recent processors.

Linux.com | Ten tips for new Ubuntu users

Ubuntu has become the most popular Linux distribution for new Linux users. It’s easy to install, easy to use, and usually “just works.” But moving to a different operating system can be confusing, no matter how well-designed it is. Here’s a list of tips that might save you some time while you’re getting used to Ubuntu.

Read more »

Jul 28 2006

Less is More

If you use less as your pager, you can quickly shift from viewing the file to monitoring additions to the file by pressing Shift-F. less changes to watch the end of the file and shows you text as it’s appended. Also, try the -N option to display line numbers.

Jul 25 2006

Festivus for the rest of us. Or in other words, Festival Text-to-Speech

I was looking for a text-to-speech package for my Ubuntu installation so that I could launch an audible alarm reminding me to take a coffee break. I went searching and found that Festival is installed as part of the base Ubuntu system.
Read more »

Jul 24 2006

Unix tr command

If you need to edit a file to make simple substitutions, try tr from the command-line. For example, this command, replaces all upper-case letters with the corresponding lower-case letters.

$ echo HELLO | tr [:upper:] [:lower:]
hello

And this command removes unprintable characters:

$ tr -d -c [:print:]

-d specifies delete instead of replace; the -c complements the list of printable characters, [:print:], yielding those that aren’t printable.

Jul 21 2006

Guide to Useless Services (Windows XP SP2)

Techtree.com India > Guides > Software Guides > Guide to Useless Services (Windows XP SP2)

An operating system is made up of various components that work with each other. The OS isn’t just one object - it’s a collection of smaller objects, each of which performs a different task. Their conjunction is what makes an “operating system”. Windows calls these components “services”, Linux calls it “daemons” and so on. Each service in Windows is essentially, to put it in a simpler way, an application that stays running in the back doing its job when required. Now each service takes up some memory, which isn’t good if your system has a low amount of memory (like 256MB or less). Fortunately, not all of the default services are required by all users, so you can turn some of them off to free up some memory.

Read more »

Jul 03 2006

sox - Linux Command

If you need to convert from one audio format to another (i.e. from .au to .wav) you can use the sox utility. For example,

sox mysong.au mysong.wav

will convert mysong.au to it’s wav equivalent.

sox - Linux Command - Unix Command

SoX is a command line program that can convert most popular audio files to most other popular audio file formats.

Jun 21 2006

Printing FAQ: Printing a Unix Man Page

Printing FAQ: Printing a Unix Man Page

man commandname | col -b | ul -t dumb | lpr -Pprinter

Jun 21 2006

xargs - construct argument list(s) and execute utility

I have a server where I’ve been too lazy to set up proper logfile
archiving. (I am much to busy to add a crontab entry!) Since all the
logfiles get rotated daily I ended up with directories containing,
uhm…lots of rotated logfiles named logfile_name.YYYYMMDD

I decided to just delete most of them, and since I am very clever and
hate to type I just said:
# rm *YYYY*

But as I said, there are lots of them.

# rm: Argument list too long.

Daag.

I suppose I could make the wildcard more specific like *YYYMM* and issue
multiple rm commands. Hmmm…but then there is that hating typing thing.
It seemed reasonable to me figure out a way to get around the argument
list limit, even if that took longer than typing in all those extra
commands.

#find . -name ‘*YYYY*’ | xargs rm

Ahhh. Now I can continue to be lazy!

Jun 10 2006

Gnome Pictures Folder Screensaver Bug (Ubuntu)

My pictures are located on a seperately mounted hard drive. So my workaround was to place a symlink in my home directory pointing to my mounted drive.

ln -s /mnt/d/My-Pictures ~/Pictures

Bug #47604 in gnome-screensaver (Ubuntu): “”Pictures Folder” isn’t configurable”

The “Pictures Folder” screensaver will only look in ~/Pictures for pictures. This isn’t configurable (which causes problems for people with existing directory structures, or who speak languages other than English).

Apr 29 2006

Keep Background Processes Running

There are times when a background process that you rely on silently crashes, which can be difficult to detect and rectify. MythTV, for example, relies on a back-end server to record television programs. If the back-end crashes, recordings will be missed. The trick is to launch a process you want to restart from within a simple script. If it crashes, control passes back to the script, which can start it again. This can be done using a simple while loop.
Read more »

Apr 27 2006

Tee for Two (or Three, Four, …)

To watch the output of a command and capture the output in a file, use tee. For example, find / -name ‘*.pm’ -print | tee log lets you watch the results and keep the results in log. Use –a to append.

Apr 27 2006

Less like Tail

You can make less work like tail: open a file and press F (uppercase “F”) to track the file as it grows, just like tail -f. Press Control-C to switch back.

Apr 27 2006

List all directories inside another directory

I found another way to list all directories inside another directory: Use find. For example, to list all of the subdirectories below the current working directory, including directories that begin with a “dot”, type:

find ./ -type d -maxdepth 1.

You can adjust the -maxdepth argument to list all directories until the given depth. What if you just need to list 2nd degree subdirectories? Just type find ./ -type d -maxdepth 2 -mindepth 2. The trick is, just put same number on -maxdepth and -mindepth.