How to Use Chattr Command in Linux (for Beginners)

Chattr is a UNIX command-line program that’s pre-shipped in most Linux distributions. The role of this command is to allow the admin user to set file attributes that impose restrictions on files.There are a handful of file attributes for different roles, such as the “+i” attribute, which prevents a file from being renamed, deleted, or modified, and the “+a” attribute, which only allows appending new content, as well as a few others that will be discussed later in this tutorial.The benefit of usi

Linux With Chris
Creating Aliases for Common Linux Commands in Bash Zsh and Fish Shells

GNU/Linux is a robust operating system known for its flexibility and power. Yet, typing lengthy commands repeatedly can become overwhelming. That's where aliases step in. These handy shortcuts can transform your workflow, allowing you to execute complex commands with just a few keystrokes. In this guide, we will examine how to create aliases in different shell configurations: `.bashrc`, `.zshrc`, and `config.fish`, so you can work more efficiently.What is an Alias?An alias is a simple shortcut t

Linux With Chris
Understanding Linux PATH Environment Variable

IntroductionEver wondered how a Linux terminal magically finds commands like ls or cd without explicit instructions on their exact location?It is not magic; it is the unsung hero called the PATH environment variable.Environment variables are like little sticky notes that hold important information for the operating system and programs.What Exactly is the Linux PATH Environment Variable?The PATH variable is a special environment variable that stores a list of directories. One can think of it as a

Linux With Chris
Understanding the $SHELL Environment Variable in Unix and Linux

In Unix and Linux systems, the $SHELL environment variable indicates the parent shell that initiated your current session. This can be useful for understanding the runtime environment, particularly when troubleshooting or scripting. It’s important to know that this value doesn’t always reflect your default login shell—it shows the shell that started your current session.For example, if you start a new shell within your login shell, $SHELL still shows the original one.Here’s a practical demonstra

Linux With Chris
Managing users and groups in Linux with the `useradd`, `usermod`, `passwd` and `userdel` commands

Creating users in a Linux system is a fundamental task required by system administrators and anyone managing a Linux server or a desktop workstation.The `useradd` command is the main tool for creating user accounts on Linux systems. In this blog post, we will look at how to effectively use the `useradd` and other user management commands, the various options available, and how to assign a user to a specific group and shell.Understanding the Useradd CommandThe `useradd` command is a low-level uti

Linux With Chris
'doas': an alternative to 'sudo'

In Linux, managing user permissions and command execution is crucial for maintaining system stability and security. Many users are familiar with the command `sudo`, which allows them to execute commands with higher privileges. However, there's an alternative tool called `doas` that provides a more efficient way to escalate privileges. In this post, I'll guide you through the installation and configuration of `doas`.What is `doas`?`doas` is a lightweight tool that enables users to run commands wi

Linux With Chris
What is a Shell in Linux?

Shell is an interface that directly interacts with the kernel by accepting a set of commands that is submitted by the user or process.There are many types of shells like fish, Zsh, Csh, etc., exists. Bash is the most popular one.Bash (Bourne Again Shell) is derived from SH (Bourne Shell). The Bourne shell is designed to comply with POSIX standards and many popular shells like Bash, Dash, Zsh, etc., are derived from the Bourne shell. As time flies, a more rich set of features has been added to ba

Linux With Chris
What's /dev/sda in Linux.

When a Windows user encounters a Linux system for the first time, their first thought is: where are the “C:/“, “D:/“, or “E:/” drives?You must know that Linux doesn’t have any concept of local disk like in Windows; here, each and everything represents a file.Before you understand exactly what “/dev/sda”, you must first know about what files are and the different types of files in Linux.What are files in LinuxIn Linux, each device, like a network adapter, mounted disk, partition, etc., is a file

Linux With Chris