Last active
May 23, 2019 10:52
-
-
Save dariadobsai/db87e6222bc6389f3d9abadc06c0944e to your computer and use it in GitHub Desktop.
Helper file for RedHat Practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://onedrive.live.com/?authkey=%21ABRgmNAPtpE8n7E&cid=B70386FBC114FFC7&id=B70386FBC114FFC7%215152&parId=root&o=OneUp | |
https://imgur.com/a/hsIw1hx (Screenshots) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Configure the network | |
1. nmtui | |
2. nmcli | |
A) If you don't have any NetworkManager connection: | |
A.1) Add new NetworkManager connection: | |
nmcli con add con-name "Exam" ifname eth0 type ethernet ip4 172.25.201.X/24 gw4 172.25.201.254 | |
nmcli con mod "Exam" ipv4.dns "172.25.201.254" | |
nmcli con mod "Exam" ipv4.method manual | |
nmcli con mod "Exam" connection.autoconnect yes | |
A.2) Activate new NetworkManager connection: | |
nmcli con up "Exam" | |
A.3) Verify NetorkManager connection and /etc/resolv.conf file: | |
nmcli con show "Exam" | |
cat /etc/resolv.conf | |
------------------------------------------------------------------------- | |
B) If you already have NetworkManager connection: | |
B.1) Add another NetworkManager connection: | |
nmcli con add con-name "Exam" ifname eth0 type ethernet ip4 172.25.201.X/24 gw4 172.25.201.254 | |
nmcli con mod "Exam" ipv4.dns "172.25.201.254" | |
nmcli con mod "Exam" ipv4.method manual | |
nmcli con mod "Exam" connection.autoconnect yes | |
B.1.2) Activate new NetworkManager connection: | |
nmcli con up "Exam" | |
B.1.3) Disable old NetworkManager connection to Automatically connect during system start-up: | |
nmcli con mod "System eth0" connection.autoconnect no | |
B.1.4) Check NetworkManager connections and verify new NetworkManager connection: | |
nmcli con show | |
nmcli con show --active | |
nmcli con show "Exam" | |
B.1.5) optional - remove old unwanted NetworkManager connection: | |
nmcli con del "System eth0" | |
B.2) Edit already existing NetworkManager connection: | |
nmcli con mod "System eth0" ip4 172.25.201.X/24 | |
nmcli con mod "System eth0" ipv4.gateway 172.25.201.254 | |
nmcli con mod "System eth0" ipv4.dns "172.25.201.254" | |
nmcli con mod "System eth0" ipv4.method manual | |
nmcli con mod "System eth0" connection.autoconnect yes | |
B.2.1) Activate updated NetworkManager connection: | |
nmcli con up "System eth0" | |
B.2.2) Verify updated NetworkManager connection: | |
nmcli con show "System eth0" | |
------------------------------------------------------------------------- | |
## Useful nmcli commands | |
# To see a list of network devices and their state: | |
nmcli dev | |
or | |
nmcli dev status | |
# Show detailed information about devices: | |
nmcli dev show | |
and | |
nmcli dev show (device) | |
# To bring down an interface and temporarily disable autoconnect use command: | |
nmcli dev dis (device) | |
# Connect the device | |
nmcli dev con (device) | |
# To disable or enable all managed interfaces use command: | |
nmcli net off | |
nmcli net on | |
# To turn off wifi: | |
nmcli r wifi off | |
------------------------------------------------------------------------- | |
### Source -> https://www.youtube.com/watch?v=v-soSvSsw18&feature=share | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create partition with the type 8e (Linux LVM) | |
------------------------------------------------------------------------- | |
# Create Pgysical Volume | |
pvcreate /dev/vdb1 | |
------------------------------------------------------------------------- | |
# Create Volume Group | |
vgcreate vg_name /dev/vdb1 (can vary) | |
------------------------------------------------------------------------- | |
# Create Logical Volume | |
lvcreate -n lv_name -L 5G vg_name (can vary -l 100%FREE) | |
Source -> https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/logical_volume_manager_administration/lv | |
------------------------------------------------------------------------- | |
# Create File System | |
mkfs -t xfs -L "label" /dev/vg_name/lv_name | |
or | |
mkfs.xfs -L "label" /dev/vg_name/lv_name | |
------------------------------------------------------------------------- | |
# Create temporary dir | |
mkdir /mnt/mysql (/mnt exists) | |
------------------------------------------------------------------------- | |
# Do mounting | |
mount /dev/vg_name/lv_name/ /mnt/mysql | |
------------------------------------------------------------------------- | |
# Stop the Mariadb service | |
systemctl stop mariadb | |
------------------------------------------------------------------------- | |
# Source of the copy operation | |
cat etc/my.cnf | grep datadir | |
------------------------------------------------------------------------- | |
# Copy the datastore directory to the new location | |
cp -a /var/lib/mysql /mnt/ | |
cp -a /var/lib/mysql/* /mnt/mysql | |
------------------------------------------------------------------------- | |
# Check the permissions | |
ls -laZ /mnt | |
------------------------------------------------------------------------- | |
# Unmount new file system from the temporary directory | |
umount /mnt/mysql | |
------------------------------------------------------------------------- | |
# Start Mariabd | |
systemctl start mariadb | |
------------------------------------------------------------------------- | |
# Stop the Mariadb service | |
systemctl stop mariadb | |
------------------------------------------------------------------------- | |
# Make new dir | |
mkdir /backup | |
------------------------------------------------------------------------- | |
# Move all the files into new dir | |
mv var/lib/mysql/* /backup/ | |
------------------------------------------------------------------------- | |
# Mount Persistently | |
1) vi /etc/fstab | |
2) file content: /dev/vg_first/lv_fisrt /var/lib/mysql auto defaults 0 0 | |
3) mount -a | |
------------------------------------------------------------------------- | |
# Start Mariabd | |
systemctl start mariadb | |
------------------------------------------------------------------------- | |
# Check Mariabd status | |
systemctl status mariadb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change to root user: | |
sudo su - | |
------------------------------------------------------------------------- | |
# Change to some user: | |
sudo su - username | |
sudo -i -u username | |
------------------------------------------------------------------------- | |
# Change the owner | |
chown newuser file-name | |
chown -R newuser dir-name | |
------------------------------------------------------------------------- | |
# Change the group | |
chgrp newgroup file-name | |
chgrp -R newgroup dir-name | |
------------------------------------------------------------------------- | |
# Change the password of any user | |
passwd username | |
------------------------------------------------------------------------- | |
# Get and Set the access control list (ACL) of a FILE | |
getfacl file-name | |
setfacl -m "u:username:rwx" file-name | |
------------------------------------------------------------------------- | |
# Get and Set the access control list (ACL) of a DIRECTORY | |
getfacl /path/to/the/folder | |
setfacl -Rm "u:username:rwX" /path/to/the/folder (g for group) | |
setfacl -Rm "d:u:username:rwx" /path/to/the/directory (default access to the file) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rht-vmctl reset server | |
rht-vmctl reset desktop | |
ssh root@serverX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create File Systems | |
mkfs -t btrfs /dev/vdb1 (file systems: xfs, ext4..) | |
------------------------------------------------------------------------- | |
# Label (btrfs) File Systems | |
btrfs filesystem label /dev/vdb1 "label-name" | |
------------------------------------------------------------------------- | |
# Label (ext4) File Systems | |
e2label /dev/vdb1 label-name | |
------------------------------------------------------------------------- | |
# Label (xfs) File Systems | |
xfs_admin -L "label-name" /dev/vdb1 | |
------------------------------------------------------------------------- | |
# Mount File Systems | |
1. create new temprorary directory | |
mkdir tempdir | |
------------------------------------------------------------------------- | |
2. apply mount command | |
mount /dev/vdb1 /tempdir | |
df -h (check mounting) | |
------------------------------------------------------------------------- | |
3. cp -pr /home/* /tempdir/ | |
------------------------------------------------------------------------- | |
4. umount /tempdir | |
------------------------------------------------------------------------- | |
5. Get partition's UUID | |
blkid /dev/vdb1 | |
or | |
lsblk -o name,uuid | |
------------------------------------------------------------------------- | |
6. persistent mounting | |
vi /etc/fstab | |
UUID=48516887-51fc-4930-af9f-735c9c0c3f2e /home btrfs defaults 0 0 | |
mount -a | |
------------------------------------------------------------------------- | |
7. view mounted FSs | |
mount | grep vdb1 | |
------------------------------------------------------------------------- | |
Source -> https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/s2-disk-storage-parted-create-part#s3-disk-storage-parted-create-part-mkfs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login to mysql | |
mysql -u root -p | |
------------------------------------------------------------------------- | |
# Create database | |
CREATE DATABASE databasename; | |
------------------------------------------------------------------------- | |
# Use database | |
use databasename; | |
------------------------------------------------------------------------- | |
# Create tables of the database | |
MariaDB [databasename]> CREATE TABLE example ( | |
did TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
dname VARCHAR(20),PRIMARY KEY(did)); | |
MariaDB [databasename]> CREATE TABLE example ( | |
id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
name VARCHAR(20),PRIMARY KEY(id)); | |
------------------------------------------------------------------------- | |
# Show tables of the database | |
show tables; | |
------------------------------------------------------------------------- | |
# Show the schema or layout of the table using the DESCRIBE command | |
DESCRIBE databasename; | |
------------------------------------------------------------------------- | |
Source -> https://www.youtube.com/watch?v=qxPnGlIxYC8 (video tutorial) | |
Source -> https://www.theurbanpenguin.com/rhce-creating-a-database-in-mariadb-using-rhel-7-1/ (sql commands) | |
Source -> https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/ (What to Do if MariaDB Doesn't Start) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Create Partitions | |
# List disks: | |
a) lsblk | |
b) lsblk -o name,label,fstype | |
------------------------------------------------------------------------- | |
# Create MBR disk partition | |
fdisk /dev/vdb | |
n (new partition) | |
p (primary partition) | |
1 (default partition number) can vary | |
enter (fist sector) can cary | |
enter (last sector) can vary | |
enter or t (define the type) | |
w (write changes) | |
------------------------------------------------------------------------- | |
# Create GPT disk partition | |
gdisk /dev/vdb | |
n (new partition) | |
p (primary partition) | |
1 (default partition number) can vary | |
enter (fist sector) can cary | |
enter (last sector) can vary | |
enter or L (define the type) | |
w (write changes) | |
y | |
------------------------------------------------------------------------- | |
### Source -> https://rhlearn.gilmore.ca/node/357/take | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SSH into CLIENT computer: | |
ssh username@desktopX | |
------------------------------------------------------------------------- | |
# Now that we are in the CLIENT computer, we do these commands: | |
# first we try to log into the SERVER with our password, it should work | |
ssh username@serverX | |
exit | |
# now we generate the key, and copy it onto the server | |
ssh-keygen | |
ssh-copy-id username@serverX | |
# then we try to log into the SERVER again, this time it shouldn't ask for password | |
ssh username@serverX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Add new user | |
useradd -m username (-m for the home directory) | |
------------------------------------------------------------------------- | |
## Add new group | |
groupadd groupname | |
------------------------------------------------------------------------- | |
## Add user to the group | |
usermod -ag groupname username | |
------------------------------------------------------------------------- | |
Source -> https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/s1-users-tools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apache accesses several directories on the fle system: | |
– The apache binary, apache modules and shared libraries in /usr/bin, /usr/lib | |
– Confguration fles in /etc/httpd/* – Web content in /var/www/html (by default) | |
– Server logs in /var/log/httpd/* | |
– Executable scripts (cgi-bin, python, php, …) in the web application directories for e.g. /usr/share/owncloud/* | |
– Documentation in /usr/share/doc/apache (The documentation is available in html format served as a web site) | |
– Possible more custom fles/directories | |
------------------------------------------------------------------------- | |
sudo yum -y install httpd httpd-manual | |
------------------------------------------------------------------------- | |
systemctl enable httpd.service | |
------------------------------------------------------------------------- | |
systemctl status httpd | |
------------------------------------------------------------------------- | |
systemctl start httpd.service | |
or | |
apachectl start | |
------------------------------------------------------------------------- | |
# Network security | |
firewall-cmd --permanent --add-service=http --add-service=https | |
firewall-cmd --reload | |
------------------------------------------------------------------------- | |
# To serve the default content outside, a new context rue must be addded | |
semanage fcontext -a -t httpd_sys_content_t '/new/location(/.*)?' | |
------------------------------------------------------------------------- | |
# Allow writable access for a group to the DocumnetRoot | |
setfacl -R -m g:groupname:rwX /var/www/html | |
setfacl -R -m d:g:groupname:rwx /var/www/html | |
------------------------------------------------------------------------- | |
# Change ServerAdmin | |
/etc/httpd/conf/httpd.conf | |
content of file: ServerAdmin username ([email protected]) | |
# Create default content page | |
in /var/www/html/ we create index.html | |
write someting to the file using vim | |
------------------------------------------------------------------------- | |
------------------------------------------------------------------------- | |
Source -> https://rhlearn.gilmore.ca/node/156/take (redhat) | |
Source -> https://www.youtube.com/watch?v=PatSrUO4o8w (video tutorial) | |
Source -> https://www.youtube.com/watch?v=HlF1egrT4Wg (video tutorial 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment