files
No ceremony here , just the operations and the damage they can do
| Action | Command | Sharp edge |
|---|---|---|
| copy | cp src dst | overwrites without asking |
| move | mv src dst | same name , different meaning across devices |
| remove | rm file | no trash , no undo |
| make | mkdir -p a/b | -p stops the “exists” error |
| touch | touch file | updates timestamps on existing files |
A safe pattern
mkdir -p /tmp/work
printf 'one\ntwo\n' > /tmp/work/a.txt
cp /tmp/work/a.txt /tmp/work/b.txt
mv /tmp/work/b.txt /tmp/work/c.txt
The paths stay inside a throwaway directory on purpose
Permissions
chmod 600 /tmp/work/a.txt
stat -c '%a' /tmp/work/a.txt
Output:
600
Owner reads and writes Nobody else does That is the right default for anything holding a token
The mistake worth memorizing
rm -rf "$var/" with an empty var becomes rm -rf /
Quote the variable and check it before destructive commands
A two second check beats a very long rebuild
Next
Text processing starts in 04 text
Posted