LogoLogo
  • Home
  • Getting Started
  • Configuration
    • LinuxGSM Config
    • Game Server Config
    • Start Parameters
    • cronjobs
    • Running on Boot
    • Running Multiple Game Servers
    • IP Address Configuration
    • LinuxGSM Stats
  • Commands
    • install
    • start-stop-restart
    • monitor
    • test-alert
    • console
    • debug
    • update
    • check-update
    • force-update
    • validate
    • update-lgsm
    • backup
    • map-compressor
    • details
    • mods
    • skeleton
    • fastdl
    • change-password
  • Game Servers
    • 7 Days to Die
    • Arma 3
    • ARK: Survival Evolved
    • Call of Duty 4
    • Dont Starve Together
    • Counter-Strike 2
    • Counter-Strike: Global Offensive
    • Factorio
    • Garry's Mod
    • Insurgency: SandStorm
    • Killing Floor 2
    • Minecraft: Java Edition
    • Multi Theft Auto
    • Rust
    • Sven Co-op
    • Trackmania Nations Forever / Trackmania United Forever
    • TeamSpeak 3
    • Unreal Tournament 99
    • Unreal Tournament 2004
    • Unreal Tournament 3
    • Valheim
    • Xonotic
    • The Front [WIP]
  • Networking
    • IP Address
    • Ports
    • Source Engine
  • Alerts
    • Discord
    • Email
    • IFTTT
    • Pushbullet
    • Pushover
    • Rocket.Chat
    • Slack
    • Telegram
  • Dependencies
    • Java
    • tmux
    • jq
    • gamedig
    • glibc
  • Features
    • ANSI Colors
    • Stop Mode
    • Log Management
    • Message Display Time
  • SteamCMD
    • Steam Master Server
    • Game Server Login Token
    • Branch
    • LAN Discovery
    • Workshop
    • Error Codes
  • Linux
    • distro
    • ftp-scp
    • file-ownership
    • firewalls
    • network-interfaces
    • permissions
    • Symlinking and ln command
  • Troubleshooting
  • FAQ
  • Guides
    • Security
    • Make Webserver Case Insensitive
    • Sourcemod and Metamod:Source
  • Other
    • server-migration
    • basic-usage
    • brand
Powered by GitBook
On this page
  • Check current permissions
  • Check permissions from a file or all files of any directory
  • Change permissions
  • Command
  • Syntax 1)
  • Syntax 2)
  • Set GUID and GID
Edit on GitHub
Export as PDF
  1. Linux

permissions

Previousnetwork-interfacesNextSymlinking and ln command

Last updated 5 years ago

In Linux, files and directories are owned by a user and a group (see ). On top of that, this user, group, and other ones (groups and users), have different permissions on these files. That's what we call file permissions. You might need to change them. If this can be boring to new users, remember that this is a huge part of what makes Linux as secured as it is, and you are required to know this if you wish to do anything serious with Linux.

Check current permissions

Check permissions from a file or all files of any directory

ls -al /path/to/file/or/dir

Sample output:

ultimatebyte@game:~$ ls -al twserver
-rwxr-x--- 1 ultimatebyte ultimatebyte 5691 Jan 30 01:14 twserver

Explaination:

  • First character is a a - for files, or a d for directories

  • Three next ones are owner permissions: rwx

  • Three next ones are group permissions: rwx

  • Three next ones are "others permissions: rwx for groups and users that are now owning the file

  • First user listed is the owner

  • Next entry is the group owning the file

"r" stands for "read", "w" stands for "write", "x" stands for execute. If any letter from rwx is showed as a -, it means that the permission is not granted.

Change permissions

Change permissions from files or directories

Command

chmod

Recursive syntax (include sub files and directories)

Append -R to your chmod

chmod -R

Syntax 1)

Set all permissions at once

chmod 777 == chmod -a+rwx chmod 000 == chmod -a-rwx

First number is for user, second is for group, third for others

Values

0 no permissions
1 x
2 w
3 wx
4 r
5 rx
6 rw
7 rwx

Example

Default permissions are 755. If you wish to prevent other users from interacting with your files, then 750 can be great.

chmod -R 750 /home/userdir

Syntax 2)

We used rwx for these, but of course, you should pick the permissions you wish to add or remove.

Permissions add

chmod +rwx filename Will add read, write, and execute permissions to this file anyone on the machine. r stands for "read", w for "write", and x for "execute"

Example : chmod +x filename Will make the file executable by anyone on the machine.

Permissions remove

chmod -rwx filename Will remove read, write, and execute permissions to this file anyone on the machine. Note : root user is the only exception.

Permissions for user/group/others/all

chmod -u+rwx chmod -g+rwx chmod -o+rwx chmod -a+rwx

Multiple permissions at once

chmod -u+r,g-w,o-rwx

Of course, you can replace +rwx by anything previously mentioned

Set GUID and GID

Advanced permissions management, you will likely not need this for game servers.

Set GUID

No GUID

chmod -R a-s /path/to/dir chmod -R 0xxx /path/to/dir

Example : chmod -R 0640 /home/user/website

Set UID

Files will run as the user

chmod -R u+s /path/to/dir/ chmod -R 2xxx /path/to/dir

Set GID

Any subdir and subfile will have the same group

chmod -R g+s /path/to/dir/ chmod -R 4xxx /path/to/dir

Set GUID

Set both UID and GID

chmod -R a+s /path/to/dir/ chmod -R 6xxx /path/to/dir

File Ownership