權限管理:
r:讀
w:寫
x:執行
三類使用者:
u:使用者自己(user/owner)
g:屬組(group)
o:其他人(other)
chown:改變檔案屬主(管理者才可以使用)
chown USERNAME file,...
-R:修改目錄以及内部檔案的屬主
--reference=/path/to/somefile file ...
chgrp GRPNAME file ...
-R:
--reference=/path/to/somefile file ...
chmod:修改檔案權限
-R
--reference=/path/to/somefile file ...
修改某類使用者或某些使用者權限:
u,g,o,a
chmod 使用者類别+|-MODE file,...
注意:chown 7 file 這裡的7相當于007,系統會自動往前補0
示例:手動建立一個完整可登陸使用者
1.修改passwd檔案
[root@logstach ~]# vi /etc/passwd
(ctrl +G 跳到最後一行,按次序填寫:
使用者名:密碼(這裡用x表示):UID:GID:注釋::家目錄:shell)
single:x:2000:2000::/home/single:/bin/bash
2.修改group檔案添加組
[root@logstach ~]# vi /etc/group
single:x:2000:
使用者名:密碼:組id:附加組
3.生成md5密碼并配置shadow檔案
[root@logstach ~]# openssl passwd -1 -salt 12345678 123456
$1$12345678$a4ge4d5iJ5vwvbFS88TEN0
生成密碼格式為:openssl passwd -1(這個是一,指定用md5加密) -salt 鹽的8位字元 密碼
具體使用者可以man sslpasswd
[root@logstach ~]# vi /etc/shadow
single:$1$12345678$a4ge4d5iJ5vwvbFS88TEN0:16795:0:99999:7:::
使用者:密碼:最後一次改動時間(`date +%s`/86400):最短使用期限:最長使用期限:警告時間:::
4.建立家目錄并修改權限和拷貝/etc/skel/下的檔案到家目錄
[root@zh-usacloud04 inc]# cp -R /etc/skel/ /home/single
[root@logstach ~]# chown -R single:single /home/single
5.測試登入
Xshell:\> ssh 192.168.1.148
Connecting to 192.168.1.148:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Sat Dec 26 14:12:51 2015 from 192.168.1.23
[single@logstach ~]$
umask:遮罩碼
umask:023
檔案:666-023=643
目錄:777-023=754
注意:檔案預設不能具有執行權限,如果算得的結果中有執行權限,則将其結果加1
登入式shell:
正常某終端登入
su - USERNAME
su -l USERNAME (完全切換)
非登入式shell:
su USERNAME
圖形終端下打開指令視窗
自動執行的shell 腳本
bash的配置檔案:
全局配置:
/etc/profile 、/etc/profile.d/*.sh 、/etc/bashrc
個人配置:
~/.bash_profile、~/.bashrc
profile類檔案:
定義環境變量
運作指令或腳本
bashrc類檔案:
定義本地變量
定義指令别名
登入shell讀取配置檔案:
/etc/profile-->/etc/profile.d/*.sh-->~/.bash_profile-->~/.bashrc-->/etc/bashrc
非登入式shell讀取配置檔案
~/.bashrc-->/etc/bashrc-->/etc/profile.d/*.sh
bash:腳本解釋器
本文轉自biao007h51CTO部落格,原文連結:http://blog.51cto.com/linzb/1729177 ,如需轉載請自行聯系原作者