Unix administration - file without a name

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > March 2004 > file without a name





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author file without a name
peter van der kamp

2004-02-11, 6:34 pm

who knows how i can remove a file without a name. /root is running low on
diskspace and when i look i see a file comsuming half the space of my
filesystem but that file has no name.
Please advice.
thx in advance


Barry Margolin

2004-02-11, 6:34 pm

In article <c0fa6n$e99$1@reader11.wxs.nl>,
"peter van der kamp" <pvdkamp@vrijuit.nl> wrote:

> who knows how i can remove a file without a name. /root is running low on
> diskspace and when i look i see a file comsuming half the space of my
> filesystem but that file has no name.
> Please advice.
> thx in advance


Every file has a name. Maybe the name is all spaces.

Try this to see the ASCII codes of the filenames:

cd /root
for file in *; do
echo "$file" | od -c
done

Once you've determined the name of the file, you should be able to
remove it by typing that name enclosed in single quotes. E.g. if the
name is two spaces, use:

rm " "

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Goran Larsson

2004-02-11, 8:34 pm

In article <barmar-05434C.02444312022004@comcast.ash.giganews.com>,
Barry Margolin <barmar@alum.mit.edu> wrote:

> Every file has a name.


This is not true. A file that is held open by a process but had all
its names removed (link count is zero) has no name. This should be
known by all Unix admins.

Situations with nameless files often happens when a process creates a
quickly growing logfile and an admin removes the logfile in an attempt
to free up disk space. The file will continue to exist, and grow,
nameless until the process closes the file or dies.

--
Göran Larsson http://www.mitt-eget.com/
Lew Pitcher

2004-02-12, 12:34 am

On Thu, 12 Feb 2004 09:50:00 GMT, hoh@invalid.invalid (Goran Larsson) wrote:

>In article <barmar-05434C.02444312022004@comcast.ash.giganews.com>,
>Barry Margolin <barmar@alum.mit.edu> wrote:
>
>
>This is not true. A file that is held open by a process but had all
>its names removed (link count is zero) has no name. This should be
>known by all Unix admins.
>
>Situations with nameless files often happens when a process creates a
>quickly growing logfile and an admin removes the logfile in an attempt
>to free up disk space. The file will continue to exist, and grow,
>nameless until the process closes the file or dies.


From my Linux Newbies cluesheet #3, I offer this...

Have you ever found yourself in this position: you notice that
/var/log/messages (or some other syslog-owned file) has grown too big, and
you
rm /var/log/messages
touch /var/log/messages
to reclaim the space, but the used space doesn't reappear? This is because,
although you've deleted the filename part, there's a process that's got the
data part open still (syslogd), and the OS won't release the space for the
data until the process closes it. In order to complete your space
reclamation, you have to
kill -SIGHUP `cat /var/run/syslogd.pid`
to get syslogd to close and reopen the file

You can use this to your advantage in programs: have you ever wondered how
you could _hide_ a temporary file? Well, you

{
FILE *fp;

fp = fopen("some.hidden.file","w");
unlink("some.hidden.file"); /* deletes the filename part */

/* some.hidden.file no longer has a filename and is truely hidden */
fprintf(fp,"This data won't be found\n"); /* access the data part */
/*etc*/
fclose(fp); /* finally release the data part */
}




>--
>Göran Larsson http://www.mitt-eget.com/


--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')
Doug Freyburger

2004-02-12, 2:36 am

Barry Margolin wrote:
> peter van der kamp wrote:
>
>
> Every file has a name. Maybe the name is all spaces.


"ls -lb" will help on this, as will "rm -i *".

But every file does not have a name. This sounds a bit like one of the
standard FAQ questions: I deleted my huge log file but no space freed
up, what's the deal?

If a file is deleted from a directory, the inode only wiped and the
associated blocks are only moved to the free space chain if no process
has the file open.

If this is the problem, start with "lsof" to find deleted files that
are still open, and "ps" to figure out what program has them open.
Then kill and restart the program or otherwise figure out how to get it
to close its files.
Barry Margolin

2004-02-12, 4:36 am

In article <HsytzC.Bx0@approve.se>, hoh@invalid.invalid (Goran Larsson)
wrote:

> In article <barmar-05434C.02444312022004@comcast.ash.giganews.com>,
> Barry Margolin <barmar@alum.mit.edu> wrote:
>
>
> This is not true. A file that is held open by a process but had all
> its names removed (link count is zero) has no name. This should be
> known by all Unix admins.


The OP mentioned a directory listing. Every file in a directory listing
*does* have a name.

Other situations may exist, but are irrelevant to this thread. Is it
necessary to confuse things by bringing them up?

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Goran Larsson

2004-02-12, 9:35 am

In article <barmar-CA889E.12534012022004@comcast.ash.giganews.com>,
Barry Margolin <barmar@alum.mit.edu> wrote:

> Every file in a directory listing
> *does* have a name.


That was not what you wrote. You wrote "Every file has a name.", a
clear sentence with a very specific meaning.

> Other situations may exist, but are irrelevant to this thread. Is it
> necessary to confuse things by bringing them up?


You argue like those who teaches students to use "void main ( ..."
just because the return value confuse things.

--
Göran Larsson http://www.mitt-eget.com/
Bev A. Kupf

2004-02-12, 9:35 am

On Thu, 12 Feb 2004 22:22:41 GMT,
Goran Larsson (hoh@invalid.invalid) wrote:
> In article <barmar-CA889E.12534012022004@comcast.ash.giganews.com>,
> Barry Margolin <barmar@alum.mit.edu> wrote:
>
>
> That was not what you wrote. You wrote "Every file has a name.", a
> clear sentence with a very specific meaning.


...... in the context of the original question. Or does that have
to be spelled out each time?

--
Bev A. Kupf
"The lyfe so short, the craft so long to lerne" -- Chaucer
Tintin turns 75 <http://www.tintin.com>
Christopher Mattern

2004-02-13, 7:34 am

peter van der kamp wrote:

> who knows how i can remove a file without a name. /root is running low on
> diskspace and when i look i see a file comsuming half the space of my
> filesystem but that file has no name.
> Please advice.
> thx in advance


Somewhere a process is holding open that file. Unfortunately, since you
deleted it, it is now difficult for you to find out what process that
is. The space will be released when the process closes the file or
is terminated. If you can, rebooting the box will solve the problem.

Chris Mattern
Christopher Mattern

2004-02-13, 7:35 am

Barry Margolin wrote:

> In article <c0fa6n$e99$1@reader11.wxs.nl>,
> "peter van der kamp" <pvdkamp@vrijuit.nl> wrote:
>
>
> Every file has a name. Maybe the name is all spaces.


Wrong. A file that is deleted while a process is holding it open
continues to exist but has no name. The only way to reclaim the
space is to terminate the process.

Chris Mattern

Barry Margolin

2004-02-15, 10:34 am

In article <Hszstu.G4y@approve.se>, hoh@invalid.invalid (Goran Larsson)
wrote:

> In article <barmar-CA889E.12534012022004@comcast.ash.giganews.com>,
> Barry Margolin <barmar@alum.mit.edu> wrote:
>
>
> That was not what you wrote. You wrote "Every file has a name.", a
> clear sentence with a very specific meaning.


Every sentence's meaning is only understandable in a specific context.

>
> You argue like those who teaches students to use "void main ( ..."
> just because the return value confuse things.


I disagree. I didn't tell someone to do something wrong.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Barry Margolin

2004-02-15, 10:34 am

In article <avmdnboncOfpqrDdRVn-uw@comcast.com>,
Christopher Mattern <matternc@comcast.net> wrote:

> Barry Margolin wrote:
>
>
> Wrong. A file that is deleted while a process is holding it open
> continues to exist but has no name. The only way to reclaim the
> space is to terminate the process.


But he said "when I look I see a file consuming half the space". If he
can see it, it's obviously not a file that has been deleted!

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
apm

2004-03-01, 8:34 am

Christopher Mattern <matternc@comcast.net> wrote in message news:<avmdnbsncOeAqrDdRVn-uw@comcast.com>...
> peter van der kamp wrote:
>
>
> Somewhere a process is holding open that file. Unfortunately, since you
> deleted it, it is now difficult for you to find out what process that
> is. The space will be released when the process closes the file or
> is terminated.


Another way to avoid the disk filling up by a process logging to it
for ages to to make the file cyclic. The cyclic logfile package
(http://cycliclogs.sourceforge.net) can be used to do this, assuming
your process does not use syslog.

Regards,

Andrew Marlow
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com