{"id":27354090,"url":"https://github.com/karan51ngh/linux-explained","last_synced_at":"2025-04-12T21:53:37.525Z","repository":{"id":118677900,"uuid":"388701033","full_name":"karan51ngh/Linux-Explained","owner":"karan51ngh","description":"This is a detailed resource about various useful Linux concepts like file system, package management, permissions, users processes etc. It is intended for use by Linux beginners, primarily focusing on Debian-based distributions such as Ubuntu, Linux Mint, Pop!_OS etc.","archived":false,"fork":false,"pushed_at":"2025-04-10T20:54:46.000Z","size":60,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:53:32.343Z","etag":null,"topics":["apt","bash","cheatsheet","debian","gnu","gnu-linux","linux","package-manager","permissions","process","script","shell","shell-script","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karan51ngh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-23T06:33:20.000Z","updated_at":"2025-04-10T21:00:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"013439e8-7ba7-4e78-ad67-06c9bcdf9610","html_url":"https://github.com/karan51ngh/Linux-Explained","commit_stats":null,"previous_names":["karan51ngh/linux-explained"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karan51ngh%2FLinux-Explained","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karan51ngh%2FLinux-Explained/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karan51ngh%2FLinux-Explained/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karan51ngh%2FLinux-Explained/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karan51ngh","download_url":"https://codeload.github.com/karan51ngh/Linux-Explained/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637830,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apt","bash","cheatsheet","debian","gnu","gnu-linux","linux","package-manager","permissions","process","script","shell","shell-script","ubuntu"],"created_at":"2025-04-12T21:53:36.545Z","updated_at":"2025-04-12T21:53:37.509Z","avatar_url":"https://github.com/karan51ngh.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linux-Explained\n\n- Welcome to **Linux-Explained** – a beginner-friendly guide to understanding and using Linux.\n- This repository is designed to help new users, tech enthusiasts, and aspiring developers get comfortable with the Linux operating system. \n- Whether you're switching from another OS, learning Linux for development, or just curious about how it works, this guide aims to simplify the core concepts and tools.\n- The goal is to offer a straightforward, beginner-friendly reference to help you build a strong foundation in Linux.\n\n## Index of Content:\n- [Introduction to Linux](#a-brief-introduction-to-linux)\n    - [What is GNU](#what-is-gnu)\n- [Linux File System](#linux-file-system)\n    - [Linux Filesystem Hierarchy Structure](#linux-filesystem-hierarchy-structure)\n    - [About various directories](#about-various-directories)\n    - [File System Navigation using CLI](#file-system-navigation-using-cli)\n    - [`pwd`](#pwd), [`ls`](#ls), [`cd`](#cd), [`touch`](#touch), [`cat`](#cat), [`mv`](#mv), [`cp`](#cp), [`rm`](#rm), [`rmdir`](#rmdir)\n- [Package Managers](#package-managers)\n    - [Introduction to Package Managers](#introduction-to-package-managers)\n    - [Package Managers and Software Packages](#from-where-do-package-managers-get-these-software-packages)\n    - [View List of Repositories](#how-to-check-the-list-of-repositories-your-system-accesses-for-installing-software)\n    - [`apt` package manager](#apt-package-manager)\n    - [`dpkg` package manager](#dpkg-package-manager)\n    - [`apt` vs `dpkg`](#apt-vs-dpkg)\n- [File Permissions](#file-permissions)\n    - [Types of Permissions and Users](#types-of-permissions-and-users)\n    - [Working with Permissions](#working-with-permissions)\n    - [chmod](#chmod-command-is-used-for-modifying-the-permissions-of-a-filedirectory)\n- [Process Management](#process-management)\n    - [`top`](#top), [`kill`](#kill), [`killall`](#killall)\n\n## A Brief Introduction to Linux\n\n- Linux is an open-source operating system kernel created by [Linus Torvalds](https://github.com/torvalds) in 1991.\n- Together, [GNU](#what-is-gnu) and Linux (also called GNU/Linux) form a complete operating system, often just called Linux.\n- The GNU Project provided all the essential tools needed to make a complete, usable operating system.\n- Linux is a Unix-like system, meaning it's inspired by the design of Unix. Unix was a closed-source operating system developed in the 1970s at AT\u0026T’s Bell Labs.\n\n- #### What is GNU\n    - GNU stands for “GNU’s Not Unix” – a recursive acronym.\n    - It’s a free software project started by Richard Stallman in 1983.\n    - It's  Goal: Create a completely free and open Unix-like operating system.\n    - GNU is a collection of free software tools (created by the Free Software Foundation) that work with the Linux kernel to form a full operating system.\n    - Since Unix was proprietary, GNU set out to recreate it with open-source alternatives:\n\n        | **Component**     | **GNU Replacement**                                       |\n        |-------------------|-----------------------------------------------------------|\n        | Shell             | GNU Bash - `bash` (Bourne Again Shell)                    |\n        | System libraries  | GNU C Library - `glibc`                                   |\n        | File utilities    | coreutils - [ls](#ls), [cp](#cp), [echo](#echo) etc.      |\n        | Compiler          | GNU Compiler Collection - `gcc`                           |\n        | Debugger          | GNU Debugger - `gdb`                                      |\n        | Build tools       | `make`, `autoconf`, etc.                                  |\n        | Bootloader        | `GRUB` (GRand Unified Bootloader)                         |\n- In 1991, Linus Torvalds released the Linux kernel. Combining GNU tools + Linux kernel = a working operating system → GNU/Linux.\n\n## LINUX FILE SYSTEM\n\n- A file system in an operating system (OS) is a way of organizing and storing data on storage devices like hard drives, SSDs, USB drives, etc. \n- It defines how files are named, stored, retrieved, and managed.\n- The Linux file system is a **hierarchical directory structure** that organizes files and directories in a **tree-like** structure, with a single **root** directory at the top of the hierarchy, represented by  `/`. \n- Below the root directory, there are a number of other directories, including `/bin`, `/dev`, `/etc`, `/home`, `/lib`, `/mnt`, `/proc`, `/sbin`, `/tmp`, and `/usr`.\n- In Linux, **Everything is a File**. For example, devices, sockets, and even processes are treated as files, enabling uniform interaction via standard I/O operations.\n- Each file has access [permissions](#file-permissions) (*read*, *write*, *execute*) for *owner*, *group*, and *others*, controlled via commands like [chmod](#chmod), [chown](#chown), and [chgrp](#chgro).\n- External filesystems (like USBs or other partitions) are integrated into the directory tree using the [mount](#mount) command at specific mount points.\n\n### Linux Filesystem Hierarchy Structure\n\n```bash\n/                       # Root directory (top-level of the filesystem)\n├── bin/                # Essential user binaries (e.g., ls, bash)\n├── boot/               # Boot loader files (e.g., kernel, initrd)\n├── dev/                # Device files (e.g., /dev/sda)\n├── etc/                # System-wide configuration files\n├── home/               # Home directories for users\n│   ├── karan51ngh/     # Personal directory for a user named karan51ngh\n│   └── torvalds/       # Personal directory for a user named  torvalds\n├── lib/                # Essential shared libraries\n├── media/              # Mount point for removable media (e.g., USB drives)\n├── mnt/                # Temporary mount point for filesystems\n├── opt/                # Optional application software packages\n├── proc/               # Virtual filesystem for process and kernel info\n├── root/               # Home directory for the root user\n├── run/                # Temporary runtime files\n├── sbin/               # System binaries (usually for root)\n├── srv/                # Data for services provided by the system\n├── sys/                # Virtual filesystem for system and device info\n├── tmp/                # Temporary files (often cleared on reboot)\n├── usr/                # Secondary hierarchy for read-only user data\n│   ├── bin/            # Non-essential user binaries\n│   ├── lib/            # Non-essential libraries\n│   └── share/          # Architecture-independent data\n└── var/                # Variable data (e.g., logs, spool files)\n```\n### About various directories\n\n - `/` : This is the root directory and the starting point of the file system. All other directories are contained within it.\n - `/bin` : This directory contains executable programs (also known as Binaries) that are essential for system operation, such as [ls](#ls), [cp](#cp), [mv](#mv), [mount](#mount), [rm](#rm), etc.\n - `/boot` : This directory contains the files needed for booting the system, including the kernel and bootloader.\n - `/dev` : This directory contains device files, which are used to communicate with hardware devices such as printers and USB drives.\n - `/etc` : This directory contains system configuration files, such as the configuration files for the network, user accounts, and startup scripts.\n - `/home` : This directory contains user home directories, where users can store their personal files.\n - `/lib` : This directory contains shared library files that are used by the system and applications.\n - `/media` : This directory is used for mounting removable media such as CDs, DVDs, and USB drives.\n - `/mnt` : This directory is used for temporarily mounting file systems, such as network file systems or external hard drives.\n - `/opt` : This directory is used for installing optional software packages.\n - `/proc` : This directory provides information about the running processes and system resources.\n - `/root` : This directory is the home directory for the root user.\n - `/sbin` : This directory contains essential system administration programs, such as init and shutdown that generally can only be employed by the [superuser]().\n - `/srv` : can contain data directories of services such as HTTP (/srv/www/) or FTP.\n - `/sys` : is a virtual filesystem that can be accessed to set or obtain information about the kernel's view of the system.\n - `/tmp` : This directory is used for temporary files that are created by the system and applications.\n - `/usr` : This directory contains non-essential system files, such as user programs and documentation.\n - `/var` : This directory contains variable data files, such as log files and spool directories.\n \n### File System Navigation using CLI.\n\nFile system navigation in Linux can be done using the command line interface.\nHere are the commands needed in brief:\n\n- ##### `pwd` \n\t\u003eThis command in Linux stands for **\"print working directory\"**. It is used to display the current working directory, which is the directory that the user is currently in.\n\n- ##### `ls`\n\t\u003eThis command in Linux is used to list the contents of a directory and it also provides information about the files and directories in the current directory / specified directory.\n\n    - *Syntax*: `ls [options] \u003cDIRECTORY_NAME\u003e`. `\u003cDIRECTORY_NAME\u003e` by default is the current working directory. \n    - *options*:\n        - `ls`: Shows files and directories in short format.\n        - `ls -a`: Shows **hidden** (that start with a dot `.`)files and directories. \n        - `ls -l` / `ll`: Shows **detailed information** about each file and directory, including the file permissions, ownership, size, and modification date.\n        - `ls -h`: Shows file sizes in a **human-readable format**, such as \"*2.3K*\" or \"*4.5M*\".\n        - `ls -t`: Sorts files and directories by **modification time**, with the most recently modified files and directories listed first.\n        - `ls -r`: **Reverses** the **order** of sort, so that files and directories are listed in reverse order.\n        - `ls -S`: **Sorts** files by size, with the largest files listed first.\n        - `ls -R`: Lists the contents of subdirectories **recursively**.\n        - `ls --color`: Adds **color** to the **output**, making it easier to read.\n- ##### `cd` \n    \u003eThis command in Linux is used to change the current working directory.\n\n    - *Options*:\n        - `cd` / `cd ~`: Changes the current working directory to your **home** directory.\n        - `cd \u003cDIRECTORY_NAME\u003e`: Changes the current working directory to the specified directory.\n        - `cd -`: Changes the current working directory to the **previous** working directory.\n        - `cd ..`: Changes the current working directory to the **parent** directory.\n- ##### `touch`\n\t\u003eThis command in Linux is used to create an empty file or update the timestamp of an existing file.\n\n    - *Syntax*: `touch [OPTION]... \u003cFILE_NAMES\u003e...`\n    - *Options*:\n        - `touch \u003cfile_name\u003e`: Creates an empty file with the specified name, or updates the timestamp of an existing file.\n        - `touch -a \u003cfile_name\u003e`: Updates only the **access time** of the specified file.\n        - `touch -m \u003cfile_name\u003e`: Updates only the **modification time** of the specified file.\n        - `touch -d [date] \u003cfile_name\u003e`: Sets the access and modification times of the specified file to the specified date and time. The date must be in the format **YYYY-MM-DD HH:MM:SS**.\n- ##### `cat`\n\t\u003eThis command is primarily used to concatenate and display the contents of one or more files, but can also be used to modify them.\n\n    - *Syntax*: `cat [OPTION]... \u003cFILE_NAMES\u003e...`\n    - *Options*:\n        - `cat \u003cfile_name\u003e`: Displays the contents of the specified file on the screen.\n        - `cat \u003cfile_1\u003e \u003cfile_2\u003e`: **Concatenates** the contents of two or more files and displays them on the screen.\n        - `cat -n \u003cfile_name\u003e`: Displays the contents of the specified file on the screen, with line numbers.\n        - `cat -b \u003cfile_name\u003e`: Displays the contents of the specified file on the screen, with line numbers only for non-blank lines.\n        - `cat \u003cfile_1\u003e \u003e\u003e \u003cfile_2\u003e`: **Appends** contents of *file_1* to the contents of *file_2*.\n        - `cat \u003cfile_1\u003e \u003e \u003cfile_2\u003e`:  **Replaces** the contents of an *file_2* with the content of *file_1*.\n- ##### `mv`\n\t\u003eThis command is used to move or rename files and directories.\n\n    - *Syntax*: `mv [Options] [source/directory/FILE_NAME] [destination/directory/FILE_NAME]`\n\t- *Options*:\n\t    - `mv file.txt /home/user/new_directory/`: move the file file.txt to the directory /home/user/new_directory/.\n\t\t- `mv -i \u003cfile_name\u003e \u003cdirectory_name\u003e`: Makes the process **interactive**, **prompts** before overwriting an existing file.\n\t\t- `mv -f \u003cfile_name\u003e \u003cdirectory_name\u003e`: **Forces** the move or rename operation without prompting, even if the destination file already exists.\n\t\t- `mv -v \u003cfile_name\u003e \u003cdirectory_name\u003e`: Displays **verbose** output, showing the names of the files or directories being moved or renamed.\n\t\t- `mv \u003cfile_1\u003e \u003cfile_2\u003e`: This will **rename** the file from *file_1* to *file_2*.\n- ##### `cp`\n\t\u003eThis is used to copy files and directories from one location to another.\n\n    - *Syntax*: `cp [Options] [source/directory/file/name] [destination/directory/file/name]`\n\t- *Options*:\n\t    - `cp \u003cfile_1\u003e /home/user/new_directory/`: copy the file *file_1* to the directory */home/user/new_directory/*.\n\t\t- `cp -i \u003cfile_name\u003e \u003cdirectory_name\u003e`: Makes the process **interactive**, **prompts** before overwriting an existing file\n\t\t- `cp -f \u003cfile_name\u003e \u003cdirectory_name\u003e`: **Forces** the copy operation without prompting, even if the destination file, with the same name already exists.\n\t\t- `cp \u003cfile_1\u003e \u003cfile_2\u003e \u003cfile_3\u003e /destination/directory`: \n\t\tCopying **multiple files**.\n\t\t- `cp -r /home/user/old_directory /home/user/new_directory/`: This will **recursively copy** the **directory** */home/user/old_directory* and its contents to the directory */home/user/new_directory/*.\n\t\t- `cp \u003cfile_1\u003e \u003cfile_2\u003e`: This will create a copy of the file *file_1* to the same directory, with the name *file_2*.\n- ##### `rm`\n\t\u003eThis is used to remove or delete files and directories.\n\n    - *Syntax*: `cat [OPTION]... \u003cFILE_NAMES\u003e \u003cDIR_NAMES\u003e...`\n    - *Options*: \n        - `rm \u003cfile_1\u003e`: This will delete file_1.\n        - `rm -r \u003cdirectory_name/\u003e`: This will recursively delete the directory directory and its contents.\n        - `rm -f \u003cfile_1\u003e`: *Forces** the deletion of file without prompting, even if the file is write-protected.\n        - `rm -i \u003cfile_1\u003e`: Makes the process **interactive**, **prompts** before deleting the file\n- ##### `rmdir`\n\t\u003eThis command is used to remove empty directories in Linux.\n   \t\n    - *Syntax*: `rmdir \u003cdirectory_name\u003e`\n\n## PACKAGE MANAGERS\n\n### Introduction to Package Managers:\n\n- **Package managers** are software tools for *installing*, *updating*, and *removing software packages* on a computer system.\n- They maintain a **database** of available **software packages** and their **dependencies**.\n- Package managers automatically download and install necessary dependencies when a user requests the installation or removal of a package.\n- Package managers also provide features for managing *package updates*, such as checking for *new versions* and *installing security patches*.\n- Popular package managers include *apt*, *dpkg*, *yum*, *rpm*, *pacman*.\n\n### From where do Package Managers get these Software Packages:\n\n- Package managers obtain software packages from **software repositories**.\n- Repositories are typically hosted on servers that are accessible over the internet. \n- Repositories can be maintained by the operating system vendor, a third-party provider, or the community.\n- Package managers connect to the appropriate repository and download the necessary packages and dependencies.\n- This ensures that the packages are obtained from a **trusted source** and are the correct version for the system.\n- Popular repositories include Ubuntu's official repositories, Arch Linux's AUR, and Red Hat's EPEL repository.\n- Package managers, such as `apt` and `yum`, are used to interact with repositories and download and install packages from them.\n\n### How to check the list of repositories your system accesses for installing software:\n\nHere Terminal Commands for checking the repositories on various major Linux distributions:\n- For **Debian** or **Ubuntu**:\n    - ` sudo nano /etc/apt/sources.list`\n    - This command will open the sources.list file in a text editor.\n- For **Fedora** or **CentOS**:\n    - `sudo yum repolist`\n    - This command will display the repository IDs and names for all enabled repositories on your system.\n    - To view more detailed information about a specific repository `sudo yum info \u003crepository-name\u003e`\n- For **Arch Linux**:\n    - `cat /etc/pacman.conf`\n    - This command will display the contents of the configuration file for the Pacman package manager.\n\n### apt package manager\n\n- The `apt` command is a package management tool for **Debian-based** Linux distributions.\n- *Syntax*: `apt [options] \u003cpackage_name\u003e`\n- *Options*:\n    - `apt update`: updates the package lists from the repositories.\n    - `apt upgrade`: upgrades the installed packages to their latest versions.\n    - `apt install package`: installs the specified package and its dependencies.\n    - `apt remove package`: removes the specified package, but leaves its configuration files intact.\n    - `apt purge package`: removes the specified package along with its configuration files.\n    - `apt autoremove`: removes any unused dependencies that were installed as a result of package  - installations or removals.\n    - `apt search package`: searches for packages with the specified name or keywords.\n    - `apt show package`: displays detailed information about the specified package.\n    - `apt list`: lists all installed packages on the system.\n        - `apt list --installed`: To see all the installed packages on the system.\n        - `apt list --upgradable`:  To see all the packages that have a newer version ready to be upgraded.\n    - ` apt dist-upgrade`: Upgrade all installed packages, including those that require the installation of new dependencies or the removal of existing ones.\n    - `--fix-broken`: Attempt to fix broken dependencies when installing a package.\n    - `apt edit-sources`: opens the sources.list file for editing.\n- You can use apt to install a .deb file by  `sudo apt-get install /path/to/package.deb`. When using apt to install a .deb file, the package manager will not automatically resolve dependencies or install any required dependencies.\n- If you want to use apt to install a .deb file and automatically resolve dependencies, use: `sudo apt --fix-broken install /path/to/package.deb`\n- the `--fix-broken` option is specific to the `apt` command and is not supported by the `dpkg` command. `dpkg` is a **lower-level** package manager that works with individual `.deb` packages. It does not have the ability to automatically resolve dependencies or install packages from a remote repository.\n- Examples:\n    - To update the package lists, run: `sudo apt update`\n    - To install the 'htop' package, run: `sudo apt install htop`\n    - To remove the 'thunderbird' package, run: `sudo apt remove thunderbird`\n    - To search for packages containing the word 'editor', run: `sudo apt search editor`\n    - To list all installed packages on the system, run: `sudo apt list`\n \n### dpkg package manager:\n \n- `dpkg` is a package manager for **Debian-based** systems such as **Ubuntu**. It is used to *install*, *remove*, and *manage software packages* in the `.deb` format.\n- *Syntax*: `dpkg [options] \u003cpackage_name.deb\u003e`\n- *Options*:\n    - `-i`/`--install`: Install a package from a .deb file.\n    - `-r`/`--remove`: Remove a package from the system, leaving its configuration files intact.\n    - `-P`/`--purge`: Purge a package from the system, and remove the package and its configuration files.\n    - `--unpack`: Unpack a package, but do not configure it.\n    - `--configure`: Configure an unpacked package.\n    - `--force-depends`: Force the installation of a package even if it depends on a package that is not installed.\n    - `--force-remove-reinstreq`: Force the removal of a package even if it is required by other installed packages.\n    - `list`: List the installed packages on the system.\n    - `search`: Search for a package by name.\n    - For a complete list of options, `--help` flag with the `dpkg` command.\n- dpkg installs packages on Ubuntu in order to follow the Filesystem Hierarchy Standard (FHS), which defines a standard directory structure for Unix-like operating systems.\n- When you use dpkg to install a package, the package and its files are installed in the following locations:\n    - **Executable files**: `/usr/bin`\n    - **Libraries**: `/usr/lib`\n    - **Documentation**: `/usr/share/doc`\n    - **Configuration files**: `/etc`\n- Examples:\n    - Install a package: `sudo dpkg -i /path/to/package.deb`\n    - Uninstall a package: `sudo dpkg -r package_name`\n    - Purge a package: `sudo dpkg -P package_name`\n    - List all installed packages: `dpkg --list`\n    - Show details about a package: `dpkg --status package_name`\n    - Query which package a file belongs to: `dpkg --search file_path`\n    - Extract files from a package: `dpkg -x package_name.deb directory_path`\n\n### Differences between `apt` and `dpkg` package managers\n \n - `dpkg` and `apt` are both package managers for Debian-based systems such as Ubuntu.\n - `dpkg` is a lower-level package manager that works with **individual .deb packages**. \n - **`dpkg` does not have the ability to automatically resolve dependencies or install packages from a remote repository.**\n - `apt` is a higher-level package manager that is built on top of `dpkg`. It has the ability to automatically resolve dependencies and install packages from a remote repository, making it easier to use than dpkg.\n \n## FILE PERMISSIONS\n\n\u003eFile permissions are a way of controlling access to files and directories. \n\n### Types of Permissions and Users\n\n\u003eThere are **three types of permissions**: *read*, *write*, and *execute*.\n\n- **Read (r)** - The read permission allows a user to **view** the contents of a file or directory. When applied to a directory, it allows the user to see the names of the files and subdirectories within it.\n- **Write (w)** - The write permission allows a user to **modify** the contents of a file or directory. When applied to a directory, it allows the user to create, delete, or rename files and subdirectories within it.\n- **Execute (x)** - The execute permission allows a user to **run** a program or script. When applied to a directory, it allows the user to access the files and subdirectories within it.\n\n\u003eThese permissions are assigned to **three categories of users**: *owner*, *group*, and *others*.\n\n- **owner** is the user who **created** it or the user who currently owns it. \n- **group** is a collection of users who share **similar permissions** to access certain files or directories. You can give multiple users the same level of access to that file or directory without having to set individual permissions for each user\n- **others** includes all users who do not fall into the categories of owner or group.\n\n### Working with Permissions\n- To view the file permissions, use `ls -l` command:\n    \n    *output*:\n    \n    ```bash\n    -rwxrw-r-- 12 karan51ngh users 64.0K Feb  26 11:11 file_name\n    |[-][-][-]-   [--------] [---]\n    | |  |  | |      |       |\n    | |  |  | |      |       +-------------\u003e 7. Group Name\n    | |  |  | |      +---------------------\u003e 6. Owner Name\n    | |  |  | +----------------------------\u003e 5. Alternate Access Method\n    | |  |  +------------------------------\u003e 4. Others Permissions\n    | |  +---------------------------------\u003e 3. Group Permissions\n    | +------------------------------------\u003e 2. Owner Permissions\n    +--------------------------------------\u003e 1. File Type\n    ```\n- The table below represents what **number is assigned** for all the different **types of permissions**.\n    | Number | Permission Type        | Symbol      |\n    | ------ | ---------------------- | ----------- |\n    | 0      | Permission Type        | ---         |\n    | 1      | Execute                | --x         |\n    | 2      | Write                  | -w-         |\n    | 3      | Execute + Write        | -wx         |\n    | 4      | Read                   | r--         |\n    | 5      | Read + Execute         | r-x         |\n    | 6      | Read + Write           | rw-         |\n    | 7      | Read + Write + Execute | rwx         |\n    \n- ##### `chmod` \n    \u003eThis is used for modifying the permissions of a file/directory.\n    \n    - *Symbollic mode*:\n        - *Syntax*: `chmod \u003cuser_type\u003e\u003ctake/remove permission\u003e\u003clist_of_permissions\u003e \u003cfile_names\u003e`\n        - *Examples*:\n            - to add execute permissions for the owner of a file you would run: `chmod u+x file_name`\n            - to add read and write permissions for the group that owns the file, you would run: `chmod g+rw file_name`\n            - to remove write permissions for the owner of a file you would run: `chmod o-w file_name`\n    - *Numeric Mode*:\n        \u003e We can use the numbers(from the above table) assigned to different permissions.\n        \n        - *Syntax*: `chmod \u003cnumber_owner\u003e\u003cnumber_group\u003e\u003cnumber_others\u003e \u003cfile_names\u003e`\n        - *Example*:\n            - to set permissions on a file to rwxrw-r-–, you would run: `chmod 764 file_name`\n\n## Process Management\n\nA process is an instance of a running program, and each process has its own unique process ID (**PID**), as well as other attributes such as a parent process ID (**PPID**), priority(**PR**), CPU and memory usage, and input/output streams.\n\n- ##### `top`\n    \u003eThis is used to monitor the performance of the system and display real-time information about the processes running on it.\n    \n    - *Syntax*: `top [options]`\n    - *Options*:\n        - `top -d \u003cn\u003e`: sets the delay as *n seconds* between updates of the process list.\n        - `top -n \u003cn\u003e`: sets the number of iterations for which the `top` command will run before exiting as *n*.\n        - `top -p \u003cprocess_id1\u003e,\u003cprocess_id2\u003e,...`: allows you to specify the process ID(s) to monitor.\n        - `top -u \u003cuser_name\u003e`: allows you to filter the output by the speified user.\n        - `top -H`: displays the process hierarchy in a tree-like format. This is useful for understanding the relationships between processes.\n        - `top -o \u003cfield_name\u003e`:allows you to sort the output by a specific field. For example `top -o %CPU`, `top -o TIME`, `top -o UID`, `top -o %MEM` etc.\n        \n- ##### `kill`\n    \u003eThe is used to send     signals to running processes. The signals can be used to control the behavior of the processes or terminate them.\n    \n    - *Syntax*: `kill [signal] [pid]`\n    - *Signals*:\n        - **TERM** (signal 15): Request that the process terminate gracefully.\n        - **KILL** (signal 9): Forcefully terminate the process without allowing it to perform any cleanup.\n        - **HUP** (signal 1): Send the hangup signal, which is typically used to request that a process reload its configuration file.\n        - **INT** (signal 2): Send the interrupt signal, which is similar to pressing Ctrl+C on the keyboard.\n        - If you **do not specify** a signal, kill sends the **TERM signal by default**, which requests that the process terminate gracefully.\n        - use the `-s` option to specify a signal by name rather than number. For example, `kill -s SIGTERM [pid]` is equivalent to `kill -15 [pid]`.\n    - *Examples*:\n        - `kill 1234`: Send the default TERM signal to the process with the ID 1234.\n        - `kill -9 5678`: Forcefully terminate the process with the ID 5678 using the KILL signal.\n        - `kill -s HUP 9876`: Send the hangup signal to the process with the ID 9876.\n        - `kill -INT 2345`: Send the interrupt signal (equivalent to Ctrl+C) to the process with the ID 2345.\n    \n- ##### `killall`\n    \u003e This command is used to send signals to all processes that match a given name, making it a more convenient way than `kill` to terminate multiple processes at once. By default, killall sends the TERM signal.\n    \n    - *Syntax*: `killall [options] \u003cname\u003e`\n    - *Options*:\n        - `killall -u \u003cuser\u003e \u003cname\u003e`: Send the default TERM signal to all \u003cname\u003e processes owned by the user \u003cuser\u003e.\n        - `killall -g \u003cgroup\u003e \u003cname\u003e`: Send the default TERM signal to all \u003cname\u003e processes belonging to the users group \u003cgroup\u003e.\n        - `-v` and `-i` are used for verbose output and interactive process respectively.\n    - *Examples*:\n        - `killall firefox`: Send the default TERM signal to all processes with the name firefox.\n        - `killall -s KILL apache2`: Forcefully terminate all processes with the name apache2 using the KILL signal.\n        - `killall -i -s TERM sshd`: Interactively prompt the user before sending the TERM signal to all sshd processes.\n        - `killall -u alice firefox`: Send the default TERM signal to all firefox processes owned by the user alice.\n        - `killall -g users chrome`: Send the default TERM signal to all chrome processes belonging to the users group.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaran51ngh%2Flinux-explained","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaran51ngh%2Flinux-explained","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaran51ngh%2Flinux-explained/lists"}