標籤:linux基礎
linux和windows互傳檔案
第一種:在linux主機上下載lrzsz軟體包
1、yum install lrzsz
2、通過rz命令上傳window的檔案到linux主機上
用過sz 檔案名稱下載到window下
使用lrzsz不能傳輸檔案夾,只能打包將其下載或者上傳
第二種:在window上下載winscp.exe
輸入linux主機的使用者名稱,密碼即可傳輸
使用者設定檔和密碼設定檔
1、/etc/passwd、/etc/shadow兩個檔案需要保留,若是刪除則系統使用者登入失敗
2、/etc/passwd檔案由":"分割為7段
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
第一段:代表使用者名稱
第二段:存放使用者的口令,用x表示,存放在/etc/shadow中
第三段:使用者的UID;0是超級使用者(root)的標識號,1~499由系統保留,作為管理帳號,普通使用者的標識號從500開始,如果我們自訂建立一個普通使用者,你會看到該賬戶的標識號是大於或等於500的。
第四段:使用者的GID
第五段:記錄說明;備忘
第六段:使用者的家目錄
第七段:shell;如果你想建立一個帳號不讓他登入,那麼就可以把該欄位改成/sbin/nologin,預設是/bin/bash.
[[email protected] ~]# cat /etc/shadow
通過":"分為9段root:$6$ERIz.x2T5fs8c8nf$vULK7LaYfyxZQccbLk7.lL0DJGgQIMFUN37nkssdvrO6qp9OakbreQYFMw6O3QWYQcF3dZQWWr/E6ceU58//m0:17411:0:99999:7:::
第一段:使用者名稱,跟/etc/passwd對應
第二段:使用者密碼,這個才是該帳號的真正的密碼,不過這個密碼已經加密過了,但是有些駭客還是能夠解密的。所以,該檔案屬性設定為000,但是root賬戶是可以訪問或更改的。
第三段:上次更改密碼的日期,這個數字是這樣計算得來的,距離1970年1月1日到上次更改密碼的日期,例如上次更改密碼的日期為2012年1月1日,則這個值就是 ‘365 x (2012-1970) + (2012-1970)/4 + 1 = 15341’. 因為如果是閏年,則有366天。
第四段:要過多少天才可以更改密碼,預設是0,即不限制。
第五段:密碼多少天后到期。即在多少天內必須更改密碼,例如這裡設定成30,則30天內必須更改一次密碼,否則將不能登入系統,預設是99999,可以理解為永遠不需要改。
第六段:密碼到期前的警告期限,若這個值設定成7,則表示當7天后密碼到期時,系統就發出警告告訴使用者,提醒使用者他的密碼將在7天后到期。
第七段:帳號失效期限。你可以這樣理解,如果設定這個值為3,則表示:密碼已經到期,然而使用者並沒有在到期前修改密碼,那麼再過3天,則這個帳號就失效了,即鎖定了。
第八段:帳號的生命週期,跟第三段一樣,是按距離1970年1月1日多少天算的。它表示的含義是,帳號在這個日期前可以使用,到期後帳號作廢。
第九段:作為保留用的,沒有什麼意義。
使用者組管理
1、新增一個組
命令 : groupadd
文法 : groupadd [-g GID] groupname
[[email protected] ~]# cat /etc/group| grep test1
test1:x:506:
[[email protected] ~]# groupadd -g 111 test2
[[email protected] ~]# cat /etc/group| grep test2
test2:x:111:
2、刪除群組
[[email protected] ~]# groupdel test1
3、新增使用者
useradd 使用者
-u 自訂UID
-g 使其屬於已經存在的某個組,後面可以跟組id, 也可以跟組名
-d 自訂使用者的家目錄
-M 不建立家目錄
-s 自訂shell
[[email protected] ~]# useradd -u511 -g111 -M -s /sbin/nologin gz2
[[email protected] ~]# id gz2
uid=511(gz2) gid=111(test2) groups=111(test2)
4、刪除使用者
-r:節目錄一起刪除
userdel -r 使用者
5、passwd
更改使用者密碼:passwd 使用者
使用者管理
1、使用su - 使用者訪問切換
如:su - test
切換到了test使用者的家目錄下;
2、sudo
若su - root都能切換到root下的話,改了root密碼則很不安全,這時需要用到sudo,使用自己使用者的密碼後,用root身份來運行命令
visudo
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
test ALL=(ALL) ALL
[[email protected] daemon]# su - test
[[email protected] ~]$ sudo ls /root/
[sudo] password for test:
2.txt anaconda-ks.cfgget-pip.py test
將使用者加到linux組,然後對組做許可權控制
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
%op ALL=(ALL) ALL
需求一:只允許使用普通賬戶登陸,而普通賬戶登入後,可以不輸入密碼就能sudo切換到root賬戶
visudo最後加入3行
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
User_Alias USER_SU = test, test1
Cmnd_Alias SU = /bin/su
USER_SU ALL=(ALL) NOPASSWD: SU
[[email protected] ~]$ sudo su -
usermod 用法:
[[email protected] ~]# usermod -a -G op test1
[[email protected] ~]# id test1
uid=509(test1) gid=509(test1) groups=509(test1),111(op)
[[email protected] ~]# usermod -g op test1
[[email protected] ~]# id test1
uid=509(test1) gid=111(op) groups=111(op)
本文出自 “探索發現新事物” 部落格,請務必保留此出處http://shenj.blog.51cto.com/5802843/1975686
linux和windows互傳檔案、使用者設定檔和密碼設定檔、使用者組管理、使用者管理