Found 1436 Articles for Linux

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

527 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

744 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

486 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

What happens to Open File Handle if file is Moved or Deleted?

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

247 Views

Overview We’ll look at how the operating systems behave when we delete, move or replace files that have open handles. We’ll first briefly talk about files and inodes. After that, we’ll look at the different scenarios and see which one occurs in each case. Understanding Files and Inodes Files stored on a Linux file system use inode numbers to keep track of their contents. We usually list the contents of a directory by listing its file names (links) and then their corresponding inode numbers (hard links). We can use stat on a file and see which inode it refers to ... Read More

How to solve “Unary operator expected” errors?

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

7K+ Views

Overview In this article, we will discuss how to solve the unary operator expected error in Linux. This is one of the most common errors that you may encounter while working with Linux. In this post, we will see how to fix it and what are the possible causes for this error. What Is Unary Operator Expected? The unary operator expects is a type of syntax error that occurs when an expression has only one operand. For example − int x 5; //error - unary operator expected The above code snippet shows an error because there is no binary operation ... Read More

How to Clear Linux terminal screen?

Satish Kumar
Updated on 26-Dec-2022 11:06:58

1K+ Views

Overview The Linux terminal is an important tool for any user of the operating system, and it's often used to perform various tasks such as viewing log files or running commands. However, sometimes you may need to clear a screen on your computer so that you can see more than one thing at once. In this article we'll look at how to clear a screen in Linux. It’ll be helpful if we clear the command prompt window so that we can see more clearly what we're doing. We’ll discuss the different ways to accomplish this. Using the clear Command You ... Read More

Count lines in a file using Linux bash

Satish Kumar
Updated on 03-Nov-2023 21:47:56

43K+ Views

Overview We sometimes need to determine how large or small a particular text document is. For example, if we're trying to figure out how long a certain email message is, we might use the number of lines in that message to help us estimate its size. Linux has several different methods for determining the length of a text document. We’ll take a closer peek at some of the most common ways of calculating the number of lines in a specific file. Setup For this quick tutorial, we’ll be using a text file called “programing.txt” which has some of the most ... Read More

Manipulating images with ImageMagick command

Satish Kumar
Updated on 26-Dec-2022 11:04:15

299 Views

Overview ImageMagick is an open source software suite for image manipulation. We can install it on our system using apt−get and then run commands through its command line interface (CLI). We’ll take a quick peek at some of the most popular methods for manipulating images with ImageMagick. Installation Let’s start by downloading ImageMagick, which we can install using our package manager (e.g., apt). We can also download the binary directly or compile it from the sources. After installing the software, let’s check whether we've successfully installed it by looking at its current status. $ magick -version Version: ImageMagick 7.0.8-13 Q16 ... Read More

Advertisements