Hot answers tagged

35

The POSIX standard says A pathname consisting of a single / shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. It makes a distinction between filenames and pathnames. / is a pathname for the path of the root directory. The name of the directory is "the root directory", but in the filesystem it is ...


35

The fastest way to create a file in a Linux system is fallocate: fallocate -l 50G file From man: fallocate is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it. For filesystems which support the fallocate system call, preallocation is done quickly by allocating blocks ...


24

slash is a separator; directory names do not include separators, but full pathnames include the separators. So the "root-level" "/" has no name. On most Unix-like systems, this is treated as a special case like "." and ".." (though of course there is no difference between the two at the root level). Nomenclature can differ. POSIX, for example lists some ...


16

According to The Open Group's published standard, the only required directories are: / /dev, which contains console, null, and tty /tmp, guaranteed writable but not necessarily preserved. The Linux Foundation maintains a Filesystem Hierarchy Standard (FHS) which extends this to include the directories you will typically see on a Linux system: /bin:...


13

In Unix, files (and directories are just files) don't have "names". Links have names, links are entries in a directory that map names to files. You might say, that links give names to files, but note: this implies that a file can have more than one name, since it can have more than one link. Since the root directory is, well, the root directory, there is ...


13

In 10.1 Directory Structure and Files, POSIX lists directories which must exist. But it specifies no limit on the number of other directories which can exist at the root-level of a filesystem. For that matter, it does not appear to place limits on the size of other directories. POSIX's attention in this area is focused on commonality rather than ...


12

Other alternatives include: to change the alarm thresholds to something near or below the current usage, or to create a very small test partition with limited inodes, size, or other attributes. Being able to test things such as running into the root reserved percentage, if any, may also be handy.


8

There is no limitation to the number of entries in a directory, either in POSIX or in typical Unix implementations. There may be an indirect limit for the number of subdirectories, which is the maximum hard link count (each subdirectory's .. entry is a hard link to the directory); that's 216 for many common filesystems, which limits a directory to 65533 ...


5

fallocate -l 50G big_file truncate -s 50G big_file dd of=bigfile bs=1 seek=50G count=0 As those three ways can all fill up a partition quickly. If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need and set count=0. That will tell the system there is a file, and its size is what you set, but the system will not create ...


4

This will go through your files and set the executable bit according to whether file believes that the file should be executable: find /var/www/html -type f -exec bash -c 'if file -b "$1" | grep -q executable; then chmod +x "$1"; else chmod -x "$1"; fi' None {} \; The find command is very similar to yours. The change is the addition of the bash commands. ...


4

The only way is to have a directory that the user can't write to. Create a single file in that directory and give them permission to write that file. They won't be able to remove the file nor to create another file. They won't be able to rename the file either. But they can overwrite the file, and they can change the file's metadata (timestamps, permissions, ...


4

The use of the word "name" is a little bit flexible; it can refer to a "fully qualified path name"; it could refer to the "directory entry"; it could refer to the "file name" passed to various functions or routines. So, for example, /etc/foo and /var/tmp/../../etc/foo and /tmp/../../../../../../foo are all ways of referring to the same file; they're all ...


3

Read-only is just that - reading from the disk. It will pick up sector read errors but (obviously) not sector write errors. Categorically, it is safe to run on a device that is being used a mounted filesystem. With respect to possible false positives, block IO is not "managed", i.e. there are no reader/writer locks. So there is no interaction between ...


3

If the image that you are writing to the mmc is a complete partition with the file allocation table, then NO you do not need to erase or zero out the old space. The old 'random' data left is not part of a file and will be over-written as the space is used. Remember that a mmc device has a finite number of writes in its life and that number of writes is much ...


2

unlike FAT the filesystems used by UNIX don't have a special size limit on the root directory, but once the partition is full you won't be able to add more.


2

There is no generic way to directly mount a subtree of a filesystem. But you can mount the whole filesystem somewhere, and then “copy” a subtree of the mount with a bind mount. mount /dev/foobar /media/foobar mount --bind /media/foobar/usr /usr In fstab syntax: /dev/foobar /media/foobar auto defaults 0 2 /media/foobar/usr /usr bind bind


1

If you suffer from frequent voltage drops or noise in your mains power then GET AN ONLINE OR LINE-INTERACTIVE UPS. See https://en.wikipedia.org/wiki/Uninterruptible_power_supply There is no software solution that can fix this. As for your question, the superblock is just data. It can be corrupted like any other data. Either when it's being deliberately ...


1

On Linux, you can use stat to list a unique identifier associated to each mounted filesystem: stat -f -c %i somefile So for example to list the mount points under the current directory (assuming no newlines in file names) you can run stat -f -c '%i %n' * | grep -v "^$(stat -f -c %i .)" In zsh, you can use the zsh/stat module. Load it with zmodload zsh/...


1

With stat (could overflow ARG_MAX if * expands to something extremely huge): stat -c '%D %n' */ | awk -v no=$(stat -c %D /) ' $1 != no { print $2 }' With find: find . -mindepth 1 -maxdepth 1 -type d -printf '%D\t%P\n' |grep -v "^$(stat -c%d /)" |cut -f2


1

I'd use df for this. $ cd /usr $ ls X11R6 include libexec mdec sbin xobj bin lib local obj share xsrc games libdata lost+found ports src $ for d in *; do test -d "$d" && df -P "$d" | awk -v d="$d" 'FNR>1{print d,$NF}'; done X11R6 /usr bin /usr games /usr include /...


1

The best way to figure out how the RHEL / CentOS kernel is built is actually to look at the source RPM's specfile. CentOS already has a wiki page on how to get the full kernel source, located at https://wiki.centos.org/HowTos/I_need_the_Kernel_Source. Read section 2 of that page. Once you have the source RPM (SRPM) installed, the file SPECS/kernel.spec ...


1

I managed to assemble my raid in the end. This is how you do it: mdadm --assemble --update=devicesize /dev/md2


1

Yes. If you have 1 file then you are using 1 inode (well, there's also a couple of extra inodes used by default for other purposes just because of the way the filesystem works; e.g. the base directory and lost+found need inodes). The other inodes are wasted... but they don't necessarily use that much space. You may be able to gain a few Mbyte... When you ...


1

In Unix everything is a file. These files are organized in a tree structure, beginning at the root /. Your filesystem or filesystems will then be mounted at the appropriate places in your / according your /etc/fstab file. This file contains information about your filesystems, which device they belong to and to which point they will get mounted to - the ...



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