๐Ÿง chmod Command Guide (Linux File Permissions)

๐Ÿง chmod Command Guide (Linux File Permissions)
Operating System(s)

The chmod (change mode) command is used to modify file and directory permissions. It controls who can read, write, or execute a file.

๐Ÿ“Œ Permission Basics

Each file has three permission groups:

  • u (user/owner)
  • g (group)
  • o (others)

And three permission types:

  • r (read) โ†’ view file
  • w (write) โ†’ modify file
  • x (execute) โ†’ run file

โ–ถ๏ธ Basic Syntax

 

chmod [options] permissions file

 

๐Ÿ”ข Numeric (Octal) Mode

Permissions use numbers:

  • 4 = read
  • 2 = write
  • 1 = execute

Example:

 

chmod 755 script.sh

 

โœ” Owner: read, write, execute
โœ” Group: read, execute
โœ” Others: read, execute

๐Ÿ”ค Symbolic Mode

Add permission

 

chmod +x script.sh

 

Remove permission

 

chmod -w file.txt

 

Set exact permissions

 

chmod u=rwx,g=rx,o=r file.txt

 

๐Ÿ“‚ Common Examples

Make a script executable

 

chmod +x script.sh

 

Secure a private file

 

chmod 600 file.txt

 

Full access for owner only

 

chmod 700 folder

 

๐Ÿ” Apply Recursively

 

chmod -R 755 /var/www/html

 

โœ” Changes permissions for all files and folders inside

โš ๏ธ Common Issues

Permission denied

  • File isnโ€™t executable or writable
  • Fix:

 

chmod +x filename

 

Script wonโ€™t run

  • Ensure it has execute permission and correct shebang (#!/bin/bash)

๐Ÿง  When to Use chmod

  • Running scripts
  • Securing sensitive files
  • Fixing permission errors
  • Managing web server directories

๐Ÿ’ก Pro Tip

Avoid 777 unless absolutely necessaryโ€”it gives full access to everyone and can create security risks.

Force Cache (Faster Mirror)

Linux Commands

Files

tar ยท pv ยท cat ยท tac ยท chmod ยท grep ยท  diff ยท sed ยท ar ยท man ยท pushd ยท popd ยท fsck ยท testdisk ยท seq ยท fd ยท pandoc ยท cd ยท $PATH ยท awk ยท join ยท jq ยท fold ยท uniq ยท journalctl ยท tail ยท stat ยท ls ยท fstab ยท echo ยท less ยท chgrp ยท chown ยท rev ยท look ยท strings ยท type ยท rename ยท zip ยท unzip ยท mount ยท umount ยท install ยท fdisk ยท mkfs ยท rm ยท rmdir ยท rsync ยท df ยท gpg ยท vi ยท nano ยท mkdir ยท du ยท ln ยท patch ยท convert ยท rclone ยท shred ยท srm ยท scp ยท gzip ยท chattr ยท cut ยท find ยท umask ยท wc ยท tr ยท hash  ยท compgen

Processes

alias ยท screen ยท top ยท nice ยท renice ยท progress ยท strace ยท systemd ยท tmux ยท chsh ยท history ยท at ยท batch ยท free ยท which ยท dmesg ยท chfn ยท usermod ยท ps ยท chroot ยท xargs ยท tty ยท pinky ยท lsof ยท vmstat ยท timeout ยท wall ยท yes ยท kill ยท sleep ยท sudo ยท su ยท time ยท groupadd ยท usermod ยท groups ยท lshw ยท shutdown ยท reboot ยท halt ยท poweroff ยท passwd ยท lscpu ยท crontab ยท date ยท bg ยท fg ยท pidof ยท nohup ยท pmap

Networking

netstat ยท ping ยท traceroute ยท ip ยท ss ยท whois ยท fail2ban ยท bmon ยท dig ยท finger ยท nmap ยท ftp ยท curl ยท wget ยท who ยท whoami ยทยท iptables ยท ssh-keygen ยท ufw ยท arping ยท firewalld