Tag Info

Hot answers tagged

26

The tool to display inode detail for a filesystem will be filesystem specific. For the ext2, ext3, ext4 filesystems (the most common Linux filesystems), you can use debugfs, for XFS xfs_db, for ZFS zdb. For btrfs some information is available using the btrfs command. For example, to explore a directory on an ext4 filesystem (in this case / is dev/sda1): # ...


8

Looks like you might be looking for chroot. Note that while something like ../../../../../.. will not escape the restricted root directory, there are other ways to escape indirectly, by leveraging other processes. If you're concerned about a malicious application, run it as a user who doesn't run any process outside the chroot. For a more ...


8

This is because files use up space in whole-block increments. So if your block size is 512 bytes and you have a small 100 byte file, the size it actually uses up will be rounded up to the nearest block - in this case 512. When tarring, because the result is a single file, that inefficiency is reduced since there is only one resultant file - the .tar file. ...


3

In this case scp will copy each source file to /home/me/logs, overwriting /home/me/logs with the contents of each new file. The result is that /home/me/logs will be a copy of the last source file in the list. All the other source files are lost. Oops! Regular cp warns and aborts in this case, at least!


3

Make sure you are typing in /usr/bin, not usr/bin. The latter means "look for usr/bin starting in the current directory." For example, if your current directory is your home directory (~), then it will look for ~/usr/bin. The former means "look for /usr/bin starting from the root directory." This makes sure that the search for usr/bin starts from the root ...


3

As Christopher suggested, archivemount can achieve this. Permits writing of files and when unmounted, the .tar.gz file is automatically updated to reflect the changes. # ls -lh download.tar.gz -rw-rw-r--. 1 steve steve 3.1M Feb 16 2010 download.tar.gz # archivemount download.tar.gz /mnt # cd /mnt # find . -ls|head 1 3127 drwxr-xr-x 0 root root ...


3

q1) Doing a ls -ld show me a . - why ? When you give no arguments to ls, the default is to run the command on the current directory, also known as .. Normally that means listing the contents of the directory, but you have used the -d option which requests listing the directory itself, not its contents. So you get the information for ., the current ...


2

With GNU find and GNU coreutils, and assuming your directories don't have newlines in their names: find ~/foo -mindepth 1 -maxdepth 1 -type d -exec du -ks {} + | awk '$1 <= 50' | cut -f 2- This will list directories with total contents smaller than 50K. If you're happy with the results and you want to delete them, add | xargs rm -rf to the end of the ...


2

Beware that choroba's solution, though elegant, can elicit unexpected behavior if no directories are available within the current directory. In this state, rather than skipping the for loop, bash will run the loop exactly once where d is equal to */: #!/usr/bin/env bash for d in */; do # Will print */ if no directories are available echo $d done ...


2

For your specific problem you can use the length of the file names to distinguish them: mv ??? first mv ???? second If you want to solve this in a more general case you really want to use a language like Python or Ruby, where looping over files and basic arithmetic are sane.


1

mv path_to_example_dir/*_jony /jony


1

Debian does not install anything into /usr/local, in the sense that official Debian packages are forbidden to touch that hierarchy. Also, Debian packages can assume absolute installation paths, so they may not work correctly if moved by hand (or by somehow tricking dpkg into installing them into a different hierarchy). On the other hand, software packages ...


1

Yes, thanks to FUSE, which allows filesystems to be implemented by userland programs. There are many FUSE filesystems out there, implementing files stored as something other than sectors on a disk, including alternate views of existing filesystems, files on a remote machine, files in an archive, etc. You can use archivemount to mount a specific archive to a ...


1

Pure ksh93 solution: FIGNORE='@(.|..)' for dir in */; do a=( "$dir"/**/* ); printf "%s\t%s\n" "$dir:" "${#a[*]}"; done Result from /usr/src: linux-3.17.7-gentoo/: 561 linux-3.5.7-gentoo/: 517 linux-3.7.10-gentoo/: 505 linux-3.7.9-gentoo/: 513 linux-3.8.13-gentoo/: 551 linux-4.0.5-gentoo/: 1849


1

Will something like this suit your need: The path /boot is used for sample demonstration. Change it to the directory you need. for DIR in $(find /boot/* -maxdepth 1 -type d) do printf "%40s: %10d\n" "${DIR}" $(find ${DIR}|wc -l) done Output: /boot/grub: 282 /boot/grub/fonts: 2 ...


1

You could find the toplevel directories first, then use a second find, to count the number of files and directories within the toplevel directory: $ for dir in $(find . -maxdepth 1 ! -path . -type d | sort); \ do echo -n "$dir " && find $dir ! -path . | wc -l ; done ./adir 1151 ./anotherdir 140 ./623de41e44 280 ./examples 154 ...


1

ls -d */ | while read d do echo $d done


1

I suppose you are talking about fragmented directory blocks. While you create file/ directory , it goes in the parent directory blocks. With time, you create and delete the objects and this blocks become fragmented. This is called non-contiguous directory. There must be feature provided by file system to make them compact . look into the particular file ...


1

Here is a method that only uses POSIX shell features: find ~/dim_import/* -type f ! -name xdir -exec sh -c ' p=${1%/*}; d=${p##*/}; f=${1##*/}; mkdir -p new/"$d"; cp "$1" new/"$d"' -- {} \;


1

I suggest you --depend of your so-- fslint, duff, fdupes, dmerge, rmlint, rdfind --which both are able to find twins much faster than fdupes or dupseek. I'd execute: $ find /path -type f -printf "%p - %s\n" | sort -nr -k3 | uniq -D -f1


1

With find and cmp: find . -type f -exec sh -c 'cmp -s data.txt "$0" 2>/dev/null && echo $0' {} \; You might want to add some more criteria to limit find.


1

If this is something that needs to be checked on a regular basis, you could setup a cron job to create a digest of the md5 hashes of the files, something like echo > $digest_file; find $search_path -type f | xargs md5sum >> $digest_file Assuming this has been ran since your file was copied, find the hash of your known file first, then check the ...


1

myfile=/full/path/to/data.txt mysearchpath=/my/search/path/root/directory for file in $(find ${mysearchpath} -type f) do diff ${myfile} ${file} > /dev/null result=${?} if [ $result -eq 0 ] then echo "Identical file found at ${file}" fi done Although this is a very expensive way (computing resources wise, especially if you are sharing ...


1

Found the answer. Something was wrong with the linkage, as @JeffSchaller suggested. The solution is to run xfs_check to see that the links were incorrect, then xfs_repair to fix them. run mount to view the device name. Mine is /dev/mapper/vg3-lv3 umount /3 xfs_check /dev/mapper/vg3-lv3 which returned the following: link count mismatch for inode ...



Only top voted, non community-wiki answers of a minimum length are eligible