Solved

Need help deleting a file in bash

Posted on 2014-04-11
4
223 Views
Last Modified: 2014-04-17
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.
0
Comment
Question by:Mark_Co
4 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 125 total points
Comment Utility
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,
0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 125 total points
Comment Utility
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

Duncan
0
 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 125 total points
Comment Utility
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.
0
 
LVL 26

Assisted Solution

by:skullnobrains
skullnobrains earned 125 total points
Comment Utility
++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.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now