这种方法成功
Enabling Numlock upon login
System -> Preferences ->Keyboard
Then choose the Layout tab. Layout ->Layout Options -> Miscellaneous compatibilityoptions -> turn on "Default numeric keypadkeys"
This setting takes effect after logging in and does notaffect the graphical login screen or localconsoles.
It requires the numlockx utility, which can be installedwith:
sudo apt-get install numlockx
Enabling NumLock during startup and before login
Here's how to enable numlock to stay on duringstartup and before you login so it is on before you enter yourusername password into the logon screen
Enabling NumLock in GDM (as used in Ubuntu Gnome and XubuntuXFCE)
If you are using GDM you can usenumlockx:
Here is a script to do exactly this
# Set numlock on in GDMecho "Setting numlock on in GDM"GDM_INIT=/etc/gdm/Init/Defaultif [ -f $GDM_INIT ]; then if ! grep -q numlockx $GDM_INIT ; then sed -i 's/^exit 0/test -x /usr/bin/numlockx && /usr/bin/numlockx onnexit 0/g' $GDM_INIT fifi
Also.. even if the numlock light on your keyboard is on.. there isa setting that can override it.System->Preferences->Keyboard.. thenclick the "Mouse Keys" tab and make sure to uncheck "Pointer can becontrolled using the keypad".
Enabling NumLock in KDM
This is similar to the instructions for GDM.Edit/etc/kde4/kdm/Xsetup(ifyou are still running kde3 you will want toedit/etc/kde3/kdm/Xsetupinstead)and add the following code to it:
if [ -x /usr/bin/numlockx ]; then /usr/bin/numlockx onfi
Enabling NumLock in KDE (as used in Kubuntu)
From the K Menu, launch System Settings andclick on Keyboard (Edgy users: K Menu -> SystemSettings -> Keyboard and Mouse ->Keyboard). You can see in the middle section the options for"NumLock on KDE Startup", where you can choose to Turn On, TurnOff, or Leave Unchanged. Select "Turn On" to turn NumLock on atstartup.
Enabling NumLock from startx
If you are not using a graphical display managerthen add the following lineto/etc/X11/xinit/xinitrc
/usr/bin/numlockx on
Enabling NumLock for Virtual Consoles (TTYs)
If you use the virtual consoles regularly, thenyou will quite likely want to have numlock on for the TTYs afterboot up. The status of numlock/scroll-lock/capslock can bemanipulated withthesetledscommand.One way to guarantee that numlock will be turned on after bootupfor the TTYs is torunsetledsviarc.local(ascript run after every runlevel change; which in particular runsafter booting up). To do so add something similar to the followingin thefile/etc/rc.local:
# Turn Numlock on for the TTYs:for tty in /dev/tty[1-6]; do /usr/bin/setleds -D +num < $ttydone