1. / etcディレクトリを表示します。文字以外で始まり、その後に文字とその他のファイルまたは任意の長さと文字のディレクトリが続きます。
[root @ txcentos7 etc] #touch 15 [root @ txcentos7 etc] #touch 1aa [root @ txcentos7 etc] #ls -d / etc / [^ [:alpha:]] [[:alpha:]] * / etc / 1a / etc / 1aa
2./etcディレクトリ内のpで始まり数字以外で終わるすべてのファイルまたはディレクトリを/ tmp / mytest1ディレクトリにコピーします。
[root @ txcentos7 tmp] #cp -a / etc / p * [^ 0-9] / tmp / mytest1 / [root @ txcentos7 tmp] #ls / tmp / mytest1 / pam.d passwd- plymouth popt.d ppp printcap profile.d python passwd pki pm postfixprelink.conf.dプロファイルプロトコル
3. / etc / issueファイルの内容を大文字に変換し、/ tmp /issue.outファイルに保存します
[root @ txcentos7 tmp] #cat / etc / issue | tr "az" "AZ" >> / tmp / ussue.out [root @ txcentos7 tmp] #cat /tmp/ussue.out \ S KERNEL \ R ON AN \ M
4.ユーザーおよびグループ管理コマンドの使用方法を要約して説明し、次の演習を完了してください。
(1)GIDが2019のグループディストリビューションを作成します。
[[email protected] / root] groupadd -g2019ディストリビューション
(2)ID番号が1005のユーザーmandrivaを作成します。基本グループはディストリビューションです。
[[email protected] / root] useradd mandriva -u 1015 -g distro [[email protected] / root] cat / etc / passwd | egrep mandriva mandriva:x:1015:2019 :: / home / mandriva:/ bin / bash [[email protected] / root] groups mandriva mandriva:distro
(3)ID番号が1100で、ホームディレクトリが/ home / linuxであるユーザーmageiaを作成します。
[root @ txcentos7〜] #useradd mageia -d / home / linux -u 1100 [root @ txcentos7〜] #cat / etc / passwd | egrep mageia mageia:x:1100:1100 :: / home / linux:/ bin / bash [root @ txcentos7 home] #ls / home linux mandriva tommy tt username wang wang1 wwwww
(4)ユーザーmageiaにパスワードを追加します。パスワードはmageeduで、ユーザーパスワードを7日後に期限切れになるように設定します。
[root @ txcentos7 home] #echo mageedu | passwd --stdinmageia ユーザーmageiaのパスワードを変更します。 passwd:すべての認証トークンが正常に更新されました。 [root @ txcentos7 home] #passwd mageia -x7 ユーザーmageiaのエージングデータを調整します。 passwd:成功 #列出密码有効率期: [root @ txcentos7 home] #chage -l mageia 最後のパスワード変更:2021年3月22日 パスワードの有効期限:2021年3月29日 パスワードの非アクティブ:なし アカウントの有効期限:なし パスワード変更間の最小日数:0 パスワード変更までの最大日数:7 パスワードの有効期限が切れるまでの警告日数:7
(5)、mandrivaを削除しますが、ホームディレクトリは保持します。
[root @ txcentos7 home] #userdel mageia
(6)ID番号が2002で、基本グループがディストリビューションで、追加のグループpeguinであるユーザーSlackwareを作成します。
[root @ txcentos7 home] #groupadd peguin [root @ txcentos7 home] #useradd slackware -u 2002 -g distro -G peguin [root @ txcentos7 home] #groups slackware slackware:distro peguin
(7)、slackwareのデフォルトシェルを/ bin / tcshに変更します。
[root @ txcentos7 home] #usermod -s / bin / tcsh slackware [root @ txcentos7 home] #cat / etc / passwd | egrep slackware slackware:x:2002:2019 :: / home / slackware:/ bin / tcsh
(8)ユーザーslackwareのグループadminを追加し、ログインしないように設定します。
[root @ txcentos7 home] #id slackware uid = 2002(slackware)gid = 2019(distro)groups = 2019(distro)、2020(peguin)、2021( admins )[root @ txcentos7 sbin] #usermod slackware -s / sbin / nologin [root @ txcentos7 sbin] #echo mageedu | passwd --stdinslackware ユーザーslackwareのパスワードを変更します。 passwd:すべての認証トークンが正常に更新されました。 警告!リモートSSHサーバーがX11転送要求を拒否しました。 最終ログイン:Mon Mar 22 22:02:57 2021 from111.196.233.254 このアカウントは現在利用できません。 接続が閉じています...ソケットが閉じています。 接続は外部ホストによって閉じられました。
5.ユーザーuser1、user2、およびuser3を作成します。/ data /の下にディレクトリテストを作成します
(1)、ディレクトリ/ data / testの所有者、グループはuser1です
[root @ txcentos7 data] #chown user1:user1 test [root @ txcentos7 data] #ll -t total 28 drwxr-xr-x 2 user1 user1 4096 Mar 22 22:05 test
(2)ディレクトリの所有者とグループが変更されていない場合、User2はファイルに対する読み取りおよび書き込み権限を持っています
[root @ txcentos7 data] #chmod o + rw test [root @ txcentos7 data] #ll -t total 28 drwxr-xrwx 2 user1 user1 4096 Mar 22 22:05 test [root @ txcentos7 data] #su user2 [user2 @ txcentos7 data] $ cd / data / [user2 @ txcentos7 data] $ ls 1111 laji lajixiangnianling.txtスクリプトテストvkokdfs [user2 @ txcentos7 data] $ cd test / [user2 @ txcentos7 test] $ touch 10.txt [user2 @ txcentos7 test ] $ ll 合計0 -rw-rw-r-- 1 user2 user2 0 Mar 22 22:11 10.txt
(3)User1は/ data / testディレクトリにファイルa1.sh、a2.sh、a3.sh、a4.shを作成し、user1とrootを除くすべてのユーザーが1.sh、2.shファイルを削除できないように設定します。また、すべてのユーザーがa3.sh、a4.shを削除することはできません。
[user1 @ txcentos7 test] $ touch a {1.2..4} \ 。sh [user1 @ txcentos7 test] $ ls a1.sh a2.sh a3.sh a4.sh すべてのユーザーを削除できない場合、通常のユーザーはcahttrを実行できません。 + iコマンド、他の方法はありますか? [root @ txcentos7 test] #chattr + i a1.sh [root @ txcentos7 test] #chattr + i a2.sh [root @ txcentos7 test] #lsattr ------------- e-- ./a3.sh ------------- e-- ./a4.sh ---- i -------- e-- ./a1.sh --- -i -------- e-- ./a2.sh
(4)追加のグループuser1をuser3に追加し、user1が/ data / testディレクトリとその下のすべてのファイルにアクセスしないように要求します。
[root @ txcentos7 test] #usermod user3 -aG user1 [root @ txcentos7 test] #id user3 uid = 2006(user3)gid = 2006(user3)groups = 2006(user3)、2004(user1) setfacl -mu:user1: -/ data / test / [root @ txcentos7 test] #su user1 [user1 @ txcentos7 test] $ cd / data / test / bash:cd:/ data / test /:アクセスが拒否されました
(5)/ data / testディレクトリとその下のすべてのファイルのacl権限をクリーンアップします
[root @ txcentos7 test] #setfacl -R -b / data / test /