51
votes
Accepted
How do I apply the changes to the .zshrc file after editing it?
Restart zsh
Zsh reads .zshrc when it starts. You don't need to log out and log back in. Just closing the terminal and opening a new one gives you your new .zshrc in this new terminal. But you can ...
40
votes
Accepted
cp behaves weirdly when . (dot) or .. (dot dot) are the source directory
The behaviour is a logical result of the documented algorithm for cp -R. See POSIX, step 2f:
The files in the directory source_file shall be copied to the directory dest_file, taking the four steps (...
23
votes
Accepted
SSHing into system with ZSH as default shell doesn't run /etc/profile
ZSH just works in this way. /etc/profile is NOT an init file for ZSH. ZSH uses /etc/zprofile and ~/.zprofile.
Init files for ZSH:
/etc/zshenv
~/.zshenv
login mode:
/etc/zprofile
~/.zprofile
...
16
votes
Accepted
When should I use .bashrc and when .profile?
.profile is read by every login shell, .xxxrc is read by every interactive shell after reading .profile.
You need to decide yourself depending on what you like to add.
A good idea is to put ...
16
votes
Dot in front of file
This can likely be explained by a google post by Rob Pike about the origin of hidden files.
In the early days of Unix there was no concept of hidden files but the files . and .. existed to ...
12
votes
When should I use .bashrc and when .profile?
Bash has a pretty complicated logic on which scripts it runs and when.
But it mostly boils down to:
if you have settings that are inherited from parent process to child (environment variables, ...
11
votes
How to match * with hidden files inside a directory
Another option is available here :
du -sm .[!.]* *
7
votes
Accepted
Grouping hidden files and directories with ls
Use -v for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, ...
7
votes
SSHing into system with ZSH as default shell doesn't run /etc/profile
sshd runs a login shell when the client doesn't send any command to run. That's to mimic the behaviour of rsh which was calling the rlogind service instead of the rshd one when not given any command ...
7
votes
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?
No. The "semantics" of dotfiles are (and this is very conventional and not very consistent) that ...
6
votes
UNIX: How to change all hidden files to visible in a multiple sub directories
With GNU find:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./${0#./.}"' {} \;
With Perl rename:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/\K\.!!' {} +
(remove -...
6
votes
How to delete all files in a current directory starting with a dot?
find /path/to/dir -type f -name ".*" -delete
6
votes
Accepted
Difference between GNU find -not and GNU find -prune -o -print
First, note that -not is a GNU extension and is the equivalent of the standard ! operator. It has virtually no advantage over !.
The -prune predicate always evaluates to true and affects the way find ...
6
votes
Opposite of `--adopt` option for GNU Stow?
I ran into the same limitation and I've found a work-flow that works well with the --adopt option. As stated in the Stow documentation:
...it allows files in the target tree, with potentially ...
6
votes
Accepted
Do dotfiles require the initial dot?
No, it's not a dotfile, since its name doesn't start with a dot. It's simply a configuration file.
The property of dotfiles is that they don't appear by default in the output of the ls command, to ...
5
votes
Accepted
Good way to prevent student from messing program settings in /home/user
Totally different approach: Create a group students, give each student his own account with group membership in students. Have a script that restores a given home directory from a template to a known ...
5
votes
Accepted
How do I match only dotfiles in bash?
With bash, setting the GLOBIGNORE special variable is some non-empty value is enough to make it ignore . and .. when expanding globs. From the Bash docs:
The GLOBIGNORE shell variable may be used to ...
5
votes
Accepted
Is there a totally empty Bash file I can use (or create) to extend .bashrc and .profile?
I know that by principle, one shouldn't change .bashrc and common changes like creating an alias should better be done in .profile instead.
This doesn't make any sense. You probably misunderstood what ...
5
votes
Accepted
How do configure ZSH commands substition to not use backticks (`)?
Wrap the backticks in strong quotes to divest them of their subshelly powers:
$ echo '`echo`'
`echo`
Beware, though, the contraction wrapped in strong quotes:
$ echo 'I can't process this.'
> Oh ...
5
votes
How do I apply the changes to the .zshrc file after editing it?
Changes to a shells initialisation files will be active in the next shell that you start, for example if you bring up a new graphical terminal or log out and in again. If you've made changes that ...
5
votes
Difference between GNU find -not and GNU find -prune -o -print
The -prune predicate in find removes a branch of the search tree. Therefore, using -prune as in the first command in your question would only give you the same results as your second command if ...
5
votes
Accepted
What language do config files use?
There's no global standard. They can be (and are) all different syntaxes.
For example,
the bashrc is simply a bash script,
the vimrc a vimscript script,
i3 uses its own syntax that's pretty
close to ...
4
votes
Good way to prevent student from messing program settings in /home/user
Setting Immutable and Undeletable attributes on the dotfiles via chattr should help. See man chattr or the wikipedia entry for chattr
Does not prevent changing or deleting totally since a user can ...
4
votes
How do you move all files (including hidden) from one directory to another?
I find that this works well for bash and there's no need to change shell options
mv sourcedir/{*,.[^.]*} destdir/
EDIT:
So as G-man stated, my original answer is not posix compliant and is pretty ...
4
votes
cp behaves weirdly when . (dot) or .. (dot dot) are the source directory
When you run cp -R src/foo dest, you'll get dest/foo. So if directory dest/foo does not exist, cp will create it, and then copy the contents of src/foo to dest/foo.
When you run cp -R src/. dest, cp ...
4
votes
How do I apply the changes to the .zshrc file after editing it?
You could source the new file, which would work for some changes, possibly including updating the PATH variable (depending on other lines). However, sourcing it would simply run .zshrc again, and you ...
4
votes
Accepted
Tmux doesn't read `~/.config/tmux/tmux.conf` by default, so where?
Despite the two answers with the traditional tmux config locations, tmux 3.1 and later does support ~/.config/tmux/tmux.conf, although it's not mentioned in the man page. See the release notes here. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dot-files × 147bash × 33
shell × 18
wildcards × 17
configuration × 15
ls × 14
git × 14
linux × 11
zsh × 11
shell-script × 10
home × 10
files × 9
filenames × 9
symlink × 7
directory × 6
macos × 5
cp × 5
mv × 5
command-line × 4
alias × 4
directory-structure × 4
profile × 4
github × 4
ubuntu × 3
tmux × 3