LoginSignup
1
1

More than 3 years have passed since last update.

linuxを簡単に使えるようにWindowsでおなじみの効果イコールをする為のコマンドのメモ

Last updated at Posted at 2019-07-04

個人的なメモ書き

linuxを簡単に使えるように極力1行でWindowsでおなじみの効果イコールをする為のコマンドのメモ

ディスク関連のコマンド

df 

ラズベリーパイでの例

$ df
ファイルシス   1K-ブロック    使用   使用可 使用% マウント位置
/dev/root         30787388 4007108 25497180   14% /
devtmpfs            494912       0   494912    0% /dev
tmpfs               499520       0   499520    0% /dev/shm
tmpfs               499520   12888   486632    3% /run
tmpfs                 5120       4     5116    1% /run/lock
tmpfs               499520       0   499520    0% /sys/fs/cgroup
/dev/mmcblk0p1       41853   22685    19168   55% /boot
tmpfs                99904       0    99904    0% /run/user/1001

ディスクをマウントする

mount -o uid=1001,gid=1002 /dev/sdb1 /mnt/ssddata

ユーザーIDやグループIDがわからない場合はこうする

ユーザーIDを見る例

whoami | id

グループID一覧を見る例

cat /etc/group

ディスクキャッシュとディスクを同期してキャッシュを開放する

sudo sync && sysctl -w vm.drop_caches=3

windowsアップデートと同じことをする

セキュリティーアップデートのみ

sudo apt update && sudo apt upgrade

ソフトウェアのアップデート

sudo apt update && sudo apt dist-upgrade

ディスクをマウント等の関連

ディスクの一覧をみる

sudo fdisk -l

UUIDの確認

sudo blkid

注意:
mountで /dev/sdbなどでマウントを行うと再起動したときに /dev/sdaと/dev/sdbなどの順番が入れ替わった時に
マウントポイントがかわってしまうのでUUIDを利用してマウントするほうが間違えなくて良い。
この場合 /etc/fstab を書き換えて mount -a とすると即座に反映される

起動時にディスクをマウントする場合

注意:テストを行わないでマウントをするのはあまり推奨しない

 proc            /proc           proc    defaults          0       0
 PARTUUID=2374e4bc-01  /boot           vfat    defaults          0       2
 PARTUUID=2374e4bc-02  /               ext4    defaults,noatime  0       1

 # ssd hdd usb
 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX mnt/ssd ext4 defaults 0 0

 # a swapfile is not a swap partition, no line here
 #   use  dphys-swapfile swap[on|off]  for that

uuid UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX mnt/ssd ext4 defaults 0 0 を
/et/fstab に追加する

注意! 間違えるとOSが起動しなくなる

Windowsのスタートアップにあたる仕組み

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

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

exit 0

exit 0より前に必要なスクリプトを組み込んだりコマンドを実行すると良いです。
しかし、サービスとして扱うものとは別です。
こちらで起動したものは安全な終了が保証されない場合がありますので要注意

1
1
3

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
1
1