
Linuxでテキストファイルを編集します。nanoコマンドは、GUIのテキストエディタを使用している感覚でテキストファイルの編集を行うことができます。
テキストファイルを編集する!
nanoコマンドでファイルを編集します。
$ ssudo nano /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
[ Read 10 lines ]
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos M-U Undo M-A Mark Text
^X Exit ^R Read File ^\ Replace ^U Uncut Text ^T To Spell ^_ Go To Line M-E Redo M-6 Copy Text
nanoコマンドの操作は、画面の下段に表示されているところが、便利なところです。
テキストファイルを保存して終了する!
テキストファイルの編集は、「Ctrl-X」で終了します。ファイルの書き出しの要否を聞かれるので「Y」キーを押します。
... Save modified buffer? (Answering "No" will DISCARD changes.) Y Yes N No ^
「Enter」キーを押して、ファイルを保存して、nanoコマンドを終了します。
... File Name to Write: /etc/sysctl.conf ^G Get Help M-D DOS Format M-A Append M-B Backup File ^C Cancel M-M Mac Format M-P Prepend ^T To Files
おわりに
Linuxでは、nanoコマンドは基本的に必ずインストールされているので、viになれていない間は、nanoコマンドを使用してもよいでしょう。
関連記事
関連書籍(Amazon)
