There are 2 files but yet there are 40 files. (And other file syncing questions.)

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
purpletree

There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by purpletree »

I'm using a file syncing service called SpiderOak and it constantly has issues with syncing certain kinds of files.
One example of "a bad choice to backup" are KeePassX database files. I assume it's the lock files that are the problem.
When I was taking a look at the directory in which I store my KeePassX (*.kdbx) files in I ran into something I don't understand:
When viewing the directory with Dolphin, I only see two files. Fine, it doesn't show hidden files...
When viewing the directory using Terminal with

Code: Select all

ls -la
it reports this:
total 40
drwxrwxrwx 2 enks enks 4096 Apr 20 14:15 .
drwxrwxrwx 4 enks enks 4096 Apr 19 18:47 ..
-rw------- 1 enks enks 58 Apr 14 02:05 .directory
-rw-rw-rw- 1 enks enks 4094 Apr 10 14:18 Passwords_D.kdbx
-rw-rw-rw- 1 enks enks 19310 Apr 19 11:35 Passwords.kdbx
-rw-r--r-- 1 enks enks 24 Apr 20 14:15 .Passwords.kdbx.lock
I'm new to linux and I'm motivated to understand what's going on, can someone explain this?
Why are there 40 files? (2+4+1+1+1+1 = 10)
How can I see these other files?
Why are there . and ..?
What does the .directory file do?
And what's with the permissions?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by phd21 »

HI purpletree

Welcome to the wonderful world of Linux Mint and its excellent forum!

Any files or folders that start with a period (dot) are "hidden" files and folders. The file managers like Dolphin can show hidden files as well, click View and Hidden files, or add the Hidden files button to its toolbar to toggle that off and on.

The first two items are almost always part of a folder and subfolder "." (current folder directory) and ".." (one folder up from current folder). If I remember correctly, that is the same with MS Windows.

The hidden lock file is created when you are in an application due to file locking to protect it. If you had to abort the application program or forcibly restart (reboot) your system, then sometimes the lock files will remain and can be safely deleted.

I do not see 40 files in your results? That is probably the total bytes (size) of the files.

ExcIuding the "." and "..", I only have three in my "/Documents/kp" folder where I store the KeePassX database files, it only shows 2 files if I run "ls -lh".
>ls -lha
total 348K
drwxrwxr-x 2 user69 user69 4.0K Apr 20 16:54 .
drwxr-xr-x 32 user69 user69 4.0K Apr 20 14:41 ..
-rw-r--r-- 1 user69 user69 240 May 19 2017 (conflicted).directory
-rw-r--r-- 1 user69 user69 269 Apr 20 16:54 .directory
-rw------- 1 user69 user69 332K Mar 23 22:23 something.kdbx

or

ls -lh
total 336K
-rw-r--r-- 1 user69 user69 240 May 19 2017 (conflicted).directory
-rw------- 1 user69 user69 332K Mar 23 22:23 something.kdbx
Linux is a very secure operating system and has "permissions" assigned to folder and files for user(s) access and "root" superuser access.

I also use 3 different cloud providers and their Linux software clients, excellent "pCloud", excellent "Mega.nz", and Google's Drive using the superb "InSync" client, to sync my stuff like KeePassX database files, AutoKey shortcut folders, etc... This will occasionally create a conflicted directory folder entry which I usually delete, I am not sure why.

What do the fields in ls -al output mean? - Unix & Linux Stack Exchange
https://unix.stackexchange.com/question ... utput-mean

what means a dot after the file permission ?
https://www.linuxquestions.org/question ... on-796947/

ls command in Linux/Unix | list files/directories
https://www.rapidtables.com/code/linux/ls.html


Hope this helps ...
Last edited by phd21 on Fri Apr 20, 2018 5:20 pm, edited 2 times in total.
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by Cosmo. »

. stands for the current directory, .. for the parent directory. You can for example enter the command cd .. and you get a hierarchy level higher. if you use the option -A instead of -a they will not get shown. If they are shown they user has the ability to check their permissions.

The permissions are as that: There are 10 columns. The first one shows d, if the object is a directory, otherwise it is empty (= -) This is not a permission, but the other 9 columns show permissions. Divide them in 3 groups. Column 1 to 3 show the permissions of the owner, the next 3 for the group members and the last 3 for the rest of the world. Column 1 / 4 / 7 says r, if there is a read permission (or - for no read permission), 2 / 5 / 8 an w for write permission, 3 / 6 / 9 an x for execution permission.

The kdbx.lock file exists, as long as the corresponding KPX database is opened. This is for preventing, that it gets erroneously double opened, which could easily destroy the data. As soon as the database gets closed, the lock file gets deleted. There is no sense to back it up.

You seem to have 2 databases, the second one is currently in use.
purpletree

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by purpletree »

Thank you. So one thing I immediately notice is that with the -h flag there's a K after the number. I though it was a count of how many files are there but you're right, it's for the size of the directory.
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by phd21 »

Hi purpletree,

You are welcome from all of us that replied...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
User avatar
slipstick
Level 6
Level 6
Posts: 1071
Joined: Sun Oct 21, 2012 9:56 pm
Location: Somewhere on the /LL0 scale

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by slipstick »

A little more about permissions (from the book "The Linux Command Line" by William Shotts) - free pdf download here:
http://linuxcommand.org/tlcl.php
Screenshot_permissions.png
In theory, theory and practice are the same. In practice, they ain't.
purpletree

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by purpletree »

Thanks again everyone. That was exceptionally helpful.
Mute Ant

Re: There are 2 files but yet there are 40 files. (And other file syncing questions.)

Post by Mute Ant »

find -type f | wc -l ### Report the number of real file objects in-or-below this folder where I am now.
Locked

Return to “Beginner Questions”