Found 2065 Articles for Operating System

Remove Line Endings From a File on Linux

Pradeep Jhuriya
Updated on 04-Jan-2023 12:00:35

4K+ Views

Introduction Line endings are special characters that mark the end of a line in a text file. On Unix-based systems like Linux, the line ending is represented by a single newline character (''). On Windows, the line ending is represented by a combination of a carriage return ('\r') and a newline character (''), which is referred to as a "carriage return-newline" or CRLF. Sometimes, you may need to remove line endings from a file for various reasons. For example, you may want to remove line endings from a file before using it as input to a command that expects a ... Read More

Limiting Process Resource Consumption in Unix

Pradeep Jhuriya
Updated on 04-Jan-2023 11:58:47

189 Views

Introduction In a Unix-based operating system, it is important to manage the resources consumed by processes to ensure that the system runs smoothly. If a process consumes too many resources, it can cause the system to become slow or unresponsive. In some cases, it can even cause the system to crash. Therefore, it is important to be able to limit the resources that a process can consume. There are several ways to limit the resource consumption of processes in Unix. One way is to use the ulimit command, which allows you to set limits on the resources that a process ... Read More

Run a Function in a Script from the Command Line on Linux

Pradeep Jhuriya
Updated on 04-Jan-2023 11:55:43

13K+ Views

Introduction BASH (Bourne Again SHell) is a Unix shell and command language that is used frequently in Linux and other Unix-like operating systems. One of the useful features of BASH is the ability to create and use functions within script files. Functions are blocks of code that complete a specific task and can be executed from within the script or from the command line. Prerequisites Before we begin, you will need − A Linux system with a command line interface (or SSH access). A script containing a function you want to run (your custom script). The required permissions to execute ... Read More

Detach Screen From Another SSH Session

Pradeep Jhuriya
Updated on 04-Jan-2023 11:45:18

409 Views

Introduction In Linux systems, it is possible to open multiple terminal sessions over SSH (Secure SHell). This can be very useful when working on a remote server and you want to keep multiple terminal shell windows open at the same time. However, there may be situations where you need to force detach/remove a screen session that is running in another SSH session. This can happen if you accidentally leave a screen session running on a remote server and then close your terminal window, or if you want to end a screen session that someone else on your team has left ... Read More

Insert a Line at Specific Line Number

Pradeep Jhuriya
Updated on 04-Jan-2023 11:43:47

15K+ Views

Introduction Inserting a line at a specific line number in a file can be a useful task when you want to add new information to an existing file, or when you want to reorganize the contents of the file. In Linux, there are several ways to achieve this, but in this article, we will focus on using the sed command to insert a line at a specific line number. What is the sed command? sed stands for "stream editor" and it is a command line utility in Linux that allows you to modify the contents of a file or stream ... Read More

Split a File at Given Line Number

Pradeep Jhuriya
Updated on 04-Jan-2023 11:41:44

3K+ Views

Introduction Sometimes, it may be necessary to split a large file into smaller chunks for easier manipulation or for transfer to other systems. In Linux, the split command can be used to split a file into smaller files based on a specified number of lines. The split command is a utility that is used to split a file into smaller files, called chunks or pieces. The split command reads the input file, and writes the output files in the specified size or at the specified line number. By default, the split command creates files with a .x suffix, where x ... Read More

How to Record Linux Terminal Sessions?

Pradeep Jhuriya
Updated on 04-Jan-2023 11:38:02

5K+ Views

Introduction Sometimes it can be helpful to record a terminal session in Linux so that you can review the commands you ran, the output they produced, and any other text that was displayed in the terminal. In this article, we'll discuss three different ways to record terminal sessions in Linux − using the script command, using the ttyrec command, and using the asciinema tool. Method 1: Using the script command The script command is a simple and easy-to-use tool for recording terminal sessions in Linux. It captures all the text that is displayed in the terminal, as well as all ... Read More

How To Script "Yes" When Installing Programs on Linux?

Pradeep Jhuriya
Updated on 04-Jan-2023 11:20:16

607 Views

Introduction Installing programs on Linux can sometimes require user interaction, such as agreeing to license terms or specifying installation options. One way to automate this process is to use a script that automatically inputs the desired responses. In this article, we will discuss how to script the word "yes" when installing programs on Linux using the command line. Using the "yes" Command The yes command is a simple utility that repeatedly outputs a string, which can be useful for automated tasks such as accepting license agreements. Installing the "yes" Command Before we can use the yes command, we need to ... Read More

How to install Git On Mac?

Muthu Annamalai Venkatachalam
Updated on 04-Jan-2023 10:14:07

327 Views

Introduction With Git, developers can collaborate on projects and track their progress without interfering with each other. This facilitates collaboration within a project and helps prevent confusion or code clashes among team members. An evolving project is tracked and saved as snapshots, effectively keeping a history of its development. It is possible for users to communicate through the system once they install the software on their machines. Developers could collaborate over a centralized source (e.g., GitHub) where they can push and pull changes. In this tutorial, I'll show you how to install Git on a Mac. What is Git? It ... Read More

Aborting a shell script on any command fails

Satish Kumar
Updated on 03-Jan-2023 11:10:33

12K+ Views

Overview By utilizing Bash scripts, we can have access to a powerful programming language. Writing such scripts is an efficient way to run several commands one after the other. Even if one command fails, the others will still be executed. We’ll learn how we can add some safeguards so that these errors don't happen. The example code has been tested in Bash. They should also work for other POSIX-compatible shell environments. The Problem Let’s first take a look at how Bash handles error messages by default. Let's say we have a simple shell script called "hello.sh" which prints out the ... Read More

Advertisements