RHCE-1

基础命令

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

mail

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吧。毕竟菜鸡会被优化。

本文为菜鸟学习笔记,如有错误,请各位大神帮忙指出,感激不尽。

你可能感兴趣的:(RHCE-1)