cmds copy and rm do not work on home directory SOLVED

Forum rules
Before you post please read how to get help
Level 3
Level 3
Posts: 124
Joined: Sun Mar 04, 2012 9:06 pm

cmds copy and rm do not work on home directory SOLVED

Postby pgmer6809 » Tue Feb 26, 2013 6:48 pm

I have been trying to move my home directory to another partition.
but the cp cmd from the cmd line just does not want to copy most of my files in my home directory. It is almost as if it cant see them.
If I

Code: Select all

sudo su - to
root, and then do an

Code: Select all

 ls -al
I can see lots of files there. But when I just cp nothing much happens.

same sort of behaviour with rm. rm does not seem to see most of the files in my home directory. even as root I cant just rm -R *
however if I do a

Code: Select all

find . -name '*' -exec rm -R \{\} \;
THEN most of the files get removed.

what has Mint done to prevent the proper operation of cp, rm, ls etc. even when running as root?

how does the MINT backup tool manage to get this done properly?


ls -a fromdir
. .. .hide1 .hide2 junk1 junk2

cp fromdir/* fromdir/.??* todir

ls -a todir
. .. .hide1 .hide2 junk1 junk2

Works like a charm thanks. I'm embarassed I did not think of that myself. I was thinking in terms of a regex * matching everything without taking into account that file system utilities might have some extra smarts built in.
Last edited by pgmer6809 on Wed Feb 27, 2013 10:42 pm, edited 2 times in total.

User avatar
Level 17
Level 17
Posts: 7957
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: cmds copy and rm do not work on home directory

Postby karlchen » Tue Feb 26, 2013 7:02 pm

Hello, pgmer6809.

The point is that the filename mask "*" will return all filesnames which do not start with a leading dot.

Code: Select all

cp * sometarget
will copy all files found in the current folder to sometarget, except all the files the names of which start with a leading dot.
Every profile folder, however, holds a lot of files and folders the names of which start with a leading .dot.

On the commandline you have to specify normal filenames and dot filenames separately, e.g. something like this

Code: Select all

cp ./* ./.* sometarget

In order to copy / move a complete home folder using a graphical file manager like Gnome Commander may be much more convenient. It can be configured to display hidden filenames and foldernames, too, i.e. the ones starting with a dot.

By the way, ignoring hidden objects by default is not special to Linux Mint, rather it is the normal behaviour on any Linux based system.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

User avatar
Level 3
Level 3
Posts: 159
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: cmds copy and rm do not work on home directory

Postby bjornmu » Wed Feb 27, 2013 2:54 am

If you need to copy the *entire* home directory it's easiest to cd to the directory above it and then just do

Code: Select all

cp -pR user <target>

(Replace user with your user name). If the target directory already exists, you will get a subdirectory under it called 'user', otherwise you'll get the target directory as a copy of the original. This should copy absolutely everything. The 'p' option to cp is important as it preserves access flags so that executable files remain executable etc.

The suggestion of using ./.* to cover "dot files" may not be a good idea, as that also includes the special links . and ..

Whenever I need to do something with all "dot" files I use the pattern .??* which covers all except those with just a single character after the dot.

Return to “Scripts & Bash”