LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I unlock a file? (http://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-unlock-a-file-201778/)

Brooksias 07-06-2004 12:40 PM

How do I unlock a file?
 
I want to throw away some files I donwloaded but I can't because some are locked.
How do I unlock them?
Thanks.

aaa 07-06-2004 12:43 PM

First make sure that no other programs are using them (close the ones that are). Then try to delete. If your are sure nothings using the files, go to /var/lock, and delete the lock file for the file you want to delete.
Edit: use 'lsof' to list open files.

Mn3moniC 07-06-2004 12:46 PM

hi,

you have to change the permissions of these files using chmod or you delete this files as root ;-)

[Mn3moniC]

Brooksias 07-07-2004 11:44 AM

You wrote . . .
you have to change the permissions of these files using chmod or you delete this files as root ;-)

1. How do you change permissions? Step by step please.
2. How do you delete files as root? I know how to become the su.

You wrote . .
First make sure that no other programs are using them (close the ones that are). Then try to delete. If your are sure nothings using the files, go to /var/lock, and delete the lock file for the file you want to delete.
Edit: use 'lsof' to list open files.

1. What do you mean "go to /var/lock"?
2. How do I delete the file when I get there?

Thanks for the replies!

Turner 07-07-2004 12:40 PM

Quote:


1. How do you change permissions? Step by step please.
2. How do you delete files as root? I know how to become the su.
3. What do you mean "go to /var/lock"?
4. How do I delete the file when I get there?
Answers:
1) To change the permissions, use "chmod" from the root (su) prompt.
2) "rm /directory/where/file/is/filename.ext
3) "cd /var/lock"
4) "rm filename" (This assumes you're in the folder/directory where the file is)

But I think you just want to do the following:

1) Get to a prompt
2) su yourself
3) "cd /whereever/the/file/is"
4) "rm filename.ext"

As root, you can pretty much do anything you want. The commands you want to look into are "chmod" (which changes read/write permissions), "chown" (which changes the owner of the file), "rm" (which deletes files/directories), and "cd" (change directory) :-D

You can always "man COMMAND" to see the help file, or google it to see what people wrote online. "chmod" settings can be a bit tricky at first....Here's a web link to help you out (http://wsabstract.com/script/script2/chmodcal.shtml)

And of course you could just be lazy and ask in a forum over here. ;-)


Turner

jim mcnamara 07-07-2004 12:43 PM

Okay - from the top. Here are step-by-step examples.

I do not know any of the names of your file - use a pretend one - /path/to/problemfile

1. change permissions on protected file
Code:

su -
<enter the password>
# change the permissions
chmod 777 /path/to/problemfile

Now you can delete the file - if it isn't locked

2. use lsof
Code:

su -
<enter the password>
lsof /path/to/problemfile
# if nobody is using the file delete it
rm -f /path/to/problemfile

/var/lock is a file.

It has all the names of locked files and what process has those files locked.

-- Based on your responses I hope this is your home machine. If it's a box at work, you should get a LOT of training before somebody gives you su access. :D

Brooksias 07-07-2004 01:46 PM

Turner/Jim,
Thanks for all the help. The files are gone and the info is on record.
Brooks

ozanbaba 12-14-2010 06:26 AM

Less known thing about UNIX is that locks are voluntary. Programs may or may not respect the locks set on files. FOr that reason, You can edit, copy, remove, rename, move a file if you have permissions to do so. If you really want to delete that file than use rm -f for forcing the remove.

Nylex 12-14-2010 06:49 AM

Quote:

Originally Posted by ozanbaba (Post 4190873)
Less known thing about UNIX is that locks are voluntary. Programs may or may not respect the locks set on files. FOr that reason, You can edit, copy, remove, rename, move a file if you have permissions to do so. If you really want to delete that file than use rm -f for forcing the remove.

Check the date on threads before posting! This thread was started in 2004 and was only revived by carlo.santos' advertising (which has now been reported).


All times are GMT -5. The time now is 06:30 AM.