Found 1383 Articles for Open Source

Redirect output of process to a file and streams?

Satish Kumar
Updated on 26-Dec-2022 12:05:35

848 Views

Overview We'll look at some ways to redirect the output of processes to files and standard streams such as STDOut and STDERR simultaneously. The tee Command Tee is one of the most common Linux command line tools that we can use to redirect a process' output. It's also known as "teeing" or "piping". The tee command takes two arguments− the file name where you want the redirected output saved, and another file name which will be used for writing the original input. Redirect stdout Here we go! We're going to look at a simple example of redirect the output of ... Read More

Remove symbolic links file in Linux?

Satish Kumar
Updated on 26-Dec-2022 12:00:46

14K+ Views

Overview Symbolic links allow us to access files more easily, even if they're located in a different location. In this tutorial we'll learn how to remove symbolic links from our system and replace them with the original file. The Problem If we have an aDir folder and an aFile.text file under our current working dir, let's say. We've also created two symbolic link files pointing to the folder and the subfolder − $ ls -l total 0 drwxr-xr-x 2 kent kent 40 Apr 26 23:48 aDir/ -rw-r--r-- 1 kent kent 0 Apr 26 23:46 aFile.txt lrwxrwxrwx 1 kent kent 4 ... Read More

The “Argument list too long” Error in Linux Commands

Satish Kumar
Updated on 26-Dec-2022 11:51:19

2K+ Views

Overview In this article, we will discuss the error message that is displayed when you try to execute a command on your Linux system and it says “argument list too long”. This error can be caused by many reasons. In this post, I am going to explain what causes this error and how to resolve it. What Is The Argument List Too Long Error? This error occurs because of an invalid argument passed to a program or shell script. It means that there are more arguments than allowed by the program. For example, if you run the following command − ... Read More

Compare two directories in Linux?

Satish Kumar
Updated on 26-Dec-2022 11:48:09

2K+ Views

Introduction It's quite common for people to compare two directories. Many different factors make us want to find out whether there really is a difference between two things. For example, we normally want to figure out what's different from a previous situation when something goes wrong. We’ll learn how we can use the command line to perform directory comparisons. There are different methods we can use to compare directory listings. We'll also see some of the most commonly used commands and their options. Setup We'll create some sample directories inside the /temp directory for this tutorial. Dir1       ... Read More

Display specific columns of a file in Linux?

Satish Kumar
Updated on 26-Dec-2022 11:42:26

5K+ Views

Overview We often perform various file operations on our Linux systems. One of the most common operations is to display certain columns from a text document. Here, we’ll cover the different methods for achieving this. Display Single Column Let's create a new folder for our example. The input.txt files contain the output of the ls -l command in the long listing (long) format. $ cat input.txt -rw-r--r-- 1 jarvis jarvis 200M Nov 27 22:04 file1.dat -rw-r--r-- 1 jarvis jarvis 400M Nov 27 22:04 file2.dat -rw-r--r-- 1 jarvis jarvis 500M Nov 27 22:04 file3.dat -rw-r--r-- 1 jarvis jarvis 600M Nov 27 ... Read More

Kill a process running on a specific port?

Satish Kumar
Updated on 26-Dec-2022 11:41:07

5K+ Views

Overview It’s common when working with Linux to want to stop a process from using a specific TCP/IP protocol. For example, you might be running an application that listens for HTTP requests and you don’t want it to listen on port 80 (the standard HTTP port). You could use the netstat command to see what ports are currently being used by processes − $ netstat -lntp | grep :80 tcp6 0 0 :::80 :::* LISTEN 8072/httpd tcp4 0 0 ::ffff:127.0.0.1:80 :::::80 8069/httpd tcp6 0 127.0.0.5:53 :::* LISTEN 903/named udp6 0 0 :::22 :::* LISTEN 4963/sshd We’ll look at how to ... Read More

Redirect Output to location with Permission denied Error?

Satish Kumar
Updated on 26-Dec-2022 11:39:59

541 Views

Overview We know that we can direct the standard output (std out) of a Linux shell script to a file by using the ">" operator at the end of the Linux shell script. Sometimes, we need to redirect to a file which requires root permissions − for example, ‘sudo command > file_requires_root_. If we use the ‘su’ command, we might get an “Access Denied” message even though we’ve used ‘su’. We’ll look at the causes of this problem and see if there are any solutions. Introduction to the Problem A good example would be an explanation of the problem. Let's ... Read More

Use ./ (Dot Slash) to execute script file?

Satish Kumar
Updated on 26-Dec-2022 11:38:25

2K+ Views

Overview In this tutorial, we will see how to execute a file using the / (dot slash) command in Linux. This is one of the most commonly used commands in Linux and it’s very easy to use. Let us first understand what does the dot slash mean? What Does Dot Slash Mean In Linux Commands? The dot slash or the forward slash (/), as you may know, is used to separate directories from files. For example: If I have a directory called “/home/user1/Desktop” then when I type ls -l on that directory, it would show me all the contents of ... Read More

Copy a directory to an existing directory Linux?

Satish Kumar
Updated on 26-Dec-2022 11:31:05

777 Views

Overview Copying files is one of the most common operations performed by using the Linux shell. We usually use the cp (copy) commands for this purpose. We're going to discuss how to recursively move a folder to another location with or without overwriting. Introduction to the Problem We first need to understand what "Copy a folder to another location" means in this problem. A good example can help you understand it better. $ tree -a . ├── src │ ├── .hidden.file │ ├── srcFile.txt │ └── subSrc │ ... Read More

Build complete path in Linux by concatenate two strings?

Satish Kumar
Updated on 26-Dec-2022 11:25:24

522 Views

Overview We’ll look at some ways to create a complete Linux path by combining two paths into one. We’ll first look at some basic techniques for accomplishing this. Then, we'll talk about a generic approach that handles some of the special cases that appear when combining paths. Concatenating Strings to Build a Path We'll start by looking at an example where we want to concatenated strings to create a complete path. $ my_home_dir="/home/shubh/baeldung/" Here we assume that the current directory is where we want to clone the Git repo from. We then create a new folder called my_home_dir inside the ... Read More

Advertisements