GO KALI FREE
Permission Commands

chmod Linux Command

Changes the read, write, and execute permissions of files and directories.

What does chmod do?

Changes the read, write, and execute permissions of files and directories.

Syntax

chmod [options] mode file

Practical example

chmod 755 script.sh

Questions about chmod

What does chmod 755 mean?

7 = owner (read+write+execute), 5 = group (read+execute), 5 = others (read+execute). This is common for executable scripts and web directories.

How do I make a file executable?

Use `chmod +x filename` to add execute permission for all users, or `chmod u+x filename` to add it only for the owner.

What is the difference between chmod 755 and 777?

755 gives owner full access and others read+execute. 777 gives everyone full access (read+write+execute), which is a security risk for most files.

How do I change permissions recursively?

Use `chmod -R 755 directory/` to apply permissions recursively to all files and subdirectories. Be careful with this on system directories.

How do I remove write permission for others?

Use `chmod o-w filename` to remove write permission for others. The `o` stands for 'others', and `-` removes a permission.

How do I set permissions using symbolic mode?

Use `chmod u+x,g-w filename` to add execute for owner and remove write for group. Symbolic mode uses u=user, g=group, o=others, a=all.

What does chmod 644 mean?

6 = owner (read+write), 4 = group (read), 4 = others (read). This is the standard permission for regular files like documents and scripts.

How do I check file permissions?

Use `ls -l filename` to see permissions in the first column. The format shows owner, group, and others permissions separately.

Related Permission Commands

visudo

Safely edits the /etc/sudoers file to configure sudo permissions.

chown

Changes the owner and/or group of a file or directory.

sudo -l

Lists the allowed and forbidden sudo commands for the current user.

chgrp

Changes the group ownership of a file or directory.

setfacl

Sets or modifies the Access Control List (ACL) for a file or directory.

umask

Sets the default permission mask for newly created files and directories.