Linux 文件系统 --入门2

Linux file system

在Linux里,所有的programs, services, texts, images, directories, input and output devices都被视为文件。在Linux里文件和文件夹是没有区别的,因为对于一个目录,只是它本身包含了其他文件的名字。在 /directory里文件下主要有/bin, /dev, /etc, /lin, /home, /usr, /var。

/bin: 存储了Linux的很多实例。

/dev:存储所有设备有关的文件。

/etc:存储所有系统有关数据(用户以及系统可以参考的)。

/lib:包含了一些引用文件,引用库,配置文件等,比如C语言编译环境等

/home:有关用户们的所有文件内容,也就是我们操作最多的目录。

/usr: 文件系统,不包括引导过程等

/var: 包含特定系统的信息,因为系统运行要改变的数据,每个系统不一样。

/home 下的file

包括:

1.Ordinary files: 数据文件,程序文件,对象文件,执行文件。

2.Directory files:目录文件存放文件。

3.Special files:和I/O设备有关,包括以下一些类型:

    a.Character Device files:Character Device files read and write data one character at a time.

    b.Block Device files:Block Device files can access a block data at a time.

    c.Hard links:允许一个单一的文件可以由多个名字。

    d.Symbolic links:和hard links 相似,但是这个可以在不同文件系统之间工作

Linux下的用户类型

1.系统管理员System administrator

2.文件所有者File owner

3.群组所有者Group owner

4.其他用户Other users

Directory Commands

$ pwd : pwd 命令 显示当前工作的完整目录路径名。

$ mkdir dir_name : mkdir 命令创建一个目录叫做dir_name

$ rmdir dir_name :  rmdir 命令移除目录dir_name

$ ls : ls 显示当前目录下的所有文件, 也可 ls /home/..     显示指定目录下的所有文件


ls -l 命令: 显示的信息依次如下:

1. File type and file access permission

2.Number of links

3.File owner

4.Group owner(group name)

5.File size(in bytes)

6,7,and 8. Day and time of last modification to the file.

9. Name of file


ls: 后面可加的命令

-a: List all the files, including hidden files.

-F: Show the file type along with the name('/' for a directory. '*' for an executable)

-R:Does a recursive(递归) listing, which means it displays the content of the specified directory and all the subdirectories.

-r: Display files and subdirectories.

-S:Sorts by file size

-A: Display the files of all directories, except the . and .. directories.((.) 表示当前目录, (..)表示父级目录)



$ cat data1: cat 命令显示data1文件的内容

$ cp data1 data2: 将data1文件的内容copy到data2里。

$ rm [option(s)] files, 将文件从当前目录下删除

$ mv data1 /home/data1: 将data1移动到/home下,或者可以$ mv data1 data2, 直接进行了重命名,mv也可以将一个目录移动到另一个目录下。只要那个文件名是一个目录就行。


$ more data: 显示文件的内容,同时可以按Enter 继续下拉显示还没有显示完全的文件内容.

$ less data: 显示文件的内容,同时可以使用键盘(arrow keys),上下移动显示文件内容.

按下$ ls -l会 显示如下(不同电脑不一样):

-rwxrwxr-x. 1 smileagaina smileagaina 169 5月  31 16:18 test
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 公共
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 模板
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 视频
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 图片
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 文档
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 下载
drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 音乐

drwxr-xr-x. 2 smileagaina smileagaina   6 4月  28 11:47 桌面


最左边的字符有10位:分别表示:


第1位:表示Type of File。文件类型一共有以下几种:

-: Ordinary file

d: Directory

b: Block special file

c: Character special file

l: Symbolic link

s:Socket:

p:Named pipes

第2~4位:表示Owner permissions:

-:表示没有权限

R: read权限, allow you to display, copy, and compile the file. allow you to list the content of the directory.

W: write权限, allow you to edit, rename, or move the file to another location. allow you to create new files and subdirectories within this directory.

X:nexecute权限, allow you to execute the file provided the file also has the read permissioon. allow you to move to the directory using the cd command.

第5-7位:表示Group permissions:

上同:

第8-~10位: 表示Other user's permissions.

上同:

Change File Access Permissions ,改变文件权限

$ chmod  mode file(s);

Symbolic Mode:

r: means Read,

w: means Write,

x: means Execute

symbolic representation of entities.

u: owner of the file or directory

g: Members of the same group

o: All the other users

a: All users


比如$ ls -l test

-rwxrwxr-x. 1 smileagaina smileagaina 169 5月  31 16:18 test

$ chmod o+w test 

执行此命令后,所有的other users权限加上+w(write权限,), 再次ls -l test

-rwxrwxrwx. 1 smileagaina smileagaina 169 5月  31 16:18 test

会发现后三个字符加上了w权限

可以用(-)命令减去相应的权限。。。

Absolute Mode:

改变权限我们还可以用absolute mode;

Number    Permission

4              Read

2              Write

1              Execute


如果有rwxrw-r--, 则三位三位计算依次得到764,

因此$ chmod 764 test 可以用来将test 的权限改成以上权限rwxrw-r--






猜你喜欢

转载自blog.csdn.net/qq_34649947/article/details/80525025