5 ‘hostname’ Command Examples for Linux Newbies

A hostname command is used to view a computer’s hostname and domain name (DNS) (Domain Name Service), and to display or set a computer’s hostname or domain name.

A hostname is a name that is given to a computer that attached to the network that uniquely identifies over a network and thus allows it to be accessed without using its IP address.

The basic syntax for the hostname command is:

# hostname [options] [new_host_name]

In this short article, we will explain 5 useful hostname command examples for Linux beginners to view, set or change Linux system hostname from the Linux command-line interface.


If you run hostname command without any options, it will displays the current host name and domain name of your Linux system.

$ hostname
tecmint
Show Linux Hostname

Show Linux Hostname

If the host name can be resolved, you can display the network address(es) (IP address) of the host name with the -i flag and the -I option establishes all configured network interfaces and shows all network addresses of the host.

$ hostname -i
$ hostname -I
Show Hostname IP Addresses

Show Hostname IP Addresses

To view the name of the DNS domain and FQDN (Fully Qualified Domain Name) of your machine, use the -f and -d switches respectively. And the -A enables you to see all the FQDNs of the machine.

$ hostname -d
$ hostname -f
$ hostname -A
Show Host DNS Names

Show Host DNS Names

To display the alias name (i.e., substitute names), if used for the host name, use the -a flag.

$ hostname -a

Last but not least, to change or set hostname of your Linux system, simply run the following command, remember to replace “NEW_HOSTNAME” with the actual hostname that you wish to set or change.

$ sudo hostname NEW_HOSTNAME
Set Linux System Hostname

Set Linux System Hostname

Note that the changes made using the above command will only last until the next reboot. Under systemd – system and service manager, you can use the hostnamectl command to permanently set or change your system hostname as explained in the following articles.

  1. How to Set or Change System Hostname in Linux
  2. How to Set or Change Hostname in CentOS 7

That’s It! In this short article, we explained 5 hostname command examples for Linux newbies. If you have any questions, use the feedback form below to reach us.

Get GOOSE VPN Subscriptions to Browse Anonymously and Securely

‘,
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: ‘tecmint’}},
click: function(api, options){
api.simulateClick();
api.openPopup(‘twitter’);
}
});
jQuery(‘#facebook’).sharrre({
share: {
facebook: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup(‘facebook’);
}
});
jQuery(‘#googleplus’).sharrre({
share: {
googlePlus: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php’,
click: function(api, options){
api.simulateClick();
api.openPopup(‘googlePlus’);
}
});
jQuery(‘#linkedin’).sharrre({
share: {
linkedin: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: ‘Get GOOSE VPN Subscriptions to Browse Anonymously and Securely’,media: ‘https://www.tecmint.com/wp-content/uploads/2018/03/Goose-VPN-Service.png’ }
},
click: function(api, options){
api.simulateClick();
api.openPopup(‘linkedin’);
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(“.sharrre-container”),
header = jQuery(‘#header’),
postEntry = jQuery(‘.entry’),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){ var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom – (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom – shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop 1024)
topSpacing = distanceFromTop + jQuery(‘.nav-wrap’).outerHeight();
else
topSpacing = distanceFromTop;
}
});
]]>

Meet the Raspberry Pi 3 Model B+

Raspberry Pi just celebrated its sixth birthday—that’s six years since the launch of the original Raspberry Pi. Since then, it has released various new models, including the Pi 2, Pi 3, and Pi Zero. So far, 9 million Raspberry Pi 3s have been sold—and over 18 million Pis in total—and those numbers are likely to grow following today’s announcement of the Raspberry Pi 3 Model B+. This new Pi features:

  • 1.4GHz 64-bit quad-core ARM Cortex-A53 CPU
  • Gigabit Ethernet (over USB)
  • Dual-band WiFi and Bluetooth
  • Power-over-Ethernet (PoE) pins
  • Improved PXE and USB booting
  • Improved thermal management

This is a big update to the existing Pi 3, including a re-spin of the BCM2837 CPU (running faster at 1.4GHz), new dual-band wireless connectivity (so you can connect to both 2.4- and 5-GHz WiFi networks), better thermal control, and more. As always, you’ll need an up-to-date Raspbian SD card, but the new model is backwards-compatible with all previous models and runs the same operating systems and programs. The Raspberry Pi 3 Model B+ is available now at the usual price of $35.

raspberry-pi-3bplus-1_1.jpg

Gigabit Ethernet and PoE

The Raspberry Pi has always suffered an Ethernet bottleneck, throttling network speeds over USB 2.0. The new 3B+ replaces the LAN9514 USB hub with a with a LAN7515 adding Gigabit Ethernet. It’s still limited by USB 2.0 but gives a 3x LAN throughput increase, which will please a lot of Pi users with network-hungry applications in the home and in industrial applications.

raspberry-pi-3bplus-5_1.jpg

The addition of four new pins offset from the main GPIO header provides support for Power-over-Ethernet. An official HAT (add-on board) has been designed to provide this feature natively, and it will be released soon.

The original Raspberry Pi 3 was the first Pi board to support multiple boot modes (an alternative to regular booting from the SD card)—including PXE network booting and booting from USB mass storage devices. This means you can boot Raspbian from a USB hard drive, which has faster disk I/O than an SD card.

The PiServer tool, launched in December, provides simple Raspberry Pi network management. This means you can manage a cluster of Raspberry Pi 3s on a wired network, and the Pis don’t need SD cards inserted as they boot remotely into a managed operating system image. This is ideal for classrooms, handy in the home, and can even be used to manage factory automation processes in industrial applications.

The 3+ also supports netbooting, and some minor bugs in the bootrom, found in the Pi 3 after rollout, have been fixed.

Thermals and power management

Over the years, as the Raspberry Pi became more powerful and increased its CPU speed, it became more power-hungry and tended run hotter. The 3+ improves power regulation, allowing the Pi to run happily at 1.4GHz when the CPU is under 70°C, and it decreases the core voltage and drops to 1.2GHz above 70°C before throttling at 80°C, but the improved power management should prevent it from reaching this point.

With Raspberry Pi 1 you could get away with using low-power mobile phone chargers. Although some of them can manage to boot the Pi 3 and 3+ ok, they likely won’t stand up to intensive applications that draw lots of power, so a quality 2.5A power supply is recommended.

What can you do with it?

There are many applications for Raspberry Pi: it’s used heavily in education (in schools and in coding clubs), in the home (see 5 projects for Raspberry Pi at home), and in industry. Many people use Pis for media centers and home automation projects or just for learning about code and building hardware projects. You can do physical computing and camera projects. Check out the getting started guide, read up on which Raspberry Pi to choose for your project, and take a look at this selection of Raspberry Pi add-on boards. Learn how to set up Postgres on the Pi and write a Twitter bot with Python!

Get involved with the Raspberry Pi Foundation

The Raspberry Pi Foundation is not just a hardware company. It’s primarily an educational charity with the aim of putting the power of digital making into the hands of people all over the world. Making affordable, programmable computers is just one of the things the Foundation does to help with this goal.

Last weekend, the Raspberry Jam Big Birthday Weekend took place, and over 120 Jam events took place around the world. Check out the round-up of these events, and see how to run a Raspberry Pi meetup in your community.

Raspberry Jam Big Birthday Weekend

You can also give young people an opportunity to learn about coding and digital making by starting a Code Club or CoderDojo near you.

How to measure particulate matter with a Raspberry Pi

We regularly measure particulate matter in the air at our school in Southeast Asia. The values here are very high, particularly between February and May, when weather conditions are very dry and hot, and many fields burn. These factors negatively affect the quality of the air. In this article, I will show you how to measure particulate matter using a Raspberry Pi.

What is particulate matter?

Particulate matter is fine dust or very small particles in the air. A distinction is made between PM10 and PM2.5: PM10 refers to particles that are smaller than 10µm; PM2.5 refers to particles that are smaller than 2.5µm. The smaller the particles—i.e., anything smaller than 2.5µm—the more dangerous they are to one’s health, as they can penetrate into the alveoli and impact the respiratory system.

The World Health Organization recommends limiting particulate matter to the following values:

  • Annual average PM10 20 µg/m³
  • Annual average PM2,5 10 µg/m³ per year
  • Daily average PM10 50 µg/m³ without permitted days on which exceeding is possible.
  • Daily average PM2,5 25 µg/m³ without permitted days on which exceeding is possible.

These values are below the limits set in most countries. In the European Union, an annual average of 40 µg/m³ for PM10 is allowed.

What is the Air Quality Index (AQI)?

The Air Quality Index indicates how “good” or “bad” air is based on its particulate measurement. Unfortunately, there is no uniform standard for AQI because not all countries calculate it the same way. The Wikipedia article on the Air Quality Index offers a helpful overview. At our school, we are guided by the classification established by the United States’ Environmental Protection Agency.

What do we need to measure particulate matter?

Measuring particulate matter requires only two things:

  • A Raspberry Pi (every model works; a model with WiFi is best)
  • A particulates sensor SDS011

If you are using a Raspberry Pi Zero W, you will also need an adapter cable to a standard USB port because the Zero has only a Micro USB. These are available for about $20. The sensor comes with a USB adapter for the serial interface.

Installation

For our Raspberry Pi we download the corresponding Raspbian Lite Image and write it on the Micro SD card. (I will not go into the details of setting up the WLAN connection; many tutorials are available online).

If you want to have SSH enabled after booting, you need to create an empty file named ssh in the boot partition. The IP of the Raspberry Pi can best be obtained via your own router/DHCP server. You can then log in via SSH (the default password is raspberry):

$ ssh pi@192.168.1.5

First we need to install some packages on the Pi:

$ sudo apt install git-core python-serial python-enum lighttpd

Before we can start, we need to know which serial port the USB adapter is connected to. dmesg helps us:


$ dmesg
[ 5.559802] usbcore: registered new interface driver usbserial
[ 5.559930] usbcore: registered new interface driver usbserial_generic
[ 5.560049] usbserial: USB Serial support registered for generic
[ 5.569938] usbcore: registered new interface driver ch341
[ 5.570079] usbserial: USB Serial support registered for ch341-uart
[ 5.570217] ch341 1–1.4:1.0: ch341-uart converter detected
[ 5.575686] usb 1–1.4: ch341-uart converter now attached to ttyUSB0

In the last line, you can see our interface: ttyUSB0. We now need a small Python script that reads the data and saves it in a JSON file, and then we will create a small HTML page that reads and displays the data.

Reading data on the Raspberry Pi

We first create an instance of the sensor and then read the sensor every 5 minutes, for 30 seconds. These values can, of course, be adjusted. Between the measuring intervals, we put the sensor into a sleep mode to increase its lifespan (according to the manufacturer, the lifespan totals approximately 8000 hours).

We can download the script with this command:

$ wget -O /home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py

For the script to run without errors, two small things are still needed:


$ sudo chown pi:pi /var/wwww/html/
$ echo[] > /var/wwww/html/aqi.json

Now you can start the script:


$ chmod +x aqi.py
$ ./aqi.py
PM2.5:55.3, PM10:47.5
PM2.5:55.5, PM10:47.7
PM2.5:55.7, PM10:47.8
PM2.5:53.9, PM10:47.6
PM2.5:53.6, PM10:47.4
PM2.5:54.2, PM10:47.3

Run the script automatically

So that we don’t have to start the script manually every time, we can let it start with a cronjob, e.g., with every restart of the Raspberry Pi. To do this, open the crontab file:

$ crontab -e

and add the following line at the end:

@reboot cd /home/pi/ && ./aqi.py

Now our script starts automatically with every restart.

HTML page for displaying measured values and AQI

We have already installed a lightweight webserver, lighttpd. So we need to save our HTML, JavaScript, and CSS files in the directory /var/www/html/ so that we can access the data from another computer or smartphone. With the next three commands, we simply download the corresponding files:


$ wget -O /var/wwww/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html
$ wget -O /var/wwww/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js
$ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css

The main work is done in the JavaScript file, which opens our JSON file, takes the last value, and calculates the AQI based on this value. Then the background colors are adjusted according to the scale of the EPA.

Now you simply open the address of the Raspberry Pi in your browser and look at the current particulates values, e.g., http://192.168.1.5:

The page is very simple and can be extended, for example, with a chart showing the history of the last hours, etc. Pull requests are welcome.

The complete source code is available on Github.

[Enter our Raspberry Pi week giveaway for a chance at this arcade gaming kit.]

Wrapping up

For relatively little money, we can measure particulate matter with a Raspberry Pi. There are many possible applications, from a permanent outdoor installation to a mobile measuring device. At our school, we use both: There is a sensor that measures outdoor values day and night, and a mobile sensor that checks the effectiveness of the air conditioning filters in our classrooms.

Luftdaten.info offers guidance to build a similar sensor. The software is delivered ready to use, and the measuring device is even more compact because it does not use a Raspberry Pi. Great project!

Creating a particulates sensor is an excellent project to do with students in computer science classes or a workshop.

What do you use a Raspberry Pi for?

AMP – A Vi/Vim Inspired Text Editor for Linux Terminal

‘,
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: ‘tecmint’}},
click: function(api, options){
api.simulateClick();
api.openPopup(‘twitter’);
}
});
jQuery(‘#facebook’).sharrre({
share: {
facebook: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup(‘facebook’);
}
});
jQuery(‘#googleplus’).sharrre({
share: {
googlePlus: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php’,
click: function(api, options){
api.simulateClick();
api.openPopup(‘googlePlus’);
}
});
jQuery(‘#linkedin’).sharrre({
share: {
linkedin: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: ‘AMP – A Vi/Vim Inspired Text Editor for Linux Terminal’,media: ‘https://www.tecmint.com/wp-content/uploads/2018/03/AMP-Vi-Vim-Inspired-Text-Editor-for-Linux.png’ }
},
click: function(api, options){
api.simulateClick();
api.openPopup(‘linkedin’);
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(“.sharrre-container”),
header = jQuery(‘#header’),
postEntry = jQuery(‘.entry’),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){ var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom – (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom – shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop 1024)
topSpacing = distanceFromTop + jQuery(‘.nav-wrap’).outerHeight();
else
topSpacing = distanceFromTop;
}
});
]]>

How to Install Rust Programming Language in Linux

Rust (commonly known as Rust-Lang) is a relatively new, open source practical systems programming language that runs extremely fast, prevents segfaults, and guarantees thread safety. It is a safe and concurrent language developed by Mozilla and backed by LLVM.

It supports zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics and pattern matching. It also supports type inference, minimal runtime as well as efficient C bindings.

Rust can run on a great number of platforms and is being used in production by companies/organizations such as Dropbox, CoreOS, NPM and many more.

In this article, we will show how to install Rust programming language in Linux and setup your system to get started with writing programs with rust.

Install Rust Programming Language in Linux


To install Rust, use the following official method of installing rust via the installer-script, which requires curl command-line downloader as shown.

$ sudo apt-get install curl [On Debian/Ubuntu]
# yum install install curl [On CentOS/RHEL]
# dnf install curl [On Fedora]

Then install rust by running the following command in your terminal, and follow the onscreen instructions. Note that rust is actually installed as well as managed by the rustup tool.

$ curl https://sh.rustup.rs -sSf | sh
Install Rust in Linux

Install Rust in Linux

Once the Rust installation is complete, the Cargo’s bin directory (~/.cargo/bin – where all tools are installed) will be added in your PATH environment variable, in ~/.profile.

During the installation rustup will attempt to add the cargo’s bin directory to your PATH; if this fails for one reason or another, do it manually to get started with using rust.

Add Rust Cargo Bin Directory to PATH

Add Rust Cargo Bin Directory to PATH

Next, source the ~/.profile file to use the modified PATH and configure your current shell to work with the rust environment by running these commands.

$ source ~/.profile
$ source ~/.cargo/env

Finally verify the version of rust installed on your system by running the following command.

$ rustc --version
Check Rust Installed Version in Linux

Check Rust Installed Version in Linux

Test Rust Programming Language in Linux

Now that you have rust installed on your system, you can test it by creating your first rust program as follows. Begin by making a directory where your program files will reside.

$ mkdir myprog
$ cd myprog

Create a file called test.rs, copy and paste the following lines of code to the file.

fn main() {
println!("Hello World, it’s TecMint.com – Best Linux HowTos, Guides on the Internet!");
}

Then run the following command which will create an executable called test in the current directory.

$ rustc main.rs

Finally, execute test as shown.

$ ./test 
Write Programs in Rust Language

Write Programs in Rust Language

Important: You should take note of these points about rust releases:

  • Rust has a 6-week rapid release process, be sure to get many builds of rust available at any time.
  • Secondly, all these builds are managed by rustup, in a consistent manner on every supported platform, enabling installation of rust from the beta and nightly release channels, and support for additional cross-compilation targets.

Rust Homepage: https://www.rust-lang.org/en-US/

In this article, we have explained how to install and use rust programming language in Linux. Try it out and give us your feedback or share any queries via the comment form below.

GRV – A Tool for Viewing Git Repositories in Linux Terminal

‘,
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: ‘tecmint’}},
click: function(api, options){
api.simulateClick();
api.openPopup(‘twitter’);
}
});
jQuery(‘#facebook’).sharrre({
share: {
facebook: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup(‘facebook’);
}
});
jQuery(‘#googleplus’).sharrre({
share: {
googlePlus: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php’,
click: function(api, options){
api.simulateClick();
api.openPopup(‘googlePlus’);
}
});
jQuery(‘#linkedin’).sharrre({
share: {
linkedin: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: ‘GRV – A Tool for Viewing Git Repositories in Linux Terminal’,media: ‘https://www.tecmint.com/wp-content/uploads/2018/03/GRV-View-Git-Repositories-in-Linux-Terminal.png’ }
},
click: function(api, options){
api.simulateClick();
api.openPopup(‘linkedin’);
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(“.sharrre-container”),
header = jQuery(‘#header’),
postEntry = jQuery(‘.entry’),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){ var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom – (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom – shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop 1024)
topSpacing = distanceFromTop + jQuery(‘.nav-wrap’).outerHeight();
else
topSpacing = distanceFromTop;
}
});
]]>

systemd-analyze – Find System Boot-up Performance Statistics in Linux

Are you using systemd system and service manager, and your Linux system taking longer time to boot or you simple want to view the reports of your system boot-up performance? If yes, you have landed on the right place.

In this article, we will show you how to analyze a Linux system boot-up performance statistics using systemd-analyze, one of numerous utilities under systemd for system management.

Read Also: How to Control Systemd Services on Remote Linux Server

To get an overview of the system boot-up time, we can run systemd-analyze command without any arguments as follows. It will list information about how much time each service took to start, which includes time taken by kernel, initrd and userspace while booting.

# systemd-analyze
Startup finished in 884ms (kernel) + 3.861s (initrd) + 48.356s (userspace) = 53.102s


If you want to view a list of all running units, sorted by the time they took to initialize (highest time on top), the blame sub-command is used for this purpose. After running the command that follows, use [Enter] to view more services in the list and q to quit.

# systemd-analyze blame 

Find Out Time Each Unit Took to Start

 16.159s mariadb.service
12.178s libvirtd.service
10.298s tuned.service
9.836s postfix.service
8.704s lsws.service
7.352s lscpd.service
4.988s [email protected]
4.779s NetworkManager-wait-online.service
4.577s lvm2-monitor.service
4.439s ModemManager.service
4.413s polkit.service
4.280s dev-sda1.device
4.225s systemd-udev-settle.service
3.957s firewalld.service
3.227s rhel-dmesg.service
3.221s abrt-ccpp.service
3.142s rsyslog.service
3.053s avahi-daemon.service
3.042s pure-ftpd.service
2.249s gssproxy.service
2.212s NetworkManager.service
1.889s proc-fs-nfsd.mount
1.780s systemd-tmpfiles-setup-dev.service
1.451s sshd.service
1.267s rhel-readonly.service
1.035s sysstat.service
1.001s rpc-statd-notify.service
910ms systemd-logind.service
739ms kdump.service
738ms network.service
...

As you can see from the above output that each unit is sorted based on the time taken, you can simply find out which service is taking longer time while booting and analyze the issue.

Next, we can also view a tree of the time-critical chain for the default target or a list of specified units with the critical-chain sub-command as shown.

# systemd-analyze critical-chain 

Print time-critical Chain for Default Target

The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
multi-user.target @48.342s
??mariadb.service @31.560s +16.159s
??network.target @31.558s
??network.service @30.819s +738ms
??NetworkManager-wait-online.service @26.035s +4.779s
??NetworkManager.service @23.821s +2.212s
??network-pre.target @23.821s
??firewalld.service @19.863s +3.957s
??polkit.service @15.381s +4.413s
??basic.target @12.271s
??sockets.target @12.271s
??virtlockd.socket @12.270s
??sysinit.target @12.251s
??systemd-update-utmp.service @12.196s +54ms
??auditd.service @11.705s +486ms
??systemd-tmpfiles-setup.service @11.609s +93ms
??rhel-import-state.service @11.397s +211ms
??local-fs.target @11.363s
??run-user-0.mount @46.910s
??local-fs-pre.target @10.575s
??lvm2-monitor.service @5.996s +4.577s
??lvm2-lvmetad.service @7.376s
??lvm2-lvmetad.socket @5.987s
??-.slice
# systemd-analyze critical-chain ntp.service networking.service

Finally, let’s look at one more important sub-command that allows for producing graphical (svg format) detailing of system services that have been started, and at what time, highlighting their initialization time, as follows.

Make sure graphical display mode or x-windows is enabled in order to view the plot.

# systemd-analyze plot > boot_analysis.svg
# xviewer boot_analysis.svg 
Linux Boot Analysis

Linux Boot Analysis

All the above commands will print the boot-up performance statistics for the local machine. To view information from a remote host over ssh, use the -H flag and specify the [email protected] directive, as shown.

# systemd-analyze time -H [email protected]
# systemd-analyze blame -H [email protected]
# systemd-analyze critical-chain -H [email protected]

systemd-analyze can also be used to find other state and tracing information from the system and systemd (service manager) and more. For more information, see its man page.

# man systemd-analyze 

Read Also: How to Change Runlevels (targets) in SystemD

That’s it for now! If you have any questions or thought to share, use the feedback form below to reach us.

Learn Ethical Hacking Using Kali Linux From A to Z Course

‘,
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: ‘tecmint’}},
click: function(api, options){
api.simulateClick();
api.openPopup(‘twitter’);
}
});
jQuery(‘#facebook’).sharrre({
share: {
facebook: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup(‘facebook’);
}
});
jQuery(‘#googleplus’).sharrre({
share: {
googlePlus: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php’,
click: function(api, options){
api.simulateClick();
api.openPopup(‘googlePlus’);
}
});
jQuery(‘#linkedin’).sharrre({
share: {
linkedin: true
},
template: ‘{total}’,
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: ‘Learn Ethical Hacking Using Kali Linux From A to Z Course’,media: ‘https://www.tecmint.com/wp-content/uploads/2018/03/Learn-Ethical-Hacking-with-Kali-Lin.jpg’ }
},
click: function(api, options){
api.simulateClick();
api.openPopup(‘linkedin’);
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(“.sharrre-container”),
header = jQuery(‘#header’),
postEntry = jQuery(‘.entry’),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){ var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom – (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom – shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop 1024)
topSpacing = distanceFromTop + jQuery(‘.nav-wrap’).outerHeight();
else
topSpacing = distanceFromTop;
}
});
]]>

Exodus – Safely Copy Linux Binaries From One Linux System to Another

Exodus is a simple yet useful program for easily and securely copying Linux ELF binaries from one system to another. For example, if you have htop (Linux Process Monitoring Tool) installed on your desktop machine, but not installed on your remote Linux server, exodus gives a way to copy/install the htop binary from the desktop machine to the remote server.

It bundles all of the binary’s dependencies, compiling a statically linked wrapper for the executable that invokes the relocated linker directly, and installing the bundle in the ~/.exodus/ directory, on the remote system.

You can see it in action here.

Exodus Htop Demo


Exodus really comes in handy in two critical cases: 1) if you do not have root access on a machine and/or 2) if the package you want to use is not available for the Linux distribution you are running on another machine.

Install Exodus in Linux Systems


You can install exodus using Python PIP package manager, as follows. The command below will perform a user specific installation (only for the account you have logged on with).

$ sudo apt install python-pip [Install PIP On Debian/Ubuntu]
$ sudo yum install epel-release python-pip [Install PIP On CentOS/RHEL]
$ sudo dnf install python-pip [Install PIP On Fedora]
$ pip install --user exodus-bundler [Install Exodus in Linux] 

Next, add the directory ~/.local/bin/ to your PATH variable in your ~/.bashrc file, in order to run the exodus executable like any other system command.

export PATH="~/.local/bin/:${PATH}"
Add Exodus Path in Bashrc

Add Exodus Path in Bashrc

Save and close the file. Then open another terminal window to start using exodus.

Note: It is also highly recommended that you install gcc and one of either musl libc or diet libc (C libraries used to compile small statically linked launchers for the bundled applications), on the machine where you’ll be packaging binaries.

Use Exodus to Copy Local Binary To a Remote Linux System

Once you have installed exodus, you can copy a local binary (htop tool) to a remote machine by simply running the following command.

$ exodus htop | ssh [email protected]
Exodus Copy Htop Binaries to Remote Linux

Exodus Copy Htop Binaries to Remote Linux

Then login to the remote machine, and add the directory /home/tecmint/.exodus/bin to your PATH in your ~/.bashrc file, in order to run the htop like any other system command.

export PATH="~/.exodus/bin:${PATH}"
Add Exodus Path in Remote Linux Bashrc

Add Exodus Path in Remote Linux Bashrc

Save and close the file, then source it as follows, for the changes to take effect.

$ source ~/.bashrc

Now you should be able to run htop on your remote Linux machine.

$ htop

If you have two or more binaries with the same name (for example, more than one version of htop installed on your system, one /usr/bin/htop and another /usr/local/bin/htop), you can copy and install them in parallel with the -r flag, it enables for assigning of aliases for each binary on the remote machine.

The following command will install the two htop versions in parallel with /usr/bin/grep called htop-1 and /usr/local/bin/htop called htop-2 as shown.

$ exodus -r htop-1 -r htop-2 /usr/bin/htop /usr/local/bin/htop | ssh [email protected]

Attention: Exodus has a number of limitations and it may fail to work with non-ELF binaries, incompatible CPU architectures, incompatible Glibc and kernel versions, driver dependent libraries, pro-grammatically loaded libraries and non-library dependencies.

For more information, see the exodus help page.

$ exodus -h 

Exodus Github repository: https://github.com/intoli/exodus

Conclusion

Exodus is simple yet powerful tool for copying binaries from one Linux machine to another remote Linux system. Try it out and give us your feedback via the comment form below.