I am trying to remove a folder from USB. I tried to change the folder permission, its giving same error.
`sudo chmod 777 stock/`
chmod: changing permissions of ‘stock/’: Read-only file system
Also I did remount usb in r/w mode.
`sudo mount -o remount, rw /media/kannan/KANNAN/`
`rm -rf stock`
rm: cannot remove ‘stock/╖ï y▀á}▀.sß÷’: Read-only file system
rm: cannot remove ‘stock/\\êα╖Γì╩ö.║\036è’: Read-only file system
rm: cannot remove ‘stock/'≤H.'║H╚.\036ΘH’: Read-only file system
rm: cannot remove ‘stock/pbr²\tñ#å.ç8▒’: Read-only file system
I think there may be some problem in the filesystem. check and repair the filesystem by
dosfsck -a /dev/sd{xn}
then again do remove action.
Related
I want to recover the /home/lufei/market/resources/views/user.blade.php, here is the place of swp file.
> lufei#localhost:~/market$ ls resources/views/.user.blade.php.swp
> resources/views/.user.blade.php.swp
I use vim -r resources/views/.user.blade.php.swp to recover the file, I get this,
E306: Cannot open resources/views/.user.blade.php.swp Press ENTER or
type command to continue
When I use sudo vim -r resources/views/.user.blade.php.swp I can open the file, but when I use :wq in the vim I get
"/root/market/resources/views/user.blade.php"
"/root/market/resources/views/user.blade.php" E212: Can't open file
for writing Press ENTER or type command to continue
From the info above I think vim want to save the file to the root directory. From the vi - getting an error E212: Can't open file for writing, I guess if I create path /root/market/resources/views/ may work. But I want to directly save the file to the right place /home/lufei/market/resources/views/user.blade.php. So I use su && cd /home/lufei/market then vim -r resources/views/.user.blade.php.swp. But when I :wq in vim , I also get
"~/market/resources/views/user.blade.php"
"~/market/resources/views/user.blade.php" E212: Can't open file for writing
Press ENTER or type command to continue
From above trying, no matter I use normal user or the root user, when I recover the file, vim will try to save the file to the wrong place which path is not exist.
Can I directly recover the file to the right place, without create a temp path and then copy the recoveried file back to the right path.
Make sure you have enough access rights to open the file as lufei, and then start your recovery:
$ chmod u=rw resources/views/.user.blade.php.swp
$ vim -r resources/views/.user.blade.php.swp
This may be caused by the edit session crush like the items 2 in command sudo vim market/resources/views/user.blade.php. It make the swp file make the wong original file path. Note I really not have the /root/market/resources/views/user.blade.php file even the /root/market/ path. This is the first I create the file user.blade.php and without save it, and then shutdown the computer.
E325: ATTENTION
Found a swap file by the name "resources/views/.user.blade.php.swp"
owned by: root dated: Thu Nov 9 17:33:23 2017
file name: ~root/market/resources/views/user.blade.php
modified: YES
user name: root host name: localhost
process ID: 128985
While opening file "resources/views/user.blade.php"
(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r resources/views/user.blade.php"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "resources/views/.user.blade.php.swp"
to avoid this message.
Swap file "resources/views/.user.blade.php.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Solution:
sudo vim market/resources/views/user.blade.php, if vim show above info, just press R and then save the file. If it not show above info, use :rec(over), then save the file.
use vim open any file env create a new file, with sudo vim aaa.txt, then use :rec(over) user.blade.php then save it. This will save the file to user.blade.php not the aaa.txt. Make sure the aaa.txt and .user.blade.php in same directory.
On ubuntu, I have the following directory structure:
/var/www/html
I am in www and I decided to move a file from this directory to html. I executed the following:
mv myfile.iso /html
Now I cannot see the file. Apparently I did not use the command properly. Any help to recover the file?
Yeah, your file is either now called html, and it stands in the root directory / (I'm not even sure this is possible), or it moved to existing directory /html
You must do the following to find it back (second case I spoke of):
mv /html/myfile.iso /var/www/html
or if it doesn't work (first case):
mv /html /var/www/html/myfile.iso
When u need to move a file you need to do this like: "mv foo ~/Desktop",
You forgot the ~ sign. What mv does is also rename the file.
The mv command will move a file to a different location or will rename a file. Examples are as follows: "mv file foo" will rename the file "file" to "foo". "mv foo ~/Desktop" will move the file "foo" to your Desktop directory, but it will not rename it. You must specify a new file name to rename a file.
You should look if u can find a folder called html in the root.
I have a function with something like
FILE *file1 = fopen("testing.txt", "r");
I can't modify this line. However, if I make a file named "testing.txt" in, say /tmp, would I be able to make the function load the file from /tmp instead of it's own directory. (Maybe by modifying the PATH variable?)
If the program doesn't change its own working directory, you could cd into /tmp and simply run the program from there.
$ cd /tmp
$ /absolute/path/to/my_program
That opens a file from your current working directory.
You can change the current working directory using chdir.
See this.
This is using C code.
You can also use cd.
For example, go to the terminal:
$ cd /tmp
$ cd /path_to_your_program
Also, cd .. will make you go to the directory above, and cd will make you go to the home directory.
Also, if you do not have the program in the directory in which you have to compile it, you can use cp which copies file.
$ cp /path_to_copy_from /path_to_copy_to
Then you can go to that directory, and run it from there.
I would recommend you to take a basic linux tutorial like this.
I want to chmod a directory to prevent any files inside that directory from being deleted or modified without my permission.
How can I achieve that, my directory is set to 777 now which I think is a issue. Could other users access and delete my file without permission if I set the permissions to 777? What permission should I set so that?
I want to be the only one who can write to my own directory, others should only be able to read my file.
Yes, with 777, anybody could delete files from the directory.
You should run chmod 0755 yourdir or chmod og-w yourdir.
You can see the contents (read), add or remove files (write) and "pass through" the folder (execute)
Members of the owning group and other users can see the contents of the folder (read) and "pass through" to child folders (execute). They cannot add or remote files (write).
This guide is a good discussion of *nix directory permissions.
Rather than thinking about it in terms of numeric codes, perhaps it's easier to use the symbolic names for permissions. For example, to remove the ability for "others" to "write" your files:
chmod o-w FILE...
You may also want g-w if you do not want members of your Unix group to write your files.
The removal of write (w) permissions is the same as "clearing bit 2" in the mode, so 7 becomes 5, but this is hard for most normal people to remember, and you don't entirely need to.
I'm currently compiling different PHP versions and want to delete some rubbish folders.
I got a folder called "php-5.4.7-src" which i want to delete but when I do
$ rm -Rf php-5.4.7-src
there always pops up
rm: cannot remove directory php-5.4.7-src/ext/standard/tests/general_functions: File exists
rm: cannot remove directory php-5.4.7-src/ext/standard/tests: File exists
rm: cannot remove directory php-5.4.7-src/ext/standard: File exists
rm: cannot remove directory php-5.4.7-src/ext: File exists
rm: cannot remove directory php-5.4.7-src: File exists
So I did
$ find .
and
$ find . -type f
and there just pop up the folders above, no files exist.
I am also owner of all folders and I tried to delete them as root too.
How can I delete files which do not exist?
I realize that this does not answer your question but just a small matter of style that may save you headaches in the future. If you ever have to move your scripts to another flavour of UNIX there's a chance they will break. The traditional flag for doing a recursive delete is -r, not -R. Saves you having to push the shift key too :)
Now on to what may answer your question. I know you said you checked for running processes but that is the only way that an inode can be kept open, and only an open inode will keep a hierarchy from being removed. There are other processes such as updated that frequently run on systems that may have been crawling through your directories at the time. One thing you may try is to execute sync to ensure that all pending writes have been flushed.
Something is holding the directory open. You may also want to try lsof +D php-5.4.7-src to see exactly what.