如何使用PHP在新的Linux分区上创建文件夹

时间:2022-05-17 02:13:11

I created a new partition in linux, and mounted it in eg / dev / test. Using php, how can I create new folders within that partition?

我在linux中创建了一个新分区,并将其安装在例如/ dev / test中。使用php,如何在该分区中创建新文件夹?

I imagined using this form:

我想象使用这种形式:

mkdir('/dev/test/newFolder', 0777);

this would create a folder inside the partition?

这会在分区内创建一个文件夹吗?

and I could give write permission to this folder only to create, and to reading all the rest?

我可以给这个文件夹写权限只是为了创建,并阅读所有其余的?

I apologize if the question is really basic, but not know much about linux.

如果问题非常基本,但我对Linux知之甚少,我深表歉意。

1 个解决方案

#1


1  

Partitions on Linux are special block devices and live in /dev/.. E.g. /dev/sda1 might be the first partition on the first physical hard drive. Just having the partition you cannot do much with it. You'll create a file system on it. like:

Linux上的分区是特殊的块设备,并且位于/ dev / ..例如。 / dev / sda1可能是第一个物理硬盘驱动器上的第一个分区。只是拥有分区,你无法做多少。您将在其上创建一个文件系统。喜欢:

mkfs.ext3 /dev/sda1

This will create an ext3 file system on the partition /dev/sda1.

这将在分区/ dev / sda1上创建一个ext3文件系统。

Then when you have a file system you can mount it, usually to an empty existing folder. like:

然后,当您有一个文件系统时,您可以将它安装到一个空的现有文件夹中。喜欢:

mkdir /data
mount /dev/sda1 /data

It will mount the file system on partition /dev/sda1 into the existing, empty folder /data. Now you can store files and create folders in /data/....

它会将分区/ dev / sda1上的文件系统挂载到现有的空文件夹/数据中。现在您可以在/ data /中存储文件并创建文件夹....

(!!! don't do anything that you don't fully understand. You may destroy existing data. you have been warned !!!)

(!!!不要做任何你不完全理解的事情。你可能会破坏现有数据。你已被警告!!!)

#1


1  

Partitions on Linux are special block devices and live in /dev/.. E.g. /dev/sda1 might be the first partition on the first physical hard drive. Just having the partition you cannot do much with it. You'll create a file system on it. like:

Linux上的分区是特殊的块设备,并且位于/ dev / ..例如。 / dev / sda1可能是第一个物理硬盘驱动器上的第一个分区。只是拥有分区,你无法做多少。您将在其上创建一个文件系统。喜欢:

mkfs.ext3 /dev/sda1

This will create an ext3 file system on the partition /dev/sda1.

这将在分区/ dev / sda1上创建一个ext3文件系统。

Then when you have a file system you can mount it, usually to an empty existing folder. like:

然后,当您有一个文件系统时,您可以将它安装到一个空的现有文件夹中。喜欢:

mkdir /data
mount /dev/sda1 /data

It will mount the file system on partition /dev/sda1 into the existing, empty folder /data. Now you can store files and create folders in /data/....

它会将分区/ dev / sda1上的文件系统挂载到现有的空文件夹/数据中。现在您可以在/ data /中存储文件并创建文件夹....

(!!! don't do anything that you don't fully understand. You may destroy existing data. you have been warned !!!)

(!!!不要做任何你不完全理解的事情。你可能会破坏现有数据。你已被警告!!!)