Skip to main content
34 votes
Accepted

Why does '/' contain '..'?

The .. entry in the root directory is a special case. From the POSIX standard (4.13 Pathname Resolution, where the . and .. entries are referred to as "dot" and "dot-dot" repsectively): The special ...
Kusalananda's user avatar
  • 356k
34 votes
Accepted

What is the difference between /lib and /usr/lib and /var/lib?

Someone else can probably explain this with much more detail and historical reference but the short answer: /lib is a place for the essential standard libraries. Think of libraries required for your ...
jesse_b's user avatar
  • 41.6k
23 votes
Accepted

How to prepend a directory to files placed in a tar archive?

You can use the --transform option. For example: touch foo bar tar cf archive.tar foo bar --transform 's,^,bazdir/,' tar tvf archive.tar -rw-r--r-- tigger/tigger 0 2017-10-11 19:32 bazdir/foo -...
Tigger's user avatar
  • 3,747
23 votes
Accepted

Is there a home directory location for overriding icons?

The historical equivalent is ~/.icons, the XDG equivalent is ~/.local/share/icons (strictly speaking, icons subdirectories of the paths in $XDG_DATA_DIRS). When you specify an icon by name only in a ....
Stephen Kitt's user avatar
19 votes

What's the right way to add directories to XDG_DATA_DIRS?

The German ubuntuusers wiki has a nice list of files and directories that can be used for that purpose. Setting it globally From my research, appending to that environment variable globally is not ...
xeruf's user avatar
  • 651
19 votes
Accepted

Why is /var/lib used by application for storing data?

/var/lib is indeed the correct directory; as described in the filesystem hierarchy standard, This hierarchy holds state information pertaining to an application or the system. State information is ...
Stephen Kitt's user avatar
18 votes
Accepted

Have group permission but unable to create file

/sys directory is special. You can't just poke around and create files Wikipedia excerpt: Modern Linux distributions include a /sys directory as a virtual filesystem (sysfs, comparable to /proc, ...
Vlastimil Burián's user avatar
18 votes
Accepted

How to find only directories without subdirectories?

To find only those leaf directories that contain non-directory files, you can combine an answer of the referenced question https://unix.stackexchange.com/a/203991/330217 or similar questions https://...
Bodo's user avatar
  • 6,441
17 votes

Where do I put my systemd unit file?

If you want to know all the places where systemd will look for unit files, the following commands should be helpful. Using systemd-analyze command: All folders which can contain user services: These ...
smac89's user avatar
  • 1,665
17 votes

Why does '/' contain '..'?

Kusalananda has already told you that this is the behavior specified by the POSIX standard. However, the history of UNIX began in earnest in the early 1970s. POSIX dates back only to the second half ...
user's user avatar
  • 30k
16 votes

What is the difference between /lib and /usr/lib and /var/lib?

Files in /lib and /usr/lib are supposed to be mostly read only and identical between systems. (If it was a container image, they could be fully read only and shared between systems; on a stand alone ...
user10489's user avatar
  • 10.9k
12 votes
Accepted

~/.local/share is set for what? And can I ignore it at backups?

The answer depends on what you count as “real user data”! It’s specified as containing “user-specific data files”. In practice it doesn’t contain documents and such like, but rather automatically-...
Stephen Kitt's user avatar
11 votes
Accepted

How to mirror directory structure and files with zero size?

GNU cp (from coreutils) can do this: cp -r --attributes-only original_folder/* mirrored_folder/ From man cp: --attributes-only don't copy the file data, just the attributes -R, -r, --recursive copy ...
αғsнιη's user avatar
  • 41.9k
10 votes

Where should a local user executable be placed (under $HOME)?

The XDG Base Directory Specification Version 0.8 states local executables should be placed in ~/.local/bin: User-specific executable files may be stored in $HOME/.local/bin. Distributions should ...
Concrete_Buddha's user avatar
10 votes
Accepted

$XDG_CACHE_HOME vs. $XDG_STATE_HOME

XDG_STATE_HOME isn’t used much because it’s a recent addition to the specification. Version 0.7 of the specification doesn’t mention it, it was added in version 0.8, published in May 2021. In previous ...
Stephen Kitt's user avatar
9 votes

Into which directory should I install programs in Linux?

~/.local/bin This is defined in systemd's standard which has the following to say about the directory's contents: Executables that shall appear in the user's $PATH search path. It is recommended not ...
Matthias Braun's user avatar
9 votes

How can I find files in directories listed in a file?

If the directory names are one-per-line, then you could avoid issues with directories that have spaces or tabs or wildcard characters in their names by using readarray (bash v4+): readarray -t dirs &...
Jeff Schaller's user avatar
  • 68.8k
8 votes

What's the most appropriate directory where to place files shared between users?

It is important to remember that the FHS addresses issues where file placements need to be coordinated between multiple parties such as local sites, distributions, applications, documentation, etc; ...
James's user avatar
  • 191
8 votes
Accepted

Why is ls -i slower than ls?

strace shows me that ls -i is calling lstat() on each filename That would explain the extra work. Given that readdir() has already returned the inode number this appears to be sub-optimal while ...
Jasen's user avatar
  • 3,915
7 votes

What is the difference between /opt and /usr/local?

I have a slightly different take on this old topic. If I am working on a new tool that I intend to be a standard part of the OS. I install it to /usr/local and ask my local users to alpha test it. ...
Jesse Chisholm's user avatar
7 votes

How to find only directories without subdirectories?

You could use nested find and count number of subdirectories: find . -type d \ \( -exec sh -c 'find "$1" -mindepth 1 -maxdepth 1 -type d -print0 | grep -cz "^" >/dev/null 2>&1' _ {} \; -o ...
pLumo's user avatar
  • 23.2k
7 votes
Accepted

How do I get XDG_CONFIG_HOME from a shell script / command line?

${XDG_CONFIG_HOME:-~/.config} is exactly how xdg-user-dirs does it (it's a shell script). It hasn't changed since 2008, so you can consider this to be stable. Incidentally, you'd better not have ...
Gilles 'SO- stop being evil''s user avatar
6 votes

Where do I put my systemd unit file?

One noticeable difference between /etc/systemd/system and /lib/systemd/system on Debian/Ubuntu system is, the service files under /lib/systemd/system can be masked while those under /etc/systemd/...
D.Liu's user avatar
  • 61
6 votes

Where should a local user executable be placed (under $HOME)?

It looks like /usr/local/bin according to the Internet website Wikitechy. Information about /usr/bin from Filesystem Hierarchy Standard, they define the folder as the primary directory of executable ...
Cloud Cho's user avatar
  • 167
6 votes
Accepted

Where should I store my application files (data, cache, logs, crashes, etc.)

Part of your confusion may be the distinction between user applications and system applications. So, for example, apache isn't run as an end user ("Harry" normally doesn't run Apache; it's run from a ...
Stephen Harris's user avatar
6 votes
Accepted

Is the .d notation for folders in /etc recommended or not?

The typical use of a .d directory is to hold multiple config files (typically sharing a common file extension, such as *.conf) which are then merged or composed to produce a single logical ...
filbranden's user avatar
  • 22.6k
6 votes
Accepted

Find all directories NOT containing matched subdirectory and create them

You can create the directories while hiding any error related to the directory already existing: for custDir in /media/storage/sqlbackup/CUSTOMER* do mkdir -p "$custDir"/{daily,weekly,monthly} ...
Chris Davies's user avatar
6 votes
Accepted

How to run a loop in all directories inside a directory

A simple loop would work: for dir in /tmp/main/*/; do touch "$dir"/test.txt done The / at the end of the pattern /tmp/main/*/ guarantees that if the pattern matches anything, it will ...
Kusalananda's user avatar
  • 356k
5 votes

What is the difference between /opt and /usr/local?

In summary, my gut answer ... Having used my fair share of FreeBSD since 2.2.6 and Red Hat Linux since version 9 ... /usr/local == Old School Conventions /opt == New School Conventions The ...
Anthony Rutledge's user avatar

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