Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
2
answers
2083
views
How to automate post-installation setup of a distribution?
As you all know, setting up a fresh installation of a distribution can be time consuming. Manually installing and setting up various packages and apps takes a lot of time, even with all the dotfiles on hand. Thus recently I have been wondering about whether there are any tools/best practices concern...
As you all know, setting up a fresh installation of a distribution can be time consuming.
Manually installing and setting up various packages and apps takes a lot of time, even with all the dotfiles on hand.
Thus recently I have been wondering about whether there are any tools/best practices concerning the automation of this process?
Are there any universal tools? Or should plain ol' shell scripts (for different distros/hardware configurations) be plenty enough?
Here's a link for some more information on this topic.
Author's post-install shell script contains ~2000 lines of code.
user503660
Jan 25, 2022, 09:48 PM
• Last activity: Jun 29, 2025, 01:02 PM
1
votes
1
answers
5419
views
git with ssh keeps asking for passphrase everytime
I'm using a git bare repository for managing dotfiles, and some other repositories for custom DWM build and all. I use SSH for pushing and pulling from git, but it keeps asking me my SSH passphrase every time try to push or pull. i have already tried ``` eval $(ssh-agent) ``` then ``` ssh-add ~/.ssh...
I'm using a git bare repository for managing dotfiles, and some other repositories for custom DWM build and all. I use SSH for pushing and pulling from git, but it keeps asking me my SSH passphrase every time try to push or pull. i have already tried
eval $(ssh-agent)
then
ssh-add ~/.ssh/id_rsa
and its added successfully, but no luck I am missing something?
apoorv569
(51 rep)
Jun 23, 2020, 08:32 AM
• Last activity: Apr 13, 2025, 01:01 AM
3
votes
3
answers
6622
views
link config files
## Problem I'm trying to move my config files **from** a `.dotfiles` folder, and link those files to the corresponding config path. ## Example In this example I'm trying ```console $ ln -s ~/.dotfiles/nvim/init.vim ~/.config/nvim/init.vim ``` And the program (`nvim` in this case), the config file do...
## Problem
I'm trying to move my config files **from** a
.dotfiles
folder, and link those files to the corresponding config path.
## Example
In this example I'm trying
$ ln -s ~/.dotfiles/nvim/init.vim ~/.config/nvim/init.vim
And the program (nvim
in this case), the config file doesn't take effect.
But when I copy the file instead of linking
$ cp ~/.dotfiles/nvim/init.vim ~/.config/nvim/init.vim
It does take effect.
## Other example
When I do the same thing but with my .zshrc
file
ln -s .dotfiles/zsh/.zshrc ~/.zshrc
It takes effect...
## Question
How could I link my .dotfiles
config files to the according path for config?
---
Thanks
Norman Perrin
(31 rep)
Nov 17, 2019, 12:28 PM
• Last activity: Apr 4, 2025, 07:05 AM
0
votes
2
answers
90
views
Do dotfiles require the initial dot?
Is there a difference between a "dot file" and a "configuration file"? For example, I have `torrc` file in `/opt/homebrew/etc/tor`. Neither filename itself nor any of its parent directories start with a dot. Nevertheless, this file is the same as `.vimrc` is for Vim. Is it correct to call it a dot f...
Is there a difference between a "dot file" and a "configuration file"?
For example, I have
torrc
file in /opt/homebrew/etc/tor
. Neither filename itself nor any of its parent directories start with a dot. Nevertheless, this file is the same as .vimrc
is for Vim. Is it correct to call it a dot file?
jsx97
(1347 rep)
Mar 12, 2025, 07:56 AM
• Last activity: Mar 12, 2025, 02:09 PM
1
votes
2
answers
83
views
How to make my configuration dotfiles also be loaded for sudo use?
Lets say I do some configuration in my $XDG_CONFIG_HOME (which is /home/user/.config). If I run `micro` text editor and it has custom keybindings and custom theme, doing `sudo micro` will load the default configuration with default keybindings. How to deal with stuff like this, for every tool I use?...
Lets say I do some configuration in my $XDG_CONFIG_HOME (which is /home/user/.config).
If I run
Is there a easier way?
micro
text editor and it has custom keybindings and custom theme, doing sudo micro
will load the default configuration with default keybindings. How to deal with stuff like this, for every tool I use? I don't want to edit global config in /etc, nor duplicate it in .root Is there a easier way?
George Răbuș
(11 rep)
Jan 8, 2025, 07:45 PM
• Last activity: Jan 13, 2025, 09:31 PM
0
votes
2
answers
526
views
Where to put my own shell scripts and configuration files?
Could anybody explain, in which directory (or directories) I should place my own shell scripts and configuation files on macOS? - `/usr/local/bin/`? - `/usr/local/etc/`? - `$HOME/bin/`? - `$HOME/etc/`? - ... ? A best practice or a most common way? Example files are: - `webpage2pdf.zsh` - an ImageMag...
Could anybody explain, in which directory (or directories) I should place my own shell scripts and configuation files on macOS?
-
/usr/local/bin/
?
- /usr/local/etc/
?
- $HOME/bin/
?
- $HOME/etc/
?
- ... ?
A best practice or a most common way?
Example files are:
- webpage2pdf.zsh
- an ImageMagick script to convert a webpage to PDF
- .webpage2pdf
- a configuration file for it
- .zshrc_my-own
- a Zsh cofiguration file that is sourced in my ~/.zshrc
using source
, as suggested by Gilles to avoid accidental overridings: https://unix.stackexchange.com/a/787409
jsx97
(1347 rep)
Dec 1, 2024, 07:39 PM
• Last activity: Dec 2, 2024, 12:52 AM
3
votes
1
answers
2700
views
Dot in front of file
If there is a file and the filename starts with a dot in front of it, does that mean that you created the file and you are hiding stuff in it? Or can the files get created on their own without you creating the filename? I have files with dots in front of them, but I didn't create them.
If there is a file and the filename starts with a dot in front of it, does that mean that you created the file and you are hiding stuff in it? Or can the files get created on their own without you creating the filename? I have files with dots in front of them, but I didn't create them.
Regina Saucedo
(81 rep)
Mar 14, 2019, 09:49 PM
• Last activity: Oct 19, 2024, 11:27 PM
0
votes
1
answers
57
views
What is the provenance of .gtkrc-xfce?
I'm currently setting up a Linux Mint 21.3 Xfce Edition installation, and part of that is tidying up the dotfiles in the home directories. There aren't that many that can be moved in the base installation, and `xdg-ninja` has been a great help, but it does not have anything to say about one dotfile:...
I'm currently setting up a Linux Mint 21.3 Xfce Edition installation, and part of that is tidying up the dotfiles in the home directories.
There aren't that many that can be moved in the base installation, and
xdg-ninja
has been a great help, but it does not have anything to say about one dotfile: .gtkrc-xfce
.
I've tried searching around on the internet and there are currently no obvious results for it in [the GTK documentation](https://duckduckgo.com/?q=gtkrc-xfce+site%3Adocs.gtk.org) or [the Xfce documentation](https://docs.xfce.org/start?do=search&id=start&sf=1&q=gtkrc-xfce) .
Where has this dotfile come from? Is there a way to get it to respect the XDG base directory specification?
EnronEvolved
(21 rep)
Sep 13, 2024, 07:59 PM
• Last activity: Sep 13, 2024, 10:05 PM
2
votes
1
answers
128
views
Were there ways to hide some files in old Unix?
According to [Rob Pike][1], [hiding files with a preceding dot was a mistake][2]. So before this modification in `ls` behaviour (hiding files starting with a '.' by default) was made, could people hide files from a directory listing with `ls` or other tools? Or did they see all files all the time? W...
According to Rob Pike , hiding files with a preceding dot was a mistake . So before this modification in
ls
behaviour (hiding files starting with a '.' by default) was made, could people hide files from a directory listing with ls
or other tools? Or did they see all files all the time?
Were there filesystems with hidden attribute like FAT?
phuclv
(2395 rep)
Aug 17, 2024, 02:53 AM
• Last activity: Sep 10, 2024, 05:53 AM
10
votes
2
answers
10411
views
When should I use .bashrc and when .profile?
I am basically putting all my settings into my .bashrc and when I was using zsh it was all in my .zshrc. The Rust installer just informed me that it has added the new installation to my PATH by modifying .profile. **When should things go into `~/.profile`?** Is it only doing that because it doesn't...
I am basically putting all my settings into my .bashrc and when I was using zsh it was all in my .zshrc.
The Rust installer just informed me that it has added the new installation to my PATH by modifying .profile.
**When should things go into
~/.profile
?**
Is it only doing that because it doesn't know which shell I am using or should all somewhat general settings be in .profile?
Franklin
(285 rep)
Oct 19, 2018, 05:20 PM
• Last activity: Sep 7, 2024, 05:26 AM
0
votes
1
answers
69
views
On a fresh machine, which should come first the syncing of dotfiles or installation of their libraries?
This is a bit of a newbie question but I'm only starting out my journey with dotfiles! Suppose I have a fresh machine and I want to sync my existing dotfiles/settings from some repo. A dotfile may or may not have originated from a library which also has to be installed via some operation such as `ap...
This is a bit of a newbie question but I'm only starting out my journey with dotfiles!
Suppose I have a fresh machine and I want to sync my existing dotfiles/settings from some repo.
A dotfile may or may not have originated from a library which also has to be installed via some operation such as
apt install
or curl
(e.g .gitconfig comes from git).
This being said, which should I install first:
- First the associated applications/libraries, and **then** sync the dotfiles from my repo? If I do this would I be able to overwrite the existing dotfiles that would have been added by installing said applications?
- On the other way hand, one can also first sync the dotfiles from my repo and then install the libraries. However, wouldn't this be overwrite the dotfiles you had synced with the default dotfiles added by installing said libraries?
mesllo
(135 rep)
Jul 31, 2024, 11:53 PM
• Last activity: Aug 1, 2024, 07:15 AM
0
votes
1
answers
104
views
Get a list of all user's commands from a non-interactive shell
I am writing a script that would automatically suggest some new aliases/functions to be added to a user's shell config. Before doing that, however, I would like to make sure the aliases being suggested would not override commands that are already present. For regular executables, that is as simple a...
I am writing a script that would automatically suggest some new aliases/functions to be added to a user's shell config. Before doing that, however, I would like to make sure the aliases being suggested would not override commands that are already present.
For regular executables, that is as simple as checking
$PATH
(or using command
or type
, etc.).
However, I've run into the issue that some other commands, such as aliases and shell functions, are lost in a non-interactive shell.
sh
#!/usr/bin/env sh
alias
Running the above file with ./print_aliases.sh
will not produce any output.
A couple of workarounds I found:
- source print_aliases.sh
will work as needed. \
However, this requires the user to source
the script every time, and requires any other script using this one to itself be sourced.
- I could parse the user's .bashrc
/.zshrc
/etc. \
This is highly unreliable and unportable - hard to guess which files the user has sourced and in what ways.
- I could attempt to source the user's shellrc. Something like this would work:
sh
#!/usr/bin/env sh
source $HOME/.bashrc
alias
This suffers from the same issue as the manual parsing approach, though.
- I've also tried playing around with spawning new shells, $SHELL --login
. That seems to just spawn a new shell marked as a login shell, but doesn't actually source the user's configs, so still no aliases.
Ideally, I would like a script that prints all commands either (1) present in the environment it's run in, or (2) present in the user's default login shell without any interaction.
Is there an (at least somewhat) portable and reliable way to achieve what I'm trying to do?
zoickx
(51 rep)
Jul 18, 2024, 09:42 PM
• Last activity: Jul 19, 2024, 12:23 PM
1
votes
0
answers
197
views
KDE applications configuration - how do they do it?
I've been tackling a project more seriously lately, a project that probably every Linux dev goes through at some point - dotfiles management. KDE (and it's applications) has a history of resisting having it's configuration files being managed in a version control system. That is because KDE's config...
I've been tackling a project more seriously lately, a project that probably every Linux dev goes through at some point - dotfiles management.
KDE (and it's applications) has a history of resisting having it's configuration files being managed in a version control system.
That is because KDE's config files are not exactly gathered all in one place and they are also not intended to be manually edited, i.e. they are autogenerated.
Here is a git repo listing some of KDE's own config files: https://github.com/shalva97/kde-configuration-files
And when trying to configure specific applications like Konsole we also have a few, for example
and the profile specific config files location in:
in which also Konsole colorscheme files are located. I have put the profile and colorscheme files in my repo, but for konsolerc that wouldn't work, as it changes depending on stuff like what my display setup is for example. But there is an alternative: using the command
~/.local/share/kxmlgui5/konsole/konsoleui.rc
~/.local/share/kxmlgui5/konsole/sessionui.rc
~/.local/share/knewstuff3/konsole.knsregistry
although I am not sure at all on what these do, more importantly though there is also:~/.config/konsolerc
and the profile specific config files location in:
~/.local/share/konsole/
in which also Konsole colorscheme files are located. I have put the profile and colorscheme files in my repo, but for konsolerc that wouldn't work, as it changes depending on stuff like what my display setup is for example. But there is an alternative: using the command
kwriteconfig5
or kwriteconfig6
(depending on if using plasma5 or plasma6) you can generate the file.
This works-ish. There are some settings I must have missed, as Konsole does not look quite the same on all my machines.
How do then distros like Manjaro, Kubuntu or OpenSUSE customize their KDE versions, do they use something like konsave
(https://github.com/Prayag2/konsave) to export all KDE settings or do they use kwriteconfig
, or some other way entirely?
Or more generally speaking, where can you find some documentation on commands like kwriteconfig
, KDE config files and/or other customization options?
In the future I would like to version control (or generate using a script) the config files for Dolphin and qt theming, but it's really hard to find out where you can find stuff like that.
dotconfig
(21 rep)
Jun 26, 2024, 07:19 AM
• Last activity: Jun 26, 2024, 12:57 PM
0
votes
1
answers
107
views
Aliases working in subjective conditions on Mac
I'm currently working on a dotfiles configuration (which runs zsh) which I've been using on my mini home server and and Linux CLIs on my PC. I've also utilised it on my work Macbook which runs MacOS, but noticed I was running into some weird issues. ``` (($+commands[terraform])) && { alias tf="terra...
I'm currently working on a dotfiles configuration (which runs zsh) which I've been using on my mini home server and and Linux CLIs on my PC. I've also utilised it on my work Macbook which runs MacOS, but noticed I was running into some weird issues.
(($+commands[terraform])) && {
alias tf="terraform"
}
The above code is part of my alias file for zsh, which maps 'tf' to the terraform command. The issue I've been running to is, that this does not work on the Mac terminal; in which I get the "'tf' command not found error" (or along the lines), but does in the VS Code intergrated terminal. Further adding confusion, I have 'g' mapped to git, and it works perfectly on both Mac terminal and VS Code intergrated terminal.
Any ideas or help would be great. Thanks
Maabat
(3 rep)
May 12, 2024, 04:05 AM
• Last activity: May 13, 2024, 12:30 PM
0
votes
1
answers
53
views
How do I copy directory structure as symlinks inside other directory
I am looking for an easy way to backup all my dotfiles in a git repository. Solution that I'm aiming for: - have git as my source of truth for my dotfiles contents - in my home directory backed up files would be symlinks to files in repository (so when I edit it, it's going to be edited in repositor...
I am looking for an easy way to backup all my dotfiles in a git repository.
Solution that I'm aiming for:
- have git as my source of truth for my dotfiles contents
- in my home directory backed up files would be symlinks to files in repository (so when I edit it, it's going to be edited in repository)
- I can create symlinks for all files in repo with one command (directory structure would be preserved but only files should be linked
For example, I have this backup repository structure:
.config
|_ nvim
|_ init.lua
.tmux
|_ tmux.conf
.zshrc
And I want to get this structure out of it:
home
|_ .config
| |_ (other contents)
| |_ nvim
| |_ (other contents)
| |_ link to init.lua
|_ .tmux
| |_ (other contents)
| |_ link to tmux.conf
|_ link to .zshrc
|_ (other home files and directories)
Other contents might exist before backup process starts, should not be backed up or affected by backup process
To my surprise I wasn't able to find an already existing solution for this. I thought that rsync
does it, but googling didn't give an answer on how to do it. I tried to hack a simple bash script, but drowned in testing and amount of edge cases (i.e. for every dir ignore .
, ..
and .git
, recurse into subdirectories and etc.)
I am sure that there should be a util for this. Maybe someone can point it out for me? Or already has a script that does this?
**UPD:**
Using Stéphane's idea from comments to use cp
I wrote this script that fully covers my usecase:
find ./dotfiles -maxdepth 1 -mindepth 1 | xargs realpath | xargs -i cp {} $HOME -rs --remove-destination
Artem Sevos
(1 rep)
Apr 5, 2024, 08:36 AM
• Last activity: Apr 9, 2024, 10:05 AM
8
votes
4
answers
5267
views
Opposite of `--adopt` option for GNU Stow?
I'm using [GNU Stow](https://www.gnu.org/software/stow/) to manage my dotfiles as per [this guide](https://alexpearce.me/2016/02/managing-dotfiles-with-stow/). This works well for cases where there is no pre-existing dotfile on the machine. E.g. if there is no file `~/.config/foo.cfg` then the follo...
I'm using [GNU Stow](https://www.gnu.org/software/stow/) to manage my dotfiles as per [this guide](https://alexpearce.me/2016/02/managing-dotfiles-with-stow/) . This works well for cases where there is no pre-existing dotfile on the machine. E.g. if there is no file
~/.config/foo.cfg
then the following works well:
~/.dotfiles$ mkdir -p foo/.config
~/.dotfiles$ echo My config > foo/.config/foo.cfg
~/.dotfiles$ stow foo
~/.dotfiles$ ls -l ~/.config
lrwxrwxrwx 1 user group 21 Dec 6 19:03 ~/.config -> .dotfiles/foo/.config
It becomes less straightforward if ~/.config/foo.cfg
already exists:
~/.dotfiles$ stow foo
WARNING! stowing bar would cause conflicts:
* existing target is neither a link nor a directory: foo.cfg
All operations aborted.
So far the only solution I can find is to manually delete ~/.config/foo.cfg
and re-run stow foo
. This is quite awkward when provisioning a stow repo to a new machine which might have dozens of pre-existing .dotfiles and essentially defeats the purpose of using stow to manage dotfiles.
Stow has the --adopt
option. Running stow --adopt foo
has the effect of replacing the stow'd foo
files with the pre-existing foo
files that are on the machine, and then creating the symlinks. What I'm looking for is the way to achieve the opposite; replace the machine's .dotfiles with a symlink to the stow'd version so that new machines can be provisioned using the stow'd dotfiles from a Git repo.
This seems like such an obvious requirement for using Stow to manage dotfiles that I feel I'm missing something and/or the problem has been solved.
Any ideas?
JBentley
(253 rep)
Dec 6, 2021, 07:26 PM
• Last activity: Mar 15, 2024, 07:06 AM
225
votes
12
answers
243629
views
How do you move all files (including hidden) from one directory to another?
How do I move all files in a directory (including the hidden ones) to another directory? For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both files to a directory named "Bar"? The following does not work, as the ".hidden" file stays in "Foo". mv F...
How do I move all files in a directory (including the hidden ones) to another directory?
For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both files to a directory named "Bar"? The following does not work, as the ".hidden" file stays in "Foo".
mv Foo/* Bar/
Try it yourself.
mkdir Foo
mkdir Bar
touch Foo/.hidden
touch Foo/notHidden
mv Foo/* Bar/
Cory Klein
(19341 rep)
Jan 24, 2011, 07:18 PM
• Last activity: Mar 11, 2024, 08:10 AM
0
votes
1
answers
329
views
zsh custom completion file not sourced properly
I encountered a strange behaviour regarding ZSH completion for my custom script and need some ideas, what went wrong and how to solve it. I have written a little custom script `myscript` and also created a corresponding completion script `_myscript`. The latter begins with the following lines as usu...
I encountered a strange behaviour regarding ZSH completion for my custom script and need some ideas, what went wrong and how to solve it.
I have written a little custom script
myscript
and also created a corresponding completion script _myscript
. The latter begins with the following lines as usual: #compdef myscript
(also tried #compdef _myscript myscript
with same result). At the beginning I had both files inside my ~/.local/bin
directory, which is part of my $PATH
. I also added it to my $fpath
so ZSH could find the completion script.
So far, so good. Everything worked fine with the completion of the myscript
command. But then I moved both files to my **.dotfiles** to share them through the corresponding git repo. My dotfiles contain a folder for completion script which is also part of my $fpath
. But when moved to this subdirectory of my dotfiles, completions stopped working...
I removed .zcompdump
to renew the completion assignments and tested different syntax to add the directory to my $fpath
, but nothing helped. I also called compinit
manually after removing .zcompdump
to be sure it is called after all assingments were executed.
The first strange thing is, that other completion scripts inside the dotfile directory are recongnised by ZSH completion system as it also contains the completion scripts for my rustup
and cargo
command. When grepping .zcompdump
after the different steps I tried, it always shows the assignments for both those commands but not for myscript
.
The second strange behaviour is, that when I move the completion script back to the ~/.local/bin
dir and restart ZSH, it suddenly recocgnises the script and completions start working again. And now I can also grep it inside my .zcompdump
Now I'm running out of ideas what could be the reason, especially since rustup
and cargo
completion is working properly from the same directory. It would be much more comfortable to have all my custom completion working from my dotfiles, so I can use them on different machines without much manual configuration. Of course, I know I could hardcode the completion assignment inside my zshrc
, but thats also not as portable as the regular fpath
It may be a minor aspect I'm missing, but hopefully someone knows the solution.
I can't offer much code, since it seems not to be due to my scripts code. JFYI: I'm running Manjaro Linux (with predefined ZSH setting, which I already checked).
lukeflo
(131 rep)
Feb 28, 2024, 09:23 PM
• Last activity: Feb 29, 2024, 09:12 AM
0
votes
1
answers
241
views
What is . and .. in Unix/Linux?
What is `.` and `..` in Unix/Linux ? I’m making a confusion here: the `..` (dots) means one dot for the current directory and one dot for the parent directory? That why `cd ..` goes back one above? From the current to one up? And also why the one dot and two dots is displayed this way: `.` `..` curr...
What is
.
and ..
in Unix/Linux ?
I’m making a confusion here: the ..
(dots) means one dot for the current directory and one dot for the parent directory? That why cd ..
goes back one above? From the current to one up?
And also why the one dot and two dots is displayed this way: .
..
current
directory and one up? It makes more sense to me like this: ..
.
one up, current directory, then the files and directories…
Please explain me this a bit more.
Guilherme Woolley
(101 rep)
Jan 19, 2024, 06:20 AM
• Last activity: Jan 19, 2024, 02:05 PM
2
votes
1
answers
376
views
Dot file and an adjacent identically named file without dot?
Is it bad practice to have a dot file and an adjacent identically named file without dot? --- Background: We already create a $HOME/.ourapp directory where we store various configuration files, log files, etc. but we are debating where to put files that the user would add, create, and modify, either...
Is it bad practice to have a dot file and an adjacent identically named file without dot?
---
Background: We already create a $HOME/.ourapp directory where we store various configuration files, log files, etc. but we are debating where to put files that the user would add, create, and modify, either from outside the app or from within it, using various tools. It would seem most natural have these in $HOME/ourapp but that might be bad practice or confusing.
Adám
(211 rep)
Jan 15, 2024, 11:35 AM
• Last activity: Jan 15, 2024, 11:49 AM
Showing page 1 of 20 total questions