directory

Delete directory and create new one with same name and permissions

Delete directory and create new one with same name and permissions I want to delete a directory with its contents recursively, and then re-create it with the same name and permissions. That directory may or may not be created or owned by me earlier before delete, but I am sure I wouldn’t touch any folder …

Total answers: 2

How does the d option for the ls command exactly work?

How does the d option for the ls command exactly work? Having the following simple structure: project main aaa aaa test ddd ddd pom.xml <— unique regular file If the current directory is project and if is executed the ls command appears main pom.xml test Until here all is OK. Now, according with man ls …

Total answers: 3

Cut folder names out of string

Cut folder names out of string How do I extract the folder named test from the following string? TRUE|/home/linux/test|(null)| Asked By: scotty030253 || Source If you would like to get "Extra credit" for your assignment, Then use awk echo ‘TRUE|/home/linux/test|(null)|’ | awk -F ‘[|/]’ ‘{print $5}’ The awk option -F defines the field separator(s). When …

Total answers: 5

How to automate the compression of the contents of each subfolder in a directory?

How to automate the compression of the contents of each subfolder in a directory? I’m looking to automate the compression of the contents of each subfolder (excluding the subfolder itself) in a directory, with each .zip of said contents corresponding to each subfolder. Is there a way to do such a thing in Ubuntu 22.04? …

Total answers: 1

Rename directories by removing part of a dir name

Rename directories by removing part of a dir name Have lot of directories like the following ./parent/inventory_control-8118c470fa3811ed9add1fef7e5ef70f/snapshots/automation ./parent/configuration_data-6be54fa0fa3e11ed9add1fef7e5ef70f/snapshots/automation ./parent/zip_code-940ac1d0fa3f11ed9add1fef7e5ef70f/snapshots/automation I would like to rename the directories by removing hypen and uuid from the directory name. The desired output is ./parent/inventory_control/snapshots/automation ./parent/configuration_data/snapshots/automation ./parent/zip_code/snapshots/automation Can you please suggest a one line command to find all the directories …

Total answers: 3

What subdirectories of a user's home directory does the user have full control over?

What subdirectories of a user's home directory does the user have full control over? What subdirectories can a user create in his or her home directory ~ with the intent (and reasonable expectation that the intent will be honored) that only that user have write priviledges? For example, maybe a new user, ignorant of Vim, …

Total answers: 2

How to find missing directories between two disk structures?

How to find missing directories between two disk structures? How to find missing directories between two disk structures? Lets say Disk A has dir A/, B/, C/, D/. (newer copy) Lets say Disk B has dir A/, B/, D/, E/. (older copy) I want to find which directories are missing from newer copy in compared …

Total answers: 5

Change the last modification time of subfolders to that of the oldest file inside

Change the last modification time of subfolders to that of the oldest file inside Hello I would like to know how to scan and change the last modified date of all subfolders based on the oldest file in each subfolder. Example of Ubuntu folder structure: home/incoming/media/Something.something.1234/ or /Soemthing Soemthing 1234/ Which means there are folders …

Total answers: 1

Directory changes in Ubuntu 22.04

Directory changes in Ubuntu 22.04 I was reading Ubuntu Linux Unleashed 2021 by Matthew Helmke and found the location of many configuration files/directories mentioned on the book has been moved or changed drastically.Why is that and where can I find the changes made to listing of the directory structure on Ubuntu 22.04 and where they …

Total answers: 1

Folder not showing up showing up with `ls`

Folder not showing up showing up with `ls` I have a folder I can cd into by simply using cd /path. However, when I use ls, the folder doesn’t show up, and it’s not hidden, meaning that ls -a doesn’t make it appear, either. What could account for this? Asked By: snapcrack || Source The …

Total answers: 1

How could i have certain directories in a removable device?

How could i have certain directories in a removable device? Lets say i want this directory structure on a SD card: SD ├── log -> var/log ├── dbs -> var/db └── desktop -> home/desktop (its just an example) This is so everytime a file goes into /var/log instead it goes to SD/var/log, how could i …

Total answers: 1

Rename and add a number to all folders in a directory

Rename and add a number to all folders in a directory I have a simulation folder on hpc which contains time directories from 0 to 50 with a step of 0.1 (so 501 folders in total with their names as 0, 0.1, 0.2.. and so forth). Example output of ls: 0 0.1 0.2 0.3 0.4 …

Total answers: 1

Bash script with different CWD from parent shell?

Bash script with different CWD from parent shell? I’m doing a puzzle for my computer science class where I need to execute the binary /challenge/executable via a shell script, from the CWD of /tmp/exampledir, with the shell’s CWD being a different directory from the shell script’s, or as the challenge phrases it: the challenge checks …

Total answers: 1

Which first level directories in Linux should be owned by user?

Which first level directories in Linux should be owned by user? Today, I have accidentally noticed that the following directories of the / are owned by user, rather than root: /home /lost+found /media /mnt /opt /snap /srv /swapfile /var I have no idea how that could happen. It seems only logical that some of them …

Total answers: 1

How to revert permissons of /media/username directory?

How to revert permissons of /media/username directory? I, by mistake, ran the command: sudo chown -R username:username /media/username/* While I intended to run: sudo chown -R username:username /media/username/586e1a3e-80c3-4057-81bz7-bbfe7662c6ff How can I revert the permissions of the /media/username directory and its contents? Asked By: Austin Rojers || Source I, by mistake, ran the command: sudo chown …

Total answers: 1

Copy the n-largest files from a certain directory to the current one

Copy the n-largest files from a certain directory to the current one I am trying to copy five largest files from a certain directory to my pwd. Using cp specific/directory$(ls -S specific/directory | head -n) ./ copies the first file and then proceeds to produce cannot stat errors for the rest of the files in …

Total answers: 4