Using “OR” in grep

To use “or” in grep, you can use “|” such as

cat /path/to/file | grep -E "aaa|bbb"

In this case I search a text file to find text including “aaa” or “bbb”.

Note that this doesn’t work:

cat /path/to/file | grep -E "aaa | bbb"

Whitespaces mustn’t be included before or after the “|”.

Rename garbled file name

On Linux, when you extract compressed files created on Windows, (especially with application developed by Japanese speakers) Japanese characters in file name are garbled. You can’t rename or delete them via file browser (like dolphin or nautilus) in usual way, so you have to rename it via command line.

First, move on to the directory which garbled file is included. In my case, files are included under /home/phanect/

$ > cd /home/phanect

Then, execute “ls” command with “-i”option.

$ > ls -i

294930 ???J?p?@archive??     294913 bin              286741 Download
319490 Documents             286820 Templates       303105 public_html
303106 Desktop

You can see numbers before the file name. This is named inode number. You can specify the file instead of the file name with it. This time, we want to delete “???J?p?@archive??” so we use “294930

Next, use find command.

$ > find /home/phanect -inum 294930

./???J?p?@archive??

With this command, you can get file name specified by inode number.
The first argument “/home/phanect” is the directory including garbled file.
And specify inode number with “-inum” option. 294930 is the inode number of garbled file in this case.

Can you see the file name which you want to rename?

Now, let’s rename it.
You can execute desired command to the file with find command.

$ > find  /home/phanect -inum 294930 -exec [command] \;

You can write command between “-exec” and “\;”

(“\;” means the end of the command. More details for Wikipedia.)

Well, in this case, you want to execute following command:

$ > mv ???J?p?@archive?? new_file_name.txt

Of course this doesn’t work because file name is garbled.

So instead you have to execute:

$ > find  /home/phanect -inum 294930 -exec mv {} new_file_name.txt \;

{} means the file name. (“???J?p?@archive??”) In this case, file is not specified with file name but inode number, so renaming is safely done.

Where is applications list of Kickoff?

Applications list is saved at “/home/jrillet/.config/menus/applications-kmenuedit.menu”
This is an XML file.
This XML file is just a list. Only *.desktop file names are listed here.

The category (Internet, Graphics, Multimedia etc.) information files are under “/usr/share/desktop-directories/”.
The applications information files are under “/usr/share/applications/”
Note that KDE applications are under “/usr/share/applications/kde4″

Refferences:
How to edit Kickoff menu manually
KDE menu category associations – KDE Community Forums

Scientific Linux 6 で研究室のサーバを構築 2日目

今日もサーバ構築を行います。
一昨日は Scientific Linux 6.0 をインストールしたのですが、昨日 Scientific Linux 6.1 がリリースされたので、また最初からやり直しですorz (しかも一回目は間違えて 32bit CPU 用の方をインストールするというバカをやらかしたため、二回もインストールを行うという…)

で、本日は Server World の [初期設定] > [管理ユーザ作成] から [ネットワークの設定] まで行いました。

取り敢えず proxy接続環境で設定すること – 仙人の心得 を参考に、システム全体のプロキシ設定を行います。ここは問題なく行けました。

詰まったのが、/etc/sysconfig/network-scripts/ifcfg-eth0 の設定のところです。どうも最初からあるファイルのようなのですが、存在しないのです。
これは、単に作成すれば良かったみたいです。
参考にしたのは http://www.el.gunma-u.ac.jp/~kobaweb/linux/erase_kernel.html の原因2のところです。

…と、ここまで悩んで、設定項目を見て気付きます。
IP アドレス、サブネットマスク、デフォルトゲートウェイ…
サーバマシンはまだ固定 IP をもらっていません。

…設定できないじゃんorz

というわけでここは飛ばします。
取り敢えず Web サーバたてて、CMS として Joomla を 入れます。

Scientific Linux 6 で研究室のサーバを構築

現在 Scientific Linux 6.1 を用いて研究室のサーバを構築中です。

今日は
- Scientific Linux のインストール
- yum のプロキシ設定
まで行いました。

参照したサイトなどをまとめておきます。

基本的には Server World の記事をベースに進め、補助的に Linux サーバ構築標準教科書 1.0.2 を用いました。

インストールは特に問題なく進めました。LiveCD を用いたので、少し手順が少し違いましたが、特に問題はありませんでした。
ハードウェアクロックは UTC にすべきなのか否か (結局ローカルタイムにした) とか、ハードディスクは暗号化すべきなのかとか (しなかった) ブートローダはインストールすべきか否かとか (インストールした) 多少悩むべきところはありましたが、それほど重要でないので適当にしました。

次に、yum でアップデートを行いました。しかし、プロキシ環境であるため、先に設定が必要です。以下を参照してプロキシの設定を行いました。

プロキシ設定 (yumによるアップデート)

まず、

# export proxy=http://proxy.hostname.com:5273/

とコマンドを打ち、システムのプロキシ設定を変更しました。

次に、”/etc/yum.conf” をテキストエディタで開き、

proxy=http://proxy.hostname.com:5273/

を適当な場所に追加しました。

※プロキシの URL はダミーなので、自分の環境に合わせて読み替えて下さい。

今日はここまでです。雨が降ってきたので、そろそろ大学から帰宅します。

明日は docs.redhat.com 上にある
35.3. グラフィカルログインへの切り替え
を参考に、グラフィカルログインからコンソールログインに変更しようかと思ったのですが、固定 IP をマシンに割り当ててもらうまでは、Web ブラウザ経由でのユーザ認証をしないとネットワークに繋げないので、やっぱりもう少しグラフィカル環境で運用することにします。

yum コマンドで発生する Transaction Check Error

CentOS 5 に pcre をインストールしようと yum コマンドを実行した際に、Transaction Check Error というものが発生してしまいました。これは 64bit OS に 32bit 用のパッケージと 64bit 用のパッケージの両方がインストールされていたことが原因でした。

rpm -q で、パッケージがインストールされているかどうかを確認すると、

$ rpm -q pcre
pcre-6.6-2.el5_1.7
pcre-6.6-2.el5_1.7

となり、同じパッケージが二つインストールされていました。

まず、arch コマンドで、CPU のアーキテクチャが 32 bit なのか 64bit なのか確認します。

$ arch
x86_64

結果は i386 か x86_64 の場合がほとんどだと思います。
…本当かな…。自信ない…。

前者は 32bit、後者は 64bit です。

次に、重複しているパッケージ (ここでは pcre) で、不要なアーキテクチャのものを削除します。
アーキテクチャを指定するには、[パッケージ名].[アーキテクチャ名] と表記します。

yum remove pcre.i386

これで正常に yum で操作ができるはずです。

参考:
CentOS 5 アップデートでエラー – samba で行こう!
CentOS 5.4 x64になぜi386のパッケージが入っているのか。 – にわかSEの独り言
システムのアーキテクチャを表示 (archコマンド) – Linux コマンドリファレンス

Linux で Google Chrome のウィンドウバーを表示しない


Linux では、以下のように Google Chrome のウィンドウバーが表示されるようになっています。

これを隠すには、オプションを開き、個人設定タブの一番下にある「システムタイトルバーを隠してコンパクトな枠線を使用する」を選択します。

これで、以下のように、Windows と同じようなウィンドウバーの表示になります。

openSUSE の KDE:Release:45 リポジトリ

openSUSE で KDE 4.5 にしてから、よく落ちます。フリーズ -> 強制終了 を何回やったことか…。
昨日の OSC で JKUG の会長に聞いた限りでは、KDE の問題ではなく openSUSE 側の問題な気がしています。

で、今までは KDE:Distro:Factory リポジトリを使っていたのですが、先程 KDE:Release:45 というリポジトリを発見しました。openSUSE Build Service の説明を見ると、KDE:Release:45 は “This is a stable snapshot of factory packages containing KDE Release 4.5.” (これは KDE 4.5 を含む Factory パッケージの安定したスナップショットです) とあるので、こっちの方がいいんでしょうか?

取り敢えず、中身を入れ替えてみます。

2010/09/15 追記: Factory のものに比べ、結構安定しています。 やはりこちらに入れ替えて正解でした。

KDM (ログイン画面) のテーマを適用する方法と、openSUSE で (?) 必要な追加作業

KDM (KDE のログイン画面) のテーマを変更するには、KDE システム設定を開き、「ログインスクリーン」のテーマタブから設定できます。「新しいテーマをインストール」を押して、KDE-Look.org などからダウロードした tar.gz ファイルを指定します。(tar.gz ファイルを展開しないことに注意。)

で、これで良いのかと思ったのですが、openSUSE では更に作業が必要です。(他のディストリビューションでどうなのかは不明)

YaST を開き、/etc/sysconfig エディタを開き、[Desktop] > [Display Manager] > [Manager_KDM_THEME] で、コンボボックスにテーマ名を入力します。(KDE のシステム設定の「ログインスクリーン」で書かれている名前と同じ名前を入力します。例: Oxygen, Ethais など)

参考: How to edit openSUSE 10.2 KDM login screen – Tryst with Linux and other Alternatives

環境: KDE 4.5.1 + openSUSE 11.3