WhileNetworking

  • Home
  • CCNA
  • Cisco Packet Tracer Download
    • Cisco packet tracer 6.3
    • cisco packet tracer 6.2
    • Cisco Packet Tracer 7
  • Linux Server Management
  • About Us
  • Privacy Policy
  • Contact Us

Discussion and working with SELinux in Linux (CentOS/Red Hat)

You are most welcome to this post.
IPv6 Bridge and bonding in Linux (CentOS/Red Hat)
Really thanks to you for your interest in this topics. :)

Some times working with Linux (CentOS/Red Hat), we need to disable the SELinux. Some admin who are working with Linux, sometimes are not aware about SELinux. So lets have a small discussion about working with SELinux.

Discussion and working with SELinux in Linux (CentOS/Red Hat)

SELinux is generally for Security Enhanced Linux. It is developed by NSA. They mainly developed it for Red Hat Enterprise Linux. This Linux security tool is related to firewall of ip tables (generally for layer 3 and layer 4). And we all know  this firewall works with different type of networking protocol like TCP/IP, ICMP, UDP etc. SELinux is directory based and mainly works with different types of directory like samba, ftp, http etc.

Generally SELinux has three modes. They are:

  1. Enforcing mode (1)
  2. Permissive mode (0)
  3. Disable mode
[root@localhost ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ] [root@localhost ~]# setenforce 1
setenforce: SELinux is disabled
[root@localhost ~]# setenforce permissive
setenforce: SELinux is disabled
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# nano /etc/sysconfig/selinux

SELINUX=disabled

 

[root@localhost ~]# reboot
[root@localhost ~]# getenforce

 

Now lets view the SELinux context:

[root@localhost ~]# cd /

[root@localhost ~]# ls -Z

SELinux contexts generally has 4 types.They are :

  1. user, which is system_u
  2. type, which is admin_home_t
  3. role, which is object_r
  4. sensitivity, which is s0

 

[root@localhost ~]# yum install -y httpd

 

[root@localhost ~]#ls -lZ /var/www/

drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 html

 

[root@localhost ~]#ls -lZ /etc/passwd

-rw-r–r–. root root system_u:object_r:passwd_file_t:s0 /etc/passwd

 

[root@localhost ~]#ls -lZ /home

drwx——. student 1000 unconfined_u:object_r:user_home_dir_t:s0 user1
drwx——. 5001 5001 unconfined_u:object_r:user_home_dir_t:s0 user2

 

Now we’ll test SELinux:

[root@localhost ~]# cd
[root@localhost ~]# ls -Zd ~
dr-xr-x—. root root system_u:object_r:admin_home_t:s0 /root

[root@localhost ~]# cal
May 2016
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

[root@localhost ~]# cal > calender

[root@localhost ~]# cat calender
May 2016
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

 

[root@localhost ~]# ls -Z calender
-rw-r–r– root root ? calender
[root@localhost ~]# cp calender /var/www/html/calender2

[root@localhost ~]# mv calender /var/www/html/

[root@localhost ~]# ls -Zd /var/www/html/
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html/
[root@localhost ~]# ls -Z /var/www/html/*
-rw-r–r– root root ? /var/www/html/calender
-rw-r–r– root root ? /var/www/html/calender2
-rw-r–r– root root ? /var/www/html/index.html
[root@localhost ~]# echo “HEllo World” >> /var/www/html/index.html
[root@localhost ~]# ls -Z /var/www/html/*
-rw-r–r– root root ? /var/www/html/calender
-rw-r–r– root root ? /var/www/html/calender2
-rw-r–r– root root ? /var/www/html/index.html
[root@localhost ~]# mkdir /websites

[root@localhost ~]# ls -Zd /websites
drwxr-xr-x root root ? /websites
[root@localhost ~]# restorecon /websites
[root@localhost ~]# ls -Zd /websites
drwxr-xr-x root root ? /websites
[root@localhost ~]# touch /websites/index.html
[root@localhost ~]# echo “HEllo SELinux World” >> /websites/index.html
[root@localhost ~]# ls -Z /websites
-rw-r–r– root root ? index.html
[root@localhost ~]# ls -Z /websites
-rw-r–r– root root ? index.html

 

So, we have configured the SELinux. Now lets reload the firewall.
[root@localhost ~]# systemctl restart firewalld
[root@localhost ~]# firewall-cmd –permanent –add-port=80/tcp
[root@localhost ~]# firewall-cmd –reload

 

Now lets test the SELinux.

  1. Go to desktop.
  2. Open browser (firefox)
  3. In the address bar, type: 192.168.2.2+X (your server IP)

Hope that you’ve able to do this work successfully. And also you’ve enjoyed this session. Finally, do’t forget to comment. Thanks.

 

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Working with SELinux in CentOS/Red Hat

Jun 22, 2016Himadri
 

Share with friends :

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to email a link to a friend (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to print (Opens in new window)

Related

Free download Cisco Packet Tracer 7 for linux (64 bit)Basic discussion about mail server

Leave a Reply Cancel reply

two × four =

Himadri

Hi, I'm Himadri. I love blogging with tech topics, specially computer networking. We'll have more fun in the upcoming day. Stay with me. :)

June 22, 2016 8 Comments Linux installation and server managementSELinux configuration in CentOS/Red Hat, SELinux configuration in Linux, SELinux manage in Linux364
Feel Free to Share :)
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Find Us on Facebook
Choose a category !!
  • CCNA
  • Cisco Certification Exam
  • cisco packet tracer 6.2
  • Cisco packet tracer 6.3
  • Cisco Packet Tracer 7
  • Cisco Packet Tracer 7.1
  • Cisco Packet Tracer 7.2.1
  • Cisco Packet Tracer 7.3
  • Cyber Security
  • Engineering Ebooks
  • Excel
  • IELTS Ebook
  • Internet
  • Know computer
  • Know your computer
  • Laser Processing of Material
  • Linux installation and server management
  • PDF
  • Technology
  • Uncategorized
Top posts
  • Packet tracer 6.2 student version for Linux - Free download
  • Free download Cisco Packet Tracer 7 for linux (64 bit)
  • Know about Host-Based Intrusion Prevention System
Archieves
Get latest updates by Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 19 other subscribers
W
SC
wordpress counter
Analytics
Recent Comments
    Browse by categories
    Cyber SecurityLinux installation and server managementCCNAKnow your computerKnow computerCisco Packet Tracer 7UncategorizedCisco Certification ExamInternetPDFCisco Packet Tracer 7.3Engineering EbooksCisco packet tracer 6.3cisco packet tracer 6.2Cisco Packet Tracer 7.1TechnologyExcelLaser Processing of MaterialCisco Packet Tracer 7.2.1IELTS Ebook
    Feel free to contact with us

    Hi, any kind of comment or suggestion is valuable to us. So feel free to contact with us.

    Email: himadri.shekhar.bd@gmail.com

    Name: WhileNetworking.com

    2021 © WhileNetworking
     

    Loading Comments...