Tag Info

Hot answers tagged

55

The switch you need is --parents, e.g.: jim@prometheus:~$ cp --parents test/1/.moo test2/ jim@prometheus:~$ ls -la test2/ total 42 drwxr-xr-x 3 jim jim 72 2010-09-14 09:32 . drwxr-xr-x 356 jim jim 43136 2010-09-14 09:32 .. drwxr-xr-x 3 jim jim 72 2010-09-14 09:32 test jim@prometheus:~$ ls -la test2/test/1/.moo -rw-r--r-- 1 jim jim 0 2010-09-14 ...


36

Use the -R or --relative option to preserve the full path.


36

So sorry, I should've RTFM ... http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.add.html You can add a directory without adding its contents: $ svn add --depth=empty otherdir A otherdir Edit: This doesn't work recursively though, is there any way to do that too?


33

According to the FHS, /usr is for shareable, read-only data - not where you want to put the website. This is where you should put your code (for example Fedora does this for Wordpress). See also the web assets packaging guide for Fedora. /var is "variable data files. This includes spool directories and files, administrative and logging data, and transient ...


32

Just to map a network share directory you would use this command: net use \\Server\ShareName\Directory This mapping would not be persistent and would have to be established and authenticated at user login, and you would access the share using the UNC path and not a local drive letter. If you want to access the network share through a location on your ...


32

How deep do your subdirectories go? /var/log/basedir/*.log /var/log/basedir/*/*.log { daily rotate 5 } Will rotate all .log files in basedir/ as well as all .log files in any direct child of basedir. If you also need to go 1 level deeper just add another /var/log/basedir/*/*/*.log until you have each level covered. This can be tested by using a ...


31

You don't. At least not just like that. The preceding line in the quoted document is of importance: Set up your prompt to do a pwd everytime you cd. Always do a cd . before doing anything. This way, you as the operator verify your current working dir before doing anything of importance, as it's printed out with each change. cd . doesn't make ...


28

Strangely enough /usr actually means Unix System Resources. "The "etc" in "/etc/bin" really does stand for "etcetera." In early Unix systems, the most important directory was the "bin" directory (short for "binaries" -- compiled programs), and "etc" was for trivial stuff like startup, shutdown and admin. The list of things you need for running Linux is: a ...


28

(Note: ~ translates as /home/user in this post) Personally, I put all of my custom-made system scripts in /usr/local/bin and all of my personal bash scripts in ~/bin. Very few programs I install place themselves in /usr/local/bin directory so it's not very cluttered and it was already in the $PATH variable on most of my machines. To add /usr/local/bin to ...


28

Whilst a major cause of this problem is ext3 performance with millions of files, the actual root cause of this problem is different. When a directory needs to be listed readdir() is called on the directory which yields a list of files. readdir is a posix call, but the real linux system call being used here is called 'getdents'. Getdents list directory ...


24

Would it be possible to backup all of the other files from this file system to a temporary storage location, reformat the partition, and then restore the files?


23

For more data on the layout of Linux file-systems, look at the Filesystem Hierarchy Standard (now at version 2.3, with the beta 3.0 version deployed on most recent distros). It does explain some of where the names came from: /bin - Binaries. /boot - Files required for booting. /dev - Device files. /etc - Etcctera. The name is inherited from the earliest ...


22


19

Take a look at the Filesystem Hierarchy Standard (Wikipedia). I myself use /srv/www/$domain/{htdocs,logs,cgi-bin,...}.


18

The data=writeback mount option deserves to be tried, in order to prevent journaling of the file system. This should be done only during the deletion time, there is a risk however if the server is being shutdown or rebooted during the delete operation. According to this page, Some applications show very significant speed improvement when it is used. For ...


18

The main difference between both, is that /tmp is wiped whenever the system reboots where as /var/tmp gets preserved across reboots. You'll be able to find further information regarding linux standard directory structures at the following link : http://www.pathname.com/fhs/pub/fhs-2.3.html#VARTMPTEMPORARYFILESPRESERVEDBETWEE.


17

If you're considering scripting it, it's always helpful to learn about the pushd and popd commands. Sometimes you can't be sure what drives letters are already used on the machine that the script will run on and you simply need to take the next available drive letter. Since net use will require you to specify the drive, you can simply use pushd ...


17

Historically, /etc stands for "etcetera" and /var is short for "variable." I suppose the former is because a large collection of unrelated system configuration files go into /etc. The latter is because the files in /var are expected to change. You can often mount /usr and / as read-only (except when performing updates), but you can never mount /var ...


17

If the current working directory of your shell is removed, it is possible to lose data. For example, $ pwd /home/user/test $ rmdir /home/user/test $ pwd /home/user/test $ some_command | tee command.log tee: command.log: No such file or directory <long output> The output of some_command was not written to the disk. Typing cd . before running a ...


16

This really depends on how you are going to restore your system. If you will rebuild then you only need the configuration/data files for your services (eg: /etc, /opt, /var, /home) If you are after a full system restore, then it you could omit /proc, /boot & /dev. Then you can install the minimum OS from your boot media and then restore your system via ...


16

You're looking for diff -rq (dir1) (dir2) Proof of concept: #!/bin/sh #create our test mkdir -p /tmp/a/b echo "test" >> /tmp/a/c mkdir -p /tmp/a/d/e echo "blah" >> /tmp/a/d/e/f #only exists here mkdir -p /tmp/q/b echo "testing" >> /tmp/q/c #/tmp/a/c shouldnt match mkdir -p /tmp/q/d/e echo "blah" >> /tmp/q/d/e/g #only exists here ...


16

You might find the output from "man hier" fascinating


16

I know it's not the answer you're looking for, but I believe the correct solution is to avoid depending on the ordering of files in a directory. Maybe it's always consistent across all HFS+ filesystems, and maybe you could find a way to make it consistent in ext4 or some other filesystem as well, but it will cost you more trouble in the long run than it will ...


15

One option is to use unionfs Unionfs: A Stackable Unification File System This project builds a stackable unification file system, which can appear to merge the contents of several directories (branches), while keeping their physical content separate. Unionfs is useful for unified source tree management, merged contents of split ...


14

Use find to select the directories and wc to count them. find <directory> -mindepth 1 -type d | wc -l


14

That limit is per-directory, not for the whole filesystem, so you could work around it by further sub-dividing things. For instance instead of having all the user subdirectories in the same directory split them per the first two characters of the name so you have something like: top_level_dir |---aa | |---aardvark1 | |---aardvark2 |---da | |---dan | ...


14

Use --compare-dest. From the man page: --compare-dest=DIR - This option instructs rsync to use DIR on the destination machine as an additional hierarchy to compare destination files against doing transfers (if the files are missing in the destination directory). If a file is found in DIR that is identical to the sender's file, the file will NOT ...


14

lftp should be able to do this in one step, in particular with lftp mirror: EDIT: the lftp command syntax is confusing, original invocation I posted doesn't work. Try it like this: lftp -e "mirror -R {local dir} {remote dir}" -u {username},{password} {host} note the comments around the arguments to the -e switch.


14

Does anybody have any best practices for how to organise a folder structure? Don't. Believe me, you don't want to own the folder hierarchy for any department (except maybe your own). You don't know what their needs are, don't have the knowledge or experience of other departments to make good choices, and don't want to be the company's file janitor. ...



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