April 30, 2025 - 13:30
Advanced File and User Management in Linux Image
Linux

Advanced File and User Management in Linux

Comments

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

BASH
ls -lah

🔹 Shows detailed listing including hidden files.

🔹 Find large files

BASH
find /var/log -type f -size +100M

🔹 Lists files larger than 100MB in the specified directory.

🔹 Search files containing specific keywords

BASH
grep -rl 'error' /var/log

🔹 Shows log files that contain the word 'error'.

🔹 Monitor file contents in real time

BASH
tail -f /var/log/syslog

🔹 Follows live updates to the system log.

🔹 Compress directory into archive

BASH
tar -czvf backup.tar.gz /home/user/

🔹 Compresses the specified folder into an archive file.


2️⃣ Advanced User Management

🔹 Add a new user

BASH
sudo useradd -m -s /bin/bash new_user

🔹 Creates user with home directory and shell.

🔹 Set user password

BASH
sudo passwd new_user

🔹 Delete user

BASH
sudo userdel -r new_user

🔹 Removes user and home directory.

🔹 Create group and add user

BASH
sudo groupadd developers
sudo usermod -aG developers new_user

🔹 Creates a group and adds user to it.

🔹 List user groups

BASH
groups new_user

🔹 Grant sudo/root privileges

BASH
sudo usermod -aG sudo new_user

🔹 Adds user to sudoers group.


3️⃣ File and Directory Permissions

🔹 View file permissions

BASH
ls -l file.txt

🔹 Sample output:

BASH
-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

BASH
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

BASH
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

BASH
setfacl -m u:new_user:rwx secret_file.txt

🔹 Assigns custom permissions to a specific user.

🔹 View file ACL permissions

BASH
getfacl secret_file.txt

🔹 Displays advanced permissions for the file.

Related Articles

Comments ()

No comments yet. Be the first to comment!

Leave a Comment