Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
171
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Organization

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

~/.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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
171
Help us understand the problem. What are the problem?