Thursday, October 30, 2014

Configure YUM repository using DVD or CD ROM

Necessary when for example you are configuring a Redhat Server without a paid for subscription
at lease this gives you access to all the programs on the CD / DVD

Mount your CD Rom. in this example we mount cd rom to  to /mnt/cdrom

mount /dev/cdrom /mnt/cdrom

Create the new repo file called cdrom.repo under /etc/repos.d directory.

vi /etc/repos.d/cdrom.repo

Add the following details.

name=CDROM Repo

cntrl -  x to save

1. [cdrom]  -  Name of the Section.
2. name =  Name of the repository
3. baseurl = Location of the package
4. Enabled = Enable repository
5 gpgcheck= Enable secure installation
6. gpgkey= Location of the key

To test
Install the package using the yum command, let’s install the MySQL package using  YUM.

yum install mysql-server

Using systemctl to Manage Services

Using systemctl to Manage Services

Note: For in all examples below, the format of may also be used instead - though it is not required in recent versions of systemd, and is therefore not shown.

Several examples of widely used services are: httpd (Apache Web server), sshd (SSH server), nfs (NFS server), autofs (AutoFS service), vsftpd (the "Very Secure FTP" server), and many more...

Start a Service

# systemctl start

Stop a Service

# systemctl stop

Restart a Service

# systemctl restart

A Conditional Restart of a Service (Restarts a service only if it's already running)

# systemctl try-restart

Reload a Service

# systemctl reload

Check whether a Service is Running

# systemctl status  

( Or:  # systemctl is-active )

List all Available Services and Show their Running Status

Note: may be "piped" through grep, to find a specific service:  | grep  

# systemctl list-units --type service --all
or systemctl list-units -t service

Enable a Service (this makes it start automatically at start up)
does what chkconfig on used to do.

# systemctl enable

Disable a Service  (this stops the service from starting at startup)
does what chkconfig off used to do.

# systemctl disable

Check whether a Service is Enabled

# systemctl is-enabled  

( Also mentioned in: # systemctl status , under "Loaded:" )

List all Available Services, and check whether they are Enabled

Note: may be piped through grep, to find a specific service:  | grep

# systemctl list-unit-files --type service 

Kill all Running Processes Related to a Service

# systemctl kill

Available unit types.
Service unit          .service         A system service.
Target unit          .target         A group of systemd units.
Automount unit .automount A file system automount point.
Device unit        .device A device file recognized by the kernel.
Mount unit        .mount A file system mount point.
Path unit                .path         A file or directory in a file system.
Scope unit        .scope An externally created process.
Slice unit                .slice         A group of organized units that manage system processes.
Snapshot unit        .snapshot         A saved state of the systemd manager.
Socket unit        .socket An inter-process communication socket.
Swap unit        .swap A swap device or a swap file.
Timer unit        .timer A systemd timer.

Boot process

Systemd primary task is to manage the boot process and provides information about it.
To get the boot process duration, type:

# systemd-analyze

To get the time spent by each task during the boot process, type:

# systemd-analyze blame

To get the list of the dependencies, type:

# systemctl list-dependencies

More examples

To move to single user mode, type:

# systemctl rescue
To move to the level 3 (equivalent to the previous level 3), type:

# systemctl isolate

# systemctl isolate
To move to the graphical level (equivalent to the previous level 5), type:

# systemctl isolate
To set the default run level to non-graphical mode, type:

# systemctl set-default
To set the default run level to graphical mode, type:

# systemctl set-default
To get the current default run level, type:

# systemctl get-default

To stop a server, type:

# systemctl poweroff
Note: You can still use the poweroff command, a link to the systemctl command has been created (the same thing is true for the halt and reboot commands).

To reboot , suspend it or put your machine into hibernation, type:

# systemctl reboot
# systemctl suspend
# systemctl hibernate

Journal analysis

In addition, Systemd handles the system event log, a syslog daemon is not mandatory any more.
To get the content of the Systemd journal, type:

# journalctl
To get all the events related to the crond process in the journal, type:

# journalctl /sbin/crond
Note: You can replace /sbin/crond by `which crond`.

To get all the events since the last boot, type:

# journalctl -b
To get all the events that appeared today in the journal, type:

# journalctl --since=today
To get all the events with a syslog priority of err, type:

# journalctl -p err
To get the 10 last events and wait for any new one (like “tail -f /var/log/messages“), type:

# journalctl -f