Sunday, December 15, 2024

man vs tldr: Why The tldr Command is Better And How You Can Use It

https://www.maketecheasier.com/linux-tldr-command

Man Vs Tldr Which Is Better And Why Feature Image

To avoid any confusion, I must first state that this article is dealing with the man and tldr commands in Linux. While man pages are incredibly detailed, they can be intimidating, especially for those just starting out. Instead, you can use the tldr command to get a short, simple, and easy-to-understand explanation of any Linux command.

In this guide, we’ll dive deep into what tldr is, how to use it, and why it’s a better alternative to the traditional man command.

The Man Command

The man command, referred to manual, is the traditional way to access documentation for commands in Unix-like operating systems. When you type man along with a command, it pulls up the manual page for that specific command, providing detailed information about its usage, options, and examples.

For example, you can get a detailed overview of the ls command by executing this:

man ls
Viewing Ls Command Using Man Command

This opens a manual page listing all the available options. The information is organized into sections like NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and EXAMPLES. While this structure makes it easy to navigate, it can also be quite extensive.

The man command can be incredibly useful for advanced users who need in-depth knowledge, but it may feel like wading through a vast amount of text for beginners or even intermediate users. The sheer volume of information can overwhelm you, and you can easily lose your way in it.

What Is Tldr?

tldr stands for too long; didn’t read, a phrase originating on the internet to describe a summary of a long text piece. Unlike man pages, tldr pages focus on the most useful options and provide clear, real-world examples.

For example, when you run tldr ls in the terminal, the tldr command will provide you with a brief overview of the ls command, along with some of its most commonly used options:

tldr ls
Viewing ls command information including its example using the tldr Command.

As you can see, tldr pages are much more concise and to the point, making it easier for new users to quickly understand and start using a command.

How to Use Tldr

To access tldr pages conveniently, install a supported client. One of the main clients is Node.js, which serves as the original client for the tldr project. To explore other client applications available for different platforms, you can refer to the TLDR clients wiki page.

You can install Node.js using the package manager corresponding to your Linux distribution. For example, on Debian-based distributions such as Linux Mint or Ubuntu, run this:

sudo apt install nodejs npm

Once you’ve installed Node.js and its package manager npm, you can globally install the tldr client by running this:

sudo npm install -g tldr
Installing Tldr Using Npm

If you prefer, you can also install tldr as a Snap package by executing:

sudo snap install tldr

After installation, the tldr client allows you to view simplified, easy-to-understand versions of command-line manual pages. For instance, to get a concise summary of the tar command, simply type:

tldr tar
Viewing Tar Command Using Tldr

You can also search for specific commands using keywords with the --search option:

tldr --search "Keyword"

Additionally, you can list all available commands using the -l option:

tldr -l

You can also simply run tldr in the terminal to explore all other tldr command options:

Tldr Command Options

If you prefer a browser-based experience, the official tldr website offers the same content in a web-friendly format. It includes features like a search bar with autocomplete and labels indicating whether a command is specific to Linux or macOS.

Tldr Web Browser Page

Sunday, December 8, 2024

34 Best Developer Tools for Building Modern Apps

https://www.tecmint.com/developer-tools-for-modern-apps

34 Best Developer Tools for Building Modern Apps

Building modern apps can seem overwhelming with the many tools and technologies available. However, having the right tools can make a huge difference in the development process, helping developers work faster and more efficiently.

Whether you’re making a mobile application, a web application, or a desktop application, there are essential tools that can improve your workflow. This article will cover some must-have developer tools for building modern apps and explain how they can help you.

1. Code Editors and IDEs (Integrated Development Environments)

The foundation of any development work is the code editor or Integrated Development Environment (IDE) you use. A good code editor is essential for writing and editing your app’s code efficiently.

Visual Studio Code (VS Code)

Visual Studio Code is a free, open-source code editor developed by Microsoft that supports a variety of programming languages, offers a rich set of extensions, and has features like IntelliSense, debugging, and version control.

Visual Studio Code
Visual Studio Code

JetBrains IntelliJ IDEA

IntelliJ IDEA is a powerful IDE that’s especially good for Java development, though it supports many other languages and comes with smart code suggestions and easy refactoring tools.

IntelliJ IDEA: A Powerful IDE
IntelliJ IDEA: A Powerful IDE

Sublime Text

Sublime Text is a lightweight code editor with a clean interface, ideal for quick edits or smaller projects, that also supports extensions and customizable features.

Sublime Text: A Versatile Code Editor
Sublime Text: A Versatile Code Editor

Vim Editor

Vim, short for “Vi Improved“, is a powerful, open-source text editor designed for both command-line and graphical interfaces.

It offers advanced capabilities which include syntax highlighting, macros, and support for numerous programming languages, making it suitable for a wide range of development tasks.

Vim: A Versatile Text Editor for Developers
Vim: A Versatile Text Editor for Developers

A code editor or IDE should be chosen based on your app’s development needs. For example, if you’re working with JavaScript or TypeScript, VS Code is an excellent choice because it supports these languages well.

2. Version Control Tools

Version control is crucial for tracking changes to your code, collaborating with other developers, and managing different versions of your app.

Git

Git is the most popular version control system used by developers worldwide, which helps you track changes in your code and share it with others.

Git allows you to go back to earlier versions of your app and resolve conflicts when multiple developers work on the same code.

Git: The Powerful Version Control System
Git: The Powerful Version Control System

GitHub

GitHub is a platform that hosts Git repositories and offers features for collaboration, code reviews, and issue tracking. It’s ideal for open-source projects and team-based development.

Git Repository Hosting Platform
Git Repository Hosting Platform

GitLab

GitLab is similar to GitHub but offers a Git repository platform with additional DevOps tools like CI/CD (Continuous Integration and Continuous Deployment) pipelines.

GitLab: A Comprehensive DevOps Platform
GitLab: A Comprehensive DevOps Platform

Bitbucket

Bitbucket is a Git repository management tool with a focus on team collaboration, which is especially popular for private repositories.

GitLab: Private Repository Management
GitLab: Private Repository Management

Version control helps you keep track of your code changes and collaborate with other developers without overwriting each other’s work. Learning Git is essential for any developer.

3. Package Managers

Managing dependencies is one of the key challenges in app development and package managers help you automate the process of installing, updating, and managing third-party libraries or frameworks your app depends on.

npm (Node Package Manager)

npm is the default package manager for Node.js that will help you manage dependencies and install packages easily when you are working with JavaScript or building web apps.

npm: The Official Package Manager for Node.js
npm: The Official Package Manager for Node.js

Yarn

Yarn is a faster alternative to npm that also helps manage dependencies for JavaScript projects. Yarn has built-in caching for faster installs and uses a lock file to ensure consistent package versions across different machines.

Yarn: A Faster Package Manager
Yarn: A Faster Package Manager

Homebrew

Homebrew is a package manager for macOS (and Linux) that allows you to install command-line tools and software easily.

Homebrew: Easy Package Management
Homebrew: Easy Package Management

pip

pip is the default package manager for Python that helps you install and manage Python libraries and dependencies.

pip - Python Package Installer
pip – Python Package Installer

Using package managers can save you a lot of time by managing all the dependencies your app needs and making sure they are up to date.

4. Containerization and Virtualization

Containers allow developers to package an app and its dependencies together, making it easier to run the app in different environments, such as development, testing, and production. Virtualization tools are also helpful for testing your app in different environments.

Docker

Docker is a tool that enables developers to package applications and their dependencies into containers, and these containers can run consistently on any machine, whether on your local computer, a cloud server, or in a production environment.

Docker: The Ultimate Tool for Containerization
Docker: The Ultimate Tool for Containerization

Kubernetes

Kubernetes is a system for automating the deployment, scaling, and management of containerized applications, which is ideal for larger projects where you need to manage multiple containers.

Kubernetes: Automate Container Management
Kubernetes: Automate Container Management

Vagrant

Vagrant is a tool for building and maintaining virtual machine environments, it allows you to create a virtual machine with the required software and dependencies for your app, making it easier to share development environments across teams.

Vagrant: Simplify Virtual Machine Management
Vagrant: Simplify Virtual Machine Management

Using Docker and Kubernetes ensures your app will run smoothly in different environments, reducing “works on my machine” issues.

5. Database Management Tools

Most modern apps need to interact with a database to store and retrieve data. Whether you’re using a relational database like MySQL or a NoSQL database like MongoDB, managing and interacting with these databases is an essential part of app development.

MySQL Workbench

MySQL Workbench is a graphical tool for managing MySQL databases, it offers an easy-to-use interface for writing queries, creating tables, and managing your database.

MySQL Workbench: Database Management Tool
MySQL Workbench: Database Management Tool

pgAdmin

pgAdmin is a management tool for PostgreSQL databases, offering a rich set of features for interacting with your database, writing queries, and performing administrative tasks.

pgAdmin: PostgreSQL Management Tool
pgAdmin: PostgreSQL Management Tool

MongoDB Compass

MongoDB Compass is a GUI for MongoDB that allows you to visualize your data, run queries, and interact with your NoSQL database.

MongoDB Compass: A GUI for MongoDB
MongoDB Compass: A GUI for MongoDB

DBeaver

DBeaver is a universal database management tool that supports multiple databases, including MySQL, PostgreSQL, SQLite, and others.

DBeaver: Database Management Tool
DBeaver: Database Management Tool

Having a good database management tool helps you efficiently interact with and manage your app’s database.

6. API Development Tools

Modern apps often rely on APIs (Application Programming Interfaces) to interact with other services or allow third-party apps to interact with your app. API development tools help you design, test, and manage APIs efficiently.

Postman

Postman is a popular tool for testing APIs, which allows you to send HTTP requests, view responses, and automate API tests. Postman is especially helpful during the development and testing phase of your app.

Postman: The Ultimate API Testing Tool
Postman: The Ultimate API Testing Tool

Swagger/OpenAPI

Swagger/OpenAPI is a framework for designing, building, and documenting RESTful APIs. Swagger can generate interactive API documentation that makes it easier for other developers to understand and use your API.

Swagger/OpenAPI: Design and Document APIs
Swagger/OpenAPI: Design and Document APIs

Insomnia

Insomnia is another API testing tool similar to Postman, but with a focus on simplicity and ease of use. It’s great for developers who want a lightweight tool to test APIs without too many distractions.

Insomnia: Simple API Testing
Insomnia: Simple API Testing

Using API development tools can make it easier to test and debug your app’s integration with external services.

7. Testing Tools

Testing is a crucial step in building modern apps, which ensures that your app works correctly and provides a good user experience. Whether you’re testing individual pieces of code (unit testing) or the entire app (end-to-end testing), the right tools are essential.

JUnit

JUnit is a framework for writing and running unit tests in Java. It’s widely used in the Java development community.

JUnit: Java Unit Testing Framework
JUnit: Java Unit Testing Framework

Mocha

Mocha is a JavaScript testing framework that runs in Node.js and in the browser, and helps you write tests for your app’s behavior.

Mocha: JavaScript Testing Framework
Mocha: JavaScript Testing Framework

Selenium

Selenium is a tool for automating web browsers, allowing you to perform end-to-end testing of your web app’s UI.

Selenium: Automate Web Browsers
Selenium: Automate Web Browsers

Jest

Jest is a testing framework for JavaScript that works well with React and other JavaScript frameworks. Jest offers fast and reliable tests with great debugging features.

Jest: A Powerful JavaScript Testing Framework
Jest: A Powerful JavaScript Testing Framework

Good testing tools help you identify bugs early, improve the quality of your app, and ensure that it works as expected.

Continuous Integration and Continuous Deployment (CI/CD) Tools

CI/CD is a modern practice that involves automating the process of testing, building, and deploying your app. CI/CD tools help you ensure that your app is always in a deployable state and can be released to production quickly and reliably.

Jenkins

Jenkins is a popular open-source automation server that allows you to automate building, testing, and deploying your app, it integrates with many version control systems and other tools.

Jenkins: The Ultimate CI/CD Automation Tool
Jenkins: The Ultimate CI/CD Automation Tool

Travis CI

Travis CI is a cloud-based CI/CD service that integrates easily with GitHub and automates the process of testing and deploying your app.

Travis CI: Automate Your Builds and Deployments
Travis CI: Automate Your Builds and Deployments

CircleCI

CircleCI is a fast, cloud-based CI/CD tool that integrates with GitHub, Bitbucket, and GitLab, and helps automate the testing and deployment of your app.

CircleCI: Automate Your Builds and Deployments
CircleCI: Automate Your Builds and Deployments

GitLab CI/CD

GitLab CI/CD offers built-in CI/CD features, allowing you to manage the entire software development lifecycle from code to deployment in one platform.

Simplify Your DevOps with GitLab CI/CD
Simplify Your DevOps with GitLab CI/CD

CI/CD tools help automate the repetitive tasks of building, testing, and deploying, saving developers a lot of time and reducing the chances of human error.

9. Cloud Platforms and Hosting Services

For modern apps, hosting them in the cloud is often the best option, as cloud platforms provide scalable infrastructure, security, and high availability for your app.

Amazon Web Services (AWS)

Amazon Web Services (AWS) is a comprehensive cloud platform offering a wide range of services, including computing, storage, databases, machine learning, and more. AWS is ideal for large-scale apps with high traffic.

AWS: Cloud Computing Platform
AWS: Cloud Computing Platform

Microsoft Azure

Microsoft Azure is a cloud platform offering various services, including hosting, storage, AI, and databases, which is a popular choice for enterprises and developers building apps on Microsoft technologies.

Microsoft Azure: Cloud Computing Platform
Microsoft Azure: Cloud Computing Platform

Google Cloud Platform (GCP)

Google Cloud Platform (GCP) offers tools for building, deploying, and scaling applications. GCP is especially popular for apps that rely on machine learning and big data.

Google Cloud Platform (GCP)
Google Cloud Platform (GCP)

Heroku

Heroku is a platform-as-a-service (PaaS) for building, running, and scaling apps, which is great for smaller apps or when you need a quick and easy way to deploy your app.

Heroku: Platform as a Service
Heroku: Platform as a Service

Cloud platforms provide the infrastructure your app needs to run in a scalable, secure, and cost-effective manner.

Conclusion

Building modern apps requires a combination of the right tools to handle different aspects of the development process. Whether you’re writing code, managing dependencies, testing your app, or deploying it to the cloud, having the right tools can make a huge difference in your productivity and the quality of your app.

By using the tools mentioned above, you’ll be well-equipped to build, test, and deploy modern apps efficiently. Happy coding!

 

Friday, December 6, 2024

8 Linux Commands to Diagnose Hard Drive Issues in Linux

https://www.tecmint.com/fix-hard-drive-bottlenecks-in-linux

8 Linux Commands to Diagnose Hard Drive Issues in Linux

As a Linux expert with over a decade of experience managing servers, I have seen how crucial it is to identify and resolve hard drive bottlenecks to keep a system running smoothly.

Bottlenecks occur when a system’s performance is limited by a specific component, in this case, the hard drive, where slow disk operations can drastically affect the performance of your applications, databases, and even the entire system.

In this article, I will explain how to identify hard drive bottlenecks on Linux using various tools and commands, and what to look for when troubleshooting disk-related issues.

What is a Hard Drive Bottleneck?

A hard drive bottleneck happens when the disk cannot read or write data fast enough to keep up with the system’s demands. This often results in slow response times, lag, and even system crashes in extreme cases.

These bottlenecks are commonly caused by the following factors:

  • Overloaded Disk I/O: When the system has too many read/write requests, the disk cannot process them all at once.
  • Disk Fragmentation: On certain file systems, files may become fragmented, leading to inefficient disk usage and slower performance.
  • Hardware Limitations: Older disks or disks with smaller capacities may not be able to handle modern workloads.
  • Disk Errors: Physical problems with the hard drive, such as bad sectors, can also lead to performance issues.

How to Find Hard Drive (Disk) Bottlenecks in Linux

Here are some key Linux commands and tools that can help you identify and diagnose hard drive bottlenecks.

1. iostat (Input/Output Statistics)

iostat is a command-line utility that provides statistics on CPU and I/O usage for devices, helping you pinpoint disk bottlenecks.

iostat -x 1

Key Metrics to Look For:

  • %util: This represents how much time the disk was busy handling requests. If this number is consistently high (over 80-90%), it indicates the disk is a bottleneck.
  • await: This is the average time (in milliseconds) for a disk I/O request to complete. A high value indicates slow disk performance.
  • svctm: This represents the average service time for I/O requests. A high value means the disk is taking longer to respond.
iostat: Monitor Disk I/O in Linux
iostat: Monitor Disk I/O in Linux

2. iotop (I/O Monitoring in Real Time)

iotop is a real-time I/O monitoring tool that displays processes and their disk activity, which is useful for identifying which processes are consuming excessive disk bandwidth.

sudo iotop

This will show a list of processes that are performing disk I/O, along with the I/O read and write statistics.

iotop: Real-time Disk I/O Monitoring Tool
iotop: Real-time Disk I/O Monitoring Tool

Key Metrics to Look For:

  • Read/Write: Look for processes that have high read or write values. These processes might be causing the disk bottleneck.
  • IO Priority: Check if any process is consuming disproportionate I/O resources. You can adjust the priority of processes using ionice to manage how they interact with disk I/O.

3. df (Disk Free)

df command shows the disk space usage on all mounted filesystems. A nearly full disk can cause significant slowdowns, especially on the root or home partitions.

df -h

Ensure that disks, especially the root (/) and home (/home) directories, are not close to being full. If the disk is more than 85-90% full, it may start to slow down due to lack of space for temporary files and disk operations.

Check Disk Space Utilization
Check Disk Space Utilization

4. dstat (Comprehensive System Resource Monitoring)

dstat is a versatile tool for monitoring various system resources, including disk I/O, which provides a comprehensive overview of the system’s performance in real-time.

dstat -dny

Key Metrics to Look For:

  • disk read/write: Look for spikes in disk read/write activity. If you see constant heavy disk activity, it could indicate a bottleneck.
  • disk await: Shows how long each I/O operation takes. Long waits here mean a disk bottleneck.
dstat - Versatile System Monitoring Tool
dstat – Versatile System Monitoring Tool

5. sar (System Activity Report)

The sar command is a powerful tool that collects, reports, and saves system activity information, which is ideal for historical performance analysis.

sar -d 1 5

Key Metrics to Look For:

  • tps: The number of transactions per second. A high value suggests the disk is handling a large number of I/O requests.
  • kB_read/s and kB_wrtn/s: The rate of data being read or written. If these numbers are unusually high, it may indicate a bottleneck.
sar: System Activity Reporter
sar: System Activity Reporter

6. smartctl (S.M.A.R.T. Monitoring)

smartctl is used for checking the health of your hard drives by querying the S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) status.

This can help identify physical issues with the disk, such as bad sectors or failing components.

sudo apt install smartmontools
sudo smartctl -a /dev/sda

Key Metrics to Look For:

  • Reallocated_Sector_Ct: The number of sectors that have been reallocated due to errors. A high value indicates the disk might be failing.
  • Seek_Error_Rate: High values suggest the disk may be having trouble seeking data, often a sign of physical damage.

7. lsblk (List Block Devices)

lsblk command lists all block devices on your system, such as hard drives and partitions, which is useful for getting an overview of your system’s storage devices.

lsblk -o NAME,SIZE,ROTA,TYPE,MOUNTPOINT

Ensure that your hard drives or partitions are not overloaded with too many tasks. SSDs (non-rotational) typically offer better performance than HDDs (rotational), and an overused rotational disk can lead to performance bottlenecks.

lsblk - List Block Devices
lsblk – List Block Devices

8. vmstat (Virtual Memory Statistics)

While vmstat primarily shows memory usage, it can also provide insight into disk I/O operations and how the system handles memory swapping.

vmstat 1

Key Metrics to Look For:

  • bi (blocks in): The number of blocks read from disk.
  • bo (blocks out): The number of blocks written to disk.
  • si and so (swap in and swap out): If these values are high, it means the system is swapping, which can be caused by insufficient RAM and heavy disk usage.
vmstat: Monitor Memory and Disk I/O
vmstat: Monitor Memory and Disk I/O
Conclusion

Hard drive bottlenecks can be caused by various factors, including overloaded disk I/O, hardware limitations, or disk errors. By using the tools and commands outlined in this article, you can effectively diagnose disk-related issues on your Linux system.

Monitoring tools like iostat, iotop, and dstat provide valuable insights into disk performance, while tools like smartctl can help you identify potential hardware failures.

As a seasoned Linux professional, I recommend regularly monitoring disk performance, especially in production environments, to ensure optimal system performance. Identifying and resolving bottlenecks early can save you from performance degradation and system downtime.

 

Wednesday, December 4, 2024

LineSelect: Interactively Select Single or Multiple Lines from Stdin

https://linuxtldr.com/lineselect-tool

In this article, you will learn about a “lineselect” tool that allows you to interactively select single or multiple lines from stdin and output them to stdout, as shown.

What is LineSelect?

LineSelect is a free and open-source CLI tool that allows those working on the command line to interactively select single or multiple lines from stdin and output them to stdout.

I’d find it more useful when writing a shell script. Suppose you’re creating a shell script to administer a running Docker container. With this tool, you can allow users to interactively choose single or multiple running containers. After selection, you can use the stdout data to perform actions like checking container details, inspecting ports, stopping, deleting, etc.

Ezoic

This is one use case, but you can use it in various ways for different purposes in your shell script, and as a Node package, anyone with Node installed can effortlessly install it on their system.

So, in this article, I’ll show you how you can install LineSelect on Linux with command-line usage.

Tutorial Details

DescriptionLineSelect
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisites
Internet RequiredYes (for installation)

How to Install LineSelect on Linux

LineSelect is available as a Node package, allowing easy installation for users. However, most Linux distros currently ship with an older version of Node that is incompatible with LineSelect. Therefore, if you have Node version <20, you can refer to our article on installing the latest version of Node.

Ezoic

Once you have it installed, run the following NPM command in your terminal to install LineSelect.

$ npm install -g lineselect

Once done, run the following command to verify it’s functioning without any errors:

$ lineselect

Output:

install lineselect

If you get the same output as shown above, it means you have properly installed LineSelect using the correct version of Node. Now, let’s see some usage examples…

Usage of LineSelect

To understand the use case of LineSelect within a command-line or shell script, you must first understand its basic workings by looking at the following syntax:

Ezoic
$ some-command | lineselect | some-othercommand

Here,

  • some-command” can be any command, such as “ls“, “docker ps“, “ps“, “ss“, etc.
  • lineselect” takes the output of the chosen command and provides an interactive interface for users to select single or multiple lines.
  • some-othercommand” will be a command where the user’s selected line will be redirected. Often, its “xargs” command is used, but it’s not limited to it.

When selecting single or multiple lines using LineSelect, remember to press the “Space” key first to select and then press “Enter” button to send the selected lines to the next command.

To showcase its use case, I’ll provide various command-line examples. Once you grasp its functionality, you can confidently use it in your own command or shell script. So, let’s start with…

1. Selecting one or more text files in the current directory using LineSelect, then removing them.

$ ls *.txt | lineselect | xargs rm

Output:

Here,

  • ls *.txt” will list all the text files in the current directory.
  • lineselect” takes the stdin of the listed file and allows user to select between them.
  • xargs rm” will take the user-selected file and delete it.

2. Selecting the running Docker containers with LineSelect, then halting the selected one.

$ docker stop $(docker ps -q | lineselect)

Output:

Here,

  • docker stop” will wait for the user action, then stop the selected Docker container.
  • $(docker ps -q | lineselect)” lists the IDs of the running Docker containers and allows users to select one or more.

3. Listing the currently running processes, selecting a single or multiple of them using LineSelect, and then killing the selected process.

$ kill -9 $(ps -a | lineselect | cut -d " " -f 4)

Output:

Here,

  • kill -9” will wait for the user action, then kill the selected process using the “SIGKILL” signal.
  • $(ps -a | lineselect | cut -d " " -f 4)” once the users have selected from the list of running processes, the cut command will receive the output and filter the first column from the selected line.

I’ll end the article here, but you can see how easy and useful it is to use while writing a shell script. Now, if you have any questions or concerns related to the topic, do let me know in the comment section.

Ezoic

Till then, peace!