Found 2065 Articles for Operating System

How to list all users in a Linux group?

Mukul Latiyan
Updated on 30-Jul-2021 08:59:51

904 Views

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 More

How to limit the number of results returned from grep in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:58:49

800 Views

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 More

How to know what the ‘errno’ means in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:54:44

907 Views

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 More

How to iterate over a list of files with spaces in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:49:46

359 Views

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 More

How to invert a grep expression on Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:47:14

8K+ Views

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 More

How to install the latest version of Git on CentOS 7.x/6.x?

Mukul Latiyan
Updated on 30-Jul-2021 08:45:33

726 Views

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 More

How to insert a text at the beginning of a file in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:44:30

2K+ Views

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 More

How to grep string without filenames in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:42:35

5K+ Views

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

How to grep multiline search patterns in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:41:10

2K+ Views

In order to be able to grep multiple lines of pattern present in a file, we will make use of the number of grep command that Linux provides us with. But first, we must 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 ... Read More

How to grep and replace a word in a file on Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:39:11

3K+ Views

While there are plenty of ways to print and make use of specific words from a particular file in a Linux directory, when we talk about grepping a particular word and then replacing it with some other word, then we will need to mix certain Linux utility commands.The two Linux utility commands that we must be aware of are −find − used to locate a particular file or directorysed −short for stream editor and is used to perform functions like searching, editing and replacing.In order to solve the problem of grep and replace a particular word we will make use ... Read More

Advertisements