文件系统信息和文件权限
cpuinfo cpu的信息
总核数 = 物理CPU个数 X 每颗物理CPU的核数
总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数
查看物理CPU个数
cat /proc/cpuinfo| grep “physical id”| sort| uniq| wc -l
查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep “cpu cores”| uniq
查看逻辑CPU的个数
cat /proc/cpuinfo| grep “processor”| wc -l
文件系统
/目录下有很多对应的文件夹
文件系统存储信息
Check the storage of system
df du
Manipulate directory
pwd cd mkdir rmdir ls
Manipulate files
rm cp mv file touch
- df命令
查看文件大小和文件挂载的位置 - df -h
大小的单位为G - 指定文件目录的大小
[s14516@gdufs]$df -h /var - du 显示文件目录及子目录的详细信息
文件大小
du /tmp
du -h /tmp - 显示文件当前目录
pwd - 创新目录
mkdir dir1 - 创新多层目录
mkdir -p dir1/dir2/dir3
文件类型
$ ls -l /dev
drwxr-xr-x
显示文件类型和文件的权限、 文件的所有者、 文件的组、 文件的字节大小、 文件的修改时间。
b 块文件
d 代表目录文件
s socket的大小
区分 ll 和 du 显示文件的大小的意义
[s14516@gdufs]$ll -l hello
-rwxr-xr-x 1 s14516 stu **7139** 2017-09-13 19:03 hello*
[s14516@gdufs]$du -h hello
**8.0K** hello
du -h 的大小为数据块的大小(分配的存储空间)
ls -l 的大小为文件的字节大小(内容的大小,实际的大小)
删除文件夹
rm -r 删除当前文件夹和对应的子目录
rmdir 删除的是当前文件夹是空的才能成功
rm -fr 删除文件,强制,不会有信息提示
复制文件
[s14516@gdufs]$cd -r dir /tmp
移动文件
mv -r dir /tmp
文件类型
file
ls -l
[s14516@gdufs]$file tmp/
tmp/: directory
文件的查找
1. 文件描述符表(操作系统会自动打开前三个描述符文件
(0号对应键盘,1号标准输入——屏幕,2号输出——屏幕))
UNIX 系统 shell 把文件描述符 0 与进程的标准输入(standard input)关联,文件描述符 1 与标准输出(standard output)关联,文件描述符 2 与标准错误(standard error)关联。
文件描述符(file descriptor)通常是一个小的非负整数,内核用以标识一个特定进程正在访问的文件。
文件的权限
- 查看文件权限
[s14516@gdufs]$ls -ld tmp
drwxr-xr-x 3 s14516 stu 4096 2017-09-20 19:34 tmp
r 读
w 写
x 执行
2. 查看id
id test
3. 查看组
groups
4. 改变所有者
chown test /tmp/hello
5. 改变文件组
chgrp test /tmp/hello
6. 添加权限
chmod u+x hello
chmod u-x hello
7. 删除读的权限
a 是所有的
u 是用户
[s14516@gdufs]
chmoda−rdir[s14516@gdufs]
ls -ld dir
d-wx–x–x 2 s14516 stu 4096 2017-09-20 20:40 dir
[s14516@gdufs]$ls dir
ls: cannot open directory dir: Permission denied
8. 数字权限
权限 rwx
二进制 000
转化八进制0
owner groups other
rwx rwx rwx
eg:
set its permissions to read and write for yourself, read for users in your group, and none to everyone else. What command did you use to set privileges?
owner | groups| other|
rwx | rwx | rwx|
110 | 100 | 000|
--> 640
如果是要实现权限不能被修改,则取消写的权限
chmod a-w file
如果是实现权限不能被删除,修改文件所在的目录的权限为取消写的权限
chmod a-w dir
9. 默认的访问权限
掩码值的存在
[s14516@gdufs]$umask
一般文件的权限计算
666-umask
666-022=644
6 4 4
(110 100 100)
rw- r– r–executable file or directory权限计算
777 - umask
10.修改为只有自己有的权限
eg: rwx — —
umask 0077