Tag Info

New answers tagged

5

Directories are special in the sense that within a directory you can have references to several files and directories, so, if you remove the parent directory, all those files lose their reference point from where they can be accessed, the same with process. For such cases, rmdir() have different checks, that are different from unlink(): If the directory is ...


1

Your file has the immutable extended attribute set, which is why you can't delete it. lsattr returns the extended attributes on the file: $ lsattr model/DailyUpdateClass.class -u-Diad--j------ DailyUpdateClass.class You will need to decipher all of the letters (-u-Diad--j) The man page for lsattr will tell you to look at the man page for chattr for a ...


1

The rmdir does not provide an -i flag like rm command does when you want to confirm a deletion of a certain directory. However, rmdir returns an exit code of 0 when it operates on an empty directory. For example: $ mkdir emptydir && rmdir emptydir && echo $? 0 As you can see, it does not ask us for confirmation when deleting an empty ...


1

The directory /tmp must have the permissions 1777 = rwxrwxrwt, i.e. everybody can read, write and access files in the directory, and (t = sticky bit) files may only be deleted by their owner. A lot of things will stop working if this isn't the case, sometimes in bizarre ways. sudo mkdir -m 1777 /tmp or sudo mkdir /tmp && sudo chmod 1777 /tmp ...


2

@Praveen J Kumar , I'm not so clear, so I'll try to cover the basics. There are four cases here: You do want to get prompt when deleting a directory. -i flag is for interactive session, and will ask you before each file is deleted. -r is for recursive, i.e. go over the entire directory and sub directories etc.... Then use: $ rm -ri <directory path> ...


5

/tmp can be considered as a typical directory in most cases. You can recreate it, give it to root (chown root:root /tmp) and set 1777 permissions on it so that everyone can use it (chmod 1777 /tmp). This operation will be even more important if your /tmp is on a separate partition (which makes it a mount point). By the way, since many programs rely on ...


4

A number of possibilities: the trailing dot in the file permissions line -rwSr-s---. indicate extended permissions, either SE Linux (confirm with ls -lZ) or ACL style permissions (confirm with getfacl ) which may block root overrides. the file has been made immutable with chattr ; confirm the file system attributes with lsattr The file is on a NFS ...


1

Assume you are using gnu find, you can use -delete option: find . -name test -delete which is easier to remember.


0

The rows of ? characters indicate directory entries that don't correspond to a file. This is a sign that your filesystem is damaged. You won't be able to call rm to remove these files because the files are not actually there, there's only a dangling label. You need to run a filesystem check and repair (fsck). Given that this is on your root partition, as ...


0

Can't think of a way to expand the glob in -exec, but putting it in a subshell should work. find /data1 -name MyTargetDir -type d -exec bash -c 'shopt -s dotglob; rm -rv "{}"/*' \;


2

What about: sudo rm directory/filename or: su -c "rm directory/filename" depending on your distro and/or setup. You are giving yourself a temporary root for the duration of the above commands and as root is almighty on Unix/Linux you are allowed to do anything. This contrasts with MS Windows where you can remove access to the administrator account ...


0

I had similar issues. Do you have Gnome, KDE or some kind of Xwindow DM?. If you do open your file broser and remove the file from there. It should work. I would like to see a solution from the command line, but in my case and after losing a lot of time trying to figure out how to remove it from the command line I found that it was as simple as removing ...


1

Recreating the directory seems a pretty clean way to do it. find /data1 -name MyTargetDir -type d -exec rm -rv {} \; -exec mkdir {} \; You could instead use a subshell in the exec to run a rm -rf * (or similar) from within the directory. But that just seems more trouble than the above. You have the side effect of cleaning up the directory size if that ...


0

No doubt there are nicer ways of doing it, but this should work: for MyTargetDir in `find /data1 -name MyTargetDir -type d -depth` do if [ $MyTargetDir != "" ]; then rm -rfvi $MyTargetDir/* fi done The if statement is required in case you never find the directory that you are looking for in which case the rm command would destroy your root file ...


-1

Or you could try this command without the r option in rm. so it don't will be able to remove directories.


0

rm -rf MyTargetDir && mkdir MyTargetDir It should do what you are trying to do.


8

The following excerpt from this essay potentially explains why that directory refuses to be deleted: NFSv4 requires that all filenames be exchanged using UTF-8 over the wire. The NFSv4 specification, RFC 3530, says that filenames should be UTF-8 encoded in section 1.4.3: “In a slight departure, file and directory names are encoded with UTF-8 to deal with ...


0

Have you tried to get the inode of that file with stat: stat mike* That should give you the inode number (and other data), and then you could try to delete it.


0

Have you tried using rm -rf ./mikeaâcnt or rm -rf "./mikeaâcnt" or an absolute path? Also instead of rm, try rmdir ./mikeaâcnt.


0

After getting the correct hex code of file / folder name (using whatever method one sees fit, I may choose ls --show-control-chars | xxd), some special construct should be used to address such characters when running under bash: rmdir $'mikea\xc3\xa2\xc2\x81\xc2\x84cnt' Otherwise backslashes are treated as vanilla backslash.


12

One way to delete files/direcories like this is by their inode-reference. To find the inodes for elements in current dir: ls -i 14813568 mikeaâcnt To delete this: find . -inum 14813568 -delete


7

You should not use non-ASCII characters in the command line since as you could see, for some reason, they won't necessarily correspond to the filename (Unicode has various ways for expressing accented letters). Something like: rm -rf mike* should work since the filename is directly generated by the shell. But make sure there's only one match (do an echo ...


3

I have personally tested using find's -exec directive: $ mkdir -p mikeaâcnt $ ls mikeaâcnt $ find -maxdepth 1 -type d -empty -exec rm -rf {} + $ ls $ The folder was correctly created and correctly removed. As pointed out by @Igeorget, there's an even simpler method if you have GNU find: $ find -maxdepth 1 -type d -empty -delete I also tested this ...


0

Linux Walkthrough of creating a file with dashes and spaces, then removing it. BE CAREFUL! Don't accidentally run a rm -rf / or similar cascade delete command. If your file you are trying to remove includes asterisks or slashes, do not accidentally pump a . or /* or * or some other wildcard which could cascade delete your operating system. Create a ...



Top 50 recent answers are included