Menu Close

rm: invalid option — ‘J’

There is a file on my Ubuntu file system named -J and I cannot remove it via command line.

A quick rmcommand gave me this error

rm: invalid option -- 'J'

This is because symbol - is used for defining options such as rm -r or rm -f. Running command rm -J will literally execute rmcomamnd with option -J.

The Fixes

There is 3 fixes available for you to try.

1. Append ./ at the front of the file name

$ rm ./-J

2. add -- after rm

$ rm -- -J

3. Use graphical interface. Access your Linux via Desktop and delete it from there by hitting DEL button or right-click and delete the file.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x