File Permissions, Access Control Lists and Understanding package manager and systemctl in Linux

Nitin DhimanNitin Dhiman
4 min read

File Permissions and Access Control

Introduction

In this blog We will understand how file permissions and access control lists (ACLs) works in Linux is key for managing security in a system and user access. In this paper we will take a look at areas like various file permissions that are used by operating systems, ownership as well as package managers and systemd.

Let us go ahead to dissect these ideas further.

🗂️ File Permissions and Ownership

Fundamental elements of Linux security are file permissions and ownership. In Linux, every file and directory has associated permissions which define who can read, write or execute them. These permissions have three categories:

  1. Owner: The user who owns the file.

  2. Group: The group that owns the file.

  3. Others: All other users.

You can view the permissions of a file using the ls -ltr command:

touch demo.txt
ls -ltr demo.txt
Changing Ownership and Group
  • Change Ownership: Use chown to change the owner of a file.
sudo chown new_owner demo.txt
  • Change Group: Use chgrp to change the group of a file.
sudo chgrp new_group demo.txt
Changing Permissions
  • Change Permissions: Use chmod to change the permissions of a file.
sudo chmod 755 demo.txt

🔒 Access Control Lists (ACLs)

ACLs provide a more flexible permission mechanism for file systems. They allow you to define permissions for specific users or groups. Here’s how you can use ACLs:

  • View ACLs: Use getfacl to view the ACLs of a file.
getfacl demo.txt
  • Set ACLs: Use setfacl to set the ACLs of a file.
setfacl -m u:username:rwx demo.txt

Package Managers and systemctl

📦 Package Managers

A package manager is a tool that automates the process of installing, upgrading, configuring, and removing software packages.

Package managers like apt in Ubuntu simplify the installation, updating, and removal of software. For example, sudo apt update updates the package lists, and sudo apt install package_name installs a package.

Install Docker on Ubuntu:

sudo apt-get update
sudo apt-get install docker.io

Install of Jenkins on Ubuntu

To install Jenkins on Ubuntu, follow these steps:

Update the system packages: Open a terminal and run:

sudo apt update
sudo apt upgrade

Install Java: Jenkins requires Java to run. Install OpenJDK:

sudo apt install openjdk-11-jdk

Verify the installation:

java -version

Install Docker on CentOS:

The Docker installation package available in the official CentOS 7 repository may not be the latest version. To get the latest and greatest version, install Docker from the official Docker repository. This section shows you how to do just that.

But first, let’s update the package database:

sudo yum check-update

Now run this command. It will add the official Docker repository, download the latest version of Docker, and install it:

curl -fsSL https://get.docker.com/ | sh

After installation has completed, start the Docker daemon:

sudo systemctl start docker

Install Jenkins on CentOS:

To install Jenkins on your CentOS, you need install java first.

you can follow the following steps.

Step 1: Install java

Jenkins is a Java application, so we need to install Java before installing Jenkins. You run the following command to install the OpenJDK 8 package.

yum install java-1.8.0-openjdk-devel -y

Step 2: Setup Jenkins repository

Next, you need to enable the Jenkins repository with the following command:

curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo

And add the repository to your system with the command:

rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

Step 3: Install Jenkins

Once the repository is enabled, let’s install the latest stable version of Jenkins with the following command:

yum install jenkins -

🔧 systemctl and systemd

systemctl is a command-line tool to control the systemd system and service manager.

Check Docker Service Status:

systemctl status docker

Stop Jenkins Service:

sudo systemctl stop jenkins
systemctl status jenkins

Conclusion

Understanding file permissions, ACLs, package managers, and systemd is essential for any Linux administrator or DevOps engineer. These tools and concepts help maintain system security and manage software efficiently.

0
Subscribe to my newsletter

Read articles from Nitin Dhiman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nitin Dhiman
Nitin Dhiman