guide | LinuxHostSupport Linux Tutorials and Guides Thu, 21 Apr 2022 06:42:21 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 Understanding The Linux File Permissions https://linuxhostsupport.com/blog/understanding-the-linux-file-permissions/ https://linuxhostsupport.com/blog/understanding-the-linux-file-permissions/#comments Fri, 15 Apr 2022 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=1655 In this tutorial we are going to explain the Linux file permissions in different Linux distributions such as Ubuntu, CentOS, Debian, and AlmaLinux. The Linux file permissions are very important to understand and use properly, due to security reasons and user access rights. The user access rights are controlled by the permissions, attributes, and ownership. […]

The post Understanding The Linux File Permissions appeared first on LinuxHostSupport.

]]>
In this tutorial we are going to explain the Linux file permissions in different Linux distributions such as Ubuntu, CentOS, Debian, and AlmaLinux. The Linux file permissions are very important to understand and use properly, due to security reasons and user access rights. The user access rights are controlled by the permissions, attributes, and ownership. This defines who will be the authorized users and which directories and files will be accessed by them.

In this blog post we will explain the permissions on Ubuntu 20.04 OS. You can choose by yourself which OS to use. Let’s get started!

Prerequisites

  • Fresh install of Ubuntu 20.04
  • User privileges: root or non-root user with sudo privileges

Update the System

If you have a fresh installation of Ubuntu 20.04 it is recommended to update the system to the latest packages available.

sudo apt update -y && sudo apt upgrade -y

Understanding Permission Types

The three permission types of the files and folders are read, write, and execute. These permission types controls which user can read the file, write the file or execute the file.

  • Read: The read permission defines if the user can or cannot read the content of the file.
  • Write: The write permission defines if the user can or cannot modify the content of the file or folder.
  • Execute: The execute permission defines if the user can or cannot execute the file. The files with execute permissions are known as script files.

Understanding Permission Groups

The three permissions groups that have every Linux file or folder are owner, group and users. These three groups are asocciated to a file or folder.

  • Owner: The owner permissions are applied only to the owner of the file and folder, and are not related to the actions of the other users. The list of Linux users are stored in /etc/passwd file.
  • Group: The group permissions are applied only to the assigned group of the file and folder, and are not related to the actions of the users. The list of Linux groups are stored in /etc/group file.
  • Other: The other user’s permissions are applied to the other users of the file and folder.

Managing the Permissions

In this section we are going to explain with real examples the permission types and permission groups of a file or folder and the procedure of changing them. For example list the root directory on your server with the following command:

ls -al

You should get the following output:

root@vps:~# ls -al
total 56
drwx------  6 root root  4096 Mar  6 15:53 .
drwxr-xr-x 19 root root  4096 Feb  5 13:27 ..
-rw-------  1 root root    42 Mar  6 15:53 .bash_history
-rw-r--r--  1 root root  3106 Dec  5  2019 .bashrc
drwx------  3 root root  4096 May  4  2020 .cache
drwx------  4 root root  4096 May  4  2020 .config
drwx------  3 root root  4096 May  4  2020 .local
-rw-------  1 root root     0 May  6  2020 .mysql_history
-rw-r--r--  1 root root   161 Dec  5  2019 .profile
-rw-r--r--  1 root root    72 May  3  2020 .selected_editor
drwx------  2 root root  4096 Mar  6 15:27 .ssh

As you can see there is information about if it is a file or directory, about the types and permission groups. To fully understand this pay attention to the following output:

-rw-r--r-- 1 root root 3106 Mar  6  2022 filename
|[-][-][-]-  [---][---][---]
| |  |  | |    |    |    |-----------> 8. Size
| |  |  | |    |    +----------------> 7. Group
| |  |  | |    +---------------------> 6. Owner
| |  |  | +--------------------------> 5. Alternate Access Method
| |  |  +----------------------------> 4. Others Permissions
| |  +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type

Each write, read, and execute permissions have the following number value:

r (read) = 4
w (write) = 2
x (execute) = 1
no permissions = 0

For example if the permission types of the file are -rw-r–r–, to get the number of this we are going to sum the values of the permissions for that group.

Owner: rw- = 4 + 2 + 0 = 6
Group: r-- = 4 + 0 + 0 = 4
Others: rw- = 4 + 0 + 0 = 4

To change the permission of this file, and set the permissions to 755 for example, execute the command below:

chmod 755 filename

After listing the file again you should receive the following output:

root@host:~# ls -al filename
-rwxr-xr-x 1 root root 3106 Mar  6  2022 filename

To check if the correct number is 755 we are going to check this as explained in the example above:

Owner: rwx = 4 + 2 + 1 = 7
Group: r-x = 4 + 0 + 1 = 5
Others: r-x = 4 + 0 + 1 = 5

At the momment the owner of the file is the root user, and the group is root as well. To change the owner and group execute the command below:

chown www-data:www-data filename

List the file again and pay attention on the output:

root@vps:~# ls -al filename
-rwxr-xr-x 1 www-data www-data 3106 Mar  6  2022 filename

You can see that the owner and the group are set to www-data. Of course, you can set different owner and group to the file as long as that user and group exist in your system.

That’s it. This blog post has explained the basics of Linux File Permission. Of course, if you find it difficult to manage the permissions of the files or folders on your Linux VPS server, you can always contact our epic technical support. They are available 24/7 and they will help you with your request.

If you liked this post about “Understanding the Linux File Permissions”, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

The post Understanding The Linux File Permissions appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/understanding-the-linux-file-permissions/feed/ 2
How to Install Laravel on Ubuntu 18.04 https://linuxhostsupport.com/blog/how-to-install-laravel-on-ubuntu-18-04/ https://linuxhostsupport.com/blog/how-to-install-laravel-on-ubuntu-18-04/#comments Wed, 21 Apr 2021 16:50:11 +0000 https://linuxhostsupport.com/blog/?p=1378   1. Connect to your server To connect to your server via SSH as user root, use the following command: ssh root@IP_ADDRESS -p PORT_NUMBER and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number. Once logged in, make sure that your server is up-to-date by running the following commands: apt-get […]

The post How to Install Laravel on Ubuntu 18.04 appeared first on LinuxHostSupport.

]]>
 

1. Connect to your serverinstalling laravel on ubuntu 18.04

To connect to your server via SSH as user root, use the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number. Once logged in, make sure that your server is up-to-date by running the following commands:

apt-get update
apt-get upgrade

2. Install the MySQL Database server

MySQL is an open-source database management system. To install MySQL, run the following command:

$ apt-get install mysql-server

This will install MySQL 5.7 on your server. In order to improve the security of your MySQL server, we recommend that you run the mysql_secure_installation script by typing the following command:

mysql_secure_installation

This script will help you to perform important security tasks like setting up a root password, disable remote root login, remove anonymous users, etc.

3. Create a database for Laravel

Now, we will create our MySQL database for our Laravel site. Login to your MySQL server with the following command and enter your MySQL root password:

mysql -u root -p

In this section, we will create a new MySQL database laravel and assign user access to it to a new user admin_user with password Strong_Password

CREATE DATABASE laravel;
GRANT ALL PRIVILEGES ON laravel.* TO 'admin_user'@'localhost' IDENTIFIED BY 'Strong_Password';
FLUSH PRIVILEGES;
exit;

Don’t forget to replace ‘Strong_Password’ with an actual strong password.

4. Install PHP and required PHP modules

To install the PHP and all necessary modules, run:

sudo apt-get install php-cli php-mcrypt php-mbstring php-zip php-opcache php-gd php-xml

5. Install Composer

A composer is a dependency manager for PHP and of course Laravel, which you can install packages with. The composer will pull all the required libraries you need for your project.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

6. Install Laravel

Install the latest version of Laravel, using the composer create-project command:

sudo composer create-project --prefer-dist laravel/laravel my_project

If the installation is successful, you will see the following lines:

Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Package manifest generated successfully.
> @php artisan key:generate
Application key [base64:NEu4D2s1Ai8HHZL3wPnrl+BVpSmcm7dMTStIBtMgSn0=] set successfully.

By default, Laravel is configured to use MySQL(MariaDB), but you need to give it the right information to connect to the database that you just set up. Next, go to the /var/www/Html/my_project/config directory, open the database.php file with your favorite text editor, for example:

nano database.php

And update the database settings, replacing them with your own details:

 'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'yourDBName'),
            'username' => env('DB_USERNAME', 'yourUserName'),
            'password' => env('DB_PASSWORD', 'yourPassword'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

7. Server your application with Artisan serve command

Once the installation is completed you can use the artisan serve command to serve your application:

php artisan serve

The output should be something like this:

Laravel development server started: <http://127.0.0.1:8000>

You can now open your browser and access your new Laravel installation at: http://127.0.0.1:8000

8. Install and configure Apache webserver

In this part of the tutorial, we will show you how to install and configure Apache to serve your Laravel application. Run the following command to install Apache webserver from the official Ubuntu repositories:

apt-get install apache2

Change the ownership of the Laravel directory to the webserver user:

chown -R www-data:www-data /path/to/laravel
chmod -R 755 my_project/storage/

Create a new Apache virtual host with the following content:

sudo nano /etc/apache2/sites-available/your_domain.com
<VirtualHost *:80>
ServerName your_domain.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/my_project/public

<Directory /var/www/html/my_project>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Activate the virtual host by creating a symbolic link :

sudo ln -s /etc/apache2/sites-available/your_domain.com /etc/apache2/sites-enabled/your_domain.com
 

Your Laravel installation is now complete.  You have successfully installed Laravel on your Ubuntu 18.04 VPS. Visit the domain name with a web browser you will see the Laravel default page.   That’s it. If you followed all of the instructions properly now you should be able to access your Laravel installation on your Ubuntu 18.04 server.

 

installing laravel on ubuntu 18.04If you are one of our web hosting customers, and use our optimized Laravel Hosting, you don’t have to install Laravel on Ubuntu 18.04, our expert Linux admins will set up and optimize your Laravel VPS, for you. They are available 24×7 and will take care of your request immediately. As a Laravel developer, you should be focusing on Laravel development and improving your code and leave the server work to us. PS. If you liked this post, on how to install Laravel on Ubuntu 18.04, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

The post How to Install Laravel on Ubuntu 18.04 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-laravel-on-ubuntu-18-04/feed/ 3