There are 3 different forms of the famous grep command. The list below also differentiates between their use cases. fgrep: Does a fast search for simple patterns. Use this command to quickly locate patterns without any wildcard characters, useful when searching for an ordinary word. grep: Pattern searches using ordinary regular expressions. egrep: Pattern searches […]
Archives for April 2022
file Command Examples in Linux
The file command comes with many Unix systems and has a database of signatures that it uses to identify the structure of an unknown file. The command can also be used against a directory to determine it as a directory. The syntax of the file command is very easy: # file [file or directory] Example: […]
fuser Command Examples in Linux
The fuser command is useful to determine which files are using system resources. One of the more common uses of this command is to determine which user is active in a filesystem, which prevents the system administrator from unmounting the filesystem: [root@localhost ~]# umount /boot umount: /boot: target is busy. (In some cases useful info […]
grep Command Examples in Linux (Cheat Sheet)
Often in a large file, you have to look for a specific line of data buried somewhere in the middle of the file. Instead of manually scrolling through the entire file, you can let the grep command search for you. The command-line format for the grep command is: # grep [options] pattern [file] The grep […]
groupmems Command Examples in Linux
A user is always a member of one group, the primary group, in the passwd database. Besides being a member of a primary group, additional group memberships can be added. This can be necessary to get access to a group directory/share or to delegate privileges in the sudo configuration. You can add existing additional groups […]
gunzip Command Examples in Linux
The gzip program is used to compress one or more files. When executed, it replaces the original file with a compressed version of the original. The corresponding gunzip program is used to restore compressed files to their original, uncompressed form. Here is an example: $ ls -l /etc > foo.txt $ ls -l foo.* -rw-r–r– […]
halt Command Examples in Linux
The process of shutting down the system involves the orderly termination of all the processes on the system, as well as performing some vital housekeeping chores (such as syncing all of the mounted file systems) before the system powers off. Four commands can perform this function: halt poweroff reboot shutdown halt command turns off the […]
head Command Examples in Linux
The head command does what you’d expect; it displays a file’s first group of lines (the file’s “head”). By default, it displays the first 10 lines of text: $ head log_file line1 line2 line3 line4 Hello World – line5 line6 line7 line8 line9 Hello again World – line10 $ Similar to the tail command, the […]
hostname Command Examples in Linux
This command can get or set the hostname or the NIS domain name. You can also get the DNS domain or the FQDN (fully qualified domain name). Unless you are using bind or NIS for host lookups you can change the FQDN (Fully Qualified Domain Name) and the DNS domain name (which is part of […]
httpd Command Examples in Linux
HTTPD refers to the Apache2 web server, and is commonly used on Linux systems. Web servers commonly use the HTTP Protocol to transfer web pages. Apart from HTTP, protocols such as HTTPS and FTP are also supported. To install httpd in a CentOS/RHEL server: # yum install httpd -y Now let’s start it, since this […]