▶ Linux for Beginners Playlist:
• Linux. Begginer course.
In this Linux tutorial for beginners, you will learn how users, groups, and permissions work in Linux. We explain sudo, root, chmod, chown, file permissions, directory permissions, and how to fix Permission denied errors step by step.
#Linux #Ubuntu #DevOps
Commands used in this lesson
Running commands with elevated privileges
sudo apt update — run a command with administrator privileges
su username — switch to another user account
Checking the current user and groups
whoami — show the current user name
id — show the user ID, group IDs, and group membership
groups — show the groups the current user belongs to
Creating users and changing passwords
sudo useradd username — create a new user with the basic low-level command
sudo adduser username — create a new user with an interactive and more user-friendly command
sudo adduser student1 — create the user student1
sudo passwd student1 — set or change the password for student1
Managing group membership
sudo usermod -aG sudo student1 — add student1 to the sudo group
Viewing user account information
cat /etc/passwd — show general user account information
sudo cat /etc/shadow — show protected password-related information
Viewing permissions and ownership
ls -l — show files with detailed permissions, owner, and group information
ls -ld /tmp — show detailed information for the /tmp directory itself
ls -l script.sh — check permissions of a script file
ls -ld mydir — check permissions of a directory
Changing permissions with chmod
chmod +x script.sh — add execute permission
chmod u+x script.sh — add execute permission for the owner
chmod g-w file.txt — remove write permission from the group
chmod 755 script.sh — set rwx for owner and r-x for group and others
chmod 644 file.txt — set rw- for owner and r-- for group and others
chmod 644 notes.txt — set common file permissions
chmod 700 ~/.ssh — allow only the owner to access the .ssh directory
chmod 600 ~/.ssh/id_rsa — allow only the owner to access the private SSH key
chmod 777 file.txt — give full access to everyone
chmod 777 mydir — give full access to everyone on a directory
Changing owner and group
sudo chown user1 file.txt — change the owner of a file
sudo chown user1:developers file.txt — change both owner and group
sudo chgrp developers file.txt — change only the group
Checking default permissions
umask -S — show the default permission mask in symbolic form