lonux基礎(chǔ)命令使用

1、顯示/etc目錄下,以非字母開(kāi)頭黑低,后面跟了一個(gè)字母以及其他任意長(zhǎng)度任意字符的文件或目錄

[root@CentOS7 ~]# ls -a /etc/ |grep ^[^[:alpha:]].[[:alpha:]]
.pwd.lock
.updated

2、復(fù)制/etc目錄下所有以p開(kāi)頭尽楔,以非數(shù)字結(jié)尾的文件或目錄到/tem/mytest1 目錄中

[root@centos7-master ~]# mkdir -p /tem/mytest1 
[root@centos7-master ~]# cd /etc/ 
[root@centos7-master etc]# cp -a ` ls | grep ^p.*[^[:digit:]]$` /tem/mytest1
[root@centos7-master etc]# ls /tem/mytest1
pam.d   passwd-  plymouth  popt.d   ppp             printcap  profile.d  python
passwd  pki      pm        postfix  prelink.conf.d  profile   protocols

3投储、將/etc/issue文件中的內(nèi)容轉(zhuǎn)換為大寫(xiě)后保存至/tmp/issue.out文件中

[root@centos7-master ~]# tr [:lower:] [:upper:] < /etc/issue > /tmp/issue.out
[root@centos7-master ~]# cat /tmp/issue.out
\S
KERNEL \R ON AN \M

4第练、請(qǐng)總結(jié)描述用戶(hù)和組管理類(lèi)命令的使用方法并完成以下練習(xí):

(1)阔馋、創(chuàng)建組distro,其GID為2019;

[root@centos7-master ~]#  groupadd distro -g 2019
[root@centos7-master ~]#  getent group distro
distro:x:2019:

(2)、創(chuàng)建用戶(hù)mandriva,其ID號(hào)為1005;基本組為distro;

[root@centos7-master ~]#  useradd mandriva -u 1005 -g distro
[root@centos7-master ~]# getent passwd mandriva
mandriva:x:1005:2019::/home/mandriva:/bin/bash

(3)娇掏、創(chuàng)建用戶(hù)mageia,其ID號(hào)為1100呕寝,家目錄為/home/linux;

[root@centos7-master ~]#  useradd mageia -u 1100 -d /home/linux
[root@centos7-master ~]#  getent passwd mageia
mageia:x:1100:1100::/home/linux:/bin/bash

(4)、給用戶(hù)mageia添加密碼婴梧,密碼為mageedu,并設(shè)置用戶(hù)密碼7天后過(guò)期

[root@centos7-master ~]# echo mageia:mageedu |chpasswd
[root@centos7-master ~]# passwd -x 7 mageia
Adjusting aging data for user mageia.
passwd: Success
[root@centos7-master ~]# getent shadow mageia
mageia:$6$nrH9d/K06JmpAPV$4L30icSaWUu1Rt4pc99h1a4Wq7xWKlhtr2mHOaLXDEpkirgNBFe.HcWeSnemE8ZkhlDKG4y8IuJmywxeVLJ9R/:18683:0:7:7:::

(5)下梢、刪除mandriva, 但保留其家目錄;

[root@centos7-master ~]# userdel mandriva
[root@centos7-master ~]# id mandriva
id: mandriva: no such user
[root@centos7-master ~]# ls /home/
linux  mandriva

(6)、創(chuàng)建用戶(hù)slackware,其ID號(hào)為2002塞蹭,基本組為distro, 附加組peguin;

[root@centos7-master ~]# groupadd peguin
[root@centos7-master ~]# useradd -u 2002 -g distro -G peguin slackware
[root@centos7-master ~]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)

(7)孽江、修改slackware的默認(rèn)shell為/bin/tcsh;

[root@centos7-master ~]# usermod -s /bin/tcsh  slackware
[root@centos7-master ~]# getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh

(8)、為用戶(hù)slackware新增附加組admins,并設(shè)置不可登陸番电。

[root@centos7-master ~]# groupadd admins
[root@centos7-master ~]# usermod -s /bin/false -aG admins  slackware
[root@centos7-master ~]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)
[root@centos7-master ~]# getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/false

5岗屏、創(chuàng)建用戶(hù)user1、user2漱办、 user3这刷。 在/data/ 下創(chuàng)建目錄test

[root@centos7-master ~]# useradd user1
[root@centos7-master ~]# useradd user2
[root@centos7-master ~]# useradd user3
[root@centos7-master ~]# mkdir -p /data/test
[root@centos7-master ~]# ll -d /data/test/
drwxr-xr-x. 2 root root 6 Feb 25 11:24 /data/test/

(1)、目錄/data/test屬主娩井、 屬組為user1

[root@centos7-master ~]# chown user1:user1 /data/test/
[root@centos7-master ~]# ll -d /data/test/
drwxr-xr-x. 2 user1 user1 6 Feb 25 11:24 /data/test/

(2)暇屋、在目錄屬主、屬組不變的情況下洞辣,user2對(duì)文件有讀寫(xiě)權(quán)限

[root@centos7-master test]# chmod g+w /data/test/
[root@centos7-master test]# gpasswd -a user2 user1
Adding user user2 to group user1

(3)咐刨、user1在/data/test目錄 下創(chuàng)建文件a1.sh,a2.sh,a3.sh,a4.sh,設(shè)置所有用戶(hù)都不可刪
除a1.sh, a2.sh文件、除了user1及root之外扬霜,所有用戶(hù)都不可刪除a3.sh,a4.sh

[user1@centos7-master test]$ touch a{1..4}.sh
[user1@centos7-master test]$ ls
a1.sh  a2.sh  a3.sh  a4.sh

[root@centos7-master test]# chmod o+t /data/test/
[root@centos7-master test]# ls -ld /data/test/
drwxrwxr-t. 2 user1 user1 48 Feb 26 09:46 /data/test/

[root@centos7-master test]# chattr +i a3.sh a4.sh
[root@centos7-master test]# rm -f a3.sh a4.sh
rm: cannot remove ‘a(chǎn)3.sh’: Operation not permitted
rm: cannot remove ‘a(chǎn)4.sh’: Operation not permitted


(4)定鸟、user3增加附加組user1,同時(shí)要求user1不能訪(fǎng)問(wèn)/data/test目錄及其下所有文件

[root@centos7-master test]# gpasswd -a user3 user1
Adding user user3 to group user1
[root@centos7-master test]# chmod  u=- /data/test/

(5)、清理/data/test目錄及 其下所有文件的acd權(quán)限

setfacl -R -b /data/test/
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末畜挥,一起剝皮案震驚了整個(gè)濱河市仔粥,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖躯泰,帶你破解...
    沈念sama閱讀 219,539評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件谭羔,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡麦向,警方通過(guò)查閱死者的電腦和手機(jī)瘟裸,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,594評(píng)論 3 396
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)诵竭,“玉大人话告,你說(shuō)我怎么就攤上這事÷盐浚” “怎么了沙郭?”我有些...
    開(kāi)封第一講書(shū)人閱讀 165,871評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)裳朋。 經(jīng)常有香客問(wèn)我病线,道長(zhǎng),這世上最難降的妖魔是什么鲤嫡? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,963評(píng)論 1 295
  • 正文 為了忘掉前任送挑,我火速辦了婚禮,結(jié)果婚禮上暖眼,老公的妹妹穿的比我還像新娘惕耕。我一直安慰自己,他們只是感情好诫肠,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,984評(píng)論 6 393
  • 文/花漫 我一把揭開(kāi)白布司澎。 她就那樣靜靜地躺著,像睡著了一般区赵。 火紅的嫁衣襯著肌膚如雪惭缰。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,763評(píng)論 1 307
  • 那天笼才,我揣著相機(jī)與錄音漱受,去河邊找鬼。 笑死骡送,一個(gè)胖子當(dāng)著我的面吹牛昂羡,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播摔踱,決...
    沈念sama閱讀 40,468評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼虐先,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了派敷?” 一聲冷哼從身側(cè)響起蛹批,我...
    開(kāi)封第一講書(shū)人閱讀 39,357評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤撰洗,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后腐芍,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體差导,經(jīng)...
    沈念sama閱讀 45,850評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,002評(píng)論 3 338
  • 正文 我和宋清朗相戀三年猪勇,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了设褐。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,144評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡泣刹,死狀恐怖助析,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情椅您,我是刑警寧澤外冀,帶...
    沈念sama閱讀 35,823評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站襟沮,受9級(jí)特大地震影響锥惋,放射性物質(zhì)發(fā)生泄漏昌腰。R本人自食惡果不足惜开伏,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,483評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望遭商。 院中可真熱鬧固灵,春花似錦、人聲如沸劫流。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,026評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)祠汇。三九已至仍秤,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間可很,已是汗流浹背诗力。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,150評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留我抠,地道東北人苇本。 一個(gè)月前我還...
    沈念sama閱讀 48,415評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像菜拓,于是被迫代替她去往敵國(guó)和親瓣窄。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,092評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • 題目1.顯示/etc目錄下纳鼎,以非字母開(kāi)頭俺夕,后面跟了一個(gè)字母以及其他任意長(zhǎng)度任意字符的文件或目錄裳凸。 解答: ls /...
    Easy_8195閱讀 234評(píng)論 0 0
  • 顯示/etc目錄下,以非字母開(kāi)頭劝贸,后面跟了一個(gè)字母以及其他任意長(zhǎng)度任意字符的文件或目錄 ls /etc/ | gr...
    紫火紅云閱讀 286評(píng)論 0 0
  • 1登舞、顯示/etc目錄下,以非字母開(kāi)頭悬荣,后面跟了一個(gè)字母以及其它任意長(zhǎng)度任意字符的文件或目錄 [11:40:51 r...
    陌路殘蟬閱讀 246評(píng)論 0 0
  • 1菠秒、顯示/etc目錄下,以非字母開(kāi)頭氯迂,后面跟了一個(gè)字母以及其它任意長(zhǎng)度任意字符的文件或目錄 ls -A /etc ...
    PeterLiang_1ddf閱讀 182評(píng)論 0 0
  • 1践叠、顯示/etc目錄下,以非字母開(kāi)頭嚼蚀,后面跟了一個(gè)字母以及其它任意長(zhǎng)度任意字符的文件或目錄禁灼。 命令如下: 執(zhí)行命令...
    82bb6438ec05閱讀 227評(píng)論 0 1