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
A story about this directory.
Filesystem Hierarchy Standard
It is standardized under the name "Filesystem Hierarchy Standard".
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.
Let's take a look at some from the version 3.0 spec.
/… Root Filesystem The Root Filesystem
/ home… User home directories (optional)](http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s08.html)
/ etc… Directory to put the configuration file Host-specific system configuration
/ bin… Directory to put commands required by all users Essential user command binaries (for use by all users)
/ usr / bin… Directory for commands used by many users Most user commands
/ var / log… Directory to put log files Log files and directories
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 ʻapt
that 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.
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
$ 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.
$ 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.
This is because
/ sbin is the directory where the commands for system administrators are placed.
Also, there are minor differences, such as
/ usr / local / sbin in front of
/ usr / local / bin.
In addition to viewing the log file, you can use
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.