Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ The most concise Systemd tutorial, just ten minutes     - Mac OS X 10.10 Yosemite compiling OpenJDK 9 (Linux)

- Ubuntu 15.04 installed JDK and configured as the default JDK (Linux)

- Go Languages Reviews (Programming)

- Docker - for the development and deployment of unified lightweight Linux containers (Linux)

- Django url () function Detailed (Programming)

- MySQL Tutorial: Philosophical Reflections on the unauthenticated user (Database)

- Android Studio Personalization (Linux)

- Getting Started with Linux system to learn: how to configure a static IP address for CentOS7 (Linux)

- Xtrabackup creates a slave node without downtime (Database)

- Binary search -Java achieve (Programming)

- Kubernetes Cluster Setup problems encountered and solutions (Server)

- Swift 2.0 brief (Linux)

- Understand ASP.NET 5 running the command: DNVM, DNX, and DNU (Server)

- CentOS6.5 install SVN & visual management tools iF.SVNAdmin (Server)

- DataGuard Standby backup error RMAN-06820 ORA-17629 to solve (Database)

- Spark and Hadoop comparison (Server)

- Linux and Unix systems really do network more secure (Linux)

- Security of data to create a safe .mdb database (Linux)

- Configuring a Linux operating system security management services Explain (Linux)

- Docker deployment practices in Ubuntu (Server)

 
         
  The most concise Systemd tutorial, just ten minutes
     
  Add Date : 2018-11-21      
         
         
         
  Linux 101: The most effective use of Systemd

Why should I do that?

Understanding of Modern Linux distributions significant change;
See how Systemd substituted SysVinit of;
Get unit (unit) and the new journal log.
Tucao messages, personal attacks, death threats --Lennart Poettering, Systemd author of receiving these things already used to it. The essence before Red Hat's employees angrily FOSS community on Google+ (http://tinyurl.com/poorlennart) of grief and despair, said: "It was a disgusting place." He highlighted the extremely harsh rhetoric Linus Torvalds posts on the mailing list, and condemned the kernel leader set the tone for the online discussion, and making personal attacks and derogatory words he become the norm.

But why Poettering suffer so much hatred? Why is it such a mess things open source software and other people who want to put up with this anger? The answer lies in the importance of his software. Today, most distributions, Systemd is the first program launched by the Linux kernel, and it also plays a variety of roles. It starts system services, user login process, perform some task every certain period of time, there are many, many. It continues to grow, and has become some kind of Linux "base system" - providing system start-up and release all the tools needed for maintenance.

Today, Systemd on the following controversial: it escape some Unix tradition already established, such as log files as plain text; it is seen as a "universal" project, trying to take over everything; it is our operating system an important pillar of innovation. However, most mainstream release has been accepted (or are about to receive) it, so it survived. And it really is good: start quicker and more easily manage those dependent services program that provides robust and secure logging systems.

Therefore, in this tutorial, we will explore the characteristics Systemd, and show you how best to use these features. At the moment this software even if you are not a fan, at least after reading this article that you can better understand and adapt to it.

The Systemd portrayed as a violent animal, devouring it passing. Most of the critics' words can not only as soft dolls.

Start-up and service

Most major releases have either adopted Systemd, or upcoming in the next release using (such as Debian and Ubuntu). In this tutorial, we use Fedora 21 (This release is already Systemd excellent experimental site) of a preview presentation, but no matter which you use the release command and precautions to use should be the same. This is a plus point Systemd: it eliminates many minor and trivial differences between different releases.

In a terminal type ps ax | grep systemd, see the first row, which numeral 1 represents its process number is 1, which means it is the first program launched by the Linux kernel. Therefore, the kernel upon detecting complete hardware and organize the memory, it will run the / usr / lib / systemd / systemd executable program, the program will be launched by order of other programs. (In the absence of Systemd days, the kernel to run / sbin / init, then the program will run the rest of the various startup script named SysVinit system.)

Systemd is a core concept of unit (unit) is called, it is there on a number of services (service) (the program running in the background), equipment, mount point, and the operating system configuration file other information. One of the goals is to simplify Systemd interaction between these things, so if you have a program that needs to be created or start running after a device to be accessed at a mount point, Systemd can make it all up to become normal operation quite easy. (In the absence of Systemd day, you want to use a script to deploy these things well, that's quite ugly.) To list all elements on your Linux system, enter the following command:

systemctllist-unit-files
Now, systemctl is the main tool Systemd interaction, it has a lot of options. In the unit list, you'll notice here there are some formatting: is enabled (enabled) unit shown in green, is disabled (disabled) is displayed in red. Marked as "static" units can not be directly enabled, they are other units dependent objects. To limit the output list contains only service, use the following command:

systemctllist-unit-files --type = service
Note that a unit is displayed as "enabled", does not mean that the corresponding service is running, but only that it can be turned on. To obtain a particular service information to GDM (Gnome Display Manager), for example, enter the following command:

systemctl status gdm.service
This command provides a lot of useful information: the location of some posters service description, unit configuration file, start time, process ID, and it belongs CGroups (each set of processes for limiting resource overhead).

If you go to view the configuration file located /usr/lib/systemd/system/gdm.service unit, you can see various options, including binary files to be run ( "ExecStart" row), other unit conflicting (ie, can not run into the unit), and the unit needs to perform in front of the unit to enter the run ( "After" the line). Some units have additional dependent options such as (optional dependency) "Requires" (necessary dependencies) and "Wants".

Here is another interesting option:

Alias ​​= display-manager.service
When you start gdm.service, you will be able to view its status by systemctl status display-manager.service. When you know that a display manager (display manager) is running and want to do something about it, but you do not care what it is GDM, when KDM, XDM display manager program or something else, this option will be very useful.

Use systemctl status command followed by a unit name, to see what the corresponding service conditions.

"Target (target)" Lock

If you enter the command ls / usr / lib / systemd / system directory, you will see all kinds of files that end with .target. Start the destination (target) is a plurality of elements coming together at the same time so that they will start the way. For example, most Unix-like operating systems have a "multi-user (multi-user)" status, meaning that the system has been successfully started, the background service is running and ready to let one or more users to log in and work - at least in text mode. (Including for other states to manage the work of a single user (single-user) status, as well as for machine shutdown restart (reboot) status.)

If you open a file multi-user.target find out, you might expect to see is a list of units to be started. However, you will find this internal documents almost empty - in fact, a service through WantedBy options allow themselves to be dependent on the target start. So if you go to open avahi-daemon.service, NetworkManager.service .service and other documents to see, you will see this line in the Install section:

WantedBy = multi-user.target
Thus, the switch to multi-user would be able to start up the object (enable) those cells containing the above statement. There are other targets are available to start (for example emergency.target provide an emergency use of shell, and halt.target for machine shutdown), you can easily switch between them in the following manner:

systemctl isolate emergency.target
In many ways, they are like SysVinit in run level (runlevel), such as text mode multi-user.target similar to the third operating level, graphical.target similar run level 5, reboot.target similar to the first 6 run level, and so on.

Compared with the traditional script, unit configuration file may seem strange, but it is not difficult to understand.

Open and stop

Now you may be lost in thought: We have seen so much, but they could not see how to stop and start the service! This is actually a reason. From the outside, Systemd may be very complex and difficult to manage general beasts. So before you start playing with it, it is necessary to look at from a macro point of view of how it works. The actual command for managing services is very simple:

systemctl stop cups.service
systemctl start cups.service
(If a unit is disabled, you may want to add the name of the unit adopted systemctl enable it enabled. Such an approach would create a symbolic link for the unit, and place it in the current boot target .wants directory, these directories .wants in / etc / systemd / system folder.)

There are two useful command is systemctl restart and systemctl reload, followed by the unit name. The latter used to allow unit to reload its configuration file. Systemd the vast majority have a good document, so you can view manuals (man systemctl) for details on each command.

Timer unit: replace Cron

In addition to system initialization and service management, Systemd also encroach on other aspects. In large part, it can complete cron job, it can be said in a more flexible way (and with more readable syntax). cron program is a predetermined time interval to perform tasks - such as removing temporary files, flush the cache and so on.

If you re-enter the / usr / lib / systemd / system directory, you'll see that there have many .timer files. Use less to view these files, you will find them with .service and .target file has a similar structure, except that the segment [Timer]. for example:

[Timer]
OnBootSec = 1h
OnUnitActiveSec = 1w
OnBootSec option tells Systemd start one hour after the system starts this unit. The second option is to mean: Since then start the unit once a week. About timer has a number of options you can set, enter man systemd.time view complete list.

Systemd time accuracy of one minute by default. That is, it will run the unit at the set time of one minute, but not necessarily accurate to that second. This is done for reasons of power management, but if you do not have any need for a delay timer and accurate to the millisecond, you can add the following line:

AccuracySec = 1us
In addition, WakeSystem option (can be set to true or false) determines whether the timer can wake dormant machine.

Systemd have a graphical interface program, even if it has not been actively maintained for many years.

Log Files: say hello to journald

The second major part Systemd the journal. This is a logging system, similar to syslog but also some significant differences. If you are a fan of a Unix log management mode, ready out of anger it: This is a binary log, so you can not use the conventional command-line text-processing tools to parse it. This design decision, not surprisingly on the Internet caused a heated debate, but there are some advantages. For example, the log can be more systematically organized, with more metadata, so you can more easily filter out information based on the name of the executable file and the process number.

To view the entire journal, enter the following command:

journalctl
Like many other Systemd command, the command will output towards less program by way of the pipeline, so you can use the spacebar to scroll down, type / (slash) search, and other familiar keyboard shortcuts. You can also see in this a little color, like red warning and error messages.

The above command will output a lot of information. In order to limit its output only the start of this message, use the following command:

journalctl-b
This is the place Systemd shine! You want to see all started since the last news? Try journalctl -b -1 bar. Then the last? Replace it with -2 -1. That from a specific time, for example, at 16:38 on October 24th, 2014 since it?

journalctl-b --since = "2014-10-2416: 38"
Even if you feel sorry for the binary log, it is still a useful feature, and many system administrators to construct similar filter than to write a regular expression in terms of easier.

We have to be able to pinpoint the specific time according to the log, and that according to a specific procedure? In terms of units, try this:

journalctl-u gdm.service
(Note: This is a good way to view the X server to generate logs) that depending on the particular process ID?

journalctl _PID = 890
You can even look at an executable file request message generated:

journalctl / usr / bin / pulseaudio
If you want the message to be output is limited to a certain priority, you can use the -p option. This option parameter is 0, then only display emergency messages (that is, it is time to pray for the $ DEITY) (LCTT Annotation: $ DEITY is a computer-related humor, DEITY means "God" in a broad sense, $ Prefix indicates that this is a variable) for 7, then displays all messages, including debugging messages. See the manual (man journalctl) For more information about priority.

It is worth noting that you can also combine several options, if you want to view the current launch by the GDM service output priority of 3 or less the message, use the following command:

journalctl-u gdm.service -p 3-b
Finally, if you just want to open a terminal window with the journal continuously updated, as used when no Systemd tail order to achieve it, enter journalctl -f enough.

Binary log is not popular, but the journal does have its advantages, such as very easy to find and filter information.

No Systemd life?

If you are totally unacceptable Systemd, you still have some major releases choice. Especially Slackware, as the oldest release, yet to make a change, but its main developer does not remove it from the future planning. Some distributions are not known to stick with SysVinit.

But this in turn how long? Gnome is increasingly dependent on Systemd, other mainstream desktop environment will follow suit. This is caused by a panic BSD community reasons: Systemd closely linked with the Linux kernel, leading to a certain extent, the desktop environment is becoming more and more non-portable. A compromise solution might be to Uselessd (http://uselessd.darknedgy.net) form soon: one cropped version Systemd, purely focused on start-up and monitoring process, without consuming the entire base system.

If you do not like Systemd, you can try Gentoo release, it Systemd initialization tool as an option, but does not force users to use Systemd.
     
         
         
         
  More:      
 
- Java, boolean operators & =, | = ^ = use (Programming)
- HBase table data processing tab (Database)
- Linux Getting Started Tutorial: / var / spool / clientmqueue fill the root directory (Linux)
- Elasticsearch 2.20 Beginners: aggregation (Server)
- Tor Browser: under Linux for anonymous Web browsing ultimate browser (Linux)
- Use GNU / Linux broadcasting of television programs (Linux)
- Git Advanced Tutorial (Linux)
- Linux System Getting Started Learning: Disable Ubuntu Apport internal error reporting procedures (Linux)
- Linux asynchronous read documents by AIO (Programming)
- Using LLVM Clang and Blocks under Linux (Programming)
- Awk include binding capacity larger than the specified size of all files directory (Linux)
- Ubuntu Tutorial - Manually install Oracle Java JDK 8 (Linux)
- Linux partition command (Linux)
- floating IP in OpenStack neutron (Server)
- Linux Mint under tty.js Installation Guide (Linux)
- 10 Regulation of painless SQL Schema (Database)
- Linux system file directory structure Introduction (Linux)
- Ceph distributed storage system is installed on a CentOS 7.1 (Server)
- Use Redis as time-series database: why and how (Database)
- Linux systems for entry-learning: Install closed-source packages in Debian (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.