Linux Files Review Questions
Answer and try out.
File permissions
- Say you have a file called "myfile.txt". Write the command to make it readable and writable by the owner, but only readable by everyone else.
- You have a shell script named "backup.sh". Write the command to make it executable by the owner only.
- There's a file called "shared_doc.txt". Write the command to give read and write permissions to both the owner and group, but no permissions to others.
- Say you have a directory called "projects". Write the command to view the detailed permissions of just this directory itself, without listing its contents.
- You have a file owned by another user called "report.pdf". Write the command to change the owner of this file to your username (assume your username is "alex").
- There's a file called "data.csv" that you need to share with a specific group. Write the command to change its group ownership to "analysts".
- Say you have a directory called "secure_files" with various contents. Write the command to recursively change permissions so that only the owner has full access to the directory and all its contents.
- You have a file called "template.txt" with the perfect permission setup. Write the command to copy these exact same permissions to another file called "newfile.txt".
- There's a file called "important.conf". Write the command to remove write permissions for all users except the owner.
- Say you have a file called "script.py". Write the command to add execute permission for everyone while maintaining existing read/write permissions.
soft link and hard link
- Say you have a file called "original.txt". Write the command to create a soft link to this file named "softlink.txt".
- You have a file called "data.csv". Write the command to create a hard link to this file named "hardlink.csv".
- Say you have a soft link called "oldlink" that points to a file that no longer exists. Write the command to update this link to point to a new file called "newfile.txt".
- You have a file with a long path "/home/user/documents/projects/important.txt". Write the command to create a soft link to it in your current directory called "shortcut.txt".
- Say you have a directory called "documents". Write the command to create a symbolic link to this directory named "docs".
- You want to verify what file a symbolic link points to. Write the command to display the target of a soft link called "config_link".
- Say you have a file called "report.pdf" in your home directory. Write the command to create a hard link to it in a directory called "backup".
- You have several soft links in your current directory. Write the command to list all files and clearly identify which ones are symbolic links.
- Say you have a symbolic link called "broken_link". Write the command to check if this link is broken (points to a non-existent target).
- You have a file called "important.txt" with multiple hard links. Write the command to find out how many hard links exist for this file.