
In Linux systems, file management and user permissions are critical for system security and organization.
In this guide, we’ll explore advanced file operations, user management, and authorization techniques.
1️⃣ Advanced File Management
🔹 List files and directories
ls -lah
🔹 Shows detailed listing including hidden files.
🔹 Find large files
find /var/log -type f -size +100M
🔹 Lists files larger than 100MB in the specified directory.
🔹 Search files containing specific keywords
grep -rl 'error' /var/log
🔹 Shows log files that contain the word 'error'.
🔹 Monitor file contents in real time
tail -f /var/log/syslog
🔹 Follows live updates to the system log.
🔹 Compress directory into archive
tar -czvf backup.tar.gz /home/user/
🔹 Compresses the specified folder into an archive file.
2️⃣ Advanced User Management
🔹 Add a new user
sudo useradd -m -s /bin/bash new_user
🔹 Creates user with home directory and shell.
🔹 Set user password
sudo passwd new_user
🔹 Delete user
sudo userdel -r new_user
🔹 Removes user and home directory.
🔹 Create group and add user
sudo groupadd developers
sudo usermod -aG developers new_user
🔹 Creates a group and adds user to it.
🔹 List user groups
groups new_user
🔹 Grant sudo/root privileges
sudo usermod -aG sudo new_user
🔹 Adds user to sudoers group.
3️⃣ File and Directory Permissions
🔹 View file permissions
ls -l file.txt
🔹 Sample output:
-rw-r--r-- 1 user user 1234 Mar 1 12:34 file.txt
Explanation:
r
(read),w
(write),x
(execute)-rw-r--r--
→ Owner (rw-), Group (r--), Others (r--)
🔹 Change file permissions
chmod 644 file.txt # Owner can write, others can read only
chmod 755 script.sh # Everyone can execute, only owner can write
🔹 Change file ownership
sudo chown new_user:new_group file.txt
🔹 Changes file owner and group.
4️⃣ Advanced Authorization and Access Control
🔹 Grant specific access to a user
setfacl -m u:new_user:rwx secret_file.txt
🔹 Assigns custom permissions to a specific user.
🔹 View file ACL permissions
getfacl secret_file.txt
🔹 Displays advanced permissions for the file.
Related Articles
