Windows XP Tips
USE RDESKTOP TO CONNECT REMOTELY TO WINDOWS XP

------------------------------------------------------
If you're working in a cross-platform environment and use both Windows and Linux, there's a fast and easy way to obtain a remote connection to your Windows system from Linux.

Previously, the only real way to do this was by using virtual network computing (VNC), but now  you can use the open source client rdesktop to connect to Windows. Rdesktop speaks the  Remote Desktop Protocol, which is employed by Windows Terminal Services.

In Windows XP Professional, more than one user can log into Windows at one time--locally or remotely. Thus, you can use rdesktop to connect to your Windows system at work when you're at home. To accomplish this in Windows NT or Windows 2000, you have to purchase a client license.

Rdesktop comes with Mandrake Linux 8.2. MandrakeSoft has written a nice graphical user interface (GUI) manager to rdesktop called RFBdrake. This GUI can also be used to connect to other Mandrake Linux systems running RFBdrake in server mode.

However, you don't need to run Mandrake Linux to use rdesktop. It's available for free at http://www.rdesktop.org/ and is extremely simple to use. To connect to a remote Windows machine called "winxp.mylan.com", create a shell script that automatically launches rdesktop. For example:

#!/bin/sh
rdesktop -u "username" -g 1024x768+0+0 winxp.mylan.com


This will connect to winxp.mylan.com as the user "username" and set the screen geometry to 1024 x 768, starting at the x and y offsets of 0 on the screen.

--------------------------------------------------------------------
Linux Tips
It's easy to see what timeserver your Linux box is using with this command:

ntptrace localhost

But what would happen to the time on your system if that timeserver failed? Use

ntpq -p

to see a chart of all the timeservers with which your NTP daemon is communicating. An * indicates the timeserver you currently are using, and a + indicates a good fall-back connection. You should always have one *, and one or two + entries mean you have a backup timeserver as
well.
-------------------------------------------------------------------

Vim versions 6.0 and later support a new feature called Code Folding. With code folding, a block of code can be "folded" into a single line, thus making the overall code easier to grasp.

The Vim commands to use code folding are quite simple:

To create a fold, position the cursor at the start of the code block and type zfap.

To open a fold, type zo.

To close a fold, type zc.

To open all the folds, type zr.

To close all the folds, type zm.
_________________________________________________________________

When you boot Linux, the kernel turns off Num Lock by default. This isn't a problem if, for you, the numeric keypad is the no-man's-land between the cursor keys and the mouse. But if you're an accountant, or setting up a system for an accountant, you probably don't want to turn it on every single time.

Here's the easy way, if you're using KDE. Go to K --> Preferences --> Peripherals --> Keyboard and select the Advanced tab. Select the radio button of your choice under NumLock on KDE startup and click OK.

If you only run KDE and want Num Lock on when you start a KDE session,
you're done. Otherwise, read on.

To set Num Lock on in a virtual console, use:

setleds +num

If you choose to put this in a .bashrc file to set Num Lock when you
log in, make it:

setleds +num &> /dev/null

to suppress the error message you'll get if you try it in an xterm or over an SSH connection.

Finally, here's the way to hit this problem with a big hammer--make the numeric keypad always work as a numeric keypad in X, no matter what Num Lock says. This will make them never work as cursor keys, but you're fine with that because you have cursor keys, right? Create a file called .Xmodmap in your home directory, and insert these lines:

keycode 79=7
keycode 80=8
keycode 81=9

keycode 83=4
keycode 84=5
keycode 85=6

keycode 86=plus
keycode 87=1
keycode 88=2
keycode 89=3

keycode 90=0
keycode 91=period

keycode 77=Escape

(from a Usenet post by Yvan Loranger:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3BFD087F.20003
00%40iquebec.com&rnum=3+)

The last line takes the now-useless Num Lock key and makes it an extra Escape key. If your favorite accounting software uses one of the F keys frequently, you might prefer that.

The number to the left of the equals sign is an X "keycode", the key on the keyboard you pressed, and the number or name to the right is an X "keysym", the character or function X thinks it is. You don't have to look these up in some X manual. To find out the keycode and keysym for any key, run xev in an xterm, move the mouse to the small white xev window and watch the keycodes and keysyms scroll by in the xterm.

----------------------------------------------------------------------------

Some proprietary implementations of the ssh2 protocol generate public
key files that start something like this:

---- BEGIN SSH2 PUBLIC KEY ----
Subject: fred
Comment: "my key"

If you want to log in to an OpenSSH server using one of these keys,
first copy the key to the OpenSSH server, then (assuming the file name
is identity.pub), use ssh-keygen to import it with the -i option, and
add it to your authorized_keys:

ssh-keygen -i -f identity.pub >> ~/.ssh/authorized_keys

If you still have trouble logging in, check the permissions for your
.ssh directory and the files in it. If your ssh client doesn't have
verbose mode, change

LogLevel INFO

to

LogLevel DEBUG

in /etc/sshd_config, and restart sshd to get more information on the
problem. See man ssh-keygen for more information on importing keys.

Secondary Sponsor

LinuxWorld Conference & Expo -- January 21 - January 24, 2003!
Discover why Linux is thriving; hear how Wall Street firms are
leveraging Linux at the all-new Linux Financial Summit; attend keynote
addresses from AMD, Morgan Stanley/Red Hat, IBM and Dell. Register
today:
http://www.linuxworldexpo.com/reg using Priority Code LNLJN
----------------------------
The find command

There are a number of commands in Linux that both confuse and delight us. One of these is find, the super-powerful utility that has so many flags, switches, and options that just reading the manual page can make you dizzy. There's lots of beginning material out there for find, so I'm going to skip that and go straight to some of its more advanced and interesting uses.

For a first example,

let's find all of the files on the system that have changed in the last fifteen minutes, regardless of who owns them. You'll have to run this command as root so you have access to everything. (I'll be lecturing you folks about this constantly: never use root unless you absolutely have to. Otherwise, you can cause lots of damage to your system with a simple typo.)

To find every file that's changed in the last fifteen minutes, no matter where it is on the machine, you'll start the command with the following construct:

find /

This tells find to start at the root directory. Any time you use the root account and start from the root directory, you know the command will take a while, so prepare to be patient. From there, we'll use the -mmin option, which stands for "modified minutes." The following tells find to look for any file that was modified (changed) within the last fifteen minutes:

find / -mmin -15

You need to place the minus before the 15 to tell find that you want any file that's been changed from one second ago to fifteen minutes ago. If you didn't use the minus, it would look for files that had changed exactly fifteen minutes ago.

How about a more complex example? Let's say that the user bob left for vacation two days ago, and hasn't had access to the system since then. Perhaps we're worried that someone's broken into his account and might be using it while he's gone. So, we want to find all of the files owned by the user bob that have been accessed in the last two days. We would use the -user option to specify we're interested in bob's files, and the -atime option to specify that we're interested in files accessed in a certain number of days.

The command we'd construct for this one - and, again, run as root - is:

find / -atime -2 -user bob

We've again used the minus in front of the number because we want it within the last two days, not exactly two days ago. Also, we used -atime instead of -amin because the time version counts in days and we don't have to list exact numbers of minutes.

Let's look at one more example - something even more complex. Perhaps we want to view the contents of all text files (since we wisely end all of our text files with .txt) in the /tmp directory that haven't been accessed for three days. You should already know part of the answer to this one. We'll use -atime 3 as one of our flags, along with -name since we're specifying part of the actual filename. This command might begin with:

find /tmp -name *txt -atime 3

But that's not all. To actually view the contents of each file, we'll need to use the -exec flag to run the cat command (type man cat for more information on this one). With -exec, things can get complex since the actual format is typically:

-exec command_to_run \{\} \;

Yes, that looks weird. Each of the back slashes (\) is an "escape character," which tells Linux to read the characters {, }, and ; literally instead of trying to interpret them as something special. They're special in the context of find, but the shell might try to make use of them before even parsing the find command. The {} actually refers to the name of the file that find just found, and the ; ends the statement. So, our whole command looks like the following:

find /tmp -name *txt -exec cat \{\} \;

So it won't all scroll off the end of the screen before I can read it, I typically pipe the whole output to less so it will show just one screen at a time:

find /tmp -name *txt -exec cat \{\} \; | less
---------------------------------