Linux Files

What are files in Linux?

File is the place to save data

Data such as text data and binary data can be saved in the file.

# Text data
example.txt
http.conf

# Binary data such as images, sounds and videos
image.png
image.jpg
music.mp3
movie.mpg

Files are a great way to store data in a storage area called your hard disk.

Users can save data to the hard disk simply by being aware of the file, without having to think about the hard disk.

This is true not only for Linux, but also for Windows files.

What is a path?

Filenames on Linux are represented using paths. The path indicates where the file is located. Paths include absolute paths and relative paths.

Absolute path

Paths that start with "/" are called absolute paths. The absolute path uniquely represents the location of the file as seen from the Linux root directory "/".

# Absolute path
/home/kimoto/foo.txt
/var/log/httpd.log
/usr/local/myapp/myapp.conf

The path delimiter on Linux is the slash "/". In Windows, it is a backslash (yen mark) "\". Please note that this is different from Windows.

Relative path

Paths that do not start with "/" are called relative paths. Relative paths represent the relative file locations as seen from the current directory.

# Relative path
foo.txt
labo/bar.txt

The current directory is

/home/kimoto

In the case of

foo.txt

teeth

/home/kimoto/foo.txt

Represents.

Directories are also a type of file

Note that on Linux, directories are also treated as one of the special files. A directory is a hierarchical representation of files and corresponds to a folder in Windows.

Note that when we say a file on Linux, we may refer to both a file that also contains a directory or a regular file that contains text or binary data, depending on the context.

For example, if you can see the "file list", it means "file list including special files such as directories" depending on the context.

In the directory, the file name that exists one level below that level is described.

foo.txt
test
bar.png

This can be checked using the ls command.

ls /home/kimoto

Associated Information