linux

Ubuntu上で日本語ファイル名のディレクトリをwindows用にzipファイルにする | make a zip file from a japanease name directory for windows on linux

for i in * do test -d "$i" || continue echo "$i" convmv -r --notest -f utf8 -t cp932 "$i"/* &&\ zip -jr "$i".zip "$i"/* &&\ rm -rf "$i" done

md raid hddのセットを別のPCへ取り付ける | how to attach md raid1 hdds to the other pc or server

PCへ取り付ける md raid1 の hdd のセットは /dev/sdb, /dev/sdc とする|attaching hdds are supposed to /dev/sdb and /dev/sdc raid hdd の 確認 | confirm raid hdds status sudo mdadm --examine --scan /dev/sdb /dev/sdc ARRAY /dev/md0 level=raid1 n…

bashプロンプトに色を付ける|set color of prompt

プロンプトを緑色に設定する|set color of prompt to green GREEN="0;32" START_COLOR="\e[${GREEN}m" END_COLOR="\e[0m" export PS1="${START_COLOR}[\u@\h \W]\$${END_COLOR} " 色を変えたい部分を ${START_COLOR} と ${END_COLOR} で囲む|change color be…

bashの履歴を複数端末で共有する|How to share bash history in multiple terminals

~/.bashrc に以下を設定|add follow settings in ~/.bashrc # Make bash append rather than overwrite the history on disk shopt -s histappend # Whenever displaying the prompt, write the previous line to disk and read unread history lines export…

1日毎に交互に2つ処理を実行する|do two commands day by day

現在日時を1970年からの日数に変換し、その数が偶数、奇数で処理を振り分ける|calculate days from 1970. when the days is even, do one command and when the days is odd, do another command. #!/bin/sh set -u A=`date +%s` echo $A is seconds from 19…

install yum-cron

デフォルトの yum-updated があまり良くないので、代わりに yum-cron をインストールして利用する stop yum-updated sudo /sbin/service yum-updated stop sudo /sbin/chkconfig yum-updatesd off install sudo yum install yum-cron sudo /sbin/chkconfig y…

vsftpdで特定ユーザーのみchrootでftp loginを許可する設定

install sudo yum install vsftpd 自動起動 sudo /sbin/chkconfig vsftpd on 匿名ユーザーの禁止 /etc/vsftpd/vsftpd.conf に以下を追加 anonymous_enable=NO 特定のユーザーのみftpを許可 /etc/vsftpd/vsftpd.conf に以下を追加 userlist_deny=NO /etc/vsft…

aliases 設定

root宛てのメールを自分のメールアドレスへ転送する設定 /etc/aliases に以下を追記 root: hoge@mailaddress.com 設定の再読み込み sudo /usr/bin/newaliases

sshd 設定

sshd をセキュアに運用するための設定 /etc/ssh/sshd_config を編集 # allow only Protocol2 Protocol 2 # deny root login PermitRootLogin no # allow only specify users AllowUsers <accountname> <accountname> ... 設定の再読み込み sudo /sbin/service sshd reload</accountname></accountname>

CentOS 5 に samba をインストール

インストール, 起動設定 sudo yum install samba sudo /sbin/chkconfig smb on ユーザーの追加 sudo pdbedit -a ユーザー名 既存のlinuxユーザー名で追加 パスワードはPAMとは別に設定する 文字コードはサーバーの文字コードがUTF-8であれば、デフォルトの設…

Intel D945GCLF に CentOS 5をインストール

Intel D945GCLF http://www.intel.com/products/motherboard/D945GCLF/index.htm D945GCLF に CentOS5 をインストールするとNICが認識しない。それ以外は問題なし。 D945GCLF の Product Specification を見ると LAN Subsystem は Realtek RTL8102EL device …

シェルスクリプトの二重起動禁止|how to forbid to start same process in shell script

pgrep コマンドを利用 use pgrep command http://www.linux.or.jp/JM/html/procps/man1/pgrep.1.html シェルスクリプト名のみ(引数は考慮しない)で二重起動を禁止 #!/bin/sh if [ `pgrep -fo $0` -ne $$ ] then echo $0' is already exist.' exit fi echo $0…

Fedora Core 5 への Samba 3.0 インストール&設定

インストール OSインストール時にインストール or yum でインストール sudo yum install samba ファイル名の文字コードセット(日本語)の設定 /etc/samba/smb.conf の [global] に以下を追加 OS の文字コードが EUC-JPの場合、unix chasert を eucJP-ms に設…