Memo

Saturday, June 21, 2008

Linux Tricks

Linux General Shortcut Key


For General Linux:


Ctrl+F# usually F1,F2,F3,F4

Enter the command mode..Terminal mode. Ctrl+F7 Back to X-Win.

In Ubuntu Ctrl+alt+F#

F1 is booting system process F7 is X-Win

In KDE Ctrl+Shift+Alt+NumLock

Enable the mouse key. Using Numpad to control cursor.

sleep 1 && xset dpms force off

Turn off the Monitor. 1 indicates wait 1 second right after hitting enter.

KDE Tricks


KDE: KIOSlave usage in Konqueror


sftp://

#access the remote ssh file system locally.

smb://

#access remote windows machine thru samba server

telnet://

#unknown

ldap://

#unknown

info:/

#unknown

ftp://

#access the remote ftp server.

media:/

#access the local hard drive system.

tar:/

#access local gzip or bzip2 achieved file

font:/

#access local font files.

man:/

#access local manual files read it in html mode.



/usr/local/share/fonts/

#The place where all the system fonts is stored. #Link the font file from some persistent location and then do

sudo mkfontscale
sudo mkfontdir
#To apply the change to the system.

/usr/share/apps/konqueror/servicemenus/ /home/keda/.kde/share/apps/konqueror/servicemenus/

#The place for all the shortcut command when right click on specific item in konqueror is stored. File in name.desktop format. Example: [Desktop Entry] Encoding=UTF-8 Actions=gvim; Icon= ServiceTypes=text/allfiles ExcludeServiceTypes=kdedevice/* [Desktop Action gvim] Exec=gvim %U Icon=gvim Name=Edit with Gvim

Ubuntu Gusty


Enable the wacom pen

uncomment the /etc/X11/xorg.conf line 102-105 InputDevice "stylus" "SendCoreEvents" InputDevice "cursor" "SendCoreEvents" InputDevice "eraser" "SendCoreEvents"



Software Package Name

Usage

bubakup

create a bootable backup. using 7z compression.

partimage

a ghost liked tool under linux. Disadvantage: Can't un-achieve specific file.

sysv-rc-conf

background service controller. Command version.

debfoster

.deb package maintainer.

ntfs-3g

essential package needed for R/W operation in NTFS partition

qtparted

QT fronted end for partition tool

gtkorphan

delete the unused library file.

wajig

Simplyfying Debian Administration. combine many apt work into single command

System Command

Usage

ctrl-z

suspend a running process.

ctrl-c

stop a running process.

fg

go back to a suspended command.

top

show the resource usage. RAM CPU etc.

fdisk -l

show the hard drive status. sudo is needed.

mount or umount (-a)

mount or unmount paritions with -a means all partition

sudo fc-cache -fv

refresh the font cache.

nohup

program started from terminal will keep running after terminals ends.

export VARIABLE = "name"

Set the environmental variable.

echo $VARIABLE

display the path for specific variable.

/etc/fstab

mounting partitions config file.

/etc/apt/sources.list

update server file

/boot/grub/menu.lst

GRUB config file.

/etc/fonts/

Font's config file

apt-get autoremove

remove unused package

apt-get purge autoremove

purge settings also.

df -h

display disk usage information.

df

display what partition is mounted and where it mounted.

tar -cvzf /backup.tgz --exclude=/proc--exclude=/backup.tgz --exclude=/mnt --exclude=/sys ->your directory:/

  • 'tar' is the program used to do a backup

  • c - create a new backup archive

  • v - verbose mode, tar will print what it's doing to the screen

  • z - compress the backup file with 'gzip' to make it smaller

  • f <filename> - specifies where to store the backup, /backup.tgz is the file used in this example

  • Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results. You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.

  • After all of the options is the directory we want to backup. Since we want to backup everything we use / for the root directory

sudo /etc/init.d/cupsys restart * Restart an system background server.

Wacom Tablet Solution

* Tested on HP TC4400

xsetwacom set stylus Button1 "button 1"

Set the cursor to be left click of the mouse.

xsetwacom set stylus Button3 "button 3"

Set the button on the pen to be right click of the mouse.

Create a shell file for above 2 command.

~/.kde/Autostart/filename.sh | chmod +x filename.sh

Example File:

keda@keda-tc4400:~$ cat .kde/Autostart/pen.sh #! /bin/sh xsetwacom set stylus Button1 "button 1" xsetwacom set stylus Button3 "button 3"

Create K menu items and assign shortcut keys.


xrandr -o 3 | xsetwacom set stylus rotate cw

Rotate to the Right.

xrandr -o 1 | xsetwacom set stylus rotate ccw

Rotate to the Left

xrandr -o 0 | xsetwacom set stylus rotate none

Rotate to normal

xrandr -o 2 | xsetwacom set stylus rotate half

Rotate to Invert

Reference site:

http://linux.die.net/man/3/xrandr http://linuxwacom.sourceforge.net/index.php/howto/xsetwacom

Example System Files

<alias> <family>serif</family> <prefer> <family>Bitstream Vera Serif</family> <family>DejaVu Serif</family> <family>AR PL ShanHeiSun Uni</family> <family>WenQuanYi Bitmap Song</family> <family>AR PL ZenKai Uni</family> </prefer> </alias>

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

apt-cache search package 搜索包

apt-cache show package 获取包的相关信息,如说明、大小、版本等

sudo apt-get install package 安装包

sudo apt-get install package - - reinstall 重新安装包

sudo apt-get -f install 修复安装"-f = --fix-missing"

sudo apt-get remove package 删除包

sudo apt-get remove package - - purge apt-get remove --purge softname1 删除包,包括删除配置文件等

sudo apt-get update 更新源

sudo apt-get upgrade 更新已安装的包

sudo apt-get dist-upgrade 升级系统

sudo apt-get dselect-upgrade 使用 dselect 升级

apt-cache depends package 了解使用依赖

apt-cache rdepends package 是查看该包被哪些包依赖

sudo apt-get build-dep package 安装相关的编译环境

apt-get source package 下载该包的源代码

sudo apt-get clean && sudo apt-get autoclean 清理无用的包

sudo apt-get check 检查是否有损坏的依赖

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

/etc/samba/smb.conf security = SHARE #most important so that windows client can access without user name and passwd. it's for the samba server sudo smbpasswd -a (user name) add a user so can use windows to access this. ------------------------------------------------------------------------------------------------------------------- Kubuntu 7.04 feisty konqueror的中文网站乱码问题可以通过设置qtconfig里面的Arial替换字体来解决。 --------------------------------------------------------- copy the font file to following diretory, or make the directory.

sudo chmod 644 /usr/share/fonts/zh_CN/TrueType/*
cd /usr/share/fonts/zh_CN/TrueType/
sudo mkfontscale
sudo mkfontdir
renew the font list
sudo fc-cache /usr/share/fonts/zh_CN/TrueType/
----------------------------------------------------
how to install jre and set the java_home
sudo ln -sf /usr/jre1.5.0_08/bin/java /usr/bin/java
sudo ln -sf /usr/jre1.5.0_08/bin/java_vm /usr/bin/java_vm
sudo ln -sf /usr/jre1.5.0_08/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla-firefox/plugins/
Set the environmental variable. for Java
#gedit /home/(username)/.bashrc
JAVA_HOME=/usr/jre1.5.0_08/
JAVA_BIN=/usr/jre1.5.0_08/bin
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

Ubuntu下的JAVA中文乱码今天配置Compiere的时候,一些中文输入正常,一些中文输入则显示乱码,估计是SUN默认用的中文字库不够全,于是上网google
1.
之,解决方案如下:在 jre/lib/fonts/ 下建立个目录 fallback
mkdir /usr/lib/jvm/java-1.5.0-sun/jre/lib/fonts/fallback/
2.在 fallback 里弄个中文字体
拷贝或链接都可以
ln -s /usr/share/fonts/truetype/arphic/uming.ttf /usr/lib/jvm/java-1.5.0-sun/jre/lib/fonts/fallback/
3.
进入 jre/lib/fonts/fallback/ 执行 mkfontscale
再把 jre/lib/fonts/fallback/fonts.scale 的内容加到 jre/lib/fonts/fonts.dir
cd /usr/lib/j2sdk1.5-sun/jre/lib/fonts/fallback/
mkfontscale
cd ..
cat fallback/fonts.scale >> fonts.dir
--------------------------------------------

中文系统初步解决方案

Install Lastest Wenquanyi fonts

Change Locale: (More about locale can be in Google Notebook)

modify file /etc/default/locale

LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" LC_CTYPE="zh_CN.UTF-8" Change the ugly fonts came with WQY-Bitmap by setting default Sans and Sans serif in KControl to BitStream Vera Sans 9 and BitStream Vera Mono 9.

install fcitx:

sudo apt-get install fcitx im-switch
create txt file fcitx in:
/etc/X11/xinit/xinput.d/
with content
##################
XIM=fcitx
XIM_PROGRAM=/usr/bin/fcitx
XIM_ARGS=""
GTK_IM_MODULE=XIM
QT_IM_MODULE=XIM
DEPENDS="fcitx"
Then do:
sudo im-switch -s fcitx -z default
im-switch -s fcitx -z default #
注意:不加sudo
Remember to set the Chinese font in configuration file under ~/.fcitx/
Problem:
conflicts with Firefox and other non-QT based software under KDE:
Solution:
Under Kubuntu 7.10:
sudo kwrite /usr/lib/gtk-2.0/2.10.0/immodule-files.d/libgtk2.0-0.immodules

others possible file location: /etc/gtk-2.0/gtk.immodules

Change last line to:
"/usr/lib/gtk-2.0/2.10.0/immodules/im-xim.so"
"xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"
Little fcitx trick:
ctrl+5 apply the setting without restarting

Printing in Unix/Linux

lpr -P $printer_name $file_name #EGR printer only support .ps file. EGR printer examples: [eb1515] [eb1307-duplex]
Multiple page per page solution: psnup -int(#number of page per sheet) $file_name #Note the output send to stdout use "|" to send output to printer. i.e psnup -int $file_name.ps | lpr -P $printer_name
Use SSHFS
Install package sshfs To mount a remote ssh to local file: sshfs example.com:/stuff /media/home-pc To umount: fusermount -u /media/home-pc