Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
3 answers
2618 views
Directory listing when using setfacl ACL
I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried setfacl -Rdm g:grouptoadd:rx /path/directory/ but, I can read files (when I use direct path to file for example "/path/directory/myfile) and can't list directory (ls /path/director...
I use setfacl command to grant read permission for reading files in directory, but I cant use ls to view files. I tried setfacl -Rdm g:grouptoadd:rx /path/directory/ but, I can read files (when I use direct path to file for example "/path/directory/myfile) and can't list directory (ls /path/directory/)
grU (11 rep)
Mar 17, 2021, 10:22 AM • Last activity: Jul 24, 2025, 12:05 PM
129 votes
7 answers
200107 views
rsync compare directories?
Is it possible to compare two directories with rsync and only print the differences? There's a dry-run option, but when I increase verbosity to a certain level, every file compared is shown. `ls -alR` and `diff` is no option here, since there are hardlinks in the source making every line different....
Is it possible to compare two directories with rsync and only print the differences? There's a dry-run option, but when I increase verbosity to a certain level, every file compared is shown. ls -alR and diff is no option here, since there are hardlinks in the source making every line different. (Of course, I could delete this column with perl.)
chris (1785 rep)
Dec 1, 2012, 11:18 AM • Last activity: Jul 20, 2025, 07:51 AM
42 votes
10 answers
57668 views
How do I create a directory in all subdirectories?
Suppose I have a directory structure like this: $ [~/practice] ls a/ b/ c/ d/ Now I want to create a directory `tmp1` in all sub directories of `practice` and I do this: $ [~/practice] mkdir */tmp1 mkdir: cannot create directory `*/tmp1': No such file or directory Then I try the `-p` switch and I en...
Suppose I have a directory structure like this:
$ [~/practice] ls
a/ b/ c/ d/
Now I want to create a directory tmp1 in all sub directories of practice and I do this:
$ [~/practice] mkdir */tmp1
mkdir: cannot create directory `*/tmp1': No such file or directory
Then I try the -p switch and I endup with a directory named * with a sub directory tmp1
$ [~/practice] mkdir -p */tmp1

$ [~/practice] ls
*/ a/ b/ c/ d/
I know the use of -p switch is to create multiple nonexistent directories. I just thought it might help. How do I create tmp1 in all subdirectories at once? If this can be done, how do I extend it to create \tmp1, \tmp2, \tmp3 in \a, \b and \c at once? **Edit:** I missed mentioning that the directories don't have to be simple and in order, like a, b, c etc., and the directory to be created is not necessarily like tmp1, tmp2.
$ [~/practice] ls
dog/ cat/ rat/
In them, I would like to have something like
$ [~/practice] ls *
dog:
red/ blue/

cat:
red/ blue/

rat:
red/ blue/
Animesh D (2017 rep)
Jan 20, 2013, 03:08 PM • Last activity: Jun 23, 2025, 02:35 PM
0 votes
0 answers
25 views
Borg files in `~/.local/share/` occur a “dir_open: [Errno 13] Permission denied” error
# General overview With BorgBackup, I do a backup of my whole $HOME. However, some files (all located on `~/.local/share/`) occur a rights error. Probably cause it’s ephemeral files belonging to root, I think. Here is an example of these files: ``` /home/fauve/.local/share/tracker/data/tracker-store...
# General overview With BorgBackup, I do a backup of my whole $HOME. However, some files (all located on ~/.local/share/) occur a rights error. Probably cause it’s ephemeral files belonging to root, I think. Here is an example of these files:
/home/fauve/.local/share/tracker/data/tracker-store.ontology.journal: open: [Errno 13] Permission denied: 'tracker-store.ontology.journal'
E /home/fauve/.local/share/tracker/data/tracker-store.ontology.journal
/home/fauve/.local/share/tracker/data/tracker-store.journal: open: [Errno 13] Permission denied: 'tracker-store.journal'
E /home/fauve/.local/share/tracker/data/tracker-store.journal
/home/fauve/.local/share/tracker/data/.meta.isrunning: open: [Errno 13] Permission denied: '.meta.isrunning'
E /home/fauve/.local/share/tracker/data/.meta.isrunning
/home/fauve/.local/share/keyrings: dir_open: [Errno 13] Permission denied: 'keyrings'
E /home/fauve/.local/share/keyrings
/home/fauve/.local/share/gnome-shell: dir_open: [Errno 13] Permission denied: 'gnome-shell'
E /home/fauve/.local/share/gnome-shell
/home/fauve/.local/share/evolution: dir_open: [Errno 13] Permission denied: 'evolution'
E /home/fauve/.local/share/evolution
/home/fauve/.local/share/sounds: dir_open: [Errno 13] Permission denied: 'sounds'
# The problem All the other files are fine saved. But these files occur a shell error. So, it’s a bit annoying cause I always get a “terminating with warning status, rc 1” at the end of backup process. As I use Borg inside a script, if the script get any error, it don’t continue. # What I did ## Exclude them explicitly I first try to explicitly exclude them with Borg’s --exclude’s option. But it’s not really useful, cause it’s not always the same files. It depend from several circumstances as I see. So I can’t really match them all. ## Exclude the whole directory ~/.local/share/ As all the annoying files comme from ~/.local/share/, I thank to fully ignore it. But after [sevral](https://unix.stackexchange.com/questions/797136/local-share-is-set-for-what-and-can-i-ignore-it-at-backups/797194#797194) asks, it seems not really possible. # The question So is it possible with Borg’s options to just ignore all files|directories according to this two conditions: 1. Located inside ~/.local/share (or child) ; 2. The current user have no right to read them.
fauve (1529 rep)
Jun 20, 2025, 01:33 PM
3 votes
1 answers
930 views
/usr/local/bin for OpenWrt
I’m attempting to add support for using Sublime Text and TextMate with files on the router: https://packagecontrol.io/packages/RemoteSubl. Essentially, the script needs to be added to the `/usr/local/bin `directory: curl -o /usr/local/bin/rmate https://raw.githubusercontent.com/aurora/rmate/master/r...
I’m attempting to add support for using Sublime Text and TextMate with files on the router: https://packagecontrol.io/packages/RemoteSubl . Essentially, the script needs to be added to the /usr/local/bin directory: curl -o /usr/local/bin/rmate https://raw.githubusercontent.com/aurora/rmate/master/rmate sudo chmod +x /usr/local/bin/rmate Unfortunately, the /usr/local/bin directory doesn’t exist (nor is it on the PATH): # echo $PATH /usr/bin:/usr/sbin:/bin:/sbin Is there a recommended location for user-related scripts, such that they are on the PATH?
craig (203 rep)
Oct 16, 2019, 02:55 AM • Last activity: Jun 18, 2025, 03:45 PM
0 votes
0 answers
34 views
Make Qutebrowser download in specific directory
#### General overview The goal is to make Qutebrowser store downloads in a subdirectory of `~/downloads` named after the ISO date of the day when the download happend. #### What I alredy did In my `~/.config/qutebrowser/config.py`, I made this function: ```python def setDownloadDirectory(): imp...
#### General overview The goal is to make Qutebrowser store downloads in a subdirectory of ~/downloads named after the ISO date of the day when the download happend. #### What I alredy did In my ~/.config/qutebrowser/config.py, I made this function:
def setDownloadDirectory():
	import os
	from datetime import datetime

	# Formater current date
	today = datetime.now().strftime('%Y-%m-%d')
	download_dir = os.path.join(os.path.expanduser('~/Téléchargements/www'), today)

	# Create the directory if any
	if not os.path.exists(download_dir):
		os.makedirs(download_dir)

	# set the new directory
	c.downloads.location.directory = download_dir

setDownloadDirectory()
So, yes, when I try to download something I get the desired behaviour, Qutebrowser suggest ~/Téléchargements/www/2025-06-07/ as download directory, as desired. #### The problem So, what’s the problem? Well their is two main problems: 1. The date is set to the moment when Qutebrowser was opened and not to the moment when the download happens. Let’s suppose I open Qutebrowser at 23:50, the directory will be set to /2025-06-07 and the downloads who will happens at 24:01 or latter in the next day will still on /2025-06-07 directory. 2. The day’s directory is immediately created at the moment when Qutebrowser starts, not when a download happens. So it could open multiple empty folders for the times I just opened Qutebrowser without asking any download. #### The question Is it possible to run setDownloadDirectory() only when some events are triggers like when a download is asked? It will ensure that the date is really the moment when the download happens and also create a directory only if needed.
fauve (1529 rep)
Jun 7, 2025, 02:09 PM
2 votes
2 answers
2299 views
Copying/Moving folders where destination folder already exists
I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged. I am attempting to use a solution from this question: [https://unix.stackexchange.com/questions/127712/merging-folders-with-mv][1] cp -rl source/...
I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged. I am attempting to use a solution from this question: https://unix.stackexchange.com/questions/127712/merging-folders-with-mv cp -rl source/folder destination rm -r source/folder If i type the first line in the terminal, source "folder" and destination "folder" are merged as expected. However, When i run the script with the line in it, instead of merging the folders the destination now contains two folders; "folder" and "blank", where "blank" has the contents of the source "folder" in it.
puyanera (21 rep)
Nov 3, 2019, 01:07 AM • Last activity: May 30, 2025, 03:09 AM
8 votes
3 answers
6860 views
Is there a way to empty the trash/wastebasket from the command line?
This would be great especially considering the latest version of Ubuntu is very slow when displaying directories on my PC...
This would be great especially considering the latest version of Ubuntu is very slow when displaying directories on my PC...
ixtmixilix (13520 rep)
Oct 10, 2010, 10:22 PM • Last activity: May 6, 2025, 08:43 PM
2 votes
1 answers
4033 views
Problem with installing Realtek rtl8188eus driver for TP-Link TL-WN722N v2 WiFi adapter in Ubuntu 20.04
I'm new to linux. I'm using Linux Lite 5.2 OS (Ubuntu 20.04). While trying to install a Realtek driver for a TP-Link TL-WN722N v2 WiFi adapter using `git clone https://github.com/aircrack-ng/rtl8188eus` , it's giving this error message: cut: /etc/redhat-release: No such file or directory Building mo...
I'm new to linux. I'm using Linux Lite 5.2 OS (Ubuntu 20.04). While trying to install a Realtek driver for a TP-Link TL-WN722N v2 WiFi adapter using git clone https://github.com/aircrack-ng/rtl8188eus , it's giving this error message: cut: /etc/redhat-release: No such file or directory Building modules, stage 2. MODPOST 1 modules CC [M] /home/user/rtl8188eus/8188eu.mod.o LD [M] /home/user/rtl8188eus/8188eu.ko make: Leaving directory '/usr/src/linux-headers-5.4.0-89-generic' cut: /etc/redhat-release: No such file or directory install -p -m 644 8188eu.ko /lib/modules/5.4.0-89-generic/kernel/drivers/net/wireless/ /sbin/depmod -a 5.4.0-89-generic I ran the code with sudo but still got this error. I tried to create redhat-release directory myself with mkdir in /etc/ and made it writable with chmod +rwx and giving permissions with sudo chmod -R 777 /etc/redhat-release but it shows this error message: cut: /etc/redhat-release: Is a directory make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/5.4.0-89-generic/build M=/home/user/rtl8188eus modules make: Entering directory '/usr/src/linux-headers-5.4.0-89-generic' cut: /etc/redhat-release: Is a directory cut: /etc/redhat-release: Is a directory Building modules, stage 2. MODPOST 1 modules make: Leaving directory '/usr/src/linux-headers-5.4.0-89-generic' cut: /etc/redhat-release: Is a directory install -p -m 644 8188eu.ko /lib/modules/5.4.0-89-generic/kernel/drivers/net/wireless/ /sbin/depmod -a 5.4.0-89-generic The internet is working using the adapter but can't turn ON the monitor mode on it. While running sudo airmon-ng, "null" is shown under "PHY" section of the adapter which is probably due to unsuccessful driver installation. Does anyone have a solution to this? Please help...
Jisooya (21 rep)
Nov 1, 2021, 04:18 PM • Last activity: May 1, 2025, 05:09 PM
5 votes
2 answers
159 views
How to show directory sizes in tree format with correct values and depth control
I can't solve what I want using the `tree`, `du`, or `df` commands. I'm using: - `du` version 9.6 - `tree` version 2.2.1 **What I want**: For the current directory, list all directories recursively to a depth of 3, showing their size and ordering them by size. For clarity, each level of subdirectory...
I can't solve what I want using the tree, du, or df commands. I'm using: - du version 9.6 - tree version 2.2.1 **What I want**: For the current directory, list all directories recursively to a depth of 3, showing their size and ordering them by size. For clarity, each level of subdirectory ought to be indented. Using du -h -d 3 does not provide a tree view. Now, tree seems to be the command to use, but I do not understand the output, so I made a test directory and here are the outputs. In the following, I do not understand the answer with - tree --du -h -L 2 for the directory size. - tree --du -h -L 3 for the directory size of immo2 as is 16M and not 4.0K, as well as immo and root size 102M and not 86M. Remark: tree --du -h -L 2 and tree -du -h -L 2 do not provide the same output. Thanks.
$ tree --du -h -L 3
[ 86M]  .
└── [ 86M]  sub1
    ├── [3.6M]  immo
    │   ├── [ 670]  00Tree.html
    │   ├── [416K]  2013-08-27_120009.jpg
    │   ├── [3.2M]  2014-04-09_093940.jpg
    │   └── [4.0K]  immo_2
    └── [ 82M]  ogg
        ├── [ 141]  00Tree.html
        └── [ 82M]  2020-06-21.ogg

  86M used in 5 directories, 5 files
$
$ tree --du -h -L 2
[4.0K]  .
└── [4.0K]  sub1
    ├── [4.0K]  immo
    └── [   0]  ogg

 4.0K used in 4 directories, 0 files
$
$ du -h -d 3
16M	./sub1/immo/immo_2
20M	./sub1/immo
83M	./sub1/ogg
102M	./sub1
102M	.
$
P.S. In the meantime, 1/ filed a bug report for tree cmd. 2/ I found an awesome app: https://apps.kde.org/fr/filelight/
user2718593 (69 rep)
Apr 11, 2025, 12:18 PM • Last activity: Apr 22, 2025, 09:03 AM
3 votes
6 answers
7218 views
Set up a shortcut to open terminal in a specific directory
As far as I know, when you hit `Ctrl+Alt+T`, the Linux terminal pops up. However, it opens in the default home directory. I want to set up this shortcut to open in the directory I am currently in at my file manager. Is there any way to do that? I know that if I right-click anywhere on the directory...
As far as I know, when you hit Ctrl+Alt+T, the Linux terminal pops up. However, it opens in the default home directory. I want to set up this shortcut to open in the directory I am currently in at my file manager. Is there any way to do that? I know that if I right-click anywhere on the directory it will give me the option to do that. But I want to do stuff using my keyboard. After doing a web search, I found this post on [How to Open the Terminal to a Specific Directory in Linux](https://www.howtogeek.com/270817/how-to-open-the-terminal-to-a-specific-directory-in-linux/) . But here, the shortcut is mapped to open in another specific directory. So, in turn, it will require me to change the .bashrc file everytime I want to open terminal in a specific directory. My Desktop environment is KDE and I use Dolphin file manager. My terminal emulator is Konsole. Is there any way to achieve what I want? Let me know. Thanks in advance.
belmont (328 rep)
May 21, 2022, 01:49 PM • Last activity: Apr 17, 2025, 11:04 PM
24 votes
3 answers
62307 views
What are ./ and ../ directories?
Simple question, but I'm not sure where to look and google doesn't respond to periods and slashes. I'm just trying to count the # of files & directories in the current directory (not including subfolders/files) and was trying to differentiate `ls -1 | wc -l` and `ls | wc -l` since they seem identica...
Simple question, but I'm not sure where to look and google doesn't respond to periods and slashes. I'm just trying to count the # of files & directories in the current directory (not including subfolders/files) and was trying to differentiate ls -1 | wc -l and ls | wc -l since they seem identical. A site I was looking at said **"Keep in mind that this is also counting the ./ and ../ directories."** regarding the one with ls -1, and I'm not sure if that means it includes the directories before or something (which I don't want), but it didn't seem to do that from testing. Could someone confirm which one of those would be most adequate for counting # of files & directories in the current directory only (not sub) and what they mean by ./ and ../ directories?
Adam (291 rep)
Jan 30, 2013, 12:53 PM • Last activity: Mar 22, 2025, 02:38 PM
-1 votes
1 answers
36 views
package installation directories
When you automatically download and install packages through the apt or dpkg command , it installed in in a very detailed instructions(i mean perfectly in usr/share and usr/lib); i wanted to know : 1 . how the developers choose the directories and not simply put all of them in a folder;i know it's r...
When you automatically download and install packages through the apt or dpkg command , it installed in in a very detailed instructions(i mean perfectly in usr/share and usr/lib); i wanted to know : 1 . how the developers choose the directories and not simply put all of them in a folder;i know it's related to FHS but if you look at the picture below you see they have made a lot of symbolic links to another directories like you have symbolic links in usr/share/firefox-esr for usr/lib/firefox-esr and vice versa; enter image description here you see symbolic link points to somewhere else , or sometimes points to usr/share (though we could just put the file in the usr/lib); i know it's FHS but no where has any instruction to guide me to this level of complexity; if there is any instruction written somewhere or any book , would be happy to know the link.
Ramin (1 rep)
Mar 18, 2025, 01:12 PM • Last activity: Mar 18, 2025, 01:40 PM
533 votes
9 answers
401267 views
Execute vs Read bit. How do directory permissions in Linux work?
In my CMS, I noticed that directories need the executable bit (`+x`) set for the user to open them. Why is the execute permission required to read a directory, and how do directory permissions in Linux work?
In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory, and how do directory permissions in Linux work?
Nick.h (6423 rep)
Sep 22, 2011, 12:13 PM • Last activity: Mar 14, 2025, 09:53 PM
13 votes
5 answers
2361 views
Is it possible to perform shell command substitution without using a subshell?
I have a scenario that calls for command substitution without using a subshell. I have a construct like this: pushd $(mktemp -d) Now I want to exit and remove the temporary directory in one go: rmdir $(popd) However that doesn't work because `popd` doesn't return the popped directory (it returns the...
I have a scenario that calls for command substitution without using a subshell. I have a construct like this: pushd $(mktemp -d) Now I want to exit and remove the temporary directory in one go: rmdir $(popd) However that doesn't work because popd doesn't return the popped directory (it returns the new, now current, directory) and also because it's performed in a subshell. Something like dirs -l -1 ; popd &> /dev/null will return the popped directory but it can't be used like this: rmdir $(dirs -l -1 ; popd &> /dev/null) because the popd will only affect the subshell. What is called for is the ability to do this: rmdir { dirs -l -1 ; popd &> /dev/null; } but that's invalid syntax. Is it possible to achieve this effect ? (note: I know I can save the temporary directory in a variable; I was trying to avoid the need to do so and learn something new in the process!)
starfry (7710 rep)
Aug 3, 2016, 02:13 PM • Last activity: Feb 28, 2025, 09:21 AM
6 votes
4 answers
792 views
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 the list. Why is the pipe working for the first item...
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 the list. Why is the pipe working for the first item and failing for the rest?
Sudoh (297 rep)
May 1, 2023, 05:31 PM • Last activity: Jan 26, 2025, 05:13 PM
32 votes
10 answers
14932 views
How to move directory into a directory with the same name?
I have a directory `foo` with several files: ``` . └── foo ├── a.txt └── b.txt ``` and I want to move it into a directory with the same name: ``` . └── foo └── foo ├── a.txt └── b.txt ``` I'm currently creating a temporary directory `bar`, move `foo` into `bar` and rename `bar` to `foo` afterwards:...
I have a directory foo with several files:
.
└── foo
    ├── a.txt
    └── b.txt
and I want to move it into a directory with the same name:
.
└── foo
    └── foo
        ├── a.txt
        └── b.txt
I'm currently creating a temporary directory bar, move foo into bar and rename bar to foo afterwards:
mkdir bar
mv foo bar
mv bar foo
But this feels a little cumbersome and I have to pick a name for bar that's not already taken. Is there a more elegant or straight-forward way to achieve this? I'm on macOS if that matters.
Stefan (431 rep)
Dec 1, 2019, 01:09 PM • Last activity: Jan 20, 2025, 06:53 AM
31 votes
9 answers
25704 views
How to set an alias on a per-directory basis?
Suppose you have an alias `go`, but want it to do different things in different directories? In one directory it should run `cmd1`, but in another directory it should run `cmd2` By the way, I have an aliases for switching to the above directories already, so is it possible to append the `go` alias a...
Suppose you have an alias go, but want it to do different things in different directories? In one directory it should run cmd1, but in another directory it should run cmd2 By the way, I have an aliases for switching to the above directories already, so is it possible to append the go alias assignment to the foo alias? alias "foo=cd /path/to/foo" Working in bash(?) on OSX.
B Seven (8469 rep)
Oct 26, 2012, 06:54 PM • Last activity: Jan 16, 2025, 11:43 AM
2 votes
0 answers
84 views
Change the MIME type for a directory in Linux
I've recently realized that I can play my old DVDs (yay!) on my old laptop with a DVD tray using VLC. This is all working fine, but I was wondering how I can get any directory named `VIDEO_TS` to open with VLC as a first priority, instead of dolphin, my file manager. I've gone to `~/.local/share/mim...
I've recently realized that I can play my old DVDs (yay!) on my old laptop with a DVD tray using VLC. This is all working fine, but I was wondering how I can get any directory named VIDEO_TS to open with VLC as a first priority, instead of dolphin, my file manager. I've gone to ~/.local/share/mime/packages and created a new file called x-content-video-dvd.xml to try and create a new MIME type. In the file, I put the following:
dvd video contents folder
I then ran update-mime-database ~/.local/share/mime in terminal, and rebooted to be sure. After it started back up, I ran file --mime-type -b ./VIDEO_TS to check the MIME type of my folder, but it is still inode/directory. If I create a file named VIDEO_TS, the MIME type is applied with no problems. How can I make the same work on a folders' MIME type?
oosh (121 rep)
Jan 10, 2025, 03:05 AM • Last activity: Jan 10, 2025, 03:07 AM
169 votes
13 answers
177554 views
How to XZ a directory with TAR using maximum compression?
So I need to compress a directory with max compression. How can I do it with `xz`? I mean I will need `tar` too because I can't compress a directory with only `xz`. Is there a oneliner to produce e.g. `foo.tar.xz`?
So I need to compress a directory with max compression. How can I do it with xz? I mean I will need tar too because I can't compress a directory with only xz. Is there a oneliner to produce e.g. foo.tar.xz?
LanceBaynes (41465 rep)
Jan 12, 2012, 09:23 PM • Last activity: Jan 7, 2025, 01:27 PM
Showing page 1 of 20 total questions