Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need help deleting a file in bash

Posted on 2014-04-11
4
231 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
ID: 39995639
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
ID: 39995684
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 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 125 total points
ID: 39995724
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 27

Assisted Solution

by:skullnobrains
skullnobrains earned 125 total points
ID: 39997464
++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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 45
php help 34 58
parallel rsync issues with Ubuntu 1 23
troubleshoot a python script 8 17
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

809 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