How to view files, created by Linux and programs in /tmp directory?

22,817

Solution 1

The number in the second column of an entry in the output of ls -la is the number of hard links pointing to the same inode; in the case of a directory entry this means the number of subdirectories including the special . dir mentioned below; you can read more details e. g. in this answer.

The entry .. represents the parent directory, which in this case is the root directory /. 19 or 20 subdirectories of / is quite normal, as far as I can tell, but depends on the distribution and local additions.

The entry . represents the current directory, in this case /tmp - it contains only . and .., as shown in the listing, thus 2 hard links: one for its sole existence in /, one for . pointing to it.

Your conclusion that /tmp has "hidden" entries is wrong; the temp dir is definitely empty right now.

There are some oddities which I mentioned in my comments, but these are out of scope for this question. If you're experiencing any problems you should open new questions for them, with a detailed description what you see (don't forget to show output for evidence), what you expect and why you think it's wrong or unusual.

Solution 2

I use ls -lah /tmp to see all 1st level files and directory in /tmp.

'l' for list
'a' for all
'h' for human readable file size

As tmp directory comes with 777 permission by default any user can read, write and index through the directory and root access is not mandatory to list it's contents.

In Linux hidden files and folders start with a . at beginning. So, form the output you can recognise a file or folder as hidden by a . at beginning.

If the above command isn't returning any content details probably /tmp in your system is currently empty.

Also if you're in a busybox Android shell the /tmp directory may be absent. /tmp directory itself is not mandatory for Android implementation.

Share:
22,817
minto
Author by

minto

Updated on September 18, 2022

Comments

  • minto
    minto over 1 year

    How to view files, created by Linux and programs in /tmp directory? The file names are hidden, command ls -al /tmp only show the presence of files not their names.

    Edit: I find that place in saved session logs:

    # ls -al /tmp
    drwxrwxrwt    2 0        0              40 Jan  1 00:00 .
    drwxr-xr-x   19 1005     1005          219 Aug  2  2017 ..
    # grep -r config /tmp
    # grep -r bin /tmp
    # umount /mnt
    # ls -l
    ----
    drwxrwxrwt    2 0        0              40 Jan  1 00:00 tmp
    ---
    

    Third line show that /tmp directory have 19 files(?), but I don't see it. Or I have missed something?

    • Murphy
      Murphy over 6 years
      "only show the presence of files not their names" - it's unclear what you mean with this, and totally contradicts the expected output of ls -al. Please add the complete output of that command to your question, best including the command itself; use copy&paste and format it as code for better readability.
    • minto
      minto over 6 years
      @Murphy I have added details.
    • Weijun Zhou
      Weijun Zhou over 6 years
      The third line is .., the parent directory. So what else can you expect?
    • Murphy
      Murphy over 6 years
      No; the third line means that this entry has 19 hard links, which in this case means that the root directory has 19 subdirs; that seems OK. However there are some strange things in this listing: UID/GID 0 is root, allright, but / belonging to user 1005, which in most cases is a manually created user, is rather unusual; it should belong to root, too. Additionally the UIDs aren't resolved to user names, what I would have expected.
    • Murphy
      Murphy over 6 years
      ... In short, your /tmp dir seems fine, but empty, but I can't say anything about the rest of the system; it may be a normal state for your system or not.
    • Kusalananda
      Kusalananda almost 6 years
      Your root directory, /, has 17 subdirectories. That's how you get a link count of 19 for /tmp/...
  • dave_thompson_085
    dave_thompson_085 over 6 years
    Linkcount 2 for dot tells you /tmp contains no (sub)directories, but it doesn't say anything about containing files (or fifos sockets devices etc). And 19 for .. tells you root contains 19-2=17 subdirs.
  • Murphy
    Murphy over 6 years
    @dave_thompson_085 Thank you for the hints; I've fixed the text.