×


Blog


w Command in Linux - Explained with Examples

This article covers all you need to know about the w command in Linux. In fact, The w command is a built-in tool that allows administrators to view information about users that are currently logged in. This includes their username, where they are logged in from, and what they are currently doing.


w Command in Linux Syntax

The Linux w command is a system utility that displays information about currently logged-in users. It uses the following syntax:

$ w [options] [username]

Where:

  • [options]: Options that change the way the command behaves.
  • [username]: Entering the name of a specific user only shows information about that particular user in the output.


The w command uses the following options:

  • -h, --no-header Print output without the header.
  • -u, --no-current Ignores username when calculating current process times and load.
  • -s, --short Print output in the short format.
  • -f, --from Toggle printing the FROM (remote hostname) field.
  • --help Display help text.
  • -i, --ip-addr Replace the hostname in the FROM field with the IP address.
  • -V, --version Display current command version.
  • -o, --old-style Print old-style output (blank space for idle times shorter than 1 minute).


Python If Else Statement - Explained with Examples

This article covers how to use the if else statement in Python. In fact, An if else Python statement evaluates whether an expression is true or false. If a condition is true, the "if" statement executes. Otherwise, the "else" statement executes. Python if else statements help coders control the flow of their programs.


Python Conditions and If statements

Python supports the usual logical conditions from mathematics:

  • Equals: a == b
  • Not Equals: a != b
  • Less than: a < b
  • Less than or equal to: a <= b
  • Greater than: a > b
  • Greater than or equal to: a >= b


Python Nested if statements

We can have a if...elif...else statement inside another if...elif...else statement. This is called nesting in computer programming.

Any number of these statements can be nested inside one another. Indentation is the only way to figure out the level of nesting. They can get confusing, so they must be avoided unless necessary.


Python Nested if Example

'''In this program, we input a number

check if the number is positive or

negative or zero and display

an appropriate message

This time we use nested if statement'''


num = float(input("Enter a number: "))
if num >= 0:
    if num == 0:
        print("Zero")
    else:
        print("Positive number")
else:
    print("Negative number")

Output 1 will give:

Enter a number: 5
Positive number


Output 2 will give:

Enter a number: -1
Negative number


Output 3 will give:

Enter a number: 0
Zero


Python Arrays in Linux - Explained with examples

This article covers how to use Array in Python. In fact, An array is a special variable, which can hold more than one value at a time.


Python Lists Vs Arrays

In Python, we can treat lists as arrays. However, we cannot constrain the type of elements stored in a list. 

For example:

# elements of different types
a = [1, 3.5, "Hello"] 
If you create arrays using the array module, all elements of the array must be of the same numeric type.
import array as arr
# Error
a = arr.array('d', [1, 3.5, "Hello"])

Output will give:

Traceback (most recent call last):
  File "<string>", line 3, in <module>
    a = arr.array('d', [1, 3.5, "Hello"])
TypeError: must be real number, not str


Monitor User Activity With acct Tool on Ubuntu 20.04

This article covers how to monitor user activity with the acct tool on Ubuntu 20.04. In fact, Acct can monitor the user activity & getting the information about the user performance. It provides the information about last commands executed by users, user logins / logouts details in hours by day-wise, system activity information,& individuals user information.


How to install acct on ubuntu ?

1. Update the System:

$ apt-get update

2. Install the psacct or acct on system:

$ apt-get install acct

3. Check the acct version:

$ ac --version


Install Grafana on CentOS 8 - Step by step guide ?

This article covers how to install and configure the Grafana monitoring tool on CentOS 8 system via the command line. In fact, Grafana is a popular open-source visualization and analytics monitoring software which renders graphs, charts, and alerts when connected to supported data sources. Now, you can use the grafana monitoring dashboard on CentOS 8 system.


Install GNU Octave on Ubuntu 20.04 LTS - Step by step guide ?

This article covers the complete installation procedure of GNU Octave on the Ubuntu machine via different methods. In fact, Octave is a scientific application that uses a Matlab-like interpreted high-level language for numerical computations and simulations. Octave offers functions to solve linear and nonlinear problems, can plot the results as graphics and offers capabilities for data manipulation and visualization. Also it provides an interactive command line interface and a GUI interface but can also be used in noninteractive scripts for data processing.