LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-14-2008, 12:57 AM   #1
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Rep: Reputation: 36
Question How to delete a file ?


Hi all,

Is it possible to delete a file without using rm command ?

conditions are as follows:-

1) mv command is not allowed
2) GUI utilities are not allowed
3) only command line is allowed to use



assumptions:-

1) immutable property is not set
2) sticky bit is not set
3) there is no permission issues
 
Old 10-14-2008, 01:04 AM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
You can truncate it to zero length by entering >filename at the command prompt
Or, remove it by unlink filename
Dave

Last edited by david1941; 10-14-2008 at 01:07 AM. Reason: added alternative
 
Old 10-14-2008, 01:52 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Definitely sounds like homework...
 
Old 10-14-2008, 02:01 AM   #4
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Original Poster
Rep: Reputation: 36
Question

Quote:
Originally Posted by david1941 View Post
You can truncate it to zero length by entering >filename at the command prompt
Or, remove it by unlink filename
Dave
suppose if more constraints are added unlink or any other file deletion commands are not allowed ?
 
Old 10-14-2008, 02:17 AM   #5
rgerhards
Member
 
Registered: Sep 2003
Distribution: Fedora/Debian
Posts: 50

Rep: Reputation: 15
Quote:
Originally Posted by sulekha View Post
suppose if more constraints are added unlink or any other file deletion commands are not allowed ?
Do you have an editor and gcc available? Then you could write a program that does the necessary system calls (aka "create your own rm")
 
Old 10-14-2008, 03:01 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Shutdown the machine, open the case, extract the hard disk, burn it, throw it away. File deleted!
 
Old 10-14-2008, 04:06 AM   #7
rgerhards
Member
 
Registered: Sep 2003
Distribution: Fedora/Debian
Posts: 50

Rep: Reputation: 15
Well... not for sure. What if I find the hard disk and install it in another machine? So, to be on the safe side, may I suggest the intensive use of a heavy hammer before the "throw away" step?

Edit: I should have mentioned that burning does not necessarily destroy anything on disk. Except, of course, if you use an extremely hot fire.
 
Old 10-15-2008, 01:08 PM   #8
evaluatinglinux
Member
 
Registered: Oct 2008
Posts: 45

Rep: Reputation: 15
There is a command called SHRED in Linux. I've seen our system administrators use it to delete files securely from the hard disks before moving the hardware.

Debian Kernel

Last edited by evaluatinglinux; 10-25-2008 at 02:48 AM.
 
Old 10-15-2008, 01:18 PM   #9
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
If you are trying to delete the contents of the file you can:

Code:
echo "" > filename
 
Old 10-15-2008, 01:51 PM   #10
rgerhards
Member
 
Registered: Sep 2003
Distribution: Fedora/Debian
Posts: 50

Rep: Reputation: 15
I think I need to clarify an earlier answer of mine. He said that any file deletion tools are not permitted. If so, that would basically rule out anything that can usually be used to delete files. This sounds like a "which gap did we overlook when securing the system" question.

My answer "is gcc allowed, if so, you can compile your own tool" was a serious one, because that would be a gap in the security settings in such a case.

Even though this smells like homework (and probably is), I think it is a quite interesting question
 
Old 10-15-2008, 02:10 PM   #11
j.todd
Member
 
Registered: Feb 2008
Location: Michigan
Distribution: Debian GNU/Linux Unstable
Posts: 144

Rep: Reputation: 16
Like evaluatinglinux said, use shred to securely delete files. It writes over the file (25 times by default) with random numbers, then d's, e's, etc. Then it deletes the file. I use it whenever I reformat my laptop, just to make sure nothing gets left behind.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM
how to delete last number/word of a file and incude file count at the end of the chennaiguy Linux - Newbie 2 02-18-2008 09:08 PM
how to delete a particular file from tar file majalee Linux - Software 2 07-12-2006 04:53 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
Delete contents of the file, but not file? mikeshn Linux - General 9 05-28-2003 06:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration