Tag Info

New answers tagged

1

This is reposted from here at the asker's behest: du --inodes -S | sort -rh | sed -n \ '1,50{/^.\{71\}/s/^\(.\{30\}\).*\(.\{37\}\)$/\1...\2/;p}' And if you want to stay in the same filesystem you do: du --inodes -xS Here's some example output: 15K /usr/share/man/man3 4.0K /usr/lib 3.6K /usr/bin 2.4K /usr/share/man/man1 1.9K ...


1

Why? Because no one has written a tool that does it. And that's probably because it's a not entirely trivial change to the filesystem metadata. There are other issues like this; for example you can't resize ext4 to >16TB. That needs 64bit structures which aren't used by default. Same with other filesystems, for example you can't shrink XFS. None of these ...


2

Use a bind mount instead of -xdev. Also, directories use inodes too. mkdir /mnt/somewhere mount -o bind / /mnt/somewhere find /mnt/somewhere -printf '%i\n' | sort -u | wc -l


11

This works also with stat: DIR=/ stat -c '%i' $DIR From man stat: -c --format=FORMAT use the specified FORMAT instead of the default; output a new‐ line after each use of FORMAT [...] The valid format sequences for files: %i inode number


11

Yes, the argument -i will print the inode number of each file or directory the ls command is listing. As you want to print the inode number of a directory, I would suggest using the argument -d to only list directories. For just printing the inode number of your home directory, use the following command line: ls -id ~ From man ls: -d, --directory ...


3

Well, yes. The manpage on my Debian system says “When +L is followed by a number, only files having a link count less than that number will be listed.”


4

Give the inode number to the find command and tell it to run the stat command on the file: find . -inum #### -exec stat -c "%h" {} \;


1

To get the link count from the inode without searching the full filesystem, on an ext2/ext3/ext4 filesystem you can use debugfs. The down side here is that you require to know the device and have root privileges. The upside of course is that it can be much, much faster. For a file with inode 5638454 on dev/sda2: sudo debugfs -R 'stat <5638454>' ...


3

Finding the link count using the name You can use the stat command to get a link count on a given file/directory: $ stat lib/ File: ‘lib/’ Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fd02h/64770d Inode: 11666186 Links: 3 Access: (0755/drwxr-xr-x) Uid: ( 1000/ saml) Gid: ( 1000/ saml) Context: ...


2

For example ls -l passwd -rw-r--r-- 1 root root 1402 2008-03-30 17:49 passwd This number (1) is actually the link-count of the file, when referring to a file, or the number of contained directory entries, when referring to a directory (including the . and .. entries). Also for example ls -i /etc/passwd 8654127 /etc/passwd This is inode number for ...



Top 50 recent answers are included