3

I recently installed a fresh CentOS 7.1 server. I'm noticing a few differences from CentOS 6.7, and I'm hoping there is a way to revert to an old view of certain things.

For example:

Question 1: top

The Top command displays data differently. For example:

New Top View:

top - 00:27:45 up  4:58,  1 user,  load average: 0.08, 0.50, 0.89
Tasks: 155 total,   2 running, 153 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  1.1 sy,  0.0 ni, 98.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  4047624 total,  1938600 free,   853888 used,  1255136 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  2860704 avail Mem

Old Top View:

top - 00:28:59 up 22:49,  1 user,  load average: 0.19, 0.21, 0.24
Tasks: 157 total,   1 running, 156 sleeping,   0 stopped,   0 zombie
Cpu(s): 17.9%us,  1.0%sy,  0.0%ni, 80.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4055052k total,  3456240k used,   598812k free,   584160k buffers
Swap:  4194296k total,   191184k used,  4003112k free,  1076124k cached

Is there any way to display the memory and stats using the old format?

Question 2: service Command

With Centos 6.7, if I did something like service httpd restart, it would give me an OK or Failure message. CentOS 7.1 doesn't seem to do that.

Old view:

# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

New view:

# service httpd restart
Redirecting to /bin/systemctl restart  httpd.service

Is there any way to go back to the old view? I realize this is somewhat trivial, but there have been plenty of times where a service wasn't already started, or would not stop for some reason. The message status is a nice way to see that.

Will
  • 1,127
  • 10
  • 25

3 Answers3

6

CentOS 7 is a significantly different OS from CentOS 6. Instead of wanting to go backwards you should embrace the change and move forwards. You can't go backwards with these commands (or any others really) without going back to C6.

Learn to use systemctl instead of service; it's just as easy once the muscle memory is relearned. Wait until you have to work with firewalld though, that's 'fun'.

Other things that you'll find different.

The net-tools package that provides netstat, ifconfig etc is not installed by default it has been superseded by the tools in iproute ss, ip etc.

Many of the logs you are used to examining are not in/var/log you need to enable rsyslog to get access to them or use journalctl.

Ohh and there's hostnamectl and ... and ...

user9517
  • 114,104
  • 20
  • 206
  • 289
  • 3
    Or sit there with a grumpy expression and a heart full of dislike for Lennart Poettering (the systemd guy), and continue using C6 for as long as you can, like me. – MadHatter Jan 02 '16 at 06:38
  • 1
    Firewalld is irritating like and old bowel for sure. The rest is just muscle memory. – user9517 Jan 02 '16 at 06:41
  • I've learned to live with firewalld, but then again I started using it two years before most of you. :) – Michael Hampton Jan 02 '16 at 06:43
  • 1
    @Iain you and I should sit down over a pint sometime and chew this over. I think I have legitimate design complaints about systemd, and I'm sure I'm not the only person who thinks so; but this is probably not the place to re-rehash that discussion. I merely note that I can still, for now, refuse to go forward into a sunny upland which triggers my allergies. – MadHatter Jan 02 '16 at 06:57
  • To move forward or not is a different discussion entirely from eeeek! this is different and scary now how can I make it the same as I'm used to. – user9517 Jan 02 '16 at 07:03
  • I agree, which is why I don't want to do the former here. To my mind, the answer to the latter is not to move forward at this time. My underlying point is that "*I want to move forward but not have things change*" isn't a legitimate option, but doing neither is, and some people are. – MadHatter Jan 02 '16 at 09:55
  • 3
    Fork ! MadHatterOS ;) – user9517 Jan 02 '16 at 09:57
6

Question 1

Try using top -M instead.

-M : Detect memory units
        Show memory units (k/M/G) and display floating point values in the
        memory summary.

KiB is a SI unit representing 1000 bytes, where KB represents 1024 bytes.

Personally, I always just install htop and use that instead, as I find it far more readable, far more informative, and far more powerful.

Also, free -k (kilobytes), free -m (megabytes), or free -g (gigabytes) will also provide the memory usage information you're looking for.

Edit: On further investigation, top -M may not work on CentOS 7. Here's a great answer with some alternative approaches, and alternatives to top and htop.

Question 2

CentOS 7 replaced the legacy sysvinit with systemd. This is a significant, but necessary change, as sysvinit has become quite outdated, and working around its deficiencies can be a struggle for developers and administrators. Ubuntu, Debian, RHEL, SUSE, and nearly every other major Linux distribution have also made the switch to systemd.

The proper way to interact with a systemd service on these distributions is to use the systemctl command:

restart NAME...
   Restart one or more units specified on the command line. If the units are not running
   yet, they will be started.

So, in your case:

systemctl restart httpd

Using systemctl will show you the indication of success or failure that you're looking for (and return an appropriate exit code).

As @Iian said, embrace these changes, as this same change has already taken place on every major Linux distribution.

Will
  • 1,127
  • 10
  • 25
  • FYI -- '-M' is not a valid switch in TOP (neither is -m). I guess they changed it. – Scott Summers Jan 02 '16 at 11:24
  • Right, it seemed to change during the migration from `procps` to `procps-ng`. I added a note. Thanks! – Will Jan 02 '16 at 11:49
  • 3
    Actually, [KiB](https://en.wikipedia.org/wiki/Kibibyte) is a unit for 1024 bytes, while a [KB](https://en.wikipedia.org/wiki/Kilobyte) is 1000 bytes (keeping consistent with the SI definition kilo=1000). – vurp0 Jan 02 '16 at 21:46
4

Your second question about the lack of status when restarting the httpd service is perfectly reasonable.
The service command being deprecated you will need to get used to the systemctl command.
But you will also need to get used to the systemctl status command.
Instead of

# service httpd restart

You will have to type

# systemctl restart httpd
# systemctl status httpd
# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2016-01-02 11:45:01 CET; 8s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 29795 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─29795 /usr/sbin/httpd -DFOREGROUND
           ├─29796 /usr/sbin/httpd -DFOREGROUND
           ├─29797 /usr/sbin/httpd -DFOREGROUND
           ├─29798 /usr/sbin/httpd -DFOREGROUND
           ├─29799 /usr/sbin/httpd -DFOREGROUND
           └─29800 /usr/sbin/httpd -DFOREGROUND

Jan 02 11:45:01 vm.certdepot.net systemd[1]: Starting The Apache HTTP Ser....
Jan 02 11:45:01 vm.certdepot.net systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

It is clear that you will need to type two commands instead of one, which is not a clear progress.
However, you will get a much better idea of the current configuration:

  • is the service running?
  • what messages did it write at boot into the log messages?
  • is the service activated at boot?
  • which configuration unit file was used?
  • which CGroup this service belongs to?
CertDepot
  • 41
  • 1