Important Linux Commands for general knowledge — 2

shrimali senevirathna
2 min readDec 14, 2020

Linux is a multi-user operating system which can be accessed by many users. As Linux systems can be used in servers without modifications, it leads to major security concerns as unauthorized users can corrupt , change or remove data. So to make the system more secure Linux provides two authorization levels to customize.

  1. Ownership
  2. Permission

Here we are focusing on how to change the Permissions and about how to change the ownerships.

Checking permissions

Before begin changing the permission of a file or folder, first need to check the permissions of the specific file/folder.

To display ownership and permissions for a file,

ls -1 [FILENAME]

Changing file permissions

To change the permissions of the file to grant the execution permission to the user ,

sudo chmod 700 [FILENAME]

Check the permissions from the below command. Now the execution permission has been added.

ls -1 [FILENAME]

Changing folder permissions

move to the directory where the file is placed that you are going to change the permission

cd [folder]

Check the current permissions using ls, this time with the -ld because we are viewing a directory instead of a normal file.

ls -ld [folder/]

Now we could see the permission types which has been already granted.

e.g: read and write permission , read only permission

Let us assume that we need to have below permissions to one of our folders.

To add execute(If owner should have all permissions) to the owner’s permissions,

sudo chmod u+x [folder/]

To fix the group’s permission to have only write permission,

sudo chmod g+w [folder/]

sudo chmod g-r [folder/]

To remove read permissions from everyone else using the command below,

sudo chmod o-r [folder/]

Changing owners

First check the current owner of the specific folder that you need to change the ownership.

ls -ld [folder/]

To change the owner ,

sudo chown [file path]

Now we can use ls again to see that the owner of the file has been changed or not.

--

--