189
180

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

linux起動時に自動的に実行するコマンド(プログラム)の設定

Last updated at Posted at 2015-11-06

~/.bashrc の中に書き込むのとは別に、

/etc/rc.local の中に書き込んでおけば、起動時に自動的に実行してくれる。

/etc/rc.local に書き込むためには、root権限が必要なので、

sudo vi /etc/rc.local 
で編集する。

たとえば、

rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount -t ext4 -o noatime /dev/disk/by-id/dm-name-isw_djicghdigb_work1p1 /work1
exit 0

mount -t ext4 -o noatime /dev/disk/by-id/dm-name-isw_djicghdigb_work1p1 /work1
を書いておくことで、起動時に毎回、外付けHDDをマウントしてくれる。

root権限を使うので、注意が必要。

注記
上記は、例としてマウントコマンドを書いたが、本来、起動時のマウントは/etc/fstabに書くべきである。
https://askubuntu.com/questions/119467/mount-ntfs-on-ubuntu-start-up-rc-local-vs-fstab

189
180
5

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
189
180

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?