標籤:使用者登入 linux
1、 用root使用者登入Linux ,建立目錄/perm ,在/perm目錄下建立檔案newfile ,授予/perm目錄所有使用者都有rwx許可權;建立普通使用者testuser ,切換到testuser執行“rm /perm/newfile”是否可以執行
[[email protected] ~]#[[email protected] ~]# mkdir /perm[[email protected] ~]# touch /perm/newfile[[email protected] ~]# chmod 777 /perm/newfile[[email protected] ~]# ls -l /perm/newfile -rwxrwxrwx. 1 root root 0 4月 21 04:57/perm/newfile[[email protected] ~]# useradd testuser[[email protected] ~]# passwd testuser[[email protected] ~]# su testuser[[email protected] perm]$ rm newfile
rm:是否刪除有防寫保護的普通空檔案 "newfile"?y
可以
2、 在/root目錄下建立檔案newfile2 ,移動檔案newfile2到/perm目錄下同時改名為file01 ;改變/perm/file01檔案的所有者為系統使用者adm ,改變其所屬組為系統使用者組games ;改變/perm/file01檔案許可權為“rwxrw-r--”;在/perm目錄下,分別給file01產生一個軟連結檔案file01.soft和一個永久連結檔案file01.hard ;刪除/perm目錄
[[email protected] ~]# touch newfile2[[email protected] ~]# mkdir /perm[[email protected] ~]# chmod 777 /perm/[[email protected] ~]# mv newfile2 /perm/file01[[email protected] ~]# chown adm /perm/file01 [[email protected] ~]# chgrp games /perm/file01 [[email protected] ~]# ls -l /perm/file01 -rw-r--r--. 1 adm games 0 4月 21 05:09/perm/file01[[email protected] ~]# chmod 764 /perm/file01 [[email protected] ~]# ls -l /perm/file01 -rwxrw-r--. 1 adm games 0 4月 21 05:09/perm/file0[[email protected] ~]# ln -s /perm/file01/perm/file01.soft[[email protected] ~]# ln /perm/file01 /perm/file01.hard[[email protected] ~]# ls -l /perm/總用量 0-rwxrw-r--. 2 adm games 0 4月 21 05:09file01-rwxrw-r--. 2 adm games 0 4月 21 05:09file01.hardlrwxrwxrwx. 1 root root 12 4月 21 05:14 file01.soft ->/perm/file01[[email protected] ~]# rm -rf /perm
3、 查看/etc目錄的詳細資料(許可權、大小等);查看/etc/目錄下檔案的詳細資料時實現分頁瀏覽;在/etc目錄下尋找5分鐘內被改變過內容的檔案;在/boot目錄下尋找檔案名稱為grub.conf的檔案並同時列出檔案的詳細資料;在根目錄下尋找系統中大於100MB小於150MB的檔案
[[email protected]~]# ls -l /etc/ | more[[email protected]~]# find /etc -ctime -5[[email protected]~]# find / -size +100M -a -size -150M[[email protected]~]# find /boot -name grub.conf/boot/grub/grub.conf
4、查看系統安裝時是否安裝了php軟體包;用grep查看Apache設定檔/etc/httpd/conf/httpd.conf的DocumentRoot選項資訊;樹狀顯示/etc/httpd目錄下檔案結構
[[email protected] ~]# cat install.log | grep php[[email protected] ~]# cat /etc/httpd/conf/httpd.conf| grep DocumentRoot[[email protected] ~]# tree /etc/httpd
5、查看使用者設定檔/etc/shadow的協助資訊;查看命令cd的協助資訊
[[email protected] ~]# man /etc/shadow[[email protected] ~]# man --help
6、建立目錄/comp ,拷貝檔案/etc/services到/comp目錄下,分別對services檔案進行壓縮,產生 .gz .zip .bz2三種格式的壓縮包;拷貝目錄/etc到/comp目錄下(保持目錄屬性不改變),把etc目錄壓縮產生etc.tar.gz,把services檔案的所有壓縮包使用rm刪除(只用一條rm命令,非執行三次rm操作);在/comp目錄下建立檔案hidefile ,並設定為隱藏
[[email protected] ~]# cp -a /etc/services comp/[[email protected] ~]# zip –r comp/services.zipcomp/services[[email protected] ~]# gzip -r comp/services[[email protected] comp]# bzip2 services[[email protected] ~]# cp -a /etc comp/[[email protected] ~]# tar -cvf comp/etc.tar.gzcomp/etc[[email protected] ~]# rm -rf comp/services.*
7、尋找命令ifconfig的絕對路徑並判斷此命令哪些使用者可以執行;更改本機IP地址為192.168.9.250(練習後改變回來)
[[email protected] ~]# whereis ifconfigifconfig: /sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz[[email protected] ~]# ifconfig eth0 192.168.9.250255.255.255.0
8、ping本機地址測試,要求發送10次ICMP包且包大小為1000 byte
[[email protected] ~]# ping -c 10 -s 1000192.168.216.1589、設定命令“cp -rf”的命令別名為dircp ,查看當前線上使用者[[email protected] ~]# who
10、查看/etc目錄下檔案名稱以.conf結尾的二進位檔案有多少個
[[email protected] ~]# find /etc/ -name"*.conf" | wc -l
本文出自 “吳老二” 部落格,請務必保留此出處http://9827789.blog.51cto.com/9817789/1659870
Linux-基礎命令測試(一)