Skip to main content

Posts

Showing posts with the label Linux/Unix/Nagios Tips & Tricks

How to change document root in Apache configuration

Below are the steps to change document root in Apache(Web server) configurations - [root@rhcsa107 rakesh]# mkdir /web [root@rhcsa107 rakesh]# ls -ld /web/ drwxr-xr-x. 2 root root 22 Apr  3 08:45 /web/ [root@rhcsa107 rakesh]# vim /etc/httpd/conf.d/rakesh.conf DocumentRoot /web <Directory /web> Require all granted </Directory> Save exit from from this file. [root@rhcsa107 rakesh]# systemctl restart httpd.service Check HTTPD status, it must be running as below -  [root@rhcsa107 rakesh]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)    Active: active (running) since Fri 2020-04-03 09:19:46 EDT; 6min ago      Docs: man:httpd.service(8)  Main PID: 10064 (httpd)    Status: "Total requests: 5; Idle/Busy workers 100/0;Requests/sec: 0.0129; Bytes served/sec:   9 B/sec" ...

Forbidden The requested URL /lw.html was not found on this server.

Forbidden You don't have permission to access /web.html on this server. If you get above error message while configuring 'Apache web server', then you can fix this error using with below configuration changes - Just add Require all granted in Apache configurations as below - [root@rhcsa107 rakesh]# vim /etc/httpd/conf.d/rakesh.conf DocumentRoot /web <Directory /web> Require all granted </Directory> [root@rhcsa107 rakesh]# apachectl -t Syntax OK [root@rhcsa107 rakesh]# [root@rhcsa107 rakesh]# systemctl restart httpd.service [root@rhcsa107 rakesh]# systemctl status httpd.service

Search files which have special permission.

If you want to search files which have some special permission. SUID or SGID [root@localhost rpm]# find /sbin/ -perm /6000 -ls 630385   12 -rwsr-xr-x   1 root     root        11224 Jul 19  2016 /sbin/pam_timestamp_check 630387   36 -rwsr-xr-x   1 root     root        36280 Jul 19  2016 /sbin/unix_chkpwd 1155906   40 -rws--x--x   1 root     root        40312 Jan 28  2014 /sbin/userhelper 1261593   12 -rwx--s--x   1 root     lock        11208 Jan 26  2014 /sbin/lockdev 1225816   12 -rwxr-sr-x   1 root     root        11224 Sep 12  2016 /sbin/netreport 1225821   12 -rwsr-xr-x   1 root     root        11288 Sep 12  2016 /sbin/u...

How to find a file in Linux/Unix?

If you forgot the path of file but know the file name, how to find? We can do this using  find  command- [root@localhost rpm]# find /etc -name passwd /etc/passwd /etc/pam.d/passwd [root@localhost rpm]# find /etc -name pass* /etc/openldap/certs/password /etc/passwd /etc/selinux/targeted/active/modules/100/passenger /etc/passwd- /etc/pam.d/passwd /etc/pam.d/password-auth-ac /etc/pam.d/password-auth [root@localhost rpm]#