Last modified: 2010/12/22 11:36:30

適当な備忘録。

Ubuntu Linuxが基準です。

備忘録
sudo haltを一般ユーザで実行
ウィンドウマネージャを変更する
/usr/local/lib/のパス設定
スクリーンショットを取る
ランレベルに応じたデーモンの変更
サーバ証明書の表示
alias
aptでインストールされたパッケージのファイル一覧表示
ファイル名の文字コード変換
Subversion(+ Apache)
サーバ 側
クライアント側
vmplayer
導入
なんかCtrlキーとかが効かなくなる時
wine
フォント追加
メニューが文字化けする場合
conky
導入
conky-colors
mp3リッピング
導入
ビットレート調整
WMA(wmap)再生
OpenBoxを使う。
導入
設定
lftp
ssh
SSHトンネリング
Skype
screen
導入
設定
設定ファイル再読み込み

備忘録

sudo haltを一般ユーザで実行

sudo visudo で以下を追加。

kazamai ALL=NOPASSWD: /sbin/halt

%admin ALL=(ALL) ALL

より下の行に書かないとだめぽです。

ウィンドウマネージャを変更する

sudo gdmsetupを実行し、

全般->デフォルトのセッション リストで変更すればOK

/usr/local/lib/のパス設定

echo /usr/local/lib > usr-local-lib.conf
sudo mv usr-local-lib.conf /etc/ld.so.conf.d/
# 設定反映
sudo ldconfig -v

スクリーンショットを取る

import -frame ss.jpg

ランレベルに応じたデーモンの変更

sudo aptitude install sysv-rc-conf
sudo sysv-rc-conf
風舞はデスクトップでBluetooth使わないので切ってます。

サーバ証明書の表示

openssl x509 -noout -text -in <filename>

alias

~/.bashrcとかに書いておくと便利かも?

alias asearch='aptitude search'
alias ainstall='sudo aptitude install'
これでasearch hoge とか ainstall piyo とか少し短縮できます。

aptでインストールされたパッケージのファイル一覧表示

dpkg -L [パッケージ名]

ファイル名の文字コード変換

convmvを使います。
例:再帰的(-r)にファイル名の文字コードをShift_JIS->UTF-8に変換。

convmv -r -f sjis -t utf8 * --notest

Subversion(+ Apache)

サーバ 側

Apache設定

ディレクトリ設定

sudo mkdir /home/repos
sudo chown -R www-data:www-data /home/repos

Apacheの設定ファイルを追加する。

<IfModule !mod_ssl.c>
  LoadModule ssl_module    modules/mod_ssl.so
</IfModule>

<Location /repos>
    SSLRequireSSL
    DAV svn
    SVNParentPath /home/repos
    # Basic認証をやる場合は以下4行追加
    AuthType Basic
    AuthName "SVN repos"
    AuthUserFile /home/repos/.svnuser
    Require valid-user
</Location>

リポジトリ作成

sudo svnadmin create /home/repos/hoge
sudo chown -R www-data:www-data /home/repos/hoge

権限変更

Web経由の場合、apache実行ユーザがアクセスできるようにする

sudo chown -R www-data:www-data /home/repos/hoge

クライアント側

インポート

インポートしたいディレクトリの中をカレントにして実行

カレントディレクトリの中身がインポートされる

cd hoge/
svn import -m '' https://svn/repos/hoge/

チェックアウト

ローカルにhogeディレクトリが作成されつつ中身を落としてくる

svn co https://svn/repos/hoge/

vmplayer

導入

http://www.vmware.com/jp/products/player/ ここから無料DL。 実行してインストール。

sudo sh VMware-Player-3.0.1-227600.i386.bundle
vmplayer コマンドで起動。 Create New Virtual Machineで仮想デバイスが作成できます。便利。

なんかCtrlキーとかが効かなくなる時

setxkbmap -rules xorg -model jp106 -layout us -option "ctrl:nocaps"
助かった。うちUS配列なのでこのオプション。 -model us にするとBackSpaceが聞かなくなったのでjp106。

wine

フォント追加

ln -s /usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf ~/.wine/drive_c/windows/Fonts/

メニューが文字化けする場合

winecfgを実行し、デスクトップ統合を選択。 項目からメニューテキスト を選択し、フォントボタンでさざなみゴシック(サイズ8)を選択してOKすると解消します。

conky

導入

sudo aptitude install conky

conky-colors

conky-colors からSourceをDL。

展開後、その中で

make && ./conky-colors && make-install

これ を~/.conkyrc として保存。

conky で起動。 ウィンドウではなく壁紙の上で表示されるスタイルがgkrellmより好きかも。

mp3リッピング

導入

sudo aptitude install sound-juicer ubuntu-restricted-extras

ビットレート調整

デフォルトは128kbpsなので変更する。個人的に192kbps以上あれば十分。 編集->設定->出力フォーマットをMP3に設定。 プロファイルの編集でMP3を選択し、GStreamer pipelineを変更(例は256kbps)。

audio/x-raw-int,rate=44100,channels=2 ! lame name=enc mode=0 vbr-quality=6 ! id3v2mux
↓
audio/x-raw-int,rate=44100,channels=2!lame name=enc bitrate=256 ! id3v2mux

WMA(wmap)再生

http://www.mplayerhq.hu/design7/dload.html ここからCodecをDL。 Linux x86 20071007の横のリンク。

tar xjf essential-20071007.tar.bz2
sudo mv essential-20071007 /usr/lib/codecs
sudo ln -s /usr/lib/codecs /usr/lib/win32
これでmplayerを実行するとWMAでも音がなるようになりました。

OpenBoxを使う。

軽量デスクトップマネージャ。

導入

sudo aptitude install openbox

設定

キーバインド設定

~/.config/openbox/rc.xml

<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/   file:///usr/X11R6/share/openbox/openbox/rc.xsd">
  <resistance>
    <strength>10</strength>
    <screen_edge_strength>10</screen_edge_strength>
  </resistance>
  <placement>
    <remember>yes</remember>
    <policy>Smart</policy>
    <center>yes</center>
    <monitor>Any</monitor>
  </placement>
  <focus>
    <focusNew>yes</focusNew>
    <followMouse>no</followMouse>
    <focusLast>yes</focusLast>
    <focusLastOnDesktop>yes</focusLastOnDesktop>
    <cyclingDialog>yes</cyclingDialog>
    <focusDelay>0</focusDelay>
    <raiseOnFocus>no</raiseOnFocus>
    <underMouse>no</underMouse>
  </focus>
  <theme>
    <name>Wblue</name>
    <!--    <titlelayout>LIMC</titlelayout> -->
    <titlelayout>L</titlelayout>
    <keepBorder>yes</keepBorder>
    <animateIconify>yes</animateIconify>
    <titleLayout>NLMC</titleLayout>
    <font place="ActiveWindow">
      <name>Sans</name>
      <size>8</size>
      <weight></weight>
      <slant></slant>
    </font>
    <font place="InactiveWindow">
      <name>Sans</name>
      <size>8</size>
      <weight></weight>
      <slant></slant>
    </font>
    <font place="MenuHeader">
      <name>Sans</name>
      <size>8</size>
      <weight></weight>
      <slant></slant>
    </font>
    <font place="MenuItem">
      <name>Sans</name>
      <size>8</size>
      <weight></weight>
      <slant></slant>
    </font>
    <font place="OnScreenDisplay">
      <name>Sans</name>
      <size>8</size>
      <weight></weight>
      <slant></slant>
    </font>
  </theme>
  <desktops>
    <number>5</number>
    <names>
      <name>Mail</name>
      <name>Web</name>
      <name>ATIS</name>
      <name>JRA</name>
      <name>SkyPerfecTV</name>
    </names>
    <cyclingDialog>yes</cyclingDialog>
    <popupTime>875</popupTime>
  </desktops>
  <resize>
    <drawContents>no</drawContents>
    <popupShow>NonPixel</popupShow>
    <popupPosition>Center</popupPosition>
    <popupFixedPosition>
      <x>0</x>
      <y>0</y>
    </popupFixedPosition>
  </resize>
  <dock>
    <position>topRight</position>
    <stacking>top</stacking>
    <direction>vertical</direction>
    <floatingX>0</floatingX>
    <floatingY>0</floatingY>
    <autoHide>no</autoHide>
    <hideTimeout>300</hideTimeout>
    <hideDelay>300</hideDelay>
    <noStrut>no</noStrut>
    <showDelay>300</showDelay>
  </dock>
  <keyboard>
    <chainQuitKey>Escape</chainQuitKey>
    <keybind key="C-A-g">
      <action name="Execute">
        <execute>
        gaim
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-k">
      <action name="Execute">
        <execute>
        xscreensaver-command -lock
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-J">
      <action name="Execute">
        <execute>
      mlterm
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-E">
      <action name="Execute">
        <execute>
        emacs
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-M">
      <action name="Execute">
        <execute>
        ~/bin/firefox.sh
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-P">
      <action name="Execute">
        <execute>
        audacious --play-pause
      </execute>
      </action>
    </keybind>
    <keybind key="C-A-T">
      <action name="Execute">
        <execute>
        XMODIFIERS=uim skype
      </execute>
      </action>
    </keybind>
    <keybind key="A-Escape">
      <action name="Lower"/>
      <action name="NextWindow">
        <linear>yes</linear>
        <dialog>no</dialog>
      </action>
    </keybind>
    <keybind key="A-F4">
      <action name="Close"/>
    </keybind>
    <keybind key="A-F7">
      <action name="Move"/>
    </keybind>
    <keybind key="A-F8">
      <action name="Resize"/>
    </keybind>
    <keybind key="A-F2">
      <action name="ToggleMaximizeFull"/>
    </keybind>
    <keybind key="A-F12">
      <action name="ToggleShade"/>
    </keybind>
    <keybind key="A-Tab">
      <action name="NextWindow"/>
    </keybind>
    <keybind key="A-S-Tab">
      <action name="PreviousWindow"/>
    </keybind>
    <!-- Desktop operations -->
    <keybind key="C-A-I">
      <action name="DesktopLeft"/>
    </keybind>
    <keybind key="C-A-O">
      <action name="DesktopRight"/>
    </keybind>
    <keybind key="S-A-I">
      <action name="SendToDesktopLeft"/>
    </keybind>
    <keybind key="S-A-O">
      <action name="SendToDesktopRight"/>
    </keybind>
  </keyboard>
  <mouse>
    <dragThreshold>3</dragThreshold>
    <doubleClickTime>200</doubleClickTime>
    <context name="frame">
      <mousebind button="A-Left" action="drag">
        <action name="move"/>
      </mousebind>
      <mousebind button="A-Right" action="drag">
        <action name="resize"/>
      </mousebind>
      <mousebind button="A-Left" action="click">
        <action name="raise"/>
      </mousebind>
      <mousebind button="A-Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="A-Middle" action="click">
        <action name="lower"/>
      </mousebind>
      <!--
      <mousebind button="A-Right" action="press">
        <action name="showmenu"><menu>client-menu</menu></action>
      </mousebind>
-->
      <mousebind button="A-Up" action="click">
        <action name="desktopright"/>
      </mousebind>
      <mousebind button="A-Down" action="click">
        <action name="desktopleft"/>
      </mousebind>
      <mousebind button="C-A-Up" action="click">
        <action name="sendtodesktopright"/>
      </mousebind>
      <mousebind button="C-A-Down" action="click">
        <action name="sendtodesktopleft"/>
      </mousebind>
    </context>
    <context name="titlebar">
      <mousebind button="Left" action="drag">
        <action name="move"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="raise"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="doubleclick">
        <action name="toggleshade"/>
      </mousebind>
      <mousebind button="Middle" action="press">
        <action name="lower"/>
      </mousebind>
      <mousebind button="Up" action="click">
        <action name="shade"/>
      </mousebind>
      <mousebind button="Down" action="click">
        <action name="unshade"/>
      </mousebind>
      <mousebind button="Right" action="press">
        <action name="showmenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
    </context>
    <context name="handle">
      <mousebind button="Left" action="drag">
        <action name="move"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="raise"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Middle" action="press">
        <action name="lower"/>
      </mousebind>
    </context>
    <context name="blcorner">
      <mousebind button="Left" action="drag">
        <action name="resize"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
    </context>
    <context name="brcorner">
      <mousebind button="Left" action="drag">
        <action name="resize"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
    </context>
    <context name="tlcorner">
      <mousebind button="Left" action="drag">
        <action name="resize"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
    </context>
    <context name="trcorner">
      <mousebind button="Left" action="drag">
        <action name="resize"/>
      </mousebind>
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
    </context>
    <context name="client">
      <mousebind button="Left" action="press">
        <action name="focus"/>
        <action name="raise"/>
      </mousebind>
      <mousebind button="Middle" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Right" action="press">
        <action name="focus"/>
      </mousebind>
    </context>
    <context name="icon">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Right" action="press">
        <action name="showmenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="showmenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
      <mousebind button="Left" action="doubleclick">
        <action name="close"/>
      </mousebind>
    </context>
    <context name="alldesktops">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="toggleomnipresent"/>
      </mousebind>
    </context>
    <context name="shade">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="toggleshade"/>
      </mousebind>
    </context>
    <context name="iconify">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="iconify"/>
      </mousebind>
    </context>
    <context name="maximize">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Middle" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Right" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="togglemaximizefull"/>
      </mousebind>
      <mousebind button="Middle" action="click">
        <action name="togglemaximizevert"/>
      </mousebind>
      <mousebind button="Right" action="click">
        <action name="togglemaximizehorz"/>
      </mousebind>
    </context>
    <context name="close">
      <mousebind button="Left" action="press">
        <action name="focus"/>
      </mousebind>
      <mousebind button="Left" action="click">
        <action name="close"/>
      </mousebind>
    </context>
    <context name="desktop">
      <mousebind button="A-Up" action="click">
        <action name="desktopright"/>
      </mousebind>
      <mousebind button="A-Down" action="click">
        <action name="desktopleft"/>
      </mousebind>
      <mousebind button="Middle" action="press">
        <action name="showmenu">
          <menu>client-list-menu</menu>
        </action>
      </mousebind>
      <mousebind button="Right" action="press">
        <action name="showmenu">
          <menu>root-menu</menu>
        </action>
      </mousebind>
    </context>
    <screenEdgeWarpTime>400</screenEdgeWarpTime>
  </mouse>
  <margins>
    <left>0</left>
    <right>0</right>
    <top>0</top>
    <bottom>0</bottom>
  </margins>
</openbox_config>

メニュー設定

~/.config/openbox/menu.xml

<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://openbox.org/
    file:///usr/X11R6/share/openbox/openbox/menu.xsd">

  <menu id="root-menu" label="STR">
    <item label="xterm">
      <action name="execute"><execute>xterm</execute></action>
    </item>
    <item label="--" />
    <menu id="openbox" label="Openbox">
      <menu id="system" label="System">
        <item label="Restart System">
          <action name="execute"><execute>shutdown -r now</execute></action>
        </item>
        <item label="Shutdown System">
          <action name="execute"><execute>shutdown -p now</execute></action>
        </item>
      </menu>
      <item label="--" /> <!-- separator -->
      <item label="Reload Settings">
        <action name="reconfigure" />
      </item>
      <item label="Restart Openbox">
        <action name="restart" />
      </item>
      <item label="Exit">
        <action name="exit" />
      </item>
    </menu>
  </menu>

</openbox_menu>

スタートアップ設定

.config/openbox/autostart.sh feh —bg-scale <filename> で背景の設定。(以前はEsetroot使ってました;)

#!/bin/sh

feh --bg-scale /usr/share/backgrounds/warty-final-ubuntu.png
xscreensaver &
emacs &
fbpanel &
skype &
(sleep 10 && conky -d -X :0.0) &

デスクトップマネージャの変更

gdmsetup を実行。 Openbox Session (...) をデフォルトセッションにして再起動。 何か困ったことが起きたらgdmsetupでセッションをGNOMEに戻せばOK。

lftp

CUIのFTPツール。

設定

~/.lftprc

set bmk:save-passwords 1
set ftp:passive-mode off
set ftp:charset shift_jis

ssh

SSHトンネリング

#ssh <接続先host> -N -L <my port>:localhost:<接続先port> -C ←情報を圧縮する場合
ssh 192.168.1.3 -N -L 8080:localhost:80
http://localhost:8080/ にアクセスするとhttp://192.168.1.3:80/ にアクセスしたことになります。 暗号化もされてものすごく便利!

Skype

メッセンジャーツール。 /etc/apt/sources.listに以下を追加。

deb http://download.skype.com/linux/repos/debian/ stable non-free
その後以下を実行。
sudo aptitude update
sudo aptitude install skype

screen

導入

ainstall screen

設定

autodetach on
defkanji utf-8
defencoding utf-8
defscrollback 10000
encoding utf-8 utf-8
escape ^Tt
startup_message off
vbell off
caption always "%{= wb} %-w%{=bu dr}%n %t%{-}%+w %= %{=b wg} (%H) %{=b wk} [%l] %{=b wm}%y/%m/%d %c"

defmonitor off
termcapinfo mlterm hs:ts=\E]0;:fs=\007:ds=\E]0;\007
hardstatus ignore

bind 2 split
bind o focus
bind n next
bind 0 remove
bind 1 only
bind 'U' eval "encoding utf8" "stuff 'export LANG=ja_JP.UTF-8\012'"
bind 'E' eval "encoding euc" "stuff 'export LANG=ja_JP.EUC-JP\012'"
bind 'J' eval "encoding sjis" "stuff 'export LANG=ja_JP.SJIS\012'"
bind y eval writebuf "stuff 'xclip /tmp/screen-exchange\012'"

設定ファイル再読み込み

escape<上記設定ならCtrl+T> :source ~/.screenrc