Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

Linux IntroductionChapter 4. User, Group and Permission

chmod Command with Numbers

chmod Command with Numbers

Efficient Access Mode Management with chmod Command

To manage the many combinations and define the access mode of each file or directory in a more efficient way, the assigned numbers are also used for the access mode setting. The numbers are assigned for each permission as shown below.

  • r : 4
  • w : 2
  • x : 1
  • - : 0

Using the sum of all numbers, you can represent all access modes with a single digit for one user type. To cover the three user types, you need only three digits. Here are some examples.

755 : typical access mode when the superuser creates a directory

  • Owner User : rwx
  • Owner Group : r-x
  • Others : r-x

775 : typical access mode when a normal user creates a directory

  • Owner User : rwx
  • Owner Group : rwx
  • Others : r-x

644 : typical access mode when the superuser creates a file

  • Owner User : rw-
  • Owner Group : r--
  • Others : r--

664 : typical access mode when a normal user creates a file

  • Owner User : rw-
  • Owner Group : rw-
  • Others : r--

700 : typical .ssh directory permission

  • Owner User : rwx
  • Owner Group : ---
  • Others : ---

600 : typical ssh private key permission

  • Owner User : rw-
  • Owner Group : ---
  • Others : ---

Practice

1. Confirm the initial permission setting when creating new documents

To check the initial permission, create four types of documents:

  • one directory created by a normal user (dir_ubuntu)
  • one file created by a normal user (file_ubuntu)
  • one directory created by the superuser (dir_root)
  • one file created by the superuser (file_root)

To create the documents, run the commands below.

Command Line - INPUT
mkdir dir_ubuntu
touch file_ubuntu
sudo su
mkdir dir_root
touch file_root

Run the ls -l command to see the permission of each document. You can see that the initial permission settings are the same as the ones explained in this section.

Command Line - INPUT
ls -l
Command Line - RESPONSE
drwxr-xr-x 2 root   root   4096 Jan  3 01:36 dir_root
drwxrwxr-x 2 ubuntu ubuntu 4096 Jan  3 01:37 dir_ubuntu
-rw-r--r-- 1 root   root      0 Jan  3 01:36 file_root
-rw-rw-r-- 1 ubuntu ubuntu    0 Jan  3 01:37 file_ubuntu

2. Change access mode using numbers

To change the access mode of dir_ubuntu to 700 and file_ubuntu to 600, run the command below.

Command Line - INPUT
chmod 700 dir_ubuntu
chmod 600 file_ubuntu
Command Line - INPUT
ls -l
Command Line - RESPONSE
drwxr-xr-x 2 root   root   4096 Jan  3 01:36 dir_root
drwx------ 2 ubuntu ubuntu 4096 Jan  3 01:37 dir_ubuntu
-rw-r--r-- 1 root   root      0 Jan  3 01:36 file_root
-rw------- 1 ubuntu ubuntu    0 Jan  3 01:37 file_ubuntu

You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Testing Django App UI on Mobile Devices

Check Developing App UI on Mobile Device

Absolute vs Relative Paths in Linux

Absolute Path and Relative Path (Linux OS)

Customizing Django Allauth Templates

Django Allauth (7) – Allauth Template File Setup

Configuring Git & GitHub Settings

Chapter 2. Git & GitHub Initial Settings

Exploring User Groups in Linux

Group – Primary Group and Secondary Group

Testing Django App UI on Mobile Devices

Check Developing App UI on Mobile Device

Absolute vs Relative Paths in Linux

Absolute Path and Relative Path (Linux OS)

Customizing Django Allauth Templates

Django Allauth (7) – Allauth Template File Setup

Configuring Git & GitHub Settings

Chapter 2. Git & GitHub Initial Settings

Exploring User Groups in Linux

Group – Primary Group and Secondary Group

Tags:

Access Mode

Permission

Linux Introduction
Course Content

Chapter 1. Linux Basics

What Is OS?

CUI and GUI

Linux Distributions

Package Manager

Kernel and Shell

Current Working Directory

Linux Directory Structure

Absolute Path and Relative Path (Linux OS)

Linux Command Syntax

Special Characters and Escape Character

Chapter 2. Linux Key Commands

Setting Up Linux Environment on AWS

pwd (Print Working Directory)

cd (Change Directory)

ls (List Contents of Directory)

mkdir (Make Directory)

rmdir (Remove Directory)

touch (Create File)

rm (Remove File)

mv (Move File and Directory)

cp (Copy File and Directory)

cat (Display File Content)

sort (Sort File Contents)

grep (Global Regular Expression Print)

Regular Expression

find (Find File and Directory)

Wildcard

ln (Create Link to File and Directory)

Chapter 3. Vim Editor

What Is Vim and How to Launch It?

Normal, Insert and Visual Mode

Normal Mode (1) – Move Cursor

Normal Mode (2) – Delete

Normal Mode (3) – Copy and Paste

Normal Mode (4) – Undo and Redo

Normal Mode (5) – Search Phrase

Normal Mode (6) – Replace Phrase

Normal Mode (7) – Save and Exit

Insert Mode

Visual Mode

Chapter 4. User, Group and Permission

What Are User, Group And Permission in Linux?

Permission (Access Mode) by Owner Status

Superuser (Root User) vs. Normal User

sudo (Run Command with Superuser Privileges)

su (Switch User)

useradd (Add User)

passwd (Set Password)

userdel (Delete User)

Group – Primary Group and Secondary Group

groupadd (Add Group)

usermod (Modify User Account Information)

gpasswd (Add and Delete Users to Group)

groupdel (Delete Group)

chown (Change Owner of File and Directory)

chgrp (Change Group of File and Directory)

chmod (Change Access Mode)

chmod Command with Numbers

w and who (Check Current User Login Status)

id and groups (Check User ID and Group)

getent (Display User and Group Data)

Chapter 5. Redirection, Pipe and Shell Script

Standard Input Output and Redirection

Pipe (Combine Commands)

less (Display Content with Pager)

tr (Replace Characters)

cut (Extract Data Sections)

uniq (Extract Unique Data Lines)

Shell Script

echo (Echo input)

read (Read and Store Input)

Shell Variable and Environmental Variable

source (Execute Shell Script and Refresh Environmental Variables)

Chapter 6. Linux Commands for Command Management

history (Check Command History)

alias (Create Command Shortcuts)

man (Display Manual)

type, which and whereis (Display Command Information)

Package Manager Command

tree (Display Directory Tree)

Chapter 7. SSH Remote Connection

SSH (Secure Shell)

Locate .ssh Directory

SSH Remote Login (1) – Use Key Pair Generated by Server

SSH Remote Login (2) – Use Key Pair Generated by Client

SSH Config File

SSH Remote Login with Visual Studio Code

SCP (Secure Copy Protocol)

SCP with SSH Config File

SFTP (Secure File Transfer Protocol)

Other File Transfer Commands

Chapter 8. Linux Process Management

Process and Job

Foreground and Background Jobs

jobs and ps (Display Jobs and Processes)

Signals

Create, Stop and Terminate Jobs

Daemon Processes

What Is Service on Linux?

Systemd

Unit File

Systemctl Sub-Commands

Create Custom Unit and Start at Boot

Firewall

UFW (Uncomplicated Firewall)

Web Server

Launch Apache Web Server

Chapter 1. Linux Basics

What Is OS?

CUI and GUI

Linux Distributions

Package Manager

Kernel and Shell

Current Working Directory

Linux Directory Structure

Absolute Path and Relative Path (Linux OS)

Linux Command Syntax

Special Characters and Escape Character

Chapter 2. Linux Key Commands

Setting Up Linux Environment on AWS

pwd (Print Working Directory)

cd (Change Directory)

ls (List Contents of Directory)

mkdir (Make Directory)

rmdir (Remove Directory)

touch (Create File)

rm (Remove File)

mv (Move File and Directory)

cp (Copy File and Directory)

cat (Display File Content)

sort (Sort File Contents)

grep (Global Regular Expression Print)

Regular Expression

find (Find File and Directory)

Wildcard

ln (Create Link to File and Directory)

Chapter 3. Vim Editor

What Is Vim and How to Launch It?

Normal, Insert and Visual Mode

Normal Mode (1) – Move Cursor

Normal Mode (2) – Delete

Normal Mode (3) – Copy and Paste

Normal Mode (4) – Undo and Redo

Normal Mode (5) – Search Phrase

Normal Mode (6) – Replace Phrase

Normal Mode (7) – Save and Exit

Insert Mode

Visual Mode

Chapter 4. User, Group and Permission

What Are User, Group And Permission in Linux?

Permission (Access Mode) by Owner Status

Superuser (Root User) vs. Normal User

sudo (Run Command with Superuser Privileges)

su (Switch User)

useradd (Add User)

passwd (Set Password)

userdel (Delete User)

Group – Primary Group and Secondary Group

groupadd (Add Group)

usermod (Modify User Account Information)

gpasswd (Add and Delete Users to Group)

groupdel (Delete Group)

chown (Change Owner of File and Directory)

chgrp (Change Group of File and Directory)

chmod (Change Access Mode)

chmod Command with Numbers

w and who (Check Current User Login Status)

id and groups (Check User ID and Group)

getent (Display User and Group Data)

Chapter 5. Redirection, Pipe and Shell Script

Standard Input Output and Redirection

Pipe (Combine Commands)

less (Display Content with Pager)

tr (Replace Characters)

cut (Extract Data Sections)

uniq (Extract Unique Data Lines)

Shell Script

echo (Echo input)

read (Read and Store Input)

Shell Variable and Environmental Variable

source (Execute Shell Script and Refresh Environmental Variables)

Chapter 6. Linux Commands for Command Management

history (Check Command History)

alias (Create Command Shortcuts)

man (Display Manual)

type, which and whereis (Display Command Information)

Package Manager Command

tree (Display Directory Tree)

Chapter 7. SSH Remote Connection

SSH (Secure Shell)

Locate .ssh Directory

SSH Remote Login (1) – Use Key Pair Generated by Server

SSH Remote Login (2) – Use Key Pair Generated by Client

SSH Config File

SSH Remote Login with Visual Studio Code

SCP (Secure Copy Protocol)

SCP with SSH Config File

SFTP (Secure File Transfer Protocol)

Other File Transfer Commands

Chapter 8. Linux Process Management

Process and Job

Foreground and Background Jobs

jobs and ps (Display Jobs and Processes)

Signals

Create, Stop and Terminate Jobs

Daemon Processes

What Is Service on Linux?

Systemd

Unit File

Systemctl Sub-Commands

Create Custom Unit and Start at Boot

Firewall

UFW (Uncomplicated Firewall)

Web Server

Launch Apache Web Server