Results for “Files & permissions”
Small, practical examples. Search by task or narrow things down below.
Create private files with a restrictive umask
Linux Commands: Apply umask in a subshell so the surrounding shell is unaffected.
Linux Commands✓ Tested
Set owner-only file permissions
Linux Commands: Use chmod 600 to allow only the owner to read and write a file.
Linux Commands✓ Tested
Set owner-only read and write permissions
C++: Replace ordinary permission bits with the requested owner permissions.
C++✓ Tested
Copy a directory while preserving attributes
Linux Commands: Use cp -a for a recursive local copy that preserves links and ordinary file attributes.
Linux Commands✓ Tested
Create a second name for the same file
Linux Commands: Use ln for a hard link and inspect the shared link count.
Linux Commands✓ Tested
Create an empty file
Linux Commands: Use touch to create a file when absent; an existing file keeps its contents but gets updated timestamps.
Linux Commands✓ Tested
Handle a filename that begins with a dash
Linux Commands: Use -- to terminate command options before an unusual filename.
Linux Commands✓ Tested
Make a script executable by its owner
Linux Commands: Add the owner execute bit without replacing all permission bits.
Linux Commands✓ Tested
Read the target stored in a symbolic link
Linux Commands: Use readlink without resolving the target path.
Linux Commands✓ Tested
Remove an empty directory only
Linux Commands: Use rmdir so a directory containing files cannot be removed accidentally.
Linux Commands✓ Tested
Rename a file with mv
Linux Commands: Rename a known file in the current directory and inspect its new contents.
Linux Commands✓ Tested
Find files by extension
Search a directory tree for regular files with a particular extension and print their paths.
find✓ Tested