Questions tagged [directory]

A file system structure in which to store computer files.

Filter by
Sorted by
Tagged with
9
votes
3answers
27k views

bunzip2 to a different directory

Say I have a file foo.tbz2 in a directory. I want to extract the tar file from the archive, but to a different directory. It seems like bunzip2 will only extract the archive to the same directory as ...
0
votes
1answer
29 views

script with suid set but not working! [duplicate]

I have a simple script that runs fine under an app ID (just touches a new file), which I am trying to get to call via my personal ID. Note the target file location is in an area that my personal ID ...
167
votes
13answers
234k views

Find the total size of certain files within a directory branch

Assume there's an image storage directory, say, ./photos/john_doe, within which there are multiple subdirectories, where many certain files reside (say, *.jpg). How can I calculate a summary size of ...
17
votes
3answers
19k views

Problem with install command to copy a whole directory

So I have a repo with some of my config files and I'm trying to create a makefile to install them in the homedir. The problem I have is that when I run the following command straight in bash install -...
-2
votes
1answer
40 views

Create a counter in a shell script that will increase every time when a file from the current director have more than 8 lines? [closed]

How can I create a counter in a shell script that will increase every time when a file from the current director have more than 8 lines and after how can I generate two lists, one of this with the ...
7
votes
4answers
14k views

Symlink all subdirectories in a directory to another directory

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
0
votes
2answers
72 views

Compare large directories recursively - but ignoring sub-directories - compare two backups - with gui

I've got 2 very old Backups of a friends computer. They were simply copied into a folder each on an external Harddrive. Both are about 300GB in Size and the contents are very much alike but not ...
3
votes
2answers
84 views

How to make a text file in every subdirectory so that the text file contains name of the directory

I have 5 empty directories: [X]$ ls dir_1 dir_2 dir_3 dir_4 dir_5 How can I make a text file in every one of these directories so that the text file would contain the name of the directory it is ...
1
vote
1answer
13k views

Without changing your current directory, create an empty file in another directory in Linux?

Suppose my current working directory is: /Users/Directories Under Directories, there are two separate directories called: firstname & last name. I move into the first name directory: $ ...
0
votes
2answers
35 views

Moving directories into subdirectories based on first character

I would like to move directories into another location and into subdirectories by first letter. For example: ./alpha would move to /otherdir/a/ ./beta would move to /otherdir/b/ All the subdirectories ...
0
votes
1answer
39 views

2 programs in different directories with the same name: what happens when I type that name?

I am a beginner in this field, and this is a question from a quiz we were handed in class. Could you guys help please? Question: "Two programs, in different directories, have the same name. One is a ...
-1
votes
0answers
28 views

How To Copy Directory To File in Unix

I'm trying to copy directory with new file. when to copy in this way : cp -r dir newfile/ It only copies the directory, but I want to copy to file.
1
vote
1answer
33 views

How to copy specific subdirectories to a new directory?

I am trying to copy specific subdirectories (and the files contained in them) to a new directory. Assuming I am in the first directory (dir0/), this contains a number of subdirectories named 000/, 001/...
0
votes
0answers
14 views

CentOS 7 Directory Permissions Not Working As Expected [duplicate]

As shown below, jamal is giving every body full access to his temp1 directory in his CentOS 7 home directory. [jamal@localhost ~]$ mkdir temp1 [jamal@localhost ~]$ [jamal@localhost ~]$ chmod a+rwx ...
155
votes
8answers
296k views

How to recursively find the amount stored in directory?

I know you are able to see the byte size of a file when you do a long listing with ll or ls -l. But I want to know how much storage is in a directory including the files within that directory and the ...
0
votes
0answers
11 views

Mate terminal GUI: set title to directory name

Using the Edit > Profile preferences > Title and Command in Mate Terminal, I can change the initial title to whatever I want... Except... Can I actually change it to something useful, namely the ...
4
votes
3answers
1k views

Removing dirs with lots of tiny files on Lustre

I have a dir with a gigantic amount of very small files that I want to remove and simply removing the dir with rm -rf /path/to/the/dir is already taking multiple days. It might sound strange that ...
0
votes
3answers
29 views

How to pass a string containing slashes to sed without treating it as a file? (No such directory or file)

I need to pass a string containing slashes to sed to extract some values from it, but when I try to do so it treats it as a directory/file and throws a "No such directory or file" error instead. I'm ...
0
votes
0answers
23 views

Cp: target is not a directory, but cd works [duplicate]

I'm trying to copy a bunch of files using the cp command. cp images/*.png "~/dataset/" which returns cp: target '~/dataset/' is not a directory however, if I use cd ~/dataset/ I can get into the ...
0
votes
0answers
22 views

How does my shell know when the current working directory has been moved?

If I am in a directory /foo, and I move (from a different session) /foo to /bar. If I then go back to the session in /foo and run ls, the files are still there, and I can see new files if they are ...
1
vote
1answer
15 views

file disappears while moving because I typed the wrong directory

While moving a file, I typed $ mv aaa.txt directory instead of $ mv aaa.txt ../directory and now I don't know where aaa.txt has gone. How can I find it?
0
votes
1answer
19 views

Delete (corrupted?) directory?

I have an Ubuntu 16.04 with a cephfs mount shared with another 2 Ubuntus. There is a folder inside the cephfs mount that won't answer to any command (ls, cd, rm, du...). So I guess it's corrupted or ...
79
votes
7answers
43k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
1
vote
1answer
2k views

Copy directory with SCP

I'm trying to copy directory from local drive to remote server with -r parameter, however I'm getting: scp: System error: 1633648 (Failed to retrieve error string (err:317)) This is the syntax I use:...
0
votes
1answer
25 views

How to remove a directory symlink without breaking files that depend on it?

For the sake of simplicity, suppose the following situation, where folder is a symlink to new_folder: . ├── folder -> new_folder/ ├── new_folder │   └── test.sh └── exectest.sh The contents of ...
2
votes
1answer
60 views

Why does my terminal emulator open in directories other than my home directory?

Every so often, after a day or so of uptime, my terminal emulators (I've tested multiple) begin opening in a directory other than $HOME. I'm running Fedora 32 (though this happened on previous ...
6
votes
3answers
3k views

Delete files in a directory which are also in another directory

I copied a directory using this: cp -r dir/ ../../ without thinking and realized that it copied the contents of dir instead of actually dir to the above directory. Now I have a mess of files I need ...
0
votes
2answers
43 views

Make folder undeletable by non-root but should be writable

I have some folders on an ext4 file system on my Ubuntu machine that I don't want to accidentally delete during normal course of operation as a non-root user. I should be able to move or create or ...
0
votes
1answer
31 views

I accidentally deleted var directory in my linux opensuse system. I can't acces the GUI as var/lib/gdm also got deleted

Message shown: Server authorization directory (daemon/ServeAuthDir) is set to /var/lib/gdm but this doesn't exist.
2
votes
2answers
34 views

How to find same filename but different content

I am trying to find the textfiles that have the same name but contain different content from two different directories. The following is my code but it keeps crashing here cati=`ls $1 | cat $i` ...
0
votes
2answers
43 views

How to allow Steam to write into root directory?

I've just installed the latest Linux Mint version and I'm trying to set up some Steam games. I only have 10 GB on my home directory, so I'm willing to create a game library inside the root directory (/...
0
votes
0answers
17 views

The same linux permission characters but with different numbers [duplicate]

I have two different folders in my directory with the following permissions: file x: drwxr-xr-x 2 , file y: drwxr-xr-x 5. What is the permission difference between these two folders? why one has ...
0
votes
1answer
27 views

read-only file system error tryng to mkdir into a windows containing HDD from a broken laptop

I just broke my laptop (running Windowns 10) which is the one that I use for music making. I've got another laptop without HDD and my plan was to mount the HDD into this second laptop and try to ...
0
votes
1answer
45 views

How preserve just read permission from an original file to a symlink?

I make a copy file, from directory A, as a symlink in directory B and I need to preserve just the read permission from original file to symlink. like this example: original file have –rwx-wxr-x, link ...
0
votes
2answers
32 views

Give the permissions to modify files only for the owner in a specific directory

I have 4 users: A, B, C, D and a directory : folder10; I want to give A and B acces to folder 10, and whenever someone create a file in this folder, he will be the only one who can modify it, the ...
1
vote
1answer
62 views

How to copy multiple files from one directory to another

I want to copy multiple files from one directory to another. I have a variable (files) that contains the following structure: file1 file2 File1 and file2 are in dir1 and I want to copy them to dir2 ...
-1
votes
3answers
102 views

How to create directory with a certain size? [closed]

How can I create a directory with a certain size? I need an empty directory with atleast 15MiB, and it must be in the /tmp directory. My assignment sounds like that: You're supposed to create ...
4
votes
2answers
8k views

rm -fr not working

I have a directory that was generated by mistake by an application and this directory has a structure that involves more than 2000 directories, one inside a another, something like: Directory aaaa ...
16
votes
7answers
29k views

How do I change folder timestamps recursively to the newest file?

I was wondering if anyone knows how to change the timestamps of folders recursively based on the latest timestamp found of the files in that folder. So for example: jon@UbuntuPanther:/media/media/...
1
vote
2answers
103 views

Using regular expression with find&replace in vim

I am wondering how to use regular expression to specify directories to be found and replaced inside vim. For example: Changing the default DocumentRoot and Directory in httpd.conf. Normally I use ...
0
votes
2answers
27 views

Creating nested directories

I want to write a bash script that will get a command line argument and create nested directories under the user home directory. E.g a/b/c mkdir -p $1/$2/$3 But I want create not just three levels ...
1
vote
1answer
35 views

How to properly exclude directories in find?

According to this question: How to exclude dirs in find, the command should be this: find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print But if I do find . -type d \( -...
1
vote
3answers
209 views

Delete set of folders contain more than one '-' in different places as a part of their name

How can I delete many folders that have more than one - in their names? For example: e97bf913-5759-4fff-bdaf-2f931b53a432/ 39f953c5-dab0-420e-a650-a50a30f48097/
1
vote
4answers
27 views

Generate tex file containing all filenames in a directory

I have a folder containing 95 tex files. I need to create a tex file all.tex that contains the following code: \documentclass[10pt]{article} \begin{document} \input{file1.tex} \input{file2.tex} ... \...
86
votes
5answers
77k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Does the star in front of ls mean how deep it will list the ...
0
votes
1answer
40 views

Shell script backup directory and check file if exists

Before copying the resulting backup file to directory, script should first check to make sure there already isn’t a file with the same name (this is my first time writing a script) #!/bin/bash time=$...
0
votes
2answers
43 views

Shortcut for quick directory navigation in the bash shell [duplicate]

I'm looking for shortcuts that would help me to navigate directories quickly and efficiently.
16
votes
6answers
19k views

Move every file that is not a directory

I have a directory that I am trying to clean out that contains both files and subdirectories. What I am trying to do is simple: move all the files into another directory, but leave all the sub-...
2
votes
2answers
26 views

Order directory by a date string of a file inside this directory

I'm having a headache with this. I'm trying to order a number of directories by a file which is within this directory which contains the creation date of the backup. This is for order my backups, i ...
85
votes
6answers
38k views

How can I create a /dev/null-like “blackhole” directory?

I would like to create a "/dev/null" directory (or a "blackhole" directory) such that any files written to it are not really written, but just disappear. I have an application that writes out large ...

1
2 3 4 5
31