• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Need help deleting a file in bash

I am trying to delete a file using rm -rf first.php and i keep getting this error:
rm: cannot remove `first.php': Read-only file system

Open in new window

Can someone please tell me how to remove the file? Thanks.
4 Solutions
If you are not the owner of the file or the dir in which the file is in then you can not delete it.

Run the script as root,
using linux command, ls -la first.php you can see the group and owner of the file.

If you have root account and password to access (su root or su on your login shell)
You can use root account and passwd to delete it.

 Or you can do it first (change group and owner of the file)

chgrp -R -v  youraccount first.php
chown -R -v youraccount first.php

And then delete it

Be reminded, using your account to ftp, putty send (pscp.exe), edit,create,write, read or delete the first.php  or New file which is owned by your account

Gerwin Jansen, EE MVETopic Advisor Commented:
The file you are trying to delete is on a read only file system. Looks like it's on a SAN/NFS location that has been mounted read-only.

Look up the folder where the file resides with "ls -l", then verify with "mount" where that folder is mounted. You either have to re-mount that folder as read-write or (s)ftp to the SAN/NFS location and delete the file there.
++Gerwind : being root or toying with access rights will not make a difference if the filesystem is mounted read-only

you can easily find the mountpoint using "df filename" and mount options using the mount command without arguments.

if you want to go the lazy way, copy-paste this
mount | grep `df first.php | tail -n +2 | cut -d \  -f 1`

Open in new window

you may or may not be able to remount the filesystem read-write ( -o rw ) depending on the circumstances. for example a cd will not be mountable rw.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now