Cheatography
https://cheatography.com
This cheatsheet will provide the essentials for any CentOS Systems Administrator
Install Apache / Verify Status
Install HTTPD service |
|
Check httpd status |
systemctl status httpd.service
|
Confirguring Apache HTTP Server
Inspect Control Script |
less /etc/systemd/system/multi-user.target.wants/httpd.service
|
|
displays the contents of the httpd.service file for the Apache HTTP server in the systemd multi-user target. |
Get default start-up state |
|
|
shows the default target (runlevel) that the system boots into. |
Find config file |
|
Inspect config file |
nano /etc/httpd/conf/httpd.conf
|
|
nano [location of config file found using find
] |
|
Note that these are hidden by default, to prevent files being viewed by web clients |
|
Find and take note of where the errorlog is located (usually logs/error_log
) |
|
The web document location is usually the /var/www/html
|
Investigate Processes, Make & Test Apache
List processes and filters for those related to httpd |
|
Rules for incoming traffic |
|
Create index.html file |
1) Navigate to appropriate directory |
|
|
|
2) create and edit file using nano |
|
e.g.: sudo nano index.html
|
View access log |
cat /var/log/httpd/access_log
|
Request local page |
|
MySQL/MariaDB Installation, Start & Status
MariaDB Installation |
yum install mariadb-server
|
Confirm MySQL/MariaDB is installed |
|
Start MariaDB |
|
Check MariaDB Status |
|
Confirm servers are running |
|
|
This produces a list of running servers, where you will search for mysql
in the far left column(the UID(User ID)) |
Set new password for mysqladmin root |
mysqladmin -u root password [INSERT PASSWORD]
|
MySQL Config file & Data Directory
Find config file (my.cnf) location |
sudo find / -name my.cnf ¦ less
|
Navigate to config file directory |
|
|
e.g. in my case, my.cnf was located found to be /etc/my.cnf, so cd /etc
is used |
View contents of config file |
|
Locate MySQL Daemon |
|
Create & Populate Database
Enter MariaDB Server |
mysql -h localhost -u root -p
|
|
Then enter password created previously. Note, password will not show any typing. |
Create database |
`CREATE DATABASE [database name]; |
|
e.g. CREATE DATABASE food;
|
Change to created database |
|
|
e.g. `USE food' |
Exit MariaDB |
|
Confirm database was created outside of MariaDB |
Change to appropriate directory cd /var/lib/mysql
|
|
Display contents of current directory using ls
|
Create Table |
CREATE TABLE restaurant (name VARCHAR(40), type VARCHAR(40), location VARCHAR(4));
` |
|
VARCHAR(n) defines variable length |
Insert values into restaurant table |
INSERT INTO restaurant (name, type, location) values ("Pizzahut", "Italian", "SW10");
|
Show table |
SHOW TABLES; DESCRIBE restaurant; SELECT * FROM restaurant;
|
Delete value from table |
DELETE FROM restaurant WHERE name="Pizza"&&location="SW10";
|
Create new user |
GRANT SELECT ON food.restaurant TO bayan@localhost IDENTIFIED BY "bayans_password";
|
Firewalls
Confirm firewalld is running |
systemctl status firewalld
|
Check firewall conifiguration |
|
Display firewall rules |
`iptables -L' |
Services/ports available for sshd |
|
Services/ports available for httpd |
|
Services/ports available for vsftp |
|
|
if not installed, use yum install. e.g. yum install vsftpd
|
Stop firewalld, then check if running to confirm it is infact stopped** |
|
Start firewalld |
systemctl start firewalld
|
Add http service to firewall configuration |
firewall-cmd --add-service http
|
Add ftp service to firewall configuration |
firewall-cmd --add-service ftp
|
iptables rules for accepting traffic for ports 22(SSH), 80(HTTP), and 21 (FTP) |
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
|
|
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
|
|
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
|
Add rules to output chain |
iptables -A OUTPUT -m state --state ESTABLISHED, RELATED -j ACCEPT
|
Dropping default rules for INPUT and OUTPUT traffic |
|
|
|
SELinux
Install setroubleshoot and httpd |
sudo yum install setroubleshoot httpd
|
Enable httpd |
|
Start httpd |
|
Check default directory for HTML files |
cat /etc/httpdconf/httpd.conf | grep DocumentRoot
|
Check SELinux permissions / context |
|
Temporarily disable SELinux enforcement for troubleshooting or testing without changing the permanent configuration. |
|
Re-enable SELinux enforcement after it has been disabled, restoring its security policies. |
|
Apply default SELinux to a file: |
/sbin/restorecon -v /var/www/html/secret.html
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Bayan.A