Another tool or utility which is known for monitoring process in a real-time situation or condition in Linux which is very useful to be able to see how much processes running and consuming resources of the CPU or memory is ‘htop’.
Normally, another tool which is way simpler in display shown by ‘top’ can be used to aim the purpose. But ‘htop’ on the other hand is much easier to use because the first great thing about htop is that it will show the usage per CPU, text graph of memory and swap usage right at top. It is much easier to understand what is being displayed by ‘htop’ at a glance compared to the default output from ‘top’ command.
To be able to start using htop, install the utility by executing the following command :
htop
root@hostname:/opt# htop The program 'htop' is currently not installed. You can install it by typing: apt install htop You have new mail in /var/mail/root
If ‘htop’ utility didn’t exist and it is never been installed before, the installation process can be started by executing the command which is being suggested in the above output :
apt-get install htop
Below is the output of the command executed :
root@hostname:/opt# apt-get install htop Reading package lists... 0% Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: htop 0 upgraded, 1 newly installed, 0 to remove and 508 not upgraded. 1 not fully installed or removed. Need to get 76,4 kB of archives. After this operation, 215 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 htop amd64 2.0.1-1ubuntu1 [76,4 kB] Fetched 76,4 kB in 1s (75,3 kB/s) Selecting previously unselected package htop. (Reading database ... 829487 files and directories currently installed.) Preparing to unpack .../htop_2.0.1-1ubuntu1_amd64.deb ... Unpacking htop (2.0.1-1ubuntu1) ... Processing triggers for gnome-menus (3.13.3-6ubuntu3) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for man-db (2.7.5-1) ... Setting up redmine (3.2.1-2) ... Determining localhost credentials from /etc/mysql/debian.cnf: succeeded. dbconfig-common: writing config to /etc/dbconfig-common/redmine/instances/default.conf granting access to database redmine_default for redmine/instance@localhost: failed. error encountered creating user: mysql said: mysql: [Warning] mysql: Empty value for 'port' specified. Will throw an error in future versions ERROR 1290 (HY000) at line 1: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement dbconfig-common: redmine/instances/default configure: aborted. dbconfig-common: flushing administrative password dpkg: error processing package redmine (--configure): subprocess installed post-installation script returned error exit status 1 Setting up htop (2.0.1-1ubuntu1) ... Errors were encountered while processing: redmine E: Sub-process /usr/bin/dpkg returned an error code (1) You have new mail in /var/mail/root root@hostname:/opt#
In the above process, the installation failed because of the following error messages :
mysql said: mysql: [Warning] mysql: Empty value for 'port' specified. Will throw an error in future versions ERROR 1290 (HY000) at line 1: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
It seems the installation process has been stalled or failed because of some unfinished installation before for redmine, so that it cannot grant redmine_default databases since MySQL runs without any privileges being validated since -skip-grant tables is used.
In order to solve this problem, I restart MySQL service and make it sure that it is running normally. It can be done by editing my.cnf file which is responsible for MySQL Database Server configuration setting. One of the function of the -skip-grant-tables of my.cnf file represented MySQL Database Server configuration can be read in the article titled Reset MySQL Database root password by editing configuration files.
After editing the file and omitting the -skip-grant-tables entry, installation process is restart by retyping the following command :
root@hostname:/opt# apt-get install htop Reading package lists... 0% Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: htop 0 upgraded, 1 newly installed, 0 to remove and 508 not upgraded. 1 not fully installed or removed. Need to get 76,4 kB of archives. After this operation, 215 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 htop amd64 2.0.1-1ubuntu1 [76,4 kB] Fetched 76,4 kB in 1s (75,3 kB/s) Selecting previously unselected package htop. (Reading database ... 829487 files and directories currently installed.) Preparing to unpack .../htop_2.0.1-1ubuntu1_amd64.deb ... Unpacking htop (2.0.1-1ubuntu1) ... Processing triggers for gnome-menus (3.13.3-6ubuntu3) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for man-db (2.7.5-1) ... Setting up redmine (3.2.1-2) ... Determining localhost credentials from /etc/mysql/debian.cnf: succeeded. dbconfig-common: writing config to /etc/dbconfig-common/redmine/instances/default.conf granting access to database redmine_default for redmine/instance@localhost: failed. error encountered creating user: mysql said: mysql: [Warning] mysql: Empty value for 'port' specified. Will throw an error in future versions ERROR 1290 (HY000) at line 1: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement dbconfig-common: redmine/instances/default configure: aborted. dbconfig-common: flushing administrative password dpkg: error processing package redmine (--configure): subprocess installed post-installation script returned error exit status 1 Setting up htop (2.0.1-1ubuntu1) ... Errors were encountered while processing: redmine E: Sub-process /usr/bin/dpkg returned an error code (1) You have new mail in /var/mail/root root@hostname:/opt# root@hostname:/opt# vim /etc/mysql/mysql.conf.d/mysqld.cnf root@hostname:/opt# service mysqld restart Failed to restart mysqld.service: Unit mysqld.service not found. root@hostname:/opt# systemctl restart mysqld.service Failed to restart mysqld.service: Unit mysqld.service not found. root@hostname:/opt# systemctl restart mysql.service
The above is also the similar error happened because the changes on my.cnf is not being applied by restarting MySQL Database service. In the end of the output the restart process is executed by typing the following command :
root@hostname:/opt# systemctl restart mysql.service
Better to make sure MySQL service name since the above output has several failed on restarting MySQL database server since the name of the service hasn’t been checked yet. Checking the name of service which in this context is MySQL is quite easy and it is discussed in the article titled ‘Check MySQL Service Status’.
Try to restart the service and retry ‘htop’ installation process. The above errors actually didn’t happened in normal situation. So, the process of the installation shown below :
root@soulreaper:/opt# apt-get install htop Reading package lists... Done Building dependency tree Reading state information... Done htop is already the newest version (2.0.1-1ubuntu1). 0 upgraded, 0 newly installed, 0 to remove and 508 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y Setting up redmine (3.2.1-2) ... Determining localhost credentials from /etc/mysql/debian.cnf: succeeded. dbconfig-common: writing config to /etc/dbconfig-common/redmine/instances/default.conf granting access to database redmine_default for redmine/instance@localhost: already exists. creating database redmine_default: already exists. dbconfig-common: flushing administrative password rake aborted! ActiveRecord::AdapterNotSpecified: 'development' database is not configured. Available: ["production"] /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:211:in `resolve_connection' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:in `establish_connection' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in `each' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in `<module:ActiveRecord>' /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26:in `<top (required)>' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' /usr/share/redmine/lib/plugins/acts_as_activity_provider/init.rb:2:in `block in <top (required)>' /usr/share/redmine/config/initializers/00-core_plugins.rb:12:in `eval' /usr/share/redmine/config/initializers/00-core_plugins.rb:12:in `block in <top (required)>' /usr/share/redmine/config/initializers/00-core_plugins.rb:2:in `each' /usr/share/redmine/config/initializers/00-core_plugins.rb:2:in `<top (required)>' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:652:in `block in load_config_initializer' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:651:in `load_config_initializer' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `each' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `block in <class:Engine>' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `each' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `tsort_each_child' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!' /usr/share/redmine/config/environment.rb:14:in `<top (required)>' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency' /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!' /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:457:in `block in run_tasks_blocks' /var/lib/gems/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start' /var/lib/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>' /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors' /var/lib/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace) dpkg: error processing package redmine (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: redmine E: Sub-process /usr/bin/dpkg returned an error code (1) You have new mail in /var/mail/root root@soulreaper:/opt#
Although there are errors happened when encountering redmine installation, overall the installation process of ‘htop’ has succeed. It can be shown by typing ‘htop’ on command line :
root@soulreaper:/opt# htop
The above image has been edited just to study as an example to show what would ‘htop’ command displaying the output looks like.
One thought on “Using htop in Linux via Command Line”