Linux Files Review Questions

Answer and try out.

File permissions

  1. 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.
  2. You have a shell script named "backup.sh". Write the command to make it executable by the owner only.
  3. 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.
  4. Say you have a directory called "projects". Write the command to view the detailed permissions of just this directory itself, without listing its contents.
  5. 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").
  6. 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".
  7. 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.
  8. 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".
  9. There's a file called "important.conf". Write the command to remove write permissions for all users except the owner.
  10. Say you have a file called "script.py". Write the command to add execute permission for everyone while maintaining existing read/write permissions.
  1. Say you have a file called "original.txt". Write the command to create a soft link to this file named "softlink.txt".
  2. You have a file called "data.csv". Write the command to create a hard link to this file named "hardlink.csv".
  3. 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".
  4. 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".
  5. Say you have a directory called "documents". Write the command to create a symbolic link to this directory named "docs".
  6. 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".
  7. 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".
  8. You have several soft links in your current directory. Write the command to list all files and clearly identify which ones are symbolic links.
  9. 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).
  10. 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.