Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Linux Articles
Page 111 of 134
How to list running screen sessions on Linux?
Screen or sometimes also known as GNU Screen, is a terminal multiplexer. What it means is that it allows you the privilege to start a screen session and then open any number of windows inside that session.It might also be interesting to note that a process that is running in Screen will continue to run even when their window is not visible anymore.Installing Linux ScreenIn order to install the screen package if it is not already present on your Linux distribution, you can run any of the suitable commands shown below for your machine.For Ubuntu and Debiansudo apt update sudo ...
Read MoreHow to list down all the available commands and aliases on Linux?
Linux provides us with a huge amount of commands along with their aliases that we can make use of. Although these commands serve different purposes we can still make use of all these commands anywhere we like in the terminal.There are different ways with which we can interact with Linux commands. When it comes to listing all the available commands to the terminal we also have different approaches, either we can write a shell script by ourselves or we can use a shell library function that does that for us.Let’s consider the first approaches where I'll make use of a ...
Read MoreHow to list all users in a Linux group?
In order to be able to understand the command to list all the users that are present in a Linux group, you first must be able to print all the users present.For that there are many different possible ways, I’ll make use of the compgen command. The compgen command is a Linux utility command that is used to list all the commands that can be executed in a Linux terminal, and when used with a -u flag we can simply print all the users present on Linux.Consider the command shown below as reference −compgen -uOutputroot daemon bin sys sync games man ...
Read MoreHow to limit the number of results returned from grep in Linux?
In order to be able to grep limit the number of results returned from grep command in Linux, we must first understand what a grep command is and how to use it on Linux.The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there are plenty ...
Read MoreHow to know what the ‘errno’ means in Linux?
Errno is a value that you get when the command you run returns the value of the call indicating an error. There is a header file that defines the integer variable errno, which is set by the system calls and some library function in the event of an error to let the developer know what’s wrong.In simple terms, the “errnos” are symptoms of operating system errors. Generally produced by failed operating system calls.In UNIX, the errnos are defined in upper case letters.ExampleEPERM ENOENT ESRCH EINTR EIO ENXIOIn the above examples, some formatted errnos are mentioned that have different values and ...
Read MoreHow to iterate over a list of files with spaces in Linux?
In order to iterate over a list of files we will need to make use of the find command that Linux provides us with.Linux find statement is one of the most widely used statements that allows us to walk a file hierarchy. It is used to mostly find a specific file or directories and we can also append different other Linux statements or flags along with it to enhance or do a complex operation.Let’s explore an example of a find statement to understand it better.In the Linux code shown below, I am trying to search for a file inside my ...
Read MoreHow to invert a grep expression on Linux?
In order to be able to invert a grep expression on Linux command line, we must first understand what a grep command is and how to use it on Linux.The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there are plenty of different options available ...
Read MoreHow to install the latest version of Git on CentOS 7.x/6.x?
Installing the latest version of Git on CentOS can be done in many ways. Below are three approaches for the same.Approach 1Commandsyum install epel-release yum remove git rpm -U https://centos7.iuscommunity.org/ius-release.rpm yum install git2u git --versionOutputimmukul@192 lib % git --version git version 2.29.2Approach 2Commandsyum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker export GIT_VERSION=2.29.2 mkdir /root/git cd /root/git wget "https://www.kernel.org/pub/software/scm/git/git-2.29.2.tar.gz" tar xvzf "git-2.29.2.tar.gz" cd git-2.29.2 make prefix=/usr/local all make prefix=/usr/local install yum remove -y git git --versionOutputimmukul@192 git-2.29.2 % git --version git version 2.29.2Approach 3Commandssudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm sudo yum install git git --versionOutputimmukul@192 git-2.29.2 % ...
Read MoreHow to insert a text at the beginning of a file in Linux?
In order to insert text at the beginning of a text file we must be familiar with either the sed command as the sed commands can be used to solve the above problem.Let’s first explore the sed command, which is short for stream editor. This command is used to perform different functions like find, replace, insert and many more on a particular file.Consider we have a directory d1 in which two .txt files are present and the directory looks something like this −immukul@192 d1 % ls -ltr total 8280 -rwxrwxrwx 1 immukul staff 4234901 Jul 7 17:41 ...
Read MoreHow to grep string without filenames in Linux?
We know that we can make use of the grep command to search for a particular pattern of characters in all the lines of a file or multiple files. The grep command performs a case-insensitive search for words in a file.Let’s see a simple example where we will grep a pattern in all the files that are present in a directory.Commandgrep -i ‘lp’ Sample*OutputSample: The sample was printed via the internet. Sample: I believe lp cares about what the device is. Sample1: This was printed via the internet. Sample1: I believe lp cares about what the device is. Sample2: This ...
Read More