一、笔记
1.文件分类
student@student-machine:~$ ls -l
总用量 172748
-rwxrw-rw- 1 student student 2411080 3月 3 16:07 001.txt
drwxrwxr-x 2 student student 4096 3月 3 16:29 abc
-rw-rw-r-- 1 student student 46 3月 3 10:41 abc.c
-rwxrwxr-x 1 student student 8552 3月 3 10:43 a.out
-rw-r--r-- 1 student student 8980 3月 24 2020 examples.desktop
-rw-rw-r-- 1 student student 72 3月 3 10:12 file.txt
drwxrwxr-x 3 student student 4096 2月 28 19:54 qwe
-rw-rw-r-- 1 student student 174407680 3月 3 16:29 tar.tar
drwxr-xr-x 2 student student 4096 3月 24 2020 公共的
drwxr-xr-x 2 student student 4096 3月 24 2020 模板
1.第一个字符为文件类型标识符
- 普通文件 文本文件 可执行文件
d 目录文件
c 字符设备 通讯方法为单个字符的设备 每次I/O仅一个字符 例如spi 单总线 鼠标
b 块设备 通讯方式为DDR等 例如硬盘 内存
I 链接文件 快捷方式 只保留了所指向文件的地址,而不是文件本身
p 管道文件 进程于进程之间 通讯方式的一种
s 套接字文件 套接字是方便进程之间通讯的特殊文件。既可以不同主机通讯也可以不同进程通讯 TCP UDP
2.第二字符 第十个字符
-rw-rw-r-- 1 student student 46 3月 3 10:41 abc.c
-rwxrwxr-x 1 student student 8552 3月 3 10:43 a.out
-rw-r--r-- 1 student student 8980 3月 24 2020 examples.desktop
- rw- rw- r--
文件类型 用户主 用户组
这里是三组权限码
第一组 文件所属用户权限
第二组 文件所属用户组权限
第三组 其他用户权限
r 写入 w 读取 x 执行 - 无权限
权限掩码 0002
最终创建文件的权限码 = 文件的满权限 - 权限掩码
0666 - 0002 = 0664 权限掩码的作用 限制文件创建时的初始权限
student student 用户名 用户组
3 10:41 上次修改时间
abc.c 文件名
2.Linux目录结构
一级子目录/bin、/boot、/etc、/home、/usr、/root、/dev、/lib、/mnt、/tmp、/var
etc 存放系统配置文件 例如 密码/ect/passwd
bin 常用命令存放目录 如rm ls cat cp
sbin 存放root的指令文件
lib 存放库文件 例如:动态库so文件 相当于Windows中的.dll
home 用户主目录 普通用户
boot 包含内核和启动文件 分配内存 分配中断 (CPU核心)
dev 设备文件存放目录(用于和底层驱动管理) dev/tty 串口设备 字符设备 dev/sda 存储设备 块设备
usr 应用程序放目录
mnt 挂载目录,为我们的共享文件夹就是挂载在这个目录下面
root root用户主目录 超级用户
proc process 的缩写,主要描述系统进程
lost + found 在该目录中可以找到一些误删除或丢失的文件,并恢复
3.绝对路径和相对路径
绝对路径:路径从文件系统的根目录 / 开始,给出从根目录到目标文件或目录的完整路劲。
相对路劲:相对路径是以当前目录为参照的路劲,它不是从 / 开始 。假设当前目录为 /usr,那么它所指向的是当前目录下的目录。 .表示当前目录 .. 表示父目录
4.压缩文件
gzip 文件名 将文件按照gzip 格式压缩
gunzip 解压文件
student@student-machine:~/bcd$ gzip 002.txt
student@student-machine:~/bcd$ ls -lh
总用量 76K
-rwxrw-r-- 1 student student 74K 3月 3 20:30 002.txt.gz
student@student-machine:~/bcd$ gunzip 002.txt.gz
student@student-machine:~/bcd$ ls -lh
总用量 14M
-rwxrw-r-- 1 student student 14M 3月 3 20:30 002.txt
bzip2压缩
bunzip2 解压文件
student@student-machine:~/bcd$ bzip2 002.txt
student@student-machine:~/bcd$ ls -lh
总用量 24K
-rwxrw-r-- 1 student student 21K 3月 3 20:30 002.txt.bz2
student@student-machine:~/bcd$ bunzip2 002.txt.bz2
student@student-machine:~/bcd$ ls -lh
总用量 14M
-rwxrw-r-- 1 student student 14M 3月 3 20:30 002.txt
xz压缩文件
unxz 解压文件
student@student-machine:~/bcd$ xz 002.txt
student@student-machine:~/bcd$ ls -lh
总用量 8.0K
-rwxrw-r-- 1 student student 7.3K 3月 3 20:30 002.txt.xz
student@student-machine:~/bcd$ unxz 002.txt.xz
student@student-machine:~/bcd$ ls -lh
总用量 14M
-rwxrw-r-- 1 student student 14M 3月 3 20:30 002.txt
二、作业
student@student-machine:~$ ps -aux |grep a.out |grep -v grep
student 31878 98.5 0.0 4216 732 pts/4 R+ 20:21 1:21 ./a.out
student@student-machine:~$ kill -9 31878
student@student-machine:~$ gcc abc.c
student@student-machine:~$ ./a.out
已杀死