0% found this document useful (0 votes)
10 views22 pages

Grep

The grep utility, developed by Ken Thompson, is a command-line tool used for searching text in files using regular expressions. It offers various options for case sensitivity, counting matches, inverting matches, and displaying line numbers, among others. The document provides syntax examples and explanations of different grep options, demonstrating how to effectively use the command in various scenarios.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views22 pages

Grep

The grep utility, developed by Ken Thompson, is a command-line tool used for searching text in files using regular expressions. It offers various options for case sensitivity, counting matches, inverting matches, and displaying line numbers, among others. The document provides syntax examples and explanations of different grep options, demonstrating how to effectively use the command in various scenarios.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

grep Utility (Global Regular Expression Print)

Grep stands for Global Regular Expression Print. The grep command is used to search for a text in a
file by pattern matching based on regular expression.

It is develope by Ken Thompson and applied on unix kernel

cmd: grep

syntax:

# grep <option> <pattern> <filename>

options:

-i  case insensitive

-I  case sensitive

-v  invert match

-w  exact match

-n print line numbers

-m stop after the numer matches

-o  display only matching pattern

-c count of matching pattern

-V print version information

-r  recursive

-l  list files from directory which contain the search pattern

-L  list files from directory which do not contain the search pattern

-x  search the exact line from file

-A  after, print specified line after the matting pattern

-B  Before, print specified line before the matting pattern

-C  Centre, print specified line before and after the mattching pattern

EG:
[root@server ~]#

[root@server ~]# # -i --> case insensitive

[root@server ~]#

[root@server ~]# ls anaconda-ks.cfg


anaconda-ks.cfg

[root@server ~]#

[root@server ~]# ls

anaconda-ks.cfg Documents Music Public Templates

Desktop Downloads Pictures sample.txt Videos

[root@server ~]#

[root@server ~]#

[root@server ~]# grep boot anaconda-ks.cfg

# Run the Setup Agent on first boot

firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -i boot anaconda-ks.cfg

# Run the Setup Agent on first boot

firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -i BOOT anaconda-ks.cfg

# Run the Setup Agent on first boot

firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# ############################

[root@server ~]# # -I --> case sensitive

[root@server ~]#

[root@server ~]# grep -I BOOT anaconda-ks.cfg

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -I agent anaconda-ks.cfg

[root@server ~]#
[root@server ~]# grep -I Agent anaconda-ks.cfg

# Run the Setup Agent on first boot

[root@server ~]#

[root@server ~]#

[root@server ~]# ##############################3

[root@server ~]#

[root@server ~]# # -w --> search the exact word

[root@server ~]#

[root@server ~]# grep boot anaconda-ks.cfg

# Run the Setup Agent on first boot

firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -w boot anaconda-ks.cfg

# Run the Setup Agent on first boot

[root@server ~]#

[root@server ~]# ###################################3

[root@server ~]#

[root@server ~]# # -c --> count the matching pattern

[root@server ~]#

[root@server ~]# grep -c boot anaconda-ks.cfg

[root@server ~]#

[root@server ~]# vim anaconda-ks.cfg

[root@server ~]# grep boot anaconda-ks.cfg

# Run the Setup Agent onboot first boot

firstboot --enable

[root@server ~]#

[root@server ~]# grep -c boot anaconda-ks.cfg

[root@server ~]#
[root@server ~]# #################################

[root@server ~]#

[root@server ~]# # -o --> print the matching pattern

[root@server ~]#

[root@server ~]# grep -o boot anaconda-ks.cfg

boot

boot

boot

[root@server ~]#

[root@server ~]# #############################

[root@server ~]#

[root@server ~]# # -n --> print with line no.

[root@server ~]#

[root@server ~]# grep -n boot anaconda-ks.cfg

25:# Run the Setup Agent onboot first boot

26:firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]# ###################################

[root@server ~]# # -m --> max count (stops after the specified matching patter)

[root@server ~]#

[root@server ~]# grep -m 1 boot anaconda-ks.cfg

# Run the Setup Agent onboot first boot

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# ###################################

[root@server ~]#

[root@server ~]# # -v --> invert match

[root@server ~]#

[root@server ~]# grep -v boot anaconda-ks.cfg


# Generated by Anaconda 34.25.0.29

# Generated by pykickstart v3.32

#version=RHEL9

# Use graphical install

graphical

repo --name="AppStream" --baseurl=file:///run/install/sources/mount-0000-cdrom/AppStream

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

# Keyboard layouts

keyboard --xlayouts='us'

# System language

lang en_US.UTF-8

# Use CDROM installation media

cdrom

%packages

@^graphical-server-environment

%end

# Generated using Blivet version 3.4.0

ignoredisk --only-use=sda

autopart

# Partition clearing information

clearpart --none --initlabel


timesource --ntp-disable

# System timezone

timezone Asia/Kolkata --utc

# Root password

rootpw --iscrypted
$6$KjtX7FtW6p9gbdHA$OL1ZwGWXlnOSfryuS4tEt.E0rAHGGG2Ksco5shqqlXyrU1gR2DoERfzs.DAS1Xs
vrq/hPBg2nb0YxcNPJNOpn1

user --groups=wheel --name=sushmita --


password=$6$EMh9QzchSuR4w6B7$t/tev7jqPZF6JGZYumuSiaA72/1yaDpdxjjzLOXzZUTUvitwzzvldLb
VQo3649TR9/RskmfEYGXa0nsE9/WL/1 --iscrypted --gecos="sushmita"

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -nv boot anaconda-ks.cfg

1:# Generated by Anaconda 34.25.0.29

2:# Generated by pykickstart v3.32

3:#version=RHEL9

4:# Use graphical install

5:graphical

6:repo --name="AppStream" --baseurl=file:///run/install/sources/mount-0000-cdrom/AppStream

7:

8:%addon com_redhat_kdump --enable --reserve-mb='auto'

9:

10:%end

11:

12:# Keyboard layouts

13:keyboard --xlayouts='us'

14:# System language

15:lang en_US.UTF-8

16:

17:# Use CDROM installation media


18:cdrom

19:

20:%packages

21:@^graphical-server-environment

22:

23:%end

24:

27:

28:# Generated using Blivet version 3.4.0

29:ignoredisk --only-use=sda

30:autopart

31:# Partition clearing information

32:clearpart --none --initlabel

33:

34:timesource --ntp-disable

35:# System timezone

36:timezone Asia/Kolkata --utc

37:

38:# Root password

39:rootpw --iscrypted
$6$KjtX7FtW6p9gbdHA$OL1ZwGWXlnOSfryuS4tEt.E0rAHGGG2Ksco5shqqlXyrU1gR2DoERfzs.DAS1Xs
vrq/hPBg2nb0YxcNPJNOpn1

40:user --groups=wheel --name=sushmita --


password=$6$EMh9QzchSuR4w6B7$t/tev7jqPZF6JGZYumuSiaA72/1yaDpdxjjzLOXzZUTUvitwzzvldLb
VQo3649TR9/RskmfEYGXa0nsE9/WL/1 --iscrypted --gecos="sushmita"

41:

[root@server ~]#

[root@server ~]#

[root@server ~]# ####################################

[root@server ~]# # -V --> version print

[root@server ~]#

[root@server ~]# grep -V


grep (GNU grep) 3.6

Copyright (C) 2020 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see

<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

[root@server ~]#

[root@server ~]#

[root@server ~]# #######################################

[root@server ~]#

[root@server ~]# # -x --> search the line

[root@server ~]#

[root@server ~]# grep -x clearpart --none --initlabel anaconda-ks.cfg

grep: unrecognized option '--none'

Usage: grep [OPTION]... PATTERNS [FILE]...

Try 'grep --help' for more information.

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -x "clearpart --none --initlabel" anaconda-ks.cfg

clearpart --none --initlabel

[root@server ~]#

[root@server ~]#

[root@server ~]# #####################################

[root@server ~]#

[root@server ~]# # -A --> print specified lines after the matching patter

[root@server ~]#

[root@server ~]# grep -A 2 boot anaconda-ks.cfg

# Run the Setup Agent onboot first boot


firstboot --enable

# Generated using Blivet version 3.4.0

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# #######################################

[root@server ~]#

[root@server ~]# # -B --> print specified lines before the matching patter

[root@server ~]#

[root@server ~]# grep -n -B 2 boot anaconda-ks.cfg

23-%end

24-

25:# Run the Setup Agent onboot first boot

26:firstboot --enable

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# #########################################

[root@server ~]# # -C --> print specified lines before and after the matching patter

[root@server ~]#

[root@server ~]# grep -n -C 2 boot anaconda-ks.cfg

23-%end

24-

25:# Run the Setup Agent onboot first boot

26:firstboot --enable

27-

28-# Generated using Blivet version 3.4.0

[root@server ~]#

[root@server ~]#

[root@server ~]# #######################################


[root@server ~]#

[root@server ~]#

[root@server ~]# ls /

afs class etc lib64 opt root srv var

bin data home lv1mount proc run sys web.sh

boot dev kali media redhat sample tmp

centos dhparams.pem lib mnt rhel sbin usr

[root@server ~]#

[root@server ~]# ls /kali/

abc2 class data sample.txt test

[root@server ~]#

[root@server ~]# cd /kali/

[root@server kali]#

[root@server kali]# cat > abc2

hello world

redhat

[root@server kali]#

[root@server kali]# cat > sample.txt

hello india

hello user

[root@server kali]#

[root@server kali]# cat > test

redhat certified

[root@server kali]#

[root@server kali]# cd

[root@server ~]#

[root@server ~]#

[root@server ~]# # -r --> recursive

[root@server ~]#
[root@server ~]# grep -r hello /kali/

/kali/abc2:hello world

/kali/sample.txt:hello india

/kali/sample.txt:hello user

[root@server ~]#

[root@server ~]#

[root@server ~]# grep hello /kali/

grep: /kali/: Is a directory

[root@server ~]#

[root@server ~]# cd /kali/

[root@server kali]#

[root@server kali]# grep hello abc2 sample.txt test

abc2:hello world

sample.txt:hello india

sample.txt:hello user

[root@server kali]#

[root@server kali]#

[root@server kali]# grep hello *

abc2:hello world

grep: class: Is a directory

grep: data: Is a directory

sample.txt:hello india

sample.txt:hello user

[root@server kali]#

[root@server kali]# cd

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -r hello /kali/

/kali/abc2:hello world

/kali/sample.txt:hello india

/kali/sample.txt:hello user
[root@server ~]#

[root@server ~]#

[root@server ~]# ########################################

[root@server ~]#

[root@server ~]# # -l print the file name having mathching patter

[root@server ~]#

[root@server ~]# grep -l -r hello /kali/

/kali/abc2

/kali/sample.txt

[root@server ~]#

[root@server ~]#

[root@server ~]# ######################################

[root@server ~]#

[root@server ~]# # -L print the file not name having mathching patter

[root@server ~]#

[root@server ~]# grep -L -r hello /kali/

/kali/test

/kali/data/abc

[root@server ~]#

[root@server ~]# ########################################

[root@server ~]#

[root@server ~]# grep akshay /etc/passwd

akshay:x:1014:1015::/home/akshay:/bin/bash

[root@server ~]#

[root@server ~]# grep amit /etc/passwd

amit:x:1018:1019::/home/amit:/bin/bash

[root@server ~]#

[root@server ~]#

[root@server ~]# #####################################

[root@server ~]#

[root@server ~]# # copy


[root@server ~]#

[root@server ~]# grep akshay /etc/passwd > grepfile

[root@server ~]#

[root@server ~]# ls

anaconda-ks.cfg Documents grepfile Pictures sample.txt Videos

Desktop Downloads Music Public Templates

[root@server ~]#

[root@server ~]# cat grepfile

akshay:x:1014:1015::/home/akshay:/bin/bash

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# grep -L -r hello /kali/ >> grepfile

[root@server ~]# cat grepfile

akshay:x:1014:1015::/home/akshay:/bin/bash

/kali/test

/kali/data/abc

[root@server ~]#

[root@server ~]#

[root@server ~]# #######################################

[root@server ~]#

[root@server ~]# ls

anaconda-ks.cfg Documents grepfile Pictures sample.txt Videos

Desktop Downloads Music Public Templates

[root@server ~]#

[root@server ~]#

[root@server ~]# ls | grep anaconda-ks.cfg

anaconda-ks.cfg

[root@server ~]#

[root@server ~]#

[root@server ~]# ls | grep grepfile


grepfile

[root@server ~]#

[root@server ~]# cat /etc/passwd | grep akshay

akshay:x:1014:1015::/home/akshay:/bin/bash

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# semanage fcontext -l | grep http

/etc/WebCalendar(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/apache(2)?(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/apache-ssl(2)?(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/cherokee(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/drupal.* all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/glpi(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/horde(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/htdig(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/etc/httpd(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/httpd/.* symbolic link system_u:object_r:etc_t:s0

/etc/httpd/alias(/.*)? all files system_u:object_r:cert_t:s0

/etc/httpd/conf/keytab regular file system_u:object_r:httpd_keytab_t:s0

/etc/init\.d/cherokee regular file system_u:object_r:httpd_initrc_exec_t:s0

/etc/lighttpd(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/mock/koji(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/nextcloud(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/nginx(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/opt/rh/rh-nginx18/nginx(/.*)? all files system_u:object_r:httpd_config_t:s0

/etc/owncloud(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/rc\.d/init\.d/httpd regular file system_u:object_r:httpd_initrc_exec_t:s0

/etc/rc\.d/init\.d/lighttpd regular file system_u:object_r:httpd_initrc_exec_t:s0

/etc/rt(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/thttpd\.conf regular file system_u:object_r:httpd_config_t:s0


/etc/vhosts regular file system_u:object_r:httpd_config_t:s0

/etc/z-push(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/etc/zabbix/web(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/home/[^/]+/((www)|(web)|(public_html))(/.*)?/\.htaccess regular file


unconfined_u:object_r:httpd_user_htaccess_t:s0

/home/[^/]+/((www)|(web)|(public_html))(/.*)?/logs(/.*)? all files


unconfined_u:object_r:httpd_user_ra_content_t:s0

/home/[^/]+/((www)|(web)|(public_html))(/.+)? all files


unconfined_u:object_r:httpd_user_content_t:s0

/home/[^/]+/((www)|(web)|(public_html))/cgi-bin(/.+)? all files


unconfined_u:object_r:httpd_user_script_exec_t:s0

/opt/.*\.cgi regular file system_u:object_r:httpd_sys_script_exec_t:s0

/opt/dirsrv/var/run/dirsrv/dsgw/cookies(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/srv/([^/]*/)?www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/srv/([^/]*/)?www/logs(/.*)? all files system_u:object_r:httpd_log_t:s0

/srv/gallery2(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/srv/gallery2/smarty(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/usr/.*\.cgi regular file system_u:object_r:httpd_sys_script_exec_t:s0

/usr/bin/htsslpass regular file system_u:object_r:httpd_helper_exec_t:s0

/usr/bin/httpd regular file system_u:object_r:publicfile_exec_t:s0

/usr/bin/mongrel_rails regular file system_u:object_r:httpd_exec_t:s0

/usr/lib(64)?/nagios/plugins/check_http regular file


system_u:object_r:nagios_services_plugin_exec_t:s0

/usr/lib/apache(/.*)? all files system_u:object_r:httpd_modules_t:s0

/usr/lib/apache(2)?/suexec(2)? regular file


system_u:object_r:httpd_suexec_exec_t:s0

/usr/lib/apache-ssl/.+ regular file system_u:object_r:httpd_exec_t:s0

/usr/lib/apache2/modules(/.*)? all files system_u:object_r:httpd_modules_t:s0

/usr/lib/cgi-bin(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0

/usr/lib/cgi-bin/(nph-)?cgiwrap(d)? regular file


system_u:object_r:httpd_suexec_exec_t:s0

/usr/lib/cherokee(/.*)? all files system_u:object_r:httpd_modules_t:s0

/usr/lib/httpd(/.*)? all files system_u:object_r:httpd_modules_t:s0


/usr/lib/lighttpd(/.*)? all files system_u:object_r:httpd_modules_t:s0

/usr/lib/systemd/system/httpd.* regular file system_u:object_r:httpd_unit_file_t:s0

/usr/lib/systemd/system/nginx.* regular file system_u:object_r:httpd_unit_file_t:s0

/usr/lib/systemd/system/php-fpm.* regular file system_u:object_r:httpd_unit_file_t:s0

/usr/lib/systemd/system/thttpd.* regular file system_u:object_r:httpd_unit_file_t:s0

/usr/libexec/httpd-ssl-pass-dialog regular file


system_u:object_r:httpd_passwd_exec_t:s0

/usr/local/nagios/sbin(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0

/usr/sbin/apache(2)? regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/apache-ssl(2)? regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/apachectl regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/cherokee regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/htcacheclean regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/httpd(\.worker)? regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/httpd\.event regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/lighttpd regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/nginx regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/php-fpm regular file system_u:object_r:httpd_exec_t:s0

/usr/sbin/rotatelogs regular file system_u:object_r:httpd_rotatelogs_exec_t:s0

/usr/sbin/suexec regular file system_u:object_r:httpd_suexec_exec_t:s0

/usr/sbin/thttpd regular file system_u:object_r:httpd_exec_t:s0

/usr/share/doc/ghc/html(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/drupal.* all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/glpi(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/htdig(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/icecast(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/joomla(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/usr/share/munin/plugins/http_loadtime regular file


system_u:object_r:services_munin_plugin_exec_t:s0

/usr/share/nginx/html(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/ntop/html(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/usr/share/openca/htdocs(/.*)? all files system_u:object_r:httpd_sys_content_t:s0


/usr/share/selinux-policy[^/]*/html(/.*)? all files
system_u:object_r:httpd_sys_content_t:s0

/usr/share/system-config-httpd/system-config-httpd regular file system_u:object_r:bin_t:s0

/usr/share/wordpress-mu/wp-config\.php regular file


system_u:object_r:httpd_sys_script_exec_t:s0

/usr/share/wordpress-mu/wp-content(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/usr/share/wordpress/.*\.php regular file


system_u:object_r:httpd_sys_script_exec_t:s0

/usr/share/wordpress/wp-content/upgrade(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/usr/share/wordpress/wp-content/uploads(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/usr/share/wordpress/wp-includes/.*\.php regular file


system_u:object_r:httpd_sys_script_exec_t:s0

/usr/share/z-push(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/cache/httpd(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/lighttpd(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/mason(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/mediawiki(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/mod_.* all files system_u:object_r:httpd_cache_t:s0

/var/cache/mod_gnutls(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/mod_proxy(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/mod_ssl(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/nginx(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/php-.* all files system_u:object_r:httpd_cache_t:s0

/var/cache/php-eaccelerator(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/php-mmcache(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/rt(3|4)(/.*)? all files system_u:object_r:httpd_cache_t:s0

/var/cache/ssl.*\.sem regular file system_u:object_r:httpd_cache_t:s0

/var/lib/cacti/rra(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/lib/cherokee(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/dav(/.*)? all files system_u:object_r:httpd_var_lib_t:s0


/var/lib/dokuwiki(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/drupal.* all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/ganglia(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/glpi(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/graphite-web(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/htdig(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/lib/httpd(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/ipsilon(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/lighttpd(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/mod_security(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/moodle(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/nextcloud(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/nginx(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/openshift/\.httpd\.d(/.*)? all files system_u:object_r:httpd_config_t:s0

/var/lib/openshift/\.log/httpd(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/lib/owncloud(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/php(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/php/session(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/var/lib/php/wsdlcache(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/var/lib/phpMyAdmin(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/pootle/po(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/roundcubemail(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/rt(3|4)/data/RT-Shredder(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/lib/squirrelmail/prefs(/.*)? all files system_u:object_r:httpd_squirrelmail_t:s0

/var/lib/stickshift/\.httpd\.d(/.*)? all files system_u:object_r:httpd_config_t:s0

/var/lib/svn(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/lib/trac(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/lib/z-push(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/log/apache(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/apache-ssl(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0


/var/log/cacti(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/cgiwrap\.log.* regular file system_u:object_r:httpd_log_t:s0

/var/log/cherokee(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/dirsrv/admin-serv(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/glpi(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/graphite-web(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/horizon(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/httpd(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/lighttpd(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/nginx(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/php-fpm(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/php_errors\.log.* regular file system_u:object_r:httpd_log_t:s0

/var/log/roundcubemail(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/log/shibboleth-www(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/log/suphp\.log.* regular file system_u:object_r:httpd_log_t:s0

/var/log/thttpd\.log.* regular file system_u:object_r:httpd_log_t:s0

/var/log/z-push(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/opt/rh/rh-nginx18/lib/nginx(/.*)? all files system_u:object_r:httpd_var_lib_t:s0

/var/opt/rh/rh-nginx18/log(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/opt/rh/rh-nginx18/run/nginx(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/var/run/apache.* all files system_u:object_r:httpd_var_run_t:s0

/var/run/cherokee\.pid regular file system_u:object_r:httpd_var_run_t:s0

/var/run/dirsrv/admin-serv.* all files system_u:object_r:httpd_var_run_t:s0

/var/run/fcgiwrap(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/var/run/gcache_port socket system_u:object_r:httpd_var_run_t:s0

/var/run/httpd.* all files system_u:object_r:httpd_var_run_t:s0

/var/run/lighttpd(/.*)? all files system_u:object_r:httpd_var_run_t:s0

/var/run/mod_.* all files system_u:object_r:httpd_var_run_t:s0

/var/run/nginx.* all files system_u:object_r:httpd_var_run_t:s0

/var/run/php-fpm(/.*)? all files system_u:object_r:httpd_var_run_t:s0


/var/run/piranha-httpd\.pid regular file
system_u:object_r:piranha_web_var_run_t:s0

/var/run/thttpd\.pid regular file system_u:object_r:httpd_var_run_t:s0

/var/run/user/apache(/.*)? all files system_u:object_r:httpd_tmp_t:s0

/var/run/wsgi.* socket system_u:object_r:httpd_var_run_t:s0

/var/spool/gosa(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/spool/viewvc(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/www(/.*)?/logs(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/[^/]*/cgi-bin(/.*)? all files


system_u:object_r:httpd_sys_script_exec_t:s0

/var/www/cgi-bin(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0

/var/www/gallery/albums(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html(/.*)?/sites/default/files(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html(/.*)?/sites/default/settings\.php regular file


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html(/.*)?/uploads(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html(/.*)?/wp-content(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html(/.*)?/wp_backups(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html/[^/]*/cgi-bin(/.*)? all files


system_u:object_r:httpd_sys_script_exec_t:s0

/var/www/html/configuration\.php all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html/nextcloud/data(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/html/owncloud/data(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/icons(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/www/miq/vmdb/log(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/moodle/data(/.*)? all files


system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/moodledata(/.*)? all files
system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/openshift/broker/httpd/logs(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/openshift/broker/httpd/run(/.*)? all files


system_u:object_r:httpd_var_run_t:s0

/var/www/openshift/console/httpd/logs(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/openshift/console/httpd/run(/.*)? all files


system_u:object_r:httpd_var_run_t:s0

/var/www/openshift/console/log(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/openshift/console/tmp(/.*)? all files system_u:object_r:httpd_tmp_t:s0

/var/www/perl(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0

/var/www/stickshift/[^/]*/log(/.*)? all files system_u:object_r:httpd_log_t:s0

/var/www/svn(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0

/var/www/svn/conf(/.*)? all files system_u:object_r:httpd_sys_content_t:s0

/var/www/svn/hooks(/.*)? all files


system_u:object_r:httpd_sys_script_exec_t:s0

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# semanage port -l | grep http

http_cache_port_t tcp 8080, 8118, 8123, 10001-10010

http_cache_port_t udp 3130

http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000

pegasus_http_port_t tcp 5988

pegasus_https_port_t tcp 5989

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# semanage port -l | grep http >> grepfile

[root@server ~]#

[root@server ~]#
[root@server ~]# cat grepfile

akshay:x:1014:1015::/home/akshay:/bin/bash

/kali/test

/kali/data/abc

http_cache_port_t tcp 8080, 8118, 8123, 10001-10010

http_cache_port_t udp 3130

http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000

pegasus_http_port_t tcp 5988

pegasus_https_port_t tcp 5989

[root@server ~]#

[root@server ~]#

[root@server ~]#

You might also like