Linux Tasks:
1. There are 6 team members in a project team, in which 3 members are part of "admin" group and
rest 3 members are from "Users" group. A directory has been created in which some confidential
files are placed, hence members from user group have a simply READ access and even sticky bit has
been applied for both root and normal user, but admin group has full access to this directory. How
can you implement the whole scenario?
A:
echo "admin users" | xargs -n1 echo groupadd ${g}; // create multiple groups in a single
command//
        sudo vi users.txt   //create a file for entering multiple users info//
            A:1234:1002:1002:comment admin:/home/A:/bin/bash
[pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell]
                B:1234:1003:1003:comment admin:/home/B:/bin/bash
                C:1234:1004:1004:comment admin:/home/C:/bin/bash
                D:1234:1005:1005:comment users:/home/D:/bin/bash
                E:1234:1006:1006:comment users:/home/E:/bin/bash
                F:1234:1007:1007:comment users:/home/F:/bin/bash
                                         chmod 0600 users.txt            //set a permission//
                                                 newusers users.txt // Run "newusers" program //
                                                          gpasswd -M A,B,C admin      //Entry the
users into admin group//
                                                                         gpasswd -M D,E,F users //Entry the
users into user group//
                                                                mkdir dir      //as a root user//
                                                        touch f1 f2 f3 f4 f5          //create five files under
'dir' directory//
                                       getfacl dir           // check the default permissions on dir. O/P be
like: drwxr-xr-x+ 2 root root 56 Apr 18 16:37 dir
                    # file: dir
                    # owner: root
                    # group: root
                      user::rwx
                      group::r-x ///
                                      setfacl -m g:admin:rx dir
                              setfacl -m g:user:r dir
                    getfacl dir     // output: group:           admin:r-x
                                                                                   group:user:r--
                                                                                   mask::r-x
                                                                                   other::r-x       //
** Now try to login as 'A' user** su - A    // 'A' is from admin group which is eligible to access 'dir'
directory and read and open the files also //
[A@ip-172-31-87-54 ~]$ cd /
[A@ip-172-31-87-54 /]$ cd dir
[A@ip-172-31-87-54 dir]$ ls -l
total 0
-rw-r--r-- 1 root root 0 Apr 18 16:37 f1
-rw-r--r-- 1 root root 0 Apr 18 16:37 f2
-rw-r--r-- 1 root root 0 Apr 18 16:37 f3
-rw-r--r-- 1 root root 0 Apr 18 16:37 f4
-rw-r--r-- 1 root root 0 Apr 18 16:37 f5
** Now try to login as 'D' user** su - D   //'D' is from user group which is not eligible to access 'dir'
directory//
[D@ip-172-31-87-54 ~]$ cd /
[D@ip-172-31-87-54 /]$ cd dir
-bash: cd: dir: Permission denied
2. Creating a LAMP Stack:
LAMP stack is a collection of free and open source softwares like Linux, Web Server (Apache),
Database server (MySQL / MariaDB) and PHP (Scripting Language). LAMP is the platform which is
required to install and build dynamic web sites and application like WordPress, Joomla, OpenCart
and Drupal.
In this article i will describe how to install LAMP on Ubuntu Server 16.04 LTS, As We know that
Ubuntu is a Linux based Operating system, so it provides the first component of LAMP and i am
assuming Ubuntu Server 16.04 is already installed on your system.
Installation of Web Server (Apache2) :
In Ubuntu Linux Web server comes with the name Apache2, Use the beneath apt command to install
it.
        linuxtechi@ubuntu:~$ sudo apt update
        linuxtechi@ubuntu:~$ sudo apt install apache2 -y
When Apache2 package is installed then its service is automatically started and enabled across the
reboot, In case it is not started and enabled, use the following command :
        linuxtechi@ubuntu:~$ sudo systemctl start apache2.service
If Ubuntu firewall (ufw) is active, then allow the Web Server ports (80 and 443) in firewall using
below commands.
        linuxtechi@ubuntu:~$ sudo ufw status
Status: active
linuxtechi@ubuntu:~$ sudo ufw allow in 'Apache Full'
Rule added
Rule added (v6)
linuxtechi@ubuntu:~$
Access Web Server now :
Open the Web browser and type the IP Address or Host name of your server
(http://IP_Address_OR_Host_Name), In my Case my server IP is ‘192.168.1.13’
Installation of Data Base Server (MySQL Server 5.7) :
MySQL and MariaDB are the database servers in Ubuntu 16.04. MySQL Server and MariaDB Server’s
packages are available in the default repositories and we can install either of the database. Run the
following apt command to install MySQL Server from terminal.
        linuxtechi@ubuntu:~$ sudo apt install mysql-server mysql-client
During the installation, it will prompt us to set the root password of mysql server.
Confirm root password and click on ‘OK’
Installation of MySQL Server is completed Now. MySQL Service will be started and enabled
automatically.We can verify the MySQL Server’s service using below systemcl command :
        linuxtechi@ubuntu:~$ sudo systemctl status mysql.service
Installation of MariaDB Server :
Use the beneath command to install MariaDB Server 10.0 from the terminal.
        linuxtechi@ubuntu:~$ sudo apt install mariadb-server
Run the following command to set root password of mariadb and disable other options like disable
remote login.
        linuxtechi@ubuntu:~$ sudo mysql_secure_installation
Installation of PHP ( Scripting Language ) :
PHP 7.0 is available in the Ubuntu repositories. Execute the beneath command from the terminal to
install PHP 7 :
        linuxtechi@ubuntu:~$ sudo apt install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi
php7.0 libapache2-mod-php7.0
Create a sample php page and place it in apache document root (/var/ww/html)
linuxtechi@ubuntu:~$ vi samplepage.php
<?php
phpinfo();
?>
Save and exit the file.
linuxtechi@ubuntu:~$ sudo mv samplepage.php /var/www/html/
Now Access the sample PHP page from the Web Browser, type :
“http://<Server_IP>/samplepage.php” , You should get the page like below.
Above Page shows that our PHP installation is completed successfully.
Installation of phpMyAdmin :
phpMyAdmin allows us to perform all the database related administrative and other DB operation
task from its web interface. Its package is already listed in the Ubuntu server repositories.
Use the below commands to Install phpMyAdmin on Ubuntu server 16.04 LTS.
        linuxtechi@ubuntu:~$ sudo apt install php-mbstring php7.0-mbstring php-gettext
        linuxtechi@ubuntu:~$ sudo systemctl restart apache2.service
        linuxtechi@ubuntu:~$ sudo apt install phpmyadmin
During its installation it will prompt us to choose the Web server to be configured for phpMyAdmin.
Select Apache2 and Click on OK.
Click on ‘Yes’ to Configure database for phpMyAdmin.
Specify the password for phpMyAdmin to register with Database Server.
    3. How to mount a S3 bucket with EC2 instance: https://youtu.be/PJdlJwhHogU
    https://linuxdady.com/mount-s3-bucket-with-ec2-instance/#:~:text=%20How%20to%20mount
    %20s3%20bucket%20with%20ec2,bucket%20with%20your%20system%20directory.%20Now...
    %20More%20
    4. How to access a S3 bucket from EC2 instance using IAM role: https://youtu.be/qRT8DuPD0Ak
    5. Installation of phpmyadmin for Amazon AMI and Ubuntu:
    For Ubuntu:
       i. sudo apt install phpmyadmin php-mbstring php-gettext
       ii. The installation process adds the phpMyAdmin Apache configuration file into the
           /etc/apache2/conf-enabled/ directory, where it is read automatically. The only thing you
           need to do is explicitly enable the mbstring PHP extension, which you can do by typing:
           sudo phpenmod mbstring
       iii. Restart apache2: sudo systemctl restart apache2
    For Amazon Ami:
           i.     sudo yum install php72-mbstring.x86_64 –y /Install the required dependencies./
           ii.    sudo service httpd restart
           iii.   cd /var/www/html
           iv .   wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-
           languages.tar.gz
                   mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C
                   phpMyAdmin --strip-components 1
                   rm phpMyAdmin-latest-all-languages.tar.gz
                   sudo service mysqld start
                   http://my.public.dns.amazonaws.com/phpMyAdmin
    6. Configuring Password Access for a Dedicated MySQL User:
           To do this, open up the MySQL shell once again
           mysql -u root –p
           From there, create a new user and give it a strong password:
          CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
    Then, grant your new user appropriate privileges. For example, you could grant the
    user privileges to all tables within the database, as well as the power to add, change,
    and remove user privileges, with this command:
           GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
    Following that, exit the MySQL shell:
           exit
    http://your_domain_or_IP/phpmyadmin
    sudo mysql -u root -p GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
    IDENTIFIED BY '1234' WITH GRANT OPTION;
    7. Installation Grafana:
    Created a file with “grafana.repo” name and placed in this directory sudo nano
    /etc/yum.repos.d/grafana.repo
    Enter the following info in grafana.repo file.:
    [grafana]
    name=grafana
    baseurl=https://packages.grafana.com/enterprise/rpm
    repo_gpgcheck=1
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.grafana.com/gpg.key
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    yum install grafana-enterprise
    sudo systemctl start grafana-server
    sudo systemctl status grafana-server
    sudo systemctl enable grafana-server
    Hit: <server ip address>:3000/login
    8. Installation and configuration of Graphite:
https://www.vultr.com/docs/how-to-install-and-configure-graphite-on-centos-7#:~:text=How%20to
%20Install%20and%20Configure%20Graphite%20on%20CentOS,for%20Graphite.%204%20Access
%20Graphite%20Web%20Interface.%20