基礎命令
home下建立share文件夾,test是子文件夾:
[root@localhost home]# mkdir -p share/test
查看/下home大小:
[root@localhost home]# du -sh /home
4.5M /home
查看CPU,內存信息:
[root@localhost home]# cat /proc/cpuinfo
[root@localhost home]# cat /proc/meminfo
文件屬性:
-rw-r--r-- 1 root lonny 12 Apr 19 19:50 file1
文件類型、文件權限、硬連接數、文件創建者、文件所屬組、文件大小、更動時間、文件名。
-:一般文件?d:目錄文件?b:塊設備文件?c:字符設備文件?l:鏈接文件?p:人工管道
創建兩個用戶:u1,u2;用root創建一個文件,zjr;要求:u1可以讀寫執行,u2仍然是others的權限。
使用技能:ACL。
建立u1,u2:
[root@localhost home]# useradd u1
[root@localhost home]# passwd u1
[root@localhost home]# useradd u2
[root@localhost home]# passwd u2
Changing password for user u2.
New password:
BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic
Retype new password:
passwd: all authentication tokens updated successfully.
創建zjr:
[root@localhost home]# cd share/test
[root@localhost test]# touch zjr
[root@localhost test]# ll
total 0
-rw-r--r--. 1 root root 0 Apr 15 18:37 zjr
設置ACL:
[root@localhost test]# setfacl -m u:u1:rwx zjr
查看ACL:
[root@localhost test]# getfacl zjr
# file: zjr
# owner: root
# group: root
user::rw-
user:u1:rwx
group::r--
mask::rwx
other::r--
setfacl –m? u:用戶名:權限? <文件名> //設置某用戶名的訪問權限
setfacl –m? g:組? ? 名:權限? <文件名> //設置某個組的訪問權限
setfacl –x u:用戶名 <文件名> //取消某用戶名的訪問權限
setfacl –x g:組名 <文件名> //取消某個組的訪問權限
文件的chmod chown chgrp太簡單了,略過。
熟悉which whereis:
[root@localhost test]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
[root@localhost test]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
熟悉find:(考試會有)
[root@localhost home]# find /etc -name "host*" -exec du -h {} \;
4.0K /etc/host.conf
4.0K /etc/hosts
4.0K /etc/hosts.allow
4.0K /etc/hosts.deny
20K /etc/selinux/targeted/active/modules/100/hostname
4.0K /etc/hostname
4.0K /etc/avahi/hosts
作用:找出/下etc下,host開頭(*通配符)文件,然后執行du -h
熟悉vim使用
[root@localhost home]# cd share/test
[root@localhost test]# cp /etc/passwd ppp
[root@localhost test]# vi ppp
查看文件一些命令:
head -n;tail -n;
more;less
wc:-c 只顯示文件的字符數(記:有一個換行符)。-l 只顯示行數。-w 只顯示單詞數。
拿passwd隨便玩,玩熟悉為之。
一條復雜的命令:
[root@localhost test]# cat /etc/passwd | head -10 | cut -d : -f 1
root
bin
daemon
adm
lp
sync
shutdown
halt
operator
前10行,以:為分隔符的第一區塊。
[root@localhost test]# tar jcvf dabao.tar.bz dabao
[root@localhost test]# tar jxvf dabao.tar.bz
備份時壓縮
tar jcvf? test.tar.bz? test*? (? j:使用bzip2 )
tar zcvf? test.tar.gz? test* ( z:使用gzip )
解壓備份文件
tar jxvf? test.tar.bz? -C /tmp(j:使用bzip2 )
tar zxvf? test.tar.gz? -C /tmp(z:使用gzip )
unzip(上課時說網絡上很多down的是zip,使用unzip)
心得:
感覺已經是夏天,開始學習RHCE,一點點學,爭取早點過了RHCA吧。畢竟菜雞會被優化。
本文為菜鳥學習筆記,如有錯誤,請各位大神幫忙指出,感激不盡。