LoginSignup
15

More than 5 years have passed since last update.

さくらインターネットのレンタルサーバーのシェルをcshからzshに変更する

Last updated at Posted at 2014-05-16

さくらインターネットのレンタルサーバー(スタンダードプラン)のログインシェルのデフォルトはcsh(C Shell)なので、zsh(Z shell)に変更した備忘録。
※シェルの種類に関しては → シェル関係の覚書

1)ログインシェルの変更

デフォルトのシェル環境を確認。
/bin/csh と出力され、cshを使用中なのが分かる。

$ echo $SHELL
/bin/csh

使用可能(インストール済み)なシェルの一覧を確認。
/usr/local/bin/zsh とあるので、さくらレンタルサーバーではzshがインストール済み。

$ cat /etc/shells
# $FreeBSD: release/9.1.0/etc/shells 59717 2000-04-27 21:58:46Z ache $
#
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
/usr/local/bin/rbash
/usr/local/bin/zsh
/usr/local/bin/rzsh
/usr/bin/passwd

ログインシェルをzshに切り替える。

$ chsh -s /usr/local/bin/zsh

パスワードを求められるので、自分のサーバパスワードを入力。

Password:

更新メッセージが出力されれば完了。

chsh: user information updated

2).zshrcの作成

exit コマンドでログアウトし、再度さくらのレンタルサーバーにログイン。
シェルを変更して初めてのログインなので、下記のメッセージが表示される。
zshの設定ファイル .zshrc を作成したいので、メッセージに従い 0 キーを実行。

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses ---

以下のコマンドで、 .zshrc ファイルが作成されているのを確認。

$ ls -al

3).zshrcの設定

vimでzshの設定ファイル .zshrc を開く。(vimをインストールしていない場合は vi

$ vim ~/.zshrc

i キーで挿入モードにして、以下を追加。(Macなら普通に Command + c 、Windowsなら Shift + Insert 、もしくは マウスの右クリック でペースト)
※下記は最低限の設定。

.zshrc
# 日本語が文字化けしないよう文字コードを指定
export LANG=ja_JP.UTF-8

# zshにメールチェックをさせない
export MAILCHECK=0

esc:wq キーで保存。以下のコマンドで実行。

$ source ~/.zshrc

再度シェル環境を確認。
/usr/local/bin/zsh と出力されればログインシェルがzshに変更されている。

$ echo $SHELL
/usr/local/bin/zsh

補足

※上記の export MAILCHECK=0 の設定で、zshを実行するたびに下記メッセージが表示されるのを防ぐ事ができる。

zsh: permission denied: /var/mail/example

参考:さくらの共有サーバーでシェルを zsh に変更してから、zsh: permission denied: /var/mail/youraccount と怒られないようにする

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15