File Permission, add user and group for Ubuntsu Samba Server

1. Permission 設定
$ sudo chown -R nobody:nogroup /mnt/sales ← 共有ディレクトリ所有者変更例
$ sudo chmod -R 777 /mnt/sales  ← 共有ディレクトリPermission 設定例
$ sudo ls /mnt/sales  ← Permission 確認コマンド

2.ユーザー設定
     a. グループを追加
$ sudo groupadd doriftars
     b. ユーザー・パスワードの追加
            以下はコマンドですが、GUIで設定する方が簡単
$ sudo useradd -s /sbin/nologin user.name
$ sudo passwd user.name

     c. Sambaに先ほど追加したユーザー・パスワードのを追加  ← これ大事 忘れるとアクセスできない
$ pdbedit -a user.name
     d. グループにユーザーを追加
$ gpasswd -a  user.name group.name


User setup Note -----------------------------------
ユーザーをグループに追加したり削除するには3種類のコマンドが有ります。
     gpasswd -通常こちらを使う -GNU/Linux only command
     usermod -全てのユーザーを記載する必要がある  -can use for macOS X or BSD
     vigr
     gpasswd -a  user.name group.name  -add user
     gpasswd -d user.name group.name  -delete user
     gpasswd が有利なポイント
     gpasswd GROUP -a username
     オプションの引数にユーザー名を入れる点。これでミスが減りやすいし、グループに対して◯◯すると明確なので、ユーザーのプライマリグループをウッカリ変えてしまうことがなくて助かります。
     gpasswd コマンドを使うメリット
     gpasswd コマンドは、引数(グループ・ユーザー)の区別が明確でミスが少ない。オペミスすると即死する系では非常に友好的に使えるはず

----------------------------
Permission の設定 Note
If the owner read & execute bit are on, then the permissions are:
-r-x------

There are three types of access restrictions:

Permission
Action
chmod option

read (view) r or 4
write (edit) w or 2
execute (execute) x or 1
There are also three types of user restrictions:

User
ls output

owner
-rwx------

group
----rwx---

other
-------rwx
Folder/Directory Permissions

Directories have directory permissions. The directory permissions restrict different actions than with files or device nodes.
Permission
Action
chmod option

read (view contents, i.e. ls command) r or 4
write (create or remove files from dir) w or 2
execute (cd into directory) x or 1

read restricts or allows viewing the directories contents, i.e. ls command
write restricts or allows creating new files or deleting files in the directory. (Caution: write access for a directory allows deleting of files in the directory even if the user does not have write permissions for the file!)
execute restricts or allows changing into the directory, i.e. cd command

Comments

Popular posts from this blog

Google: How to disable Auto Licensing

Microsoft 365で多要素認証の設定を解除したい