Linux (about files and directories)

Here, we will explain about files </ b> and directories </ b>. Do you know the file? To put it very simply, an Excel file or a word file is a file.

Have you heard of the directory? If you're using a Mac, you may have heard of it. You don't hear about Windows. Think of a directory as a folder. A folder is a collection of multiple files and folders. Folder inside the folder ,,? It may be, but ... For example, if you want to divide the files for January and February in the 2020 folder, the January folder (the files for January are collected) and the February folder (2) in the 2020 folder. It will be easier to understand if you think that you are creating a file for the month).

Well, to the main subject Let's actually check the file on the terminal.

Before that, let's create a neko user using the useradd command. Let's also create a home directory with the -m (--create-home) option. (Simply think of your home directory as a private room where neko users can create files, because you can't create files in other directories without permissions)

[root@localhost ]# useradd -m neko

ls

Enter the ls command on the terminal. A list of files is displayed. If nothing comes out, it means that the file does not exist.
[neko@localhost ~]$ ls
tyu-ru.txt  nabe.txt

In the above case, the files tyu-ru.txt and nabe.txt exist. Use the touch </ b> </ font> command to create a mike-neko file.

[neko@localhost ~]$ touch mike-neko.txt

Let's check the file again.

[neko@localhost ~]$ ls
tyu-ru.txt  nabe.txt  mike-neko.txt

It's completed. As an aside, ls stands for LiSt files. On Linux, commands with names that omit English are common. It is helpful to have this idea in mind as you learn commands.

cp

Copy the created mike-neko file and create a kuro-neko file. Use the cp </ b> </ font> command.

[neko@localhost ~]$  cp mike-neko.txt kuro-neko.txt

Let's check if the file copy is done well with the ls command.

[neko@localhost ~]$ ls
tyu-ru.txt  nabe.txt  mike-neko.txt  kuro-neko.txt

Did you do it well?

mv

Let's rename the file. Use the mv </ b> </ font> command. mv </ b> </ font> is often used when moving files. Let's change the kuro-neko file to the siro-neko file.

[neko@localhost ~]$ mv kuro-neko.txt siro-neko.txt

Now let's check the changes.

[neko@localhost ~]$ ls
tyu-ru.txt  nabe.txt  mike-neko.txt  siro-neko.txt

It has been changed.

rm

Let's delete the file. Use the rm </ b> </ font> command. Delete the tyu-ru.txt file.

[neko@localhost ~]$ rm tyu-ru.txt

Now for confirmation.

[neko@localhost ~]$ ls
nabe.txt  mike-neko.txt  siro-neko.txt

How about that?

Let's leave it around here this time.

  • ls
  • touch
  • cp
  • mv
  • rm

Let's remember the command.

Continued

Recommended Posts