Linux-基礎命令測試(二)

來源:互聯網
上載者:User

標籤:使用者登入   linux   

1、用root使用者登入Linux ,建立目錄/perm ,在/perm目錄下建立檔案newfile ,授予/perm目錄所有使用者都有rwx許可權;建立普通使用者wlr ,切換到wlr執行“rm /perm/newfile”是否可以執行

[[email protected]~]# mkdir /perm[[email protected] ~]# touch /perm/newfile[[email protected] ~]# chmod 777 /perm[[email protected] ~]# useradd wlr[[email protected] ~]# passwd wlr更改使用者 wlr 的密碼。新的密碼:無效的密碼: WAY 過短無效的密碼:過於簡單重新輸入新的密碼:passwd:所有的身分識別驗證令牌已經成功更新。[[email protected] ~]# su - wlr[[email protected] ~]$ rm /perm/newfile rm:是否刪除有防寫保護的普通空檔案 "/perm/newfile"?y[[email protected] ~]$ ls

2、在/root目錄下建立檔案newfile2 ,移動檔案newfile2到/perm目錄下同時改名為file01 ;改變/perm/file01檔案的所有者為系統使用者adm ,改變其所屬組為系統使用者組games ;改變/perm/file01檔案許可權為“rwxrw-r--”;在/perm目錄下,分別給file01產生一個軟連結檔案file01.soft和一個永久連結檔案file01.hard ;刪除/perm目錄

[[email protected] ~]# touch /root/newfile2[[email protected] ~]# mv /root/newfile2 /perm/file01[[email protected] ~]# chown adm /perm/file01 [[email protected] ~]# chgrp games /perm/file01 [[email protected] ~]# chmod 764 /perm/file01 [[email protected] ~]# ln -s /perm/file01 /perm/file01.soft[[email protected] ~]# ln /perm/file01 /perm/file01.hard[[email protected] ~]# rm -rf /perm/

3、查看/etc目錄的詳細資料(許可權、大小等);查看/etc/目錄下檔案的詳細資料時實現分頁瀏覽;在/etc目錄下尋找5分鐘內被改變過內容的檔案;在/boot目錄下尋找檔案名稱為grub.conf的檔案並同時列出檔案的詳細資料;在根目錄下尋找系統中大於100MB小於150MB的檔案

[[email protected] ~]# ls -ld /etcdrwxr-xr-x. 103 root root 12288 5月  28 03:49/etc[[email protected] ~]# ls -l /etc | more總用量 1780drwxr-xr-x. 3 root root   4096 5月  27 17:46abrtdrwxr-xr-x. 4 root root   4096 5月  27 17:49acpi-rw-r--r--. 1 root root     44 5月  27 17:54adjtime-rw-r--r--. 1 root root   1512 1月  12 2010aliases................................省略部分..........................................[[email protected] ~]# find /etc -mmin -5 -a -typef                     #因為我沒改過所以沒有[[email protected] ~]# find /boot -name grub.conf-exec ls -l {} \;-rw-------. 1 root root 811 5月  27 17:52/boot/grub/grub.conf[[email protected] ~]# find / -size +204800 -a-size -307200find: “/proc/30990/task/30990/fd/5”: 沒有那個檔案或目錄find: “/proc/30990/task/30990/fdinfo/5”: 沒有那個檔案或目錄find: “/proc/30990/fd/5”: 沒有那個檔案或目錄find: “/proc/30990/fdinfo/5”: 沒有那個檔案或目錄/mnt/sr0/images/install.img/sys/devices/pci0000:00/0000:00:0f.0/resource1/sys/devices/pci0000:00/0000:00:0f.0/resource1_wc

4、查看系統安裝時是否安裝了php軟體包;用grep查看Apache設定檔/etc/httpd/conf/httpd.conf的DocumentRoot選項資訊;樹狀顯示/etc/httpd目錄下檔案結構

[[email protected] ~]# grepphp /root/install.log            安裝的rpm包[[email protected] ~]# grepDocumentRoot /etc/httpd/conf/httpd.conf # DocumentRoot: Thedirectory out of which you will serve yourDocumentRoot"/var/www/html"# This should be changedto whatever you set DocumentRoot to.#    DocumentRoot/www/docs/dummy-host.example.com[[email protected] ~]# tree/etc/httpd                     #tree系統用沒有需要自己安裝/etc/httpd├── conf│   ├── httpd.conf│   └── magic├── conf.d│   ├── php.conf│   ├── README│   └── welcome.conf├── logs ->../../var/log/httpd├── modules ->../../usr/lib64/httpd/modules└── run ->../../var/run/httpd

5、查看使用者設定檔/etc/shadow的協助資訊;查看命令cd的協助資訊

[[email protected] ~]# man 5shadownCannot open the messagecatalog "man" for locale "zh_CN.UTF-8"(NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N") No entry for shadown insection 5 of the manual[[email protected] ~]# helpcdcd: cd [-L|-P] [dir]    Change the shell working directory.        Change the current directory to DIR.  The default DIR is the value of theHOMEshell variable.……………………….省略部分……………………

6、建立目錄/comp ,拷貝檔案/etc/services到/comp目錄下,分別對services檔案進行壓縮,產生 .gz .zip .bz2三種格式的壓縮包;拷貝目錄/etc到/comp目錄下(保持目錄屬性不改變),把etc目錄壓縮產生etc.tar.gz,把services檔案的所有壓縮包使用rm刪除(只用一條rm命令,非執行三次rm操作);在/comp目錄下建立檔案hidefile ,並設定為隱藏

 [[email protected] ~]# mkdir /compcp /etc/services/comp[[email protected] ~]# cp /etc/services /comp[[email protected] ~]# cd /comp/[[email protected] comp]# zip services.zip services  adding:services (deflated 80%)[[email protected] comp]# bzip2 -k services[[email protected] comp]# gzip services[[email protected] comp]# rm -f services.*   (-f 強制移除,不提示確認)[[email protected]]# cp -rf /etc /comp[[email protected]]# cd /comp/[[email protected]]# tar -zcf etc.tar.gz etc[[email protected]]# touch hidefile[[email protected]]# mv hidefile .hidefile

7、尋找命令ifconfig的絕對路徑並判斷此命令哪些使用者可以執行;更改本機IP地址為192.168.9.250(練習後改變回來)

[[email protected] ~]# which ifconfig/sbin/ifconfig只有root可以使用ifconfig(sbin目錄下的命令只有root可以執行)[[email protected] ~]# ifconfig eth0 192.168.1.250

8、ping本機地址測試,要求發送10次ICMP包且包大小為1000 byte

[[email protected] ~]# ping -c 10 -s 1000 192.168.1.250

9、設定命令“cp -rf”的命令別名為dircp ,查看當前線上使用者

[[email protected] ~]# vi~/.bashrc   1 # .bashrc  2   3 # User specific aliases and functions  4   5 alias rm=‘rm -i‘  6 alias dircp=‘cp -rf‘………………………….省略部分………………………[[email protected] ~]# whoroot     pts/0        2015-05-28 04:14 (192.168.1.250)

10、查看/etc目錄下檔案名稱以.conf結尾的二進位檔案有多少個

[[email protected] ~]# mkdir/test[[email protected] ~]# touch/test/find.list[[email protected] ~]# find/etc -name *.conf -a -type f > /test/find.list [[email protected] ~]# wc -l/test/find.list231 /test/find.list



本文出自 “吳老二” 部落格,請務必保留此出處http://9827789.blog.51cto.com/9817789/1659882

Linux-基礎命令測試(二)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.