I was trying to delete a locked file but managed to delete it in other way. Will the command that I wrote cause any issues? Please advice.
I wrote ‘chflags -R nouchg’ on terminal accidently. Will there be any issue
macos
Related Solutions
Command line editing is a function of your shell, not of Terminal. Probably your shell is bash and probably its command line editing style is set to “emacs”.
Here are a few of the Emacs-style key combinations that you might find handy:
- C-a:
beginning-of-line
- C-e:
end-of-line
- M-f:
forward-word
- M-b:
backward-word
- C-d:
delete-char
- M-d:
kill-word
(delete the next ‘word’) - M-DEL:
backward-kill-word
C-x means Control+x, so C-a is Control+a.
M-x means Meta+x, but there probably is no Meta key on your keyboard. So instead, you can use ESC x (i.e. Escape then x). Terminal has an setting to automatically send ESC before keys pressed with Option held down. Using this feature disables the extended character handling that Mac OS X usually provides when using the Option modifier. So, if you use few extended characters and want to have Option+x send ESC x, then you can enable this Terminal option.
There are lots of ways of moving to “Hello” in your example:
- Search for “Hello”: C-r H e l l o C-j (or ESC)
- In normal Emacs, you would just use RET (Return) to end the search at the current location and return to editing. But in bash, the default bindings cause RET (i.e. C-m) to always execute the current line, even if an incremental search is active. So the C-j/ESC part is a deviation from normal Emacs.
- Jump to the beginning of the line and move forward: C-a M-f C-f (or →)
- Jump to the beginning of the line, then move by words: C-a M-f M-f M-b
- Use M-b a lot (only really feasible if you map Option to Meta).
There are also several ways of accomplishing your desired replacement:
- delete the word and replace it: M-d H i
- delete characters and replace them: C-d C-d C-d C-d C-d H i
- move past “H” and delete the following work, replace it: C-f M-d i
- move past “H” and delete the remaining characters, replace them: C-f C-d C-d C-d C-d i
If you stopped at the end of the word (maybe via C-a M-f M-f), you could use M-DEL H i.
You might do something like bind -P | less
to find other interesting bindings. Consult the readline section of the bash man page (or the readline parts of the bash info pages) for details.
When you click the Locked in the file's title bar, a menu opens. Select Unlock. It will tell you if there's a reason it fails.
Fix that reason. In my example, I'm missing write permissions to the parent folder, and the editor requires those to perform atomic writes. To fix this specific error, run sudo chmod a+w /Applications/XAMPP/xamppfiles/etc
, giving every account on your system write permission to that etc
folder.
Alternatively, edit the file in a text editor that supports inline editing, such as vim
or emacs
. You'll find many tutorials on their basic use online.
Best Answer
The
nouchg
keyword instructschflags
to turn off the user immutable file flag, thereby unlocking the file.One usually does that so as to be able to delete files or folders that are otherwise blocked, for example to delete something in the Trash through normal means.
It shouldn't cause any problem, but if in doubt, reboot.