What are the directories such as Linux, / etc and / var / log?

Introduction

For those who have started using \ * Nix OS such as Linux.

When I first touch Linux or when I'm not used to it, people say "I don't know what's where", "I don't know what's in the first place", or "Read the log", but where is the log? ?? ?? ?? I think there are things that I think.

Then, as you get used to it, you will somehow know and remember that "the log seems to be in the / var / log directory "and" the configuration file seems to be in the / etc".

A story about this directory.

Filesystem Hierarchy Standard

It is standardized under the name "Filesystem Hierarchy Standard".

Filesystem Hierarchy Standard / Wikipedia

From Wikipedia.

The Filesystem Hierarchy Standard defines the main directories and their contents on UNIX-like operating systems, including Linux.

The current version of Filesystem Hierarchy Standard is 3.0.

Filesystem Hierarchy Standard Specifications Archive

The Filesystem Hierarchy Standard (FHS)

Filesystem Hierarchy Standard

Let's take a look at some from the version 3.0 spec.

Filesystem Hierarchy Standard Version 3.0

etc.

A quick glance at the directories listed in the table of contents of this specification (in addition to Wikipedia, etc.) may give the impression that "this directory has been seen".

Also, many packages such as yum and ʻaptthat are installed using the package manager of each Linux distribution follow the Filesystem Hierarchy Standard, so once you get used to this, somehow" the configuration file is/ etc. You can make inferences such as "Is it in / foo" or "The log is in / var / log / bar` ", which makes it easier to understand.

Even if you put or create files yourself, if you are aware of the directory structure around here, it will be easier for others to understand your intentions later.

Environment variable PATH

From here, it's a little extra.

It's often said to "pass through PATH ". Commands in directories that are set to this environment variable separated by : allow the shell to resolve the path.

For example, for a virtual machine (CentOS 7) started with Vagrant, let's display the contents of the environment variable PATH.

$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/vagrant/.local/bin:/home/vagrant/bin

If you look at this, there are paths under / usr / local / bin and / usr / local / sbin, and by default there is nothing in these directories, but the user commands You can install common commands that can be used as a whole by placing.

$ ll /usr/local/bin
total 0

docker-compose is an example of installation using the / usr / local / bin directory.

Install Docker Compose

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

You can see what kind of path is set for general users by looking at $ HOME / .bashrc, $ HOME / .bash_profile, / etc / bashrc, / etc / profile, etc. ..

By the way, if you are a root user, the contents set in the environment variable PATH will change a little.

# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

It's around here.

/sbin

This is because / sbin is the directory where the commands for system administrators are placed.

System binaries

Also, there are minor differences, such as / usr / local / sbin in front of / usr / local / bin.

/usr/local/sbin:/usr/local/bin

View service status and logs with systemctl / journalctl

In addition to viewing the log file, you can use systemctl and journalctl to check the status of services (daemon processes) and system logs.

Check the status of the service.

$ sudo systemctl status [Unit name]

Check the log output by the service or OS.

#Specify the service unit and view the log
$ sudo journalctl -u [Unit name]

#View kernel log
$ sudo journalctl -k

#Output all logs
$ sudo journalctl

It's a good idea to gradually get used to Linux and become stronger while holding down the information around here and looking at the logs.

And let's face a stronger opponent.

Recommended Posts

What are the directories such as Linux, / etc and / var / log?
What are Linux POSIX options and GNU options?
What is the difference between Unix and Linux?
Linux: files and directories
Linux (about files and directories)
What are environment variables? (Linux)
What is the Linux kernel?
Differences between Windows and Linux directories
Are macOS and Linux completely different?
What are "sudo ln -s" and "ln -s"?
[Python] What are @classmethods and decorators?
(Beginner) What are cores and threads?
What are the "pipeline" and "{...}" in the Jenkins Pipeline pipeline {...} (for Groovy beginners, for experienced languages)