date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,312,577,351,000
There's no directory above /, so what's the point of the .. in it?
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 filename dot shall refer to the directory specified by its predecessor. The special filename dot-dot shall refer to the ...
Why does '/' contain '..'? [duplicate]
1,312,577,351,000
I know when a program crashes, some files creating in /var/crash/. But I don't know what these files are! Is that error logs?
No, they are crash dumps of the kernel, i.e. files that contains useful information to recover the state of the kernel when it was crashing. These files are for your kernel what core dumps are for ordinary executables. There exists an utility that can be used to analyze those files : crash.
What are the files located in `/var/crash/`?
1,312,577,351,000
On a standard Linux distribution (e.g. Ubuntu) there is usually /etc/group and /etc/group-, where the second one is only readable by root. man group only describes /etc/group. Thus my question: What is the purpose of /etc/group-?
It is a backup of the previous copy of the file that is version of the file before the last change. It is kept because it is very important file. You can delete it, but backups are a "good thing". You can easily verify it. Try # groupadd test # diff /etc/group /etc/group- There are other files also that are backed ...
What is the purpose of `/etc/group-`
1,312,577,351,000
According to the Filesystem Hierarchy Standard the /bin directory should contain utilities needed in single user mode. In practice, many Linux distributions make the directory a symbolic link to /usr/bin. Similarly, /sbin is nowadays often a symbolic link to /usr/bin as well. What's the rationale behind the symlinks?
Short summary of the page suggested by don_crissti: Scattering utilities over different directories is no longer necessary and storing them all in /usr/bin simplifies the file system hierarchy. Also, the change makes Unix and Linux scripts / programmes more compatible. Historically the utilities in the /bin and /sbin ...
Why is /bin a symbolic link to /usr/bin?
1,312,577,351,000
Is there a standard location in Linux for holding source files for example OpenSSL. I am building Nginx from source with non default version of OpenSSL. I need to download and untar OpenSSL and I did it in home directory. Now, I wonder is there a standard location in Linux maybe /opt ?
Whenever you ask yourself something like this, check out the Filesystem Hierarchy Standard (FHS).There, you will find the following entry: usr/src : Source code (optional) Purpose Source code may be placed in this subdirectory, only for reference purposes So you can put your source files in subdirectories of /usr/sr...
Standard location for holding software source files
1,449,536,881,000
I am relatively new to Linux and I apologise if this is a silly question. I read the Linux FS Hierarchy document but it didn't answer my question. I would like to know if there is a typical drive mounting scheme for general-use internal HDDs in Linux. I ask because I have two HDDs that were mounted as "E:" and "F:" i...
Is this permanent or temporary? A hard drive that wasn't a part of my filesystem table (i.e. wouldn't get auto-mounted) I typically have ~/mnt/hd1 or ~/mnt/usb - not terribly imaginative, but the use case is something I'm not going to keep in the machine permanently. For something I'm adding for good, I like create a ...
Preferred mount points for internal HDDs [duplicate]
1,449,536,881,000
In a system with Ubuntu 14.04 and bash, I have the PS1 variable ending with the following contents: \u@\h:\w\$ so that the prompt appears as user@machinename:/home/mydirectory$ Sometimes, however, the current directory has a long name, or it is inside directories with long names, so that the prompt looks like user@m...
First of all, you might simply want to change the \w with \W. That way, only the name of the current directory is printed and not its entire path: terdon@oregano:/home/mydirectory1/second_directory_with_a_too_long_name/my_actual_directory_with_another_long_name $ PS1="\u@\h:\W \$ " terdon@oregano:my_actual_directory_w...
Compact bash prompt when using a directory tree / filename
1,449,536,881,000
In a standard Linux filesystem, which of these common directories are world-writable by default? /tmp /etc /var /proc /bin /boot /.... .... Why are they world-writable? Does that pose a security risk?
The only FHS-mandated directories that are commonly world-writable are /tmp and /var/tmp. In both cases, that's because they are intended for storing temporary files that may be made by anyone. Also common is /dev/shm, as a tmpfs (filesystem backed by RAM), for fast access to mid-sized data shared between processes, o...
What are the world writable directories by default?
1,449,536,881,000
I am writing a daemon process for a Debian system in C that uses a Unix Domain Socket. If the daemon process's working directory is the root directory, is there an idiomatic directory to place the socket on the file system?
They are commonly found in /tmp or a subdirectory thereof. Note that everything in /tmp is subject to erasure at shutdown -- not that it necessarily is erased, just beware that it can be, so if you use that, check if you have to create your subdirectory each time. You will want to use a subdirectory if you want to r...
Idiomatic location for file based sockets on Debian systems
1,449,536,881,000
I'm starting to write a few bash scripts for my project and they need some intermediate files or variables to be written. I want to know which folders can I be sure of having access to when someone runs my script? Is it a common practice to use /tmp/ ? Or should I used something else?
I find the Filesystem Hierarchy Standard document invaluable when looking for this stuff. There are a few options, /tmp - 'non-permanent' temporary files /var/tmp - 'permanent' temporary files /var/cache - 'application' transient data files It really depends on the kind of data you're storing.
Which folder should I write to for my intermediate files, as a dev?
1,449,536,881,000
I'm working on a LAMP web app and there is a scheduled process somewhere which keeps creating a folder called shop in the root of the site. Every time this appears it causes conflicts with rewrite rules in the app, not good. Until I find the offending script, is there a way to prevent any folder called shop being crea...
You can't, given the user creating the directory has sufficient permission to write on the parent directory. You can instead leverage the inotify family of system calls provided by the Linux kernel, to watch for the creation (and optionally mv-ing) of directory shop in the given directory, if created (or optionally mv...
Can I prevent a folder of a certain name being created?
1,449,536,881,000
I have deleted some files around /var/lib/dpkg/, namely: /var/lib/dpkg/status /var/lib/dpkg/available /var/lib/dpkg/info/* I understand Debian uses these files to keep some information about installed packages. Now when I do apt-get update, I get following error: Reading package lists... Error! E: Could not open file...
If you look at the purpose of /var as given in the Filesystem Hierarchy Standard, it says: /var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files. Note that "transient and temporary" files are just one of the things it contains...
How to recreate /var/lib/dpkg/status?
1,449,536,881,000
I keep reading/hearing that /etc is for system configuration files. Can someone explain/give me some intuition for why these scripts that start/stop/restart various programs are usually in /etc instead of /var or /usr or something similar?
Early on (both historically, and in the process of booting...), /etc is a part of / (the first mounted filesystem), while /usr was not (until disks got large). /var holds temporary data, while these scripts are not temporary. It's not that simple, but it started that way and there's little reason to rework the entire...
Why are init.d scripts in etc?
1,449,536,881,000
For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation I recently asked where to but a systemd unit file: Where do I put my systemd unit file on Arch Linux? I would like to run a python script every 5 minutes (not to be confused with a systemd unit file ...
I also was thinking about this same question and wanted to see other's opinion. My take on it is /usr/local/sbin as sbin is where you put things that should be run by admin. Your analysis is correct the /usr/local is the location dedicated for installing stuff not managed by package manager. But bin is for stuff that ...
Where do I put scripts executed by systemd units?
1,449,536,881,000
MySQL, fail2ban and many other server applications store their data in /var/lib. Are they using the correct directory? If so why is it named lib, which implies libraries?
/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 data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files i...
Why is /var/lib used by application for storing data?
1,449,536,881,000
I want to tar the files foo and bar into a tar archive archive.tar, but I want them to appear, within the archive, as being within a directory, bazdir. Thus when I untar someplace I want bazdir to be created and foo and bar to be created within it. How can I do that? This would be the opposite of: https://stackoverflo...
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 -rw-r--r-- tigger/tigger 0 2017-10-11 19:32 bazdir/bar For more details and more complex options see How to create a ...
How to prepend a directory to files placed in a tar archive?
1,449,536,881,000
There are a few home directory locations that complement /usr locations. Files in these locations override their /usr counterparts. For example: ~/.local/bin complements /usr/bin ~/.local/share/applications complements /usr/share/applications If I want to override an application, I can create a custom .desktop file ...
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 .desktop file, that relies on icon themes, so it’s worth reading the icon theme spec. Ideally you should use xdg-icon-re...
Is there a home directory location for overriding icons?
1,449,536,881,000
I have read that I should not mount /var/tmp as a temporary filesystem (e.g., as tmpfs), because files in /var/tmp must not be deleted on reboot. Is that correct? Suppose I did mount /var/tmp as a tmpfs, so its contents are deleted on every reboot. Would that be bad? If yes, what could go wrong? How bad would it b...
Files in /var/tmp are expected to be persistent across reboots. From the FHS: The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp. Files in /var/tmp ar...
What can go wrong if /var/tmp is on a temporary filesystem?
1,449,536,881,000
I have created a virtual image for Scientific Linux and came across this after I finished installing it: [root@ftpserver home]# pwd /home [root]@ftpserver home]# ls When I cd into ~ I get this: [root@ftpserver ~]# pwd /root What is the overall difference between /home and /root?
According to the Filesystem Hierarchy Standard (FHS): /home : User home directories (optional) /root : Home directory for the root user (optional) A typical non-root user's home directory would be /home/$USER. /root is also special in that (in many distros) /root is readable only to root (700), but a normal user's ho...
Root /home Directory vs ~ (tilde)
1,449,536,881,000
In studying for the lcpi exam, I met the following statement. If multiple disks are available it is good practice to also have the /usr and /home directories on different partitions. http://en.wikibooks.org/wiki/LPI_Linux_Certification/Design_Hard_Disk_Layout For desktop workstations, it makes sense to put your hom...
The 3 primary reasons you would create these as separate partitions are as follows: performance isolation security Examples By separating /home you can put this data on a shared network disk so that when UserA logs into servers in a given domain, their /home/$USER will be a single copy that follows them from machin...
Should /usr and /home be on different partitions?
1,449,536,881,000
I want to synchronize processes based on lock files (/ socket files). These files should only be removable by their creator user. There are plenty of choices: /dev/shm /var/lock /run/lock /run/user/<UID> /tmp What's the best location for this purpose? And what way are above locations meant to be used for?
/dev/shm : It is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things. /run/lock (formerly /var/lock) contains lock...
Linux file hierarchy - what's the best location to store lockfiles?
1,449,536,881,000
Is there a way in linux to look through a directory tree for only those directories that are the ends of branches (I will call them leaves here), i.e., dircetories with no subdirectories in them? I looked at this question but it was never properly answered. So if I have a directory tree root/ ├── branch1 │   ├── bran...
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://stackoverflow.com/a/4269862/10622916 or https://serverfault.com/a/530328 with find's ! -empty find rootdir -type d -link...
How to find only directories without subdirectories? [duplicate]
1,449,536,881,000
I am going to write a simple replacement for Ubunutu's NetworkManager. Is there any place where the Wifi network passwords would be stored in Linux? I know about /etc/NetworkManager/nm-system-settings.conf If not, can I store them safely somewhere using some builtin OS utilities?
Ubuntu (and most likely many flavors of Debian) stores the information at /etc/NetworkManager/system-connections. Each of the connections has its own file entry. The files are secured with file mode 600 and owned by root. The files in this directory are not limited to wireless connections; there are files for the wi...
Where does Linux store Wifi passwords?
1,449,536,881,000
If I look at my home directory there are a large number of dot files. If I am creating a new program that needs a user configuration file, is there any guidance where to put it? I could imagine creating a new dot directory ~/.myProgramName or maybe I should add it to /.config or ~/.local.
The .config directory is a newish development courtesy of XDG that seems, deservedly, to have won favour. Personally, I don't mind a dot directory of your own. A bunch of separate dot files (ala bash and various old school tools) in the toplevel of $HOME is a bit silly. Choosing a single dot file is a bad idea, be...
Where should user configuration files go? [duplicate]
1,449,536,881,000
I have a DNS-321 NAS drive which apparently runs Linux, so I logged in via ssh and I see .Trash-500 and .Trash-1000 directories. I realize that they're for trash, but why do I need two? Inside of them I see expunged, files, and info directories -- what are those for?
You can find the answers in the The FreeDesktop.org Trash specification: Some excerpts: $topdir/.Trash-$uid directory is to be used as the user's trash directory for this device/partition. $uid is the user's numeric identifier. The $trash/files directory contains the files and directories that were trashed. The $tras...
What are the .Trash-500 and .Trash-1000 directories?
1,449,536,881,000
I was running into performance problems with hundredthousands of files in single directories when I needed to do certain wildcard matches. From my applications point of view, a simple solution is to place the files in deeply nested folders. The expected upper bound for the total number of folders across the whole h...
Each folder consumes one inode (256 byte) and at least one block (probably 4096 byte). The bigger problem may be access time over several hierarchy layers. The performance problem is probably not due to the folder size but to pathname expansion. Pathname expansion has two problems: It sorts the results (which cannot ...
What is the "cost" of deeply nested folders in ext4?
1,449,536,881,000
I have this kind of directory tree that is obtained from unzipping a zip file: x -> y -> z -> run -> FILES AND DIRECTORIES HERE So there are 4 directories, 3 of whom are empty of files (x, y, z) and only contain 1 sub-directory, and there is the directory I am interested in, named "run". I want to move the "run" dir...
what about find . -type d -name run -exec mv {} /path/to/X \; where /path/to/X is your destination directory you start from this same place. then use other answer to remove empty directories. (on a side note there is a --junk-paths option in zip, either when zipping or unzipping)
How to extract a specifically named folder from a recursive directory, delete the others?
1,449,536,881,000
In our UNIX machine my home path looks like /home/<userid> and we have another batch user whose home looks like /export/home/<userid> I want to know what's the difference between /export/home/<userid> and /home/<userid>? Why there are difference in folders when both are some user in UNIX?
As Noufal Ibrahim says, I think this is a Solaris convention. IIRC, /export/home is used on the server where the actual files live, and /home is where the other servers mount it. What does mount | grep home say? I'm guessing that /export/home has a file system type of UFS, and /home has a type of NFS? /etc/fstab may ...
Difference between “/export/home” and “/home”
1,449,536,881,000
What is the difference between directory structure and file system? Unix/Linux directories and file system looks as follows: The following two directories obviously we know directories. /home/abc/xyzdir1 --is a directory /home/abc/xyzdir2 -- is a directory the following three samples are saying file system. /proc...
People don't use file system too carefully. In your examples, I would say that /, /bin and /proc are file systems because an entire partition (like /dev/sdb1) is mounted on those directories. My Arch linux system doesn't have /bin as a file system so this example isn't perfect but... % ls -lid /proc /home /boot / 2 dr...
directory structure vs file system
1,449,536,881,000
One thing that puzzles me about desktop Linux, at least, is that just about everything is in my PATH. By everything, I mean every desktop application, including things like gnome-character-map and glchess. These have no command line interfaces to speak of, so I can't think of a case where I would be regularly launchin...
All the commands that a user might want to run are in the PATH. That's what it's for. This includes commands that you run directly, commands that other people run directly, and commands that you or other people run indirectly because they are invoked by other commands. This is not limited to commands run from a termin...
Why do so many programs live in PATH?
1,449,536,881,000
When installing software compiled from source, I normally place them in /usr/local/, which is by far the most common default in my experience, and standard practice at least on Debian and its derivatives. Now I want to install something in my home directory, and while I could in theory create any subdirectory and plac...
It's fine. Remember, it's your home directory; you can do anything you want in there. GNOME/KDE/whatever might complain if you go around deleting .config, but anything you do in your home directory will, by definition, only affect you. Adding some directories in .local is harmless. Putting something in a dot directo...
Installing files in ~/.local
1,449,536,881,000
One of the things that really slows me down in catching on with Linux is the huge difference between the file system in Linux versus Windows. Up until the last 3-4 years I only used Windows systems and its only been the last 2-3 months that I've really worked at getting accustomed to Linux. I think one of the things...
Have a look at the Filesystem Hierarchy Standard (FHS), which is a standard of organising directory structure. I strongly suspect most (all?) Linux-based systems more or less follow it.
How does the Linux file system/organization differ from Windows?
1,449,536,881,000
I thought the bin directory is the place for binary files. If so, what about script files? Should they be placed somewhere else? What's the history of bin directory and where should I put script files if the bin means binary?
With regard to the meaning of the /bin directory, to quote the intro(0) manual page source from the Unix Research V3 snapshot now available on github and elsewhere: Commands generally reside in directory /bin____ (for bin___ary programs). This same text appears in The Unix Programmer's Manual (implicitly the first ed...
Why the unix bin directory named in that way?
1,449,536,881,000
I found a strange thing while playing with pi3B. I want to create a file in /sys/class/gpio (just poking around, no specific reason) but I get a Permission Denied. Below is some information. pi@raspberrypi:/sys/class/gpio $ groups pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi pi@r...
/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, which is a procfs), which stores and allows modification of the devices connected to the system, whereas many traditional U...
Have group permission but unable to create file
1,449,536,881,000
In Ubuntu 14.04, listing the contents of the directory /var/spool/cron with ls -l provides the following permissions on the directories within (irrelevant columns snipped): drwxrwx--T daemon daemon atjobs drwxrwx--T daemon daemon atspool drwx-wx--T root crontab crontabs What purpose does setting a sticky bit on a dir...
From the manual page for sticky: STICKY DIRECTORIES A directory whose `sticky bit' is set becomes an append-only directory, or, more accurately, a directory in which the deletion of files is restricted. A file in a sticky directory may only be removed or renamed by a user if the user has write permission fo...
Why would a directory have the sticky bit set without the executable bit?
1,449,536,881,000
I noticed that when I install new application there are a few possible directories where the resulting binary file will be placed. You can install with packaging manager, compile with make, easy_install for Python etc. My $PATH looks as follows: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games A...
There is no hard and fast rule but each distribution has its own logic behind putting things where they do. Generally, /bin is used for system binaries, /usr/bin for default applications that comes with the distribution and /usr/local/bin for things that are installed outside of the normal distribution. You can add a...
Directories with binary files in Linux
1,449,536,881,000
When deploying my application under linux, where do I put my libraries, executable and the desktop entry file? And what about other files my program needs? For example background pictures, audio files etc. I heard that I put my executable file in the /usr/bin/ folder, my libraries in the /opt/<myapp>/lib/ folder and m...
The Filesystem Hierarchy Standard specifies where to put files. If you're installing files outside of the package manager, always put them under /usr/local or under /opt. Never touch anything under /usr except via the package manager, except for things under /usr/local. /usr/local/bin: executables intended to be exec...
Deploying my application
1,449,536,881,000
I'm a long-time Windows user in the middle of a multi-year personal migration to Linux-based development. On Windows when I installed an application it got put in the Program Files folder and I'd have the app store the files that I create while using the app in a separate data folder hierarchy that I could back up re...
For Linux, the Linux Standard Base describes the filesystem layout and where and how applications and their data are installed. The LSB references the Filesystem Hierarchy Standard (even though it's terribly out of date) for most items in the filesystem. As a practical matter, you will find that most applications have...
Where to install applications
1,449,536,881,000
Using Bash So let's say I have a bunch of files randomly placed in a parent directory ~/src, I want to grab all the files matching a certain suffix and move (or copy) them to a ~/dist directory. Let's assume for this purpose that all filenames have this naming convention: <filename_prefix>.<filename_suffix> I found o...
It would be a hell to tell find what to do in this case. Better use the shell: for i in **/*.{xrt,ini,moo}; do FILE=$(basename "$i") DIR=~/dst/${FILE%.*} echo mkdir -p -- "$DIR" echo mv -i -t "$DIR" -- "$i" done Use shopt -s globstar to make the ** glob work (or use zsh!). And remove the echos later if the co...
How can you move (or copy) all files to a directory with the same filename prefix?
1,449,536,881,000
Is it good practice to create a directory in /run/shm (formerly /dev/shm) and use that like a temp directory for an application? Background: I am writing black box tests for a program which does a lot of stuff with files and directories. For every test I create a lot of files and directories and then run the program a...
It's perfectly okay to use some directory in /run as long as you have the appropriate rights on it. In some modern distros, /tmp is already a virtual file system in memory or a symlink to a directory inside /run. If this is your case (you can check that in /etc/fstab, or typing mtab), you could use /tmp as your tempor...
use `/run/shm` (formerly `/dev/shm`) as a temp directory
1,449,536,881,000
cp has a useful feature --parents that allows a file's directory structure to be copied to another directory: $ cp -v --parents source/directory/from target/ ‘source/directory/from’ -> ‘target/source/directory/from’ How do I similarly move a file?
Not directly, at least not for GNU mv according to its man page. A possible workaround would be adding a function like this: pmv(){ source=$1 target=${2%/} mkdir -p -- "$target/$(dirname -- "$source")" && mv -- "$source" "$target/$(dirname -- "$source")/" } Add that function to your shell's configur...
Is there a --parents option for mv like for cp?
1,449,536,881,000
If I install an application in Linux for example Debian/Gnu Linux, the files of the applications are copied to many different directories in the file system. Some scripts goes into /usr/share .. /usr/local some other files into /var .. /log .. etc/ and so on. For me this is o.k because I learned something about the fi...
What seems to me the easiest-to-think-of advantage is that similar files live in the same directory tree. Configuration files live in /etc, log files and/or run-time trace files live in /var/log, executables live in /usr/bin, run-time information like PID files lives in /var/run. You want to know what's in the NTP c...
What are the advantages of the Unix file system structure
1,449,536,881,000
I am using Ubuntu. I know by using cd ~/ , I can go to home/ directory. But if I want to go to the directory (I do not know the official name of this directory) which contains etc/, var/, opt/, ... sub-directories, what is the symbol used to refer to this directory? (And by the way what is the official name of this di...
This directory is called the root directory and is referenced by the symbol "/" You can try cd / to go there. Notice that if you try this: $ cd / $ cd .. You're still at the root directory. NB: Every Unix system has a super user account called root, whose home directory is /root. I know it's redundant, it can be amb...
What's the name of the top-level directory
1,468,278,470,000
What is the conventional directory to keep shared scripts that might be used by more than one user? I've read through this overview of the standard file system hierarchy, but it doesn't seem to recommend a location for storing shared scripts. Creating a /opt/scripts directory seems like a reasonable option, but I'd l...
I believe it's /usr/local/bin/ - it's for installing custom, not maintained by package manager executables.
Best directory for shared scripts
1,468,278,470,000
Darwin has a private directory that I don't see in the Unix documentation I've found. Is that a Mac-specific directory? What is it for? Is it preserved between system upgrades?
/private is a container for parts of the standard unix filesystem hierarchy that may vary between individual computers (e.g. /etc is a symlink to /private/etc, where the actual config files are). AIUI this was originally done to support netbooting under NextSTEP. The idea was that / would be a network-mounted shared d...
What is Darwin's 'private' directory for?
1,468,278,470,000
I have seen many tutorials saying that the bin directory is used to store binary files, meaning there is only 0 and 1 in the files in that directory. However, in many cases, I see files in bin that are not only 0 and 1. For example, the django-admin.py under the xx/bin/ directory: #!/usr/bin/env python from django.cor...
No, a bin directory is not for storing only binary files. It's for keeping executable files, primarily. Historically, before scripts written in various scripting languages became more common, bin directories would have contained mainly binary (compiled or assembled) non-text files, as opposed to source code. The main...
Is the bin/ directory for storing binary files?
1,468,278,470,000
After reading the question When you type “ls -a”, what is the significance of “.” and “..”?, I have a similar one. Why to display .? I mean, is there any directory where cd . would not work? How is it helpful to a user to see this line every time?
The reason behind ls -a showing . and .. has nothing to do with utility and everything to do with Unix (and Linux) filesystems. Everything is a file. Directories are really files that contain lists of files. "Inside" any given directory, because that is the perspective of the user, if not exactly the perspective of t...
Why `.` is displayed by `ls`?
1,468,278,470,000
I have read that you should not store /tmp on a SSD, because the frequent writes will shorten the lifetime of the SSD. But what about /var/tmp? Is it reasonable for /var/tmp to be stored on a SSD? Or should we avoid having /var/tmp stored on a SSD, to avoid killing the SSD prematurely?
While it is true that all flash based storage devices have a limited number of writes before the transistor insulation breaks down, it's not as bad as it was when SSDs were first introduced years ago. Basically due to the fact that most modern SSD's employ wear leveling and are based on NandFlash, burning through a dr...
Is it OK to store /var/tmp on a SSD? [duplicate]
1,468,278,470,000
I have a script that gathers debugging info from the running environment and I need to figure out were I can save that info. It may be called anytime: at boot when the system is running at shutdown, etc... and by any user or process / service. I need a folder that is accessible at all time to EVERYTHING. Does that ...
/tmp, but the data stored there will be deleted upon reboot
Is there a folder accessible to all process and users at all times?
1,468,278,470,000
I have downloaded the ChromePlus tarball and extracted it to my home directory. The extracted folder contains an executable that I can double-click to launch ChromePlus. So I assume I do not need to any extra things to install it. I'm new to Linux. Where should I place the ChromePlus directory? It's currently sitting ...
By convention, /opt is used for manually installed programs with self contained directories. Programs in self contained directories will not show up in your PATH by default, but generally this is solved by creating symlinks in /usr/local/bin to any binaries under /opt. As implied above, /usr/local is the other locati...
Where should I place a downloaded tarball?
1,468,278,470,000
Question about wget, subfolder, and index.html. Let's say I am inside "travels/" folder and this is in "website.com": "website.com/travels/". Folder "travels/" contains a lot of files and other (sub)folders: "website.com/travels/list.doc" , "website.com/travels/cover.png" , "website.com/travels/[1990] America/" , "web...
This command will download only images and movies from a given website: wget -nd -r -P /save/location -A jpeg,jpg,bmp,gif,png,mov "http://www.somedomain.com" According to wget man: -nd prevents the creation of a directory hierarchy (i.e. no directories). -r enables recursive retrieval. See Recursive Download for mor...
Wget: downloading files selectively and recursively?
1,468,278,470,000
i am building a webpage where a the user can upload images. i am going to use the file-system to store my images. i was wondering what is the best directory to hold such data? is it /var/ directory? /srv/ directory? or maybe other directory?
There are several factors to consider before choosing a directory path. The best directory is the one that has enough capacity to store the expected volume of files, that has the right level of protection and finally that has no risk to be overwritten or messed by standard packages. /srv/www or /srv/images are fine an...
what is best directory for storing uploaded files / images from my website
1,468,278,470,000
Whenever you type ls -a into the command prompt, you usually get all of your folders, files, and then you see that the first two entries are . and .. Just curious, but what is the significance of these two entries?
. is the relative reference for the current directory. .. is the relative reference for the parent directory. This is why cd .. makes the parent directory the new working directory.
When you type "ls -a", what is the significance of "." and ".."?
1,468,278,470,000
I am trying to mirror the directory and file structure of a particular directory. However, I want the mirrored files to have no size. So for example, if I had the following directory tree: original_folder ├── images │ ├── image1.jpg (2 MB) │ ├── image2.jpg (3 MB) ├── videos │ ├── video1.mp4 ...
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 directories recursively Using find command as OP says xe is on MacOS and cp command has no --attributes-only option:...
How to mirror directory structure and files with zero size?
1,468,278,470,000
Is there a way to do this: "How can I copy a subset of files from a directory while preserving the folder structure?", but without using rsync? Is it possible to be done using only cp, find and grep? I have very limited bash shell (i.e. its a git shell under windows :( ), so rsync is not an option. I know I can get cy...
You can use tar or cpio or pax (if any of these is available) to copy certain files, creating target directories as necessary. With GNU tar, to copy all regular files called *.txt or README.* underneath the current directory to the same hierarchy under ../destination: find . -type f \( -name '*.txt' -o -name 'README.*...
How to copy only matching files, preserving subdirectories
1,468,278,470,000
I'm working on Mac OS X which is shipped with several binaries mostly located in /usr/bin/ and /usr/sbin/. Since it doesn't have a native package manager like some Linux distros, I got used to managing my own binaries, building and installing in /usr/local/<package_name>/. This way, I am able to fully remove a package...
Replacing a system binary should be a last resort. My advice is to: Put /usr/local/bin ahead of /usr/bin and other system directories on the PATH. Make /usr/local/bin/ant a symbolic link to /usr/local/apache-ant-1.8.2/bin/ant. Don't include /usr/local/apache-ant-1.8.2/bin in the PATH at all. This way: Your customiz...
Which is the best practice when replacing a system binary?
1,468,278,470,000
I tried Ubuntu 12.04 and based on my understanding I made the following partitions: 2GB Swap (I have 2GB of RAM) 1GB /boot, since I'll be installing different kernel versions (I'm starting kernel development) 35GB /var 40GB /usr/local 407GB /home 15GB / (root) Now I want to install OpenSUSE 12.2 alongside...
You can share /usr/local. Sometimes the two distributions will have different versions of libraries available, so you may need to install a few libraries on one side or the other or in /usr/local itself. The burden of installing the odd extra library is likely to be compensated by not having to maintain two installati...
Can I share /usr/local between multiple Linux distributions?
1,468,278,470,000
How would it be possible to copy all new contents from one directory to another so that only new files are copied from the source directory (both directories have the same naming tree). For example, here is the layout of directory A: /dirA a.php b.txt subdirA1/ readme.txt co...
rsync was designed exactly to solve this problem: [$]> rsync -av --ignore-existing dirA/ dirB/
How to copy files from one directory to another so that only new files are copied? [duplicate]
1,468,278,470,000
My bashrc issues a cow from cowsay and with a random fortune. Like this: echo -e "\e[00;33m $(fortune -a -o -s | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) | sed -e 's/^/ /g')\e[00m" This works on Linux Mint but I moved to Arch Linux, and the cowfile directory is different now. Is there a standard way t...
cowsay -l lists all avaliable cowfiles. cowsay -l | tail -n +2 | tr ' ' '\n' | shuf -n 1 tail -n +2 removes the first line, which states the path to Cow files that will be used ("Cow files in /usr/share/cows:" in cowsay 3.02-8 in Arch linux), tr ' ' '\n' separates the output into lines and, finally, shuf -n 1 chooses...
Cowfiles directory?
1,468,278,470,000
In which directories should I place the following? I have an application with few .net assemblies, a default database (containing default application settings), a directory with 100's of images, a directory for sounds (e.g. mp3's). e.g. somedir/myapp.exe somedir/myassembly1.dll somedir/myassembly2.dll somedir...
If your application needs to be modifiable by a user, you should not be installing it to the system but have them do some kind of local-install to their user home folder. $HOME/yourapp/{bin,images,sounds} etc. Most system paths like /var, /usr, are not and should not be write accessible by users. The alternative is to...
Placement of application and user files on linux system
1,468,278,470,000
Folder structure: etc (dir) deploy (dir) src (dir) config (dir) dist ├- config (dir) ├- index.js What I'd like to do is pack up everything except the root config folder and place it in a tar in deploy. It's important that the dist/config folder be present in the output. Started with: tar -czf deploy/deploy.gz -...
You could use find to create your arguments - a bit longish though: find -mindepth 1 ! -wholename './config' ! -wholename './config/*' mindepth 1 to exclude ., and two wholename exclutions for the directory itself, as well as its contents. tar -xzf deploy/deploy.gz --exclude="deploy" \ $( find -mindepth 1 ! -wholena...
how do I tell tar to only exclude a directory off of the root but not a directory with the same name deeper in the tree?
1,468,278,470,000
(You can skip the details to the last couple of lines if you're able to answer the question :) ) I'm on an Ubuntu 12.04. I'm trying to resolve an old issue that I've posted about in the past (if you're curious: https://superuser.com/questions/339877/trouble-viewing-files-with-non-english-names-on-hard-disk/339895#3398...
opendir and readdir themselves work on bytes. They do not perform and reencoding. Some filesystem drivers may impose contraints on the byte sequences. For example, HFS+ normalizes file names using a proprietary Unicode normalization scheme. I would expect the form returned by readdir to work when passed to opendir, ho...
opendir and readdir encoding strings behind my back?
1,468,278,470,000
In Mac OS X, there are directories like Desktop, Users and Library. On localized systems, these would be named Skrivbord, Anv√§ndare and Bibliotek (Swedish) But when I am in the terminal I can't type, for example: sudo mv ~/Skrivbord ~/Bibliotek, but instead I have to type their actual names like this: sudo mv ~/Deskt...
Since Finder is built in objective-c it uses nib localizations. Here is an example. /System/Library/CoreServices/Finder.app/Contents/Resources/sv.lproj/ServicesMenu.strings sv.lproj stands for Svenska.localized project Here is the contents of ServicesMenu.strings bplist00”[Finder/Open]Finder/Reveal_Finder/Show In...
How do folder name localizations work?
1,468,278,470,000
I am in a Linux machine and am working with a directory that is aptly named "stealth", because it runs and hides! Take a look at this behavior: bash-3.2$ ls /net bash-3.2$ ls -la /net total 4 drwxr-xr-x 2 root root 0 Jun 19 16:10 . drwxr-xr-x 29 root root 4096 Jun 15 09:51 .. bash-3.2$ ls /net/stealth dir1 dir2 ...
You are seeing autofs behaviour. /net tends to contain directories that are auto-mounted. Auto-mounted directories aren't mounted until you specifically use them. They will stay mounted for a set amount of time, and then if not used in that time period, they are automatically unmounted. Try running man autofs to se...
Strange kind of "stealth" directory on Linux
1,468,278,470,000
I'm talking about files like ~/.foo found on a user's home dir. I'm working on a program that reads from such a file, and I'd also like to clean up my user root directory if I can. Is there a POSIX-specified variable, such as ~/$(conf) where config like .emacs can be found?
POSIX Searching through the specification for the strings "user config" or "configuration files" turned up zero hits, so I would say no it doesn't specify this in any way. http://pubs.opengroup.org/onlinepubs/9699919799/ FHS Looking at the FHS - Filesystem Hierarchy Standard it had this bit: User specific configura...
Is there a standards-specified location for user configuration files?
1,468,278,470,000
I need to look into a particular directory and list the number of files per level. The directory is pretty large, about 10-15 levels deep. For instance, if I have the following: D1 | |-- D2A (5 files in this directory) | |-- D3A (6 files in this directory) | |-- D3B (7 Files in this directory) | |-- D2B (1 file ...
find . -type d | \ perl -ne 'BEGIN{ sub cnt{ $file=shift; $c="find $file -maxdepth 1 -type f | wc -l";int(`$c`) }} chomp; printf "%s %s\n", $_, cnt($_)' | \ perl -ne '/^(.*) (\d*)$/; $_{scalar(split /\//, $1)}+=$2; END { printf "Depth %d has %d files.\n", @$_ for map { [$_,$_{$_}] } sort keys %_ }' Results: Depth 1 h...
Can tree be used to list the number of files per level?
1,468,278,470,000
I know that rc*.d directories are used at startup, or reboot, or so on time, for starting or stopping programs. Can anybody explain me what's the difference between the rc*.d folders placed under the /etc/ path and the other placed under the /etc/rc.d/ path. Also, what's the difference between /etc/init.d and /etc/rc...
Nothing. Different Linux distributions, and the LSB, had different standards, so both are present on CentOS to make it easier to run software from different versions. One is just a symbolic link to the other. http://www.centos.org/docs/5/html/5.1/Installation_Guide/s2-boot-init-shutdown-init.html gives details on th...
What's the difference between /etc/rc.d/rc*.d and /etc/rc*.d
1,468,278,470,000
Is ${XDG_CONFIG_HOME:-${HOME}/.config} enough or there are more tricks to it? Is there maybe some xdg-user-dir CONFIG or xdg-settings invocation that gives me where to expect programs' configs?
${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 whitespace or wildcard in the value of XDG_CONFIG_HOME. If XDG_CONFIG_HOME is unset, special characters in the home directo...
How do I get XDG_CONFIG_HOME from a shell script / command line?
1,468,278,470,000
~ is $HOME. For me, cd ~ is /home/cat. Simple so far, yes? In Bash, the following happens: cat @ mint-kitty : ~/Downloads $ cd ~ # from /home/cat/Downloads to /home/cat/, as an example, but behaviour happens with any directory cat @ mint-kitty : ~ $ cd ~<TAB>proxy/ # oh? what's this? cat @ mint-kitty : /bin $ cd ~<TAB...
A ~user is the $HOME directory for that user. That's the list of directories in ~ augmented by all this (second column): awk -F ":" '{printf( "%15s \t %-20s\n",$1,$6)}' /etc/passwd From man bash (search for "Tilde Expansion") Tilde Expansion If none of the characters in the tilde-prefix are quoted, the characters ...
What's the relevance of these bash completion suggestions?
1,468,278,470,000
I am in a situation where I want to delete some cruft, but there might be some symlinks pointing to the cruft, so I don't want to delete those targets. Is there a command or some switches that will tell me which files and directories have symlinks pointing to them? In my case, I'm only concerned about files/dirs in t...
A file does not keep track of the symbolic links pointing to it. Instead, search for symbolic links under your tree and find out which file/dir they point to using readlink: find -type l -exec readlink -e -- "{}" \+ | sort | uniq Since find's default behavior is recursion, this will work for arbitrary depth.
Find all dirs/files that have symlinks pointing to them?
1,468,278,470,000
I'm writing a local program to be called by a udev IMPORT{program} rule. Normally, I'd install local software in /usr/local, but these udev rules are run when block devices appear. So they're running long before /usr is necessarily mounted. I believe I'll also have to configure this to be copied to initramfs (which is...
I would put these in /lib/udev if provided by a deb package and in /etc otherwise. If you deploy the program on several machines, I recommend making a deb package; it will make deployment and version tracking easier. The Debian wiki has information, or you can read the Debian New Maintainers' Guide (ignoring the non-t...
Where to install local software that runs before /usr is available?
1,468,278,470,000
I'm mainly a Windows guy, programming C#, but I often do use technologies that were intended for Linux machines like git, MySQL, perl scripts, memcached, php, etc... And therefore I am exposed to these tools. I like looking at the code base of these tools every once in a while, and something I realized in many code ba...
What are these files? The $PROJECT/t directory is the canonical place for a project to keep its automated unit tests. How come the folder doesn't have a more descriptive name? By adhering to what is basically a standard naming convention, it is perfectly descriptive of what files go into this directory. Other prog...
What is the 't' folder?
1,468,278,470,000
Ok this may not be a very concrete question, and is perhaps subject to taste, yet I'm struggling to get this right so here it goes. I have a computer. This computer has linux on it (thank god). Arch Linux to be specific (with awesome wm). I am the single user on this computer. As to good practice I've set up two users...
One day you're going to change your computer, or to give someone else (a family member, for example) an account on your computer. If you want to keep a setting on your next computer, put it in your home directory. If the other person might want a different setting, put it in your home directory. If the setting is com...
configuration ethics (esthetics): /etc vs $HOME
1,468,278,470,000
I would like to know in what filesystem mount point I am currently on, similarly to using pwd to know what directory I am in. I know you can use df . (or df $(pwd) or many variants), but I find it somehow overkilling to check the file system usage just to know where I am. So: is there any command showing in what files...
I think df . is your best bet. The filesystem usage check is not that expensive (it doesn't have to count any blocks on disk, that information is readily available and stored in memory once the filesystem is mounted). Alternatives like comparing the current path against mount points by using a script would be more exp...
What filesystem mount point am I currently working on?
1,468,278,470,000
Certain applications like Blender and Eclipse come precompiled in a tarball. Usually I put the directories in my home folder and access them from the command line. Is there a better place to put them and still adhere to POSIX standards (to a degree).
The place for this is in /opt for "Add-on application software packages" - these are packages that do not come with the distribution/OS. http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
Where is a good place to put applications that come pre-compiled?
1,383,413,207,000
This systemd wiki page about the /usr merge, under Myth #6, states that /bin has traditionally been a symlink to /usr/bin on System V UNIX. What is the motivation for this? For backwards compatibility it makes sense, but I don't understand why it was like this in the early days. (Or, am I misunderstanding? Did early U...
The short answers are, yes, it was done for compatibility (lots of programs referenced /bin/sh and /bin/ed), and in the early days /bin and /usr/bin contained totally disjoint sets of files. /bin was on the root filesystem, a small disk that the computer's boot firmware had to be able to access, and held the more crit...
Why does System V traditionally symlink /bin to /usr/bin?
1,383,413,207,000
I know Linux is very permissive and allows customization at many levels but let's said that I have downloaded some .tar.gz files like for example phpStorm and Smargit (both have binaries and libraries used by software) and I want to use them as any other software installed through DNF. Where would you place the uncom...
You should prefer to put your application folders in /opt which is exactly what you are asking for. /usr (apart from /usr/local) is the folder in which the files and folders are maintained by package managers like apt-get for Debian or yum for CentOS. Also, you may want to check Filesystem Hierarchy Standard for Linux...
Where is the best place to put custom software? [duplicate]
1,383,413,207,000
I have family pictures and movies in a folder /media/data/Selbstgemacht and I'd like to find the size of all pictures. In /media/data I use find Selbstgemacht -type f -iname '*.jpg' -exec du -ch '{}' + which returns 5,1GB. However, if I step down into the folder "Selbstgemacht" and use find . -type f -iname '*.jpg' -e...
find ... -exec cmd {} + will execute cmd as many times as necessary so as not to break the limit of the size of the arguments passed to a command. When using find . -exec du {} +, the size of the file list is smaller than when using find verylongdirname -exec du {} +. So it's likely the find verylongdirname will run m...
Why does find -exec du sum up differently?
1,383,413,207,000
On a RHEL 6.5 Desktop, if I use: sudo grep -r foo /* my desktop reboots. Q: Why?? How to debug this? It's the third time my Desktop reboots because of this :D
strace helped, the bad device was the /dev/cdrom
Why does a grep reboot the machine?
1,383,413,207,000
Does Linux/Unix have a unified location for Application files, like "~/Library/Application Support" on Mac OS X? I'm making a Python script that will need to store permanent but changing data, and I want it to work universally.
Have a look at the XDG Base Directory Specification. In your case it should probably be $XDG_DATA_HOME: $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used. Please...
Location of application files?
1,383,413,207,000
I'm installing IntelliJ, and the readme tells me to choose an installation folder. Where is a good, standard place to put installed programs?
If you are the only user of it, just slap it in /home. If not, /opt/intellij. Avoid /usr, which should only be used by distro-managed software. Many source installers use /usr/local by default, but the advantage of /opt/intellij is that you can wipe the entire directory if you no longer have a use for it. Putting it ...
Where should I copy-paste-install software to?
1,383,413,207,000
I noticed that this does not work: /tomcatDirectory/bin $ startup.sh //command not found but this does work /tomcatDirectory $ bin/startup.sh I am used to Windows. It seems counter-intuitive to me that I can not run a program from its working directory, only from the parent folder. What's the bigger picture of wha...
The current directory (i.e., .) is not in your path. Try with ./startup.sh You can check your path with echo ${PATH} You could add the current directory (.) to your path but this is considered a risk (especially if . is before other directories): when typing a command the shell will first try to execute it in the cu...
Why can I only run a .sh file from the parent directory, not the child directory
1,383,413,207,000
This question was asked/answered previously, and I know it's safe to chown on /usr/local for my admin user account, which I've done to install git with homebrew (using brew install git). sudo chown -R $USER:admin /usr/local Now I'm wondering if I should change ownership back to root. Does it matter who owns /usr/loca...
Let's start with some "history". /usr/local is typically used to store user programs/data that were not installed with the base operating system. Commonly, when you make programs from source using automake, they will install somewhere under /usr/local. Because the main operating system itself doesn't rely on this dire...
sudo chown -R $USER:admin /usr/local - revert back to ROOT?
1,383,413,207,000
I use Emacs 23 on my system. I received a file from a colleague (who has a different Linux distro) to add to the /usr/share/emacs/site-lisp/ directory. As I worked to do this, I noticed another, similarly-named, directory: /usr/share/emacs23/site-lisp/. When viewing their contents, I notice that they are not identi...
It's possible to have multiple versions of Emacs installed on the same machine. Only Emacs 23 would load files from /usr/share/emacs23/site-lisp/. All versions of Emacs would load files from /usr/share/emacs/site-lisp/. Generally, you just use /usr/share/emacs/site-lisp/, unless there's some reason the code applies ...
What's the difference between `/usr/share/emacs/site-lisp/` directory and `/usr/share/emacs23/site-lisp/` directory?
1,383,413,207,000
If I only encrypt the home directory, what are some common ways for information to leak out to the unencrypted part of the file system? Aside from the obvious problems like swap space files in /tmp are there any common Linux programs leaking information (those which are nearly certainly part of a normal installation...
Aside from home directories, there are three directory hierarchies with writable data: /etc, /tmp and /var. /etc contains system configuration files, most of which are typically not sensitive. But there can be sensitive data there, e.g. wifi passwords. /tmp can potentially contain sensitive data; just about any progr...
Information leaks out of encrypted file system
1,383,413,207,000
I have noticed that essentially all the files in /usr/bin are stand-alone executables, rather than a directory containing the executable plus other files that the executable might need (such as configuration files, data files, etc.) If I develop an application that consists of multiple files, where should it be saved?...
There are two main ways to organize files from installed software: by package, or by type. Unix systems tend to organize program files by type: executables in /usr/bin, executables that are only useful to the system administrator in /usr/sbin, code libraries and other processor-architecture-dependent files in /usr/lib...
Where should an application be installed if it consists of multiple files?
1,383,413,207,000
I'm working on a FHS2-conforming application that used to store data in $sharedstatedir (i.e. $(prefix)/com, e.g. /usr/local/com). This directory is no more in FHS 3.0, and it seems that we need to start using either /var/lib, which should store Variable state information or more verbosely, state information perta...
You should choose /var/lib. /usr/com does not exist in FHS 2.3 or FHS 3. FHS 2.3 FHS 3.0 sharedstatedir is a concept in GNU autotools and GNU coding standards GNU and freestandards.org do not always align. The issue you mention came up in a 2006 mailing list post. In the case of Red Hat, the conclusion was to use /v...
Where to store shared data in FHS 3.0?
1,383,413,207,000
When writing small utility programs, I sometimes want to keep small amounts of data around between executions, usually for caching purposes, but don't want the program to run as a daemon. Are there any conventions regarding this? Making files in /tmp seems obvious, as it is usually kept in memory, and is only wiped at...
If the program is installed by a system administrator, and it's ok if the data is erased now and then, create a directory under /var/cache. Files under /var/cache can be deleted by the system administrator at any time, but normally aren't unless the system is running out of disk space. Managing /var/cache/YOUR-DIRECTO...
convention regarding offline temporary data
1,383,413,207,000
I see the different folders bin, dev, mnt, proc, srv, sys, etc. What are the properties of all these different folders? What are their purposes? Are there files in some of them that I should not touch? Should I be touching files in the other folders? Final question: in a Unix environment, do folders == directories? I...
Filesystem Hierarchy Standard: http://refspecs.linuxfoundation.org/fhs.shtml GNU coding standards: http://www.gnu.org/prep/standards/ also has policies on directory usage, and sometimes disagrees with FHS "Folder" is a term used by Mac and Windows people to refer to directories. Using it in unix land makes you sound l...
How does the Linux file structure work?
1,383,413,207,000
I have the following folder structure root folder |-al2 |- GER.zip |- ENG.zip |-ww |- GER.zip |- ENG.zip and so on. The folder names are random strings. I want to sort the files in the following way: root folder |-ENG |-al2 |- ENG.zip |-ww |- ENG.zip |-GER |-al2 |- GER.zip |...
Here is a simple bash script: #!/bin/bash for file in ./*/* ; do lang=${file%.zip} # Remove the extension. lang=${lang#./*/} # Remove the folder. mkdir -p "$lang/${file%/*}" # Create the target folders. mv "$file" "$lang/$file" done
Transform directory structure
1,383,413,207,000
Reading Filesystem Hierarchy Standard I was considering those directories: /opt: Optional application software packages. /home: Users' home directories, containing saved files, personal settings, etc. I was more inclined to use /opt but many tutorials use /home (e.g. Archlinux wiki) Question Where should I install ...
Considering /home is generally used for end users' home directories, it is not a good practice to mount general use filesystems in /home, as it may lead to a confusion later on with other sysadmins, whom, one day, will take over this system from you upon your departure for greener pastures. I am not familiar with seaf...
Where should I install seafile-server: /opt or /home?
1,383,413,207,000
All NFS4 tutorials I have encountered so far recommend bind mounting real directories into the export root. Is this a technical necessity? If I had a directory that's only meant to be exported, is it sufficient to make it a subdirectory of the export root or does it really need to be bind mounted?
It's not compulsory. It gives you flexibility to export other filesystems which were mounted at arbitrary locations. I guess it's good practice; it would let you change the "real" mount point of the filesystems without necessarily confusing NFS clients. It's not compulsory to use separate filesystems either, but Fr...
Why do the nfs4 tutorials recommend to bind mount sub directories
1,383,413,207,000
I am searching files who have either been created or modified for the last 60 minuts. I find these via find ~/data/ -cmin -60 -mmin -60 -type f ~ the home directory /usr/wg/ After that I want to copy these files and preserve the main folder structure... The results of the find command are for instance... /usr/wg/data/...
You should rewrite your command on this way: cd ~/data; find . -cmin -60 -mmin -60 -type f to be able to get from find relative paths And maybe something like find ... -exec cp -r "{}" ../vee/ \; will do the work with copy the files with subdirectory structure
Finding files and copy with folder structure intact
1,383,413,207,000
Here is an example of the file structure of a Linux distro: https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-filesystem-fhs.html Each directory has a specific purpose, and seems like a web application should be distributed in different directories rather than being encapsulated in a folder. The initial str...
I am not an expert on this topic, but the original solution I came to by reading the FHS specifications, seems to be actually right (or pretty close), I even found this article, which says that the /opt and /usr/local directories are not necessary anymore with the apparition of RPM's, that article says that those dire...
Where should be located a web application in Linux?
1,383,413,207,000
When building a new software that will store a directory of configuration files in /etc, should the directory be named software_name.d or just software_name? I can't seem to find good style guides regarding this subject. Debian is the primary distribution I have in mind but more general style guides or guidelines are ...
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 configuration. This mechanism is typically equivalent to one where the multiple config files were concatenated to form a single co...
Is the .d notation for folders in /etc recommended or not?
1,383,413,207,000
Suppose I have created two folders in /tmp called parent and child. child contains a file called test-child.txt and parent contains a file called test-parent.txt. Now let's go inside the parent and create a symbolic link to the child. Next, go inside the child and try to copy the test-parent.txt from the parent. The b...
Shells keep track of symbolic links as a convenience for users. This has the nice effect that cd foo && cd .. always goes back to the original directory, even when foo is a symbolic link to a directory. It has two kinds of downsides: the main one is that other programs don't behave this way; additionally, symbolic dir...
copy files from the parent location when I am inside a symbolically linked folder
1,383,413,207,000
Based on the XDG Base Directory Spacifications, $XDG_STATE_HOME should store history and log of the programs. But it is very common to see UNIX programs storing these kind of stuff at $XDG_CACHE_HOME, that is, $HOME/.cache. Why?
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 versions, XDG_CACHE_HOME was the most appropriate location for logs etc. since they arguably qualify as “non-essential...
$XDG_CACHE_HOME vs. $XDG_STATE_HOME
1,383,413,207,000
I was restoring a 200 GB database into a newly installed RHEL machine. However, while restoring I ran into no space available issue. Is it possible to change the directory where the databases are stored?
First, I was able to verify that it was related to space issue only using the below mysql query. mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"' The above command returned me the output as, +---------------------------+----------------------------+ | Variable_name | Value ...
mysql database no space available
1,383,413,207,000
I was trying to install Matlab, and used the following commands: # mkdir -p /mnt/disk # mount -o loop R2014a_UNIX.iso /mnt/disk # cd /mnt/disk # ls -l # ./install However, I don't want it in a directory called disk, I want it in a directory called Matlab using mkdir /mnt/matlab mount -o ro,loop ./R2014a_UNIX.iso...
The best place to install additional software packages in linux is /opt/. So create a directory for MatLab there and install it. # mkdir /opt/matlab # mount -o ro,loop ./R2014a_UNIX.iso /media/cdrom # /media/cdrom/install # umount /media/cdrom As your installer is in the form of an ISO image, mount it in /media/cdrom...
Installing Matlab from an ISO image
1,383,413,207,000
I am using the command: install ./prog /usr/bin to copy the program to the /usr/bin directory. Doing this automatically installs the prog to /usr/bin/X11. Deleting from /usr/bin also automatically removes it from /usr/bin/X11. Does my Linux Mint automatically do this? What is the reason for this feature?
This because /usr/bin/X11 is a symlink to /usr/bin (the dot at the end means the same directory as the link is in ): $ ls -l /usr/bin/X11 lrwxrwxrwx 1 root root 1 May 5 2013 /usr/bin/X11 -> . If you browse or cd to this directory, you are really just looking at /usr/bin.
Why does installing to /usr/bin automatically install to /usr/bin/X11?