Linuxに関するTips集
サーバの運用に関連した情報は link集/サーバ管理 を参照方。
# /usr/sbin/prelink -avmR
# /usr/sbin/lsof -c プロセス名
# /sbin/ldconfigRHEL4系において「/usr/local/lib」を追加するには「/etc/ld.so.conf.d/」配下に適当なファイル(usr-local.conf)を作成する。
/etc/xdg/menu/*.menu /usr/share/applications/*.desktop /usr/share/applnk/*.desktop /usr/share/desktop-directories/*.directory /usr/local/share/applications/*.desktop
# /bin/dmesg
RedHat社のFAQ
How do I enable core file dumps when my application crashes or segmentation faults?
# ulimit -ccoreファイルを作成しない
# ulimit -c 0サイズ制限無し
# ulimit -c unlimited
# limit coredumpsizecoreファイルを作成しない
# limit coredumpsize 0サイズ制限無し
# limit coredumpsize unlimited
# /usr/bin/strings /etc/sasldb2 | grep /usr/bin/strings /etc/sasldb2
# /sbin/sysctl -a
# hdparm -ft /dev/hda
# mount -t tmpfs -o size=64m tmpfs /dev/shm
# yum install yum-fastestmirror
# glxinfo簡易ベンチマークツール
# glxgears
# rpmbuild --rebuild --target i686 XXX
# mount -t vfat /dev/sda1 /mnt/usbfm/
type=AVC msg=audit(1122113324.490:351515): avc: denied { read } for pid=2866 comm="syslogd" name="syslog.conf" dev=dm-0 ino=653814 scontext=root:system_r:syslogd_t tcontext=system_u:object_r:etc_runtime_t tclass=file type=SYSCALL msg=audit(1122113324.490:351515): arch=40000003 syscall=5 success=no exit=-13 a0=2998c6 a1=0 a2=1b6 a3=98f1298 items=1 pid=2866 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 comm="syslogd" exe="/sbin/syslogd" syslogd: /dev/console: permission deniedどうもこれは、auditのログファイルのパスが原因でSELinuxのパーミッションエラーとなった模様。
# touch /.autorelabel # reboot次回のOS起動時にSELinuxの処理が走り、上記のsyslogデーモンの問題が修正される。
# ls -Z ファイル # ps -auxZなどとするとSELinuxのロール・ドメインの表示確認が可能。
bad interpreter: そのようなファイルやディレクトリはありませんそうなった場合は、下記のようにdos2unixコマンドで改行コードを変換する。
$ dos2unix 変換対象スクリプトファイル
# update-alternatives --config mta但し、切り替え直後は以前のserviceが起動したままなので停止・起動する必要がある。
# service sendmail stop # service postfix start
# /sbin/shutdown -h now
$ rpm2cpio hoge.rpm | cpio -id
$ diff -u original_file new_file > patch_file
[Ctrl] + [Alt] + [Backspace]
# xmodmap -pkexev
# xev
# X -config /etc/X11/xorg.conf
# /usr/X11R6/bin/gtf 1920 1200 60(出力結果)
# 1920x1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz Modeline "1920x1200_60.00" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync(巷では出力結果を下記のように修正しろとある)
Modeline "1920x1200" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
# vi /etc/X11/xorg.conf(編集前)
Section "Monitor" (内緒) HorizSync 31-82 VertRefresh 55-120 EndSection(編集後)
Section "Monitor" (内緒) HorizSync 31-82 VertRefresh 55-120 # 1920x1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz Modeline "1920x1200_60.00" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync EndSection
# vi /etc/X11/xorg.conf(編集前)
Section "Screen" (内緒) SubSection "Display" Depth 24 Modes "1600x1200" "1280x1024" "1152x864" "1024x768" "800x600" "640x480" EndSubSection EndSection(編集後)
Section "Screen" (内緒) SubSection "Display" Depth 24 Modes "1920x1200" "1600x1200" "1280x1024" "1024x768" "800x600" "640x480" EndSubSection EndSection※この設定は何かの拍子に元に戻される場合があるので、xorg.confのバックアップを取っておくと良い
この現象は、ブラウザでWikiのようにページ名称に「/」が含まれるURLショートカットをデスクトップに作成し、それを開いた場合に発生する。この状態で、KDE / xfce / WindowMakerを利用した場合は動作に問題はない。
原因については、ここの情報が正しい模様。上記ダイアログメッセージが出たら下記のコマンドを実行する。
# rm -fr ~/.recently-used
# mkfontdir
# mkfontscale又は
# ttmkfdir
# fc-cache -f -v
# vi /etc/X11/fs/configxfsデーモンの再起動
# /etc/init.d/xfs restart
# fc-list
# kcc -c tgt_file
対応文字コード一覧
# iconv -l
[ShiftJIS] -> [UTF-8]
# iconv -f SHIFT_JIS -t UTF8 src_file -o dst_file
[EUC-JP] -> [UTF-8]
# iconv -f EUC-JP -t UTF8 src_file -o dst_file
[UTF-8] -> [ShiftJIS]
# iconv -f UTF8 -t SHIFT_JIS src_file -o dst_file
[UTF-8] -> [EUC-JP]
# iconv -f UTF8 -t EUC-JP src_file -o dst_file
[ShiftJIS] -> [UTF-8]
# lv -Ou8 src_file > dst_file
[EUC-JP] -> [UTF-8]
# lv -Ou8 src_file > dst_file
[UTF-8] -> [ShiftJIS]
# lv -Os src_file > dst_file
[UTF-8] -> [EUC-JP]
# lv -Oej src_file > dst_file
文字コードチェック
# nkf --guess src_file
[ShiftJIS] -> [UTF-8] (LF)&ファイルを上書き変換
# nkf -Sw -Lu --overwrite src_file
[ShiftJIS] -> [UTF-8] (LF)
# nkf -Sw -Lu src_file > dst_file
[EUC-JP] -> [UTF-8] (LF)
# nkf -Ew -Lu src_file > dst_file
[UTF-8] -> [ShiftJIS] (CR+LF)
# nkf -Ws -Lw src_file > dst_file
[UTF-8] -> [EUC-JP] (CR+LF)
# nkf -We -Lw src_file > dst_file
[CR+LF] -> [LF]
# dos2unix -n src_file dst_file
[LF] -> [CR+LF]
# unix2dos -n src_file dst_file
[CR] -> [LF]
# mac2unix -n src_file dst_file
[LF] -> [CR]
# unix2mac -n src_file dst_file
[???] -> [LF]
# nkf -Lu src_file > dst_file
[???] -> [CR+LF]
# nkf -Lw src_file > dst_file
[???] -> [CR]
# nkf -Lm src_file > dst_file
対応エンコーディング一覧
# convmv --list
[ShiftJIS] -> [UTF-8] (実際に変換する場合は「--notest」を付ける)
# convmv -f shiftjis -t utf8 dst_file
[EUC-JP] -> [UTF-8] (実際に変換する場合は「--notest」を付ける)
# convmv -f euc-jp -t utf8 dst_file
[UTF-8] -> [ShiftJIS] (実際に変換する場合は「--notest」を付ける)
# convmv -f utf8 -t shiftjis dst_file
[UTF-8] -> [EUC-JP] (実際に変換する場合は「--notest」を付ける)
# convmv -f utf8 -t euc-jp dst_file
SAVEHIST=200 HISTSIZE=200 HISTFILE=.zsh_history
# history # history -m降順表示
# history -r10番目から表示
# history 10番号表示なし
# history -n時刻表示
# history -d日時表示
# history -f # history -i
# cat /proc/cpuinfo
# /usr/sbin/smartctl -a /dev/hda
# vi /boot/grub/grub.conf(変更前)
kernel /vmlinuz-2.6.9-22.0.2.ELsmp ro root=省略 rhgb quiet(変更後)
kernel /vmlinuz-2.6.9-22.0.2.ELsmp ro root=省略 rhgb quiet i8042.noacpi下記の環境ではそんなオプションねぇよと怒られた。
# uname -ri 2.6.9-22.0.2.ELsmp i386
# vi /boot/grub/grub.conf(変更前)
kernel /vmlinuz-2.6.9-22.0.2.ELsmp ro root=省略 rhgb quiet(変更後)
kernel /vmlinuz-2.6.9-22.0.2.ELsmp ro root=省略 rhgb quiet acpi=off apm=on但し下記のような弊害がある。
https://www.amazon.co.jp/dp/B0001M4AQ2
https://www.amazon.co.jp/dp/B0001M4AQC
https://www.amazon.co.jp/dp/B0009MKBJ4
https://www.amazon.co.jp/dp/B0002ZQGR4
# gs -h
# vi /etc/cups/cupsd.conf
(変更前)
LogLevel info(変更後)
LogLevel debug
# /sbin/service cups reload
/etc/sysconfig/i18n各ユーザのHOMEディレクトリに「.vimrc」を作成し制御可能。
# touch ~/.vimrc # vi ~/.vimrc下記の内容を追加する(.vimrc内でコメントを入れる場合は行頭に「"」を入れる)
set fileencodings=utf-8,cp932,euc-jp,iso-2022-jp,iso-8859-1,ucs2le,ucs-2vim上で
:set enc=utf-8 tenc=utf-8
/var/cache/yum保存されたrpmを削除するには下記コマンドを実行
# yum clean packages
$ acroread -DEBUG起動
$ acroread
# cat /etc/redhat-release # cat /etc/issueLSB(Linux Standard Base)
# lsb_release -a
# yum install switchdesk-gui # switchdesk
/etc/hosts /etc/resolv.conf /etc/sysconfig/network /etc/sysconfig/networking/device/ifcfg-eth0変更した設定を反映するには、以下のコマンドを実行する。
# /etc/init.d/network restart
# cd /etc/yum.repos.d
# wget http://centos.karan.org/kbsingh-CentOS-Extras.repo
# rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
[Ctrl] + [Space] の削除
# iiimf-le-tools -v --lang ja \ --remove-key /usr/lib/im/leif/CannaLE.so \ --hotkey '<Control>space'[Shift] + [Space] の削除
# iiimf-le-tools -v --lang ja \ --remove-key /usr/lib/im/leif/CannaLE.so \ --hotkey '<Shift>space'[半角/全角] の追加
# iiimf-le-tools -v --lang ja \ --add-key /usr/lib/im/leif/CannaLE.so \ --hotkey 'kanji'上記コマンドにより下記ファイルは変更されているがうまくいかなかった。
/etc/iiimf/le.xml.conf
# im-switch -l # im-switch -s kinput2-canna # im-switch -l
# touch ~/.Xresources # vi ~/.Xresources(追加)
Kinput2*ConversionStartKeys: <Key>Zenkaku_Hankaku
但し、日本語入力状態の解除は[Shift] + [Space]となってしまう・・・。
# yum install \ scim \ scim-libs \ scim-anthy \ anthy-7100b \ kasumi \ tomoe \ scim-tomoe \ libtomoe-gtk
原因は、「/usr/share/system-switch-im/locale-list」に記述が無いロケール情報が「/etc/X11/xinit/xinput.d/」に作成されてしまう為。
関連するフォルダ
/usr/share/system-switch-im/ /etc/alternatives/ /etc/X11/xinit/xinput.d/ /var/lib/alternatives/ ~/.xinput.d/下記のコマンドを実行し、記載の無いロケール情報を処理しないようにする。
# cd /etc/X11/xinit/xinput.d # mv bn_IN bn_IN.bak # mv gu_IN gu_IN.bak # mv kn_IN kn_IN.bak # mv ml_IN ml_IN.bak # mv pa_IN pa_IN.bak
# system-switch-im
IMの確認
# im-switch -lIMをSCIMに変更
# im-switch -s scim
# /sbin/service iiim stop # /sbin/service canna stop
# /sbin/chkconfig iiim off # /sbin/chkconfig canna off
# vi /etc/scim/config
# yum install \ uim \ uim-anthy \ anthy-7100b \ kasumi \ tomoe \ libtomoe-gtk uim-canna \ uim-el \ uim-el-common \ uim-gnome \ uim-gtk2 \ uim-m17n \ libm17n \ uim-qt \ uim-skk \ skkdic
# system-switch-im
IMの確認
# im-switch -lIMをuimに変更
# im-switch -s uim
入力状態表示はパネル上で「パネルへ追加」から「uimアプレット」を追加する。
解決策
# rpm -e flex # yum install -y flex
後は通常の手順でRPMパッケージを作成する
# rpm -ivh automake-1.9.2-3.src.rpm
# cd /usr/src/redhat/SOURCES # wget http://ftp.gnu.org/gnu/automake/automake-1.9.6.tar.bz2
# cd /usr/src/redhat/SPECS # vi automake.spec
(編集前)
Version: %{api_version}.2(編集後)
Version: %{api_version}.6
(編集前)
make check || make check VERBOSE=yes(編集後)
make check VERBOSE=yes
# rpmbuild --ba automake.spec
# cd /usr/src/redhat/RPMS/noarc # rpm -Uvh automake-1.9.6-3.noarch.rpm
Ver4.0.x/Ver4.1.x
gcc4, g++4Ver3.4.x
gcc, g++Ver2.9.6
gcc296, g++296
# yum groupinstall XFCE-4.2
# yum install WindowMakerそのままではメニューの日本語表示が駄目なのでフォントを「Kochi Gothic」に変更する
# cd /etc/WindowMaker # egrep "Luxi Sans" --color -InR *(編集前)
... = "Trebuchet MS,Luxi Sans:pixelsize=...";(編集後)
... = "Trebuchet MS,Kochi Gothic:pixelsize=...";
# vi /usr/local/Adobe/Acrobat7.0/bin/acroread(追加)
GTK_IM_MODULE=xim
# yum install -y cups-devel libtiff-devel foomatic # tar zxf gutenprint-5.0.1-rpm-el4.tgz # mv gutenprint-el4.spec /usr/src/redhat/SPECS # wget -O /usr/src/redhat/SOURCES/gutenprint-5.0.1.tar.bz2 \ http://jaist.dl.sourceforge.net/sourceforge/gimp-print/gutenprint-5.0.1.tar.bz2 # rpmbuild --ba /usr/src/redhat/SPECS/gutenprint-el4.spec -D _with_rhel4=1 # cd /usr/src/redhat/RPMS/(i386|x86_64) # rpm -e gimp-print-utils # rpm -Uvh gutenprint-5.0.1-1.el4.(i386|x86_64).rpmv5.0.1向けと書いたけど、SPECファイル3行目/9行目の下記バージョン番号を書き換えれば、v5.1.x系でも多分利用可能
Version: 5.0.1 %define dotversion 5.0v5.2.xの場合、上記の修正に加えて493行目に一文を追加する。
%{_pkglibdir} %{_localedir} ←この行を追加 %{_gutenprintdir}
# yum install -y cups-devel libtiff-devel foomatic # tar zxf gutenprint-5.0.1-rpm-el5.tgz # mv gutenprint-el5.spec /usr/src/redhat/SPECS # wget -O /usr/src/redhat/SOURCES/gutenprint-5.0.1.tar.bz2 \ http://jaist.dl.sourceforge.net/sourceforge/gimp-print/gutenprint-5.0.1.tar.bz2 # rpmbuild --ba /usr/src/redhat/SPECS/gutenprint-el5.spec -D _with_rhel5=1 # cd /usr/src/redhat/RPMS/(i386|x86_64) # rpm -e gimp-print-utils # rpm -Uvh gutenprint-5.0.1-1.el5.(i386|x86_64).rpmv5.0.1向けと書いたけど、SPECファイル3行目/9行目の下記バージョン番号を書き換えれば、v5.1.x系でも多分利用可能
Version: 5.0.1 %define dotversion 5.0v5.2.xの場合、上記の修正に加えて493行目に一文を追加する。
%{_pkglibdir} %{_localedir} ←この行を追加 %{_gutenprintdir}
# yum install bitmap-fonts-cjk # yum install fonts-japanesexfsデーモンの再起動
# /sbin/service xfs restart
# cat /etc/SuSE-release
$ su
# modprobe dm-mod
# apt-get update
# apt-get install lvm-common lvm2
# lndir /lib/lvm-200/ /usr/sbin/
# vgscan && vgchange -a y
# cd /dev/mapper # ls VolGroup00-LogVol00 VolGroup00-LogVol01 control
# mkdir /mnt/centos # mount -t ext3 /dev/mapper/VolGroup00-LogVol00 /mnt/centos
# umount /mnt/centos