Advanced Linux

Advanced Linux

File permissions and package managers

Introduction

Linux's file permissions and package manager are vital for how the system functions and user interactions. File permissions control access to files and directories, determining read, write, and execute privileges to safeguard sensitive data. The package manager streamlines software management, making installations and updates seamless, handling dependencies. Understanding these concepts is essential for effective system administration and a smooth software experience. In this guide, we'll explore them to empower you to take control of your Linux system. Let's master file permissions and package management in Linux!

let's get started

Create and check file details

File Permission with Alphabetical

File permissions are at the core of the Linux security model, governing access to files and directories. There are three types of permissions:

  1. Basic Permission:

    • The owner (u): Permissions for the owner of the file.

    • Group(g): Permissions for the members of the file's group.

    • Others (o): Permissions for all other users.

Each type of permission can be granted in three modes:

  • Read (r): allows read-only

  • Write (w): Permits Write/Edit/Append/Delete content.

  • Execute (x): Enables execution/run the file.

now create a file "demo4" and check its permissions using the ls -lrth command:

To change file permissions, we use the chmod command. To grant permissions, we use the + symbol, and to remove permissions, we use the - symbol.

For example, to give read, write, and execute access to the user for the "demo4" file:

now we can give the read, write access to others for the same demo4 file

File Permission With Numerically:

Linux also allows setting permissions numerically using three-digit numbers. Each permission (read, write, execute) is assigned a numeric value:

  • Read (r): 4

  • Write (w): 2

  • Execute (x): 1

For example:

  • Read and write permissions (4 + 2 = 6)

  • Read and execute permissions (4 + 1 = 5)

  • Read, write, and execute permissions (4 + 2 + 1 = 7)

  • No permissions (0)

Let's create another file named "demo5" and check its permissions using ls -lrth command:

To give read and execute access to the group and remove all access from the user and others for the "demo5" file:

What is a package?

A package is usually referred to as an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.

In the older days, software used to be installed from its source code. You would refer to a file (usually named readme) and see what software components it needs, and the location of binaries. A configure script or makefile is often included. You will have to compile the software on your own along with handling all the dependencies (some software require installation of other software) on your own.

What is Package Manager in Linux

In simpler words, a package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like apt-get. These packages are collections of software bundled together with essential metadata, including version details and dependencies, ensuring a hassle-free software deployment.

There are two popular package managers in the Linux world - APT (Advanced Packaging Tool) and YUM (Yellowdog Updater, Modified). We will learn how things work and the commands they use. We'll also understand how systemd and systemctl manage system services. Moreover, we'll show how to set up Docker and Jenkins with these tools, putting what we learn into real use.

APT (Advanced Packaging Tool)

APT is a robust and widely-used command-line package management system, serving as a front-end for the dpkg package management system. It is prevalent in Debian-based distributions such as Ubuntu and Linux Mint, making software management a breeze with its user-friendly commands.

To install a package using APT, execute the following command in the terminal: Command apt-get install package_name

Keeping your system up-to-date is crucial for security and performance reasons. To update the packages on your system, run the following commands:

sudo apt-get update

sudo apt-get upgrade

To remove a package, simply use the following command:

sudo apt-get remove package-name

YUM (Yellowdog Updater, Modified)

YUM is another widely-used open-source command-line package manager that operates with the RPM (Red Hat Package Manager) format. It is common in RPM-based distributions like Red Hat Enterprise Linux (RHEL) and CentOS, providing functionalities similar to APT but with different commands.

To install a package using YUM, use the below command:

sudo yum install package-name

Keep your packages up-to-date is crucial, and YUM simplifies this process with the below command:

sudo yum update

To remove a package using YUM, use the below command:

sudo yum remove package -name

Getting to know systemd and systemctl

systemd

Systemd is a powerful software suite designed to unify service configuration and behavior across various Linux distributions. Its primary component is a "system and service manager," serving as an init system to manage user processes and bootstrap the user space. Systemctl, a command-line utility, interacts with systemd, enabling users to efficiently manage system and service configurations.

systemctl

The systemctl command is a command line utility that interacts with the systemd system and service manager. It is the primary tool used to control and manage systemd services, allowing users to start, stop, enable, disable, and check the status of services.

Some common systemctl commands include:

  • Start a service:- systemctl start SERVICE_NAME

  • Stop a service:- systemctl stop SERVICE_NAME

  • Restart a service:- systemctl restart SERVICE_NAME

  • Enable a service to start at boot:- systemctl enable SERVICE_NAME

  • Disable a service from starting at boot:- systemctl disable SERVICE_NAME

  • Check the status of a service:- systemctl status SERVICE_NAME

Install Terraform using Package Managers

1: Update the packages using yum:

sudo yum update

2: Install Terraform on Amazon Linux using Yum:

sudo yum install terraform

3: Check the version of Terraform:

sudo terraform version

Install Docker using Package Managers

1: Update the packages using APT:

sudo apt update

2: Install Docker on Ubuntu using APT:

sudo apt-get install docker.io -y

3: Check the version of Docker:

sudo Docker --version

Install Ansible using Package Managers

1: Update the packages using APT:

sudo apt update

2: Install Ansible on Ubuntu using APT:

sudo apt install ansible

3: Check the version of Ansible:

ansible --version

Conclusion

Understanding file permissions is crucial for keeping your Linux system safe and in good shape. Basic permissions and numbers help you control who can do what with your files. By learning these things, you can make sure your files stay secret and available. In the tech world, package managers are like magic helpers for Linux. They make installing, updating, and removing software super easy. APT and YUM are famous ones. Think of them as the "get stuff done" tools. Also, systemd and systemctl are like superhero managers for your system. They make sure things run smoothly. Together, they help you take charge of what's on your computer and keep it running great.

Stay tuned for more exciting blogs, where we will go further into Linux concepts to continue our journey in the world of DevOps. Happy learning!

Thank you for reading, and happy Linux exploring!

Let's learn together! I appreciate any comments or suggestions you may have to improve my blog content.

Thank you,

Akshay Nazirkar