A file system structure in which to store computer files.

learn more… | top users | synonyms

1
vote
2answers
111 views

Is there a problem if I add a non-existing path to `PATH` environment variable?

I have a following lines in my .bash_profile. if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi I think I found it somewhere in the internet. Is it also ok, if I write only ...
1
vote
3answers
66 views

Can tree be used to list the number of files per level?

As title, 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 | |-- ...
2
votes
3answers
1k views

cp --no-target-directory explained

Question: I need a simple example of how to use cp --no-target-directory. I do experience some difficulties in understanding cp --no-target-directory. I do understand the explanation for mv ...
1
vote
2answers
885 views

Resetting user directory permissions etc [closed]

My "Linux mint Debian edition" installation worked well until I used a live-CD to boot and then copied some files back and forth to and between the hard drive and a usb device. Now it says that it is ...
1
vote
2answers
197 views

How to find certain files and move them to a new directory in the same command?

So I was looking around and all I have found is how to do this only if the directory is already made, which is this: find source -name '*.z' -exec cp {} destination \; But how can I make a new ...
2
votes
2answers
53 views

Directory permissions vs file permssions

If I have two users called john and sally. Both are part of the users group. john creates a directory with permissions 775. sally then puts a file there with 644 permissions. Even though the file ...
4
votes
2answers
595 views

Recursively add a file to all sub-directories

How do I recursively add(or touch) a file into the current directory, as well as all sub-directories? For example, I would like to turn this directory tree: . ├── 1 │   ├── A │   └── B ├── 2 │   └── ...
4
votes
1answer
357 views

How search for a file beginning with either a or z and ending with a or z?

I attempted find -name 'a*' 'z*' '*a' '*z' but it gave me the error code find: paths must precede expression: z* I know how to find files starting with a though z, or ending with a-z, but not ...
1
vote
1answer
90 views

How to change mountpoint name?

This question has been asked before, but because I have a few more doubts about the process. I am working in ubuntu, this is what df -h shows: Filesystem Size Used Avail Use% Mounted on ...
3
votes
3answers
299 views

How to create a short path?

We have so many useful folders, which are in different path, for our working in Linux. For example : $ cd ~/Documents/Courses/EDX/physics2013/ $ cd ~/Documents/Company/OpenGL/Proj/... $ cd ...
1
vote
1answer
264 views

Process owned by root can't write files

I'm running a program (syslog-ng) that must read and write several files in a given path. It was failing at start, claiming that it is unable to open a file in that path. Please, assume this ...
0
votes
1answer
80 views

Recursively Move All MP3's in a Directory [duplicate]

I have a lot of mp3 files located at various levels of subdirectories inside a single folder and I want to move them all to a single directory, what command could I use to do this? Thanks!
1
vote
2answers
546 views

Check recursively if directories in a path exist

I want to check recursively if directories in a given path exist; if they do not, I want to create them. So if I have the path /dir1/dir2/dir3/dir4, if want to check first if dir1/ exists, and if not, ...
1
vote
1answer
688 views

mount.cifs not respecting file permissions in Ubuntu 12.04.2 LTS

I am attempting to mount a cifs drive in standard Ubuntu 12.04.2 LTS using the following line in /etc/fstab: //server-name/share-name /mnt/archive cifs ...
3
votes
2answers
55 views

Is there a way to condense ../.. parts of a path out programatically?

Say for example I have these types of paths to files in a script: /path/to/some/file/../../file1.txt Is there a command I can call such as readlink that will convert this path to its actual ...
2
votes
2answers
528 views

\uFFFD character in directory name

I have a lot of directories with a \uFFFD (65533) character in it. The problem is that I can't really access this directory because of this character. For example I got a directory with the name: ...
6
votes
4answers
353 views

set read and write permissions to folder and all its parent directories

I need to set read and write permissions for root user to directory subfolderN and all its parent folders till root. I can do it by hands: $ sudo chmod +rx /root/subfolder1/subfolder2/subfolderN $ ...
21
votes
9answers
2k views

What's the most resource efficient way to count how many files are in a directory?

CentOS 5.9 I came across an issue the other day where a directory had a lot of files. To count it, I ran ls -l /foo/foo2/ | wc -l Turns out that there were over 1 million files in a single ...
2
votes
1answer
83 views

bash - inherit directory stack in children

If, in my newly created bash, I do: pushd foo pushd bar dirs -l -v I will get something like 0 bar 1 foo 2 old_dir If I then do bash dirs -l -v I get only 0 bar The same thing happens ...
3
votes
2answers
840 views

Automatically moving files to a directory, one by one, and only when the target folder is empty

Is it possible? And in reverse alphabetical order? Essentially, this: How can I move files by type recursively from a directory and its sub-directories to another directory? Except that each file is ...
0
votes
0answers
31 views

Howto get the “relative size” of two directories [duplicate]

Consider two directories dirA and dirB. Suppose dirB consists to a part (P1) of hardlinks which points to files in dirA and to a part (P2) of files which are not hardlinked to files in A. Is there a ...
3
votes
3answers
682 views

Merging two directory without copying the files

Let's say I have as follows : Folder A C1 file a A2 Folder B C1 B2 file b B3 What I want is to merge these two folders, which would give me : Folder C ...
1
vote
1answer
85 views

If I hardlink to a directory, will the contents be “preserved” as if I hard-linked to every file?

I've seen people on the internet talk about using hardlinks to force files to stay on disk as a backup, even if they're deleted in their original location. Would this work for a directory too? Why or ...
1
vote
3answers
224 views

Group+rx permission only in directories using ACL?

I need to install acl in order to set up a very specific permission structure. Group members should be able to see the files in a directory and change into the subdirectories. However, they should not ...
2
votes
2answers
339 views

In Linux, is 'make folder/path/clean' same as running 'make clean' command in folder/path?

I'm new to Linux, more so for Makefile. In Linux, is 'make folder/path/clean' same as running 'make clean' command in folder/path/? (folder/path/ refers to an arbitrary directory.) Apart from this ...
1
vote
2answers
898 views

Find and move directories based on file type and date

I have a directory "New Movies" containing 200+ subdirectories "Movie Name (year)". The subdirectories "Movie Name (year)" contains a single video file (avi/mkv) and several related jpg/xml files. I ...
0
votes
2answers
403 views

Delete all files except certain subfolder [duplicate]

I want to recursively delete all files not accessed in a while in folder a, except all files in the subfolder b. find a \( -name b -prune \) -o -type f -delete However, I get an error message: ...
5
votes
1answer
544 views

Why is this empty directory 3.5MB?

I've just read this question: What does size of a directory mean in output of 'ls -l' command? ...which doesn't quite answer my question. Basically, I'm moving files onto a NAS. The folders ...
3
votes
3answers
1k views

How to determine how many files are within a directory without counting?

I've been having a fairly serious issue on a high traffic web server. PHP pages are slowing down considerably, and it only seems to be an issue on pages where sessions are accessed, or a certain table ...
20
votes
8answers
10k views

How do I loop through only directories in bash?

I have a folder with some directories and some files (some are hidden, beginning with dot). for d in *; do echo $d done will loop through all files, but I want to loop only through directories. ...
4
votes
3answers
111 views

How to condense subdirectories

I have one directory with many sub-directories. All of those sub-directories contain files which each have unique names. I want to take all the files from all of the sub-directories and move them all ...
3
votes
2answers
137 views

Preventing accidental directory deletion. Making an alias that contains options?

I use an alias to prevent me from accidentally deleting files, and I would like to do something similar for directories. For files, I have the following added to my .bashrc: alias rm="rm -i" I ...
7
votes
1answer
193 views

Boot into a chroot?

I have Linux (Debian Jessie) installed on a hard drive. Drive - sda1, ext4fs, and sda2 - swap I have a /chroot folder. There is installed another system, in /chroot folder. Question: How to tell ...
1
vote
0answers
36 views

Directory size as reported by stat on NTFS

We all have seen gazillions of directory size reports from ls or stat. We know they don't mean real size of the content, but they do have meaning, but since the meaning is not very useful for normal ...
2
votes
1answer
272 views

Allow world access to directory under 0750 directory

I prefer to keep my /home/dotancohen/ directory as permissions 0750. However, I do need Apache to access /home/dotancohen/someProject/public_html/. I know that I could configure the home directory as ...
4
votes
2answers
54 views

List all directories that do NOT have a file with a given file name inside

How would I go into listing all directories that do not have a file with a given file name inside? e.g. given this tree / /a README file001 file002 /b README file001 /c ...
2
votes
5answers
161 views

List a directory but only if it contains sub-directories?

In Unix, is it possible to use one command ONLY to list directories if they contain a sub-directory? For example, I would like to list the directory name if it contains a sub-directory called ...
1
vote
3answers
77 views

Mode to set Directory in Only READ-WRITE mode

Can anyone tell me how to set a directory only in read/write mode as below? -rw-rw-r-- I tried with 640,644 but I am able to achieve...
3
votes
2answers
122 views

How to make directory modication date change when files from that dir change?

For example, if a file has been changed in that directory, then directory modification date should be updated. Basically any changes that happen in that directory should trigger a "touch" on the ...
0
votes
2answers
539 views

How to create nested directory in a single command? [duplicate]

Apparently, it's not possible to create a nested directory in a single command? $ sudo mkdir x/y/z mkdir: cannot create directory 'x/y/z': No such file or directory
11
votes
1answer
7k views

Create a symbolic link relative to the current directory

I'm trying to create a symbolic link in my home directory that points to a directory on my external HDD. It works fine when I specify it like this: cd ~ ln -s /run/media/name/exhdd/Data/ Data ...
3
votes
1answer
684 views

How to download all html files from a URL's directory with wget?

I'd like to use wget to download a tutorial in a website, but this tutorial is in a specific directory. Suppose the URL is the tutorial main page http://www.abc.com/aaa/bbb/ccc/index.html. But the ...
2
votes
2answers
45 views

Average number of subdirs

I have a directory which contains a number of subdirs. Each of these subdirs again contains a number of subdirs (call them subsubdirs). Now I would like to count the average number of subsubdirs in ...
0
votes
2answers
57 views

chowning each home user to itself recursively

Okay so I have about 100 directories in my home folder each owned by the home user itself. Sometimes I have to manually replace some files as root so the permissions are disturbed and some files are ...
1
vote
3answers
59 views

Rename directory from within directory?

How would I rename a directory from within that directory? For example: ~/tmp $ rn tmp2 ~/tmp2 $ I can do that with: cd .. && mv tmp tmp2 && cd tmp2, but not sure how to make it ...
0
votes
1answer
373 views

Find and remove sub-directories without error?

I need to find a way to remove sub-directories from within a particular directory without receiving an error if no sub-directories exist. This command will successfully remove sub-directories if they ...
1
vote
2answers
1k views

Cheapest way to find the oldest file (recursively) from a directory under heavy load

What is the least expensive way to find the oldest file in a directory, including all directories underneath. Assume directory is backed by SAN and under heavy load. There is concern that "ls" could ...
2
votes
3answers
184 views

Safer way for granting permissions for self user?

I know sometimes we can do chmod 777 so we have a directory at our complete reach for accessing, reading and writing. But usually I prefer to do a sudo chown {myusername} {directory}. Obviously, the ...
3
votes
3answers
196 views

Quick access to work directory of background job

Minimal effort to reproduce what I am looking for, is as follows /$ sleep 1h & [1] 6564 /$ cd ~$ jobs [1]+ Running sleep 1h & (wd: /) When I use jobs to manage my ...
1
vote
2answers
50 views

Copying Files in a Folder To Individual Folders

This might sound like something quite odd but for my HTPC, I need to rearrange how my files are stored such that each of the individual files in a folder needs to be moved to a subdirectory of its own ...