Day 3: Linux Files & Permissions

CloudDevOpsHub Batch 45 | Guided by Vikas Ratnawat Sir

1. File permissions

ls -l
chmod 644 notes.txt
chmod 755 myscript.sh

Linux permissions are defined for the owner, group and others. r means read, w means write and x means execute. Numeric permissions use read=4, write=2 and execute=1.

2. Users and groups

id
getent group
sudo adduser learner1
sudo groupadd devteam
sudo usermod -aG devteam learner1
id learner1

These examples create a practice user and group and add the user to the supplementary group. Use them only on a system you administer.

3. Ownership

ls -l notes.txt
sudo chown learner1:devteam notes.txt

chown changes file ownership. Verify the owner and group using ls -l. Do not change ownership of system files unless you understand the impact.

4. Sudo permissions

sudo -l
groups
id

sudo -l shows commands the current user is allowed to run with sudo. Administrative access should follow the system's security policy. Edit sudoers only with visudo and only when authorised.

5. Password aging

sudo chage -l learner1
sudo chage -M 90 learner1

chage -l displays password-aging settings. chage -M 90 sets a maximum password age of 90 days for the specified account. Confirm organisational policy before changing real accounts.

6. Logs and archives

ls -lah /var/log
find /var/log -type f
tar -cvf logs.tar /var/log

Logs help with troubleshooting. Archive only the files you are authorised to access. A safer practice example is to create a small archive from your own practice directory:

tar -cvf practice.tar practice/
tar -tvf practice.tar

Revision Questions

  1. What do read, write and execute permissions mean?
  2. What is the purpose of a group?
  3. What does chown do?
  4. Why should sudoers be edited using visudo?