Hot answers tagged

19

1. Automatically change folder icon into the first found image inside The python script below will change the icon of all folders inside a directory (recursively) into the first found valid image file inside the folder. The script #!/usr/bin/env python3 import subprocess import os import sys # --- set the list of valid extensions below (lowercase) # --- ...


16

That's not an error - it's telling you that you do not have permission to read the files in that directory as a normal user as you will see if you click on it. If you want to see the contents of the directory you must do so as root. In a terminal type: sudo -i nautilus You notice that you have to enter your password. Now you have root privilege you ...


9

Let us say you want to start find in the current directory, and restrict it to the first level of subdirectories: find . -maxdepth 1 The find command has a useful flag -not (or !) which negates the following test. So in order to find a name which does not contain a substring, add -not -name "*substring*" IMPORTANT: you will want to exclude the current ...


4

If you don't want to empty the directory first, you can use rm -r to recursively remove directories and their content. Please note also that this is already explained in the documentation. rmdir: The rmdir command will delete an empty directory. To delete a directory and all of its contents recursively, use rm -r instead. Since you are not an ...


4

The bash shell's extended glob operators can do pattern negation e.g. given $ tree . . ├── subdir │   ├── other file │   └── somefile ├── subdirbar │   ├── other file │   └── somefile ├── subdirbaz │   ├── other file │   └── somefile └── subdirfoo ├── other file └── somefile 4 directories, 8 files then if extended globbing is enabled (shopt -s ...


4

Short answer: The number of links to a directory is at least two: The link to the parent directory The link to itself See also here: The number of links is the number of hard links to the file. For a directory, the number of hard links is the number of (immediate) subdirectories plus the parent directory and itself.


3

This is normal ... the X indicates you do not have permissions to view root folder ... If you want to use the file manager (nautilus) while logged in as root then from a terminal issue sudo -i then in same terminal issue nautilus once there you can see there is no longer the X


3

One way would be to use find's -exec action to execute a custom test of the number of files. One could use a second find command along with wc to find and count files within each directory, but probably a better option would be to shell globbing to slurp the filenames into an array, and then return a logical value indicating whether the size of the array is ...


3

If you want to remove an entire directory with everything in it, you can use rm -r like dadexix said and if you really want to make sure add the f for force rm -rf i Always do that and it Always works


2

You could use tree to see the visual structure like: tree folderA tree folderB or you could use diff to see what files are different in each subfolders diff folderA folderB


2

Turn on the autocd option (shopt -s autocd), so that you don't have to type cd. For example, you just need the two-character command .. to go to the parent directory. If you're navigating between two directories, you can toggle between them with cd -, which goes to the previous working directory. The autocd option doesn't make - run cd - but you can define ...


2

It happens presumably because you tarred the whole public_html directory and its name is in the archive. You can use the --strip-components argument to cut off the head of the path when extracting. In your case: tar -xvzf --strip-components 1 orbit.tar.gz To remove the public_html/ and extract files directly into the current directory. 1 in the above ...


1

When you created /var/www/orbitcode/public_html/orbit.tar.gz you missed the message that told you tar: Removing leading `/' from member names Use tar tf /var/www/orbitcode/public_html/orbit.tar.gz to list the member names. To correct for the current situation (use sudo to taste), cd /var/www/orbitcode/public_html # Assume extracted files must ...


1

This is definitely possible. First, change /db-data's group to app-data: sudo chgrp -R app-data /db-data Now set up the permissions: sudo chmod -R g+rwx /db-data sudo chmod -R g-w /db-data/archived-data/* sudo find /db-data/archived-data -type d -exec 'chmod' 'g+rwx' '{}' ';' sudo chmod -R g+rwx /db-data gives app-data full permissions to /db-data and ...


1

Here is something , that I found was easier to do instead of opening terminal. Right-Click the file and open properties. Then switch to the permissions tab. Then wherever it says Access: change it from whatever it is to Create And Delete Files. This should remove the lock and then you can delete the file normally.



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