date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,442,499,868,000
I was battling with setting up a Mint install on an encrypted hard-drive, and I think I partially succeeded. But I cannot boot the system because some configuration is not correct. I have no idea how to fix it now. The rough guidelines I followed was along the lines of http://blog.andreas-haerter.com/2011/06/18/ubuntu...
There's a evident wrong configuration: lvm_crypt /dev/sda5 none luks You decrypted the volume and named it lvm_crypt while mounting /dev/mapper/mint-root Were you asked to input the password during boot ? Also, did you updated initramfs afterwards ? Because this crypttab need to be embedded since it's for root partiti...
How to salvage a lvm/luks install from custom install
1,442,499,868,000
I'd like to setup Arch Linux with encryption. I found the tutorial on the Arch wiki, and think that the second option (LVM on LUKS) is the best option for me. Here's the partitioning I'd like to use (Thinkpad X1 Carbon, ~ 500 GB SSD, 16 GB RAM): [alignment gap] 1 MB /boot 256 MB (FAT 32) swap 16 GB (size of memory) /...
Since @frostschutz hasn't written his correct solution to the problem as an answer yet, I'll summarize the issue here quickly: I picked the UUID of the wrong partition. The root partition under /dev/VolumeGroup/root is not the one to be chosen, but the actual partition /dev/nvme0n1p2. Here's how to extract that UUID: ...
Arch Linux Setup with Encryption (LVM on LUKS)
1,442,499,868,000
I currently have an unencrypted external hard drive that I use as a backup for my encrypted (with LUKS) main machine. To update my backup, I simply log in to the main machine and rsync to my external hard drive. Clearly, having an unencrypted backup for material that was worth encrypting in the first place is a bad id...
Nowadays cryptsetup itself supports non-destructively transforming an unencrypted partition into a encrypted LUKS device with the reencrypt subcommand. Assuming that your external drive is accessible via /dev/sdX and the current filesystem is located on /dev/sdXY you need first shrink the filesystem to make room for t...
Encrypting a currently used external hard drive such that it can be updated with rsync?
1,442,499,868,000
I need to encrypt an SSD drive and I have opted to use dm-crypt. This is not something I do on a regular basis. So far I have successfully cleared the memory cells of my SSD with the ATA secure erase command. I have also filled the entire disk with random data using: dd if=/dev/urandom of=/dev/sdx bs=4096 status=prog...
dd if=/dev/urandom of=/dev/sdx bs=4096 status=progress This command will overwrite the entire drive with random data. That random data will stay there until you write other data, or secure-erase, or TRIM. In other words, will the random data that I generated with dd still reside inside of the encrypted partitions ...
Filling SSD with Random Data for Encryption with Dm-Crypt
1,442,499,868,000
Are there, from a cryptanalysis point of view, security drawbacks when reusing the same key for different volumes in dm-crypt plain mode with cypher aes-xts-plain64? # Example: Encrypt two volumes with the same key cryptsetup --type plain --cipher=aes-xts-plain64 --key-size=256 --key-file mykey open /dev/sda myvol1 c...
Well, this isn't security stackexchange and I'm not a cryptography expert, but on the face of things: Alice unencrypted: 00000000 48 65 6c 6c 6f 20 6d 79 20 6e 61 6d 65 20 69 73 |Hello my name is| 00000010 20 41 6c 69 63 65 0a 00 00 00 00 00 00 00 00 00 | Alice..........| 00000020 00 00 00 00 00 00 00 00 00 00...
Security of key reuse with dm-crypt in plain mode?
1,679,406,126,000
I just read this discussion between Linus Torvalds and (among others) Milan Broz, one of dm-crypt's maintainers. I am intrigued by the the following part of the discussion : Linus Torvalds: I thought the people who used hidden ("deniable") things didn't actually ever use the outer filesystem at all, exactly so that t...
There are probably a few ways to do this with reasonable safety, with potentially different approaches if starting with a new outer volume or an existing one. Probably the best way to do this would be with the debugfs setb command on the unmounted outer filesystem device to mark range(s) of blocks that belong to the i...
How to refresh decoy data on a plausible deniability dm-crypt scheme?
1,679,406,126,000
I'm considering replacing single-core Raspberry Pi with an encrypted disk with multi-core Banana Pi M3. Encryption/decryption performance is currently the bottleneck, so I'd like to know if encryption and decryption with dm-crypt can utilize multiple cores.
Yes, in recent kernels, dmcrypt requests can be parallelized. The parallelization patches have been integrated into 4.0, at a glance (4.0's dm-crypt.c includes kthread.h, previous versions didn't). Older versions had a single work queue for dmcrypt requests so different blocks couldn't be encrypted or decrypted in par...
Does dm-crypt utilize multiple cores? (Interested in multi-core Pi clones)
1,679,406,126,000
Tonight I decided I wanted to tweak the configuration of my Debian install on my netbook (Ideapad S10-2) to work better with the SSD I put in it. I have done this before and never had any issues but just in case I double-checked what I was doing against the Debian SSD Optimization guide and everything seemed right. At...
Get to a shell ( boot into rescue / single user mode if needed ) and just mount -o remount,rw /. Or if you are booting from a rescue cd, then it knows nothing about /etc/fstab, so just don't specify the -o discard when mounting.
Followed SSD-optimization advice, now root partition won't mount rw
1,679,406,126,000
I've just written over the wrong hard drive using the command: sudo sh -c 'pv /dev/sdb >/dev/sdc' How do I go about undoing this? I was creating the first even backup of the drive, and I backed up over the wrong drive... The drive which got written over also has no backups, I was going to backup that drive next. Bot...
If you do not have backups, your data wasn't important. It's gone. There is no undo. Especially not with encryption involved. something that produces output > /dev/somedisk overwrites data on the device. Whatever is overwritten can not be restored, so your only chance would be if you noticed and cancelled it right awa...
Backed up over wrong hard drive
1,679,406,126,000
I have an external eSATA-hdd on an OpenSUSE 12.2 system. The external hdd has an LVM on a dm-crypt partition. I mount it by powering it up and then doing rescan-scsi-bus.sh cryptsetup -v luksOpen vgchange -ay mount Now when I want to power the hdd down, I do umount vgchange -an extern-1 cryptsetup -v remove /dev/...
Yes, you can find the information in /sys/block/$DEVICE/slaves. If you only have the canonical name you can use readlink to get the details, e.g: devdm="$(readlink -f /dev/mapper/extern-1-crypt)" dm="${devdm#/dev/}" ls /sys/block/$dm/slaves/ If you want to remove all you can just utilize directly the sys filesystem: ...
Detecting the device of a crypto mount
1,679,406,126,000
I installed debian stretch using encrypted lvm from the installer on a usb drive. during installation, with all disks connected, sdo5 is assigned to my boot disk. when running the full system, my boot disk is now assigned sdn5 this is problematic, because I have an encrypted data disk that shows up as sdo1, as per bl...
Got it. dmsetup rename sdo5_crypt sdn5_crypt sed -i -e 's/sdo5_crypt/sdn5_crypt/g' /etc/crypttab update-initramfs -u -k all
change designated name of encrypted lvm root? from sdo to sdn in crypttab?
1,679,406,126,000
My / was originally on an encrypted volume and was transferred to an unencrypted volume by recursively copying every directory, and then grub was reinstalled: sudo -s cp -ax /mnt/encrypted /mnt/decrypted for f in sys dev proc ; do mount --bind /$f /mnt/decrypted/$f ; done chroot /mnt/decrypted grub-install /mnt/decryp...
Removing cryptsetup and regenerating initramfs fixed the problem: apt-get remove --purge cryptsetup update-initramfs -u -k all
How to remove LUKS encryption after transferring files to an unencrypted disk
1,679,406,126,000
I have Gentoo Linux installed on a 25.93GB/62.43GB partition /dev/sda4. The other partitions on the disk are 150MB /boot on /dev/sda1 and 56,66GB unused space on other two partitions. I am planning to encrypt the unused space with dm-crypt, format it to ext4 and after migrating my installation onto it, to nuke the old...
1.- Yes it is possible but you will have to do some tweaking. 2.- You can't encrypt the whole disk, at least boot partition must be unencrypted if you want your system to start (someone has to ask for the decryption password -initrd- and you need it unencrypted). 3.- encfs has some flaws, you can read about them here....
Cloning a root partition onto a dm-crypt encrypted one
1,679,406,126,000
I already did some research on my question (see below), and it's as good as a 'done deal' but I would still like to put forward my problem to this knowledgeable community. Short version of the issue: in partman (the disk partitioner of the Debian installer) the passphrase of a previously dm-crypt/LUKS encrypted volume...
There is no way to recover whatsoever. (*) With LUKS, the passphrase you use to open the encryption, and the master key actually used for the encryption, are completely unrelated to one another. Basically your passphrase decrypts a completely random key, and this random key is stored in the LUKS header. Losing the LUK...
The password of previously encrypted volume got changed by the Debian installer
1,679,406,126,000
I'd like to use dm-crypt with btrfs, because of the bitrot protection of this filesystem. What I am worrying about that the RADI1 is on the filesystem level above the dm-crypt, so if I write a file, it will be encrypted twice. HDD.x ⇄ dm-crypt.x ↰ btrfs-raid1 ⇒ btrfs HDD.y ⇄ dm-crypt.y ↲ Is there ...
With BTRFS there is currently not such an option directly integrated. There has been talk in the past on the BTRFS mailing list about adding support for the VFS Encryption API (the same thing used by ext4 and F2FS for their transparent file encryption), but that appears to never have gone anywhere. At the moment the ...
How to dm-crypt the data only once by filesystem level RAID?
1,679,406,126,000
I have a T61 with C2D T7300 CPU/4 GByte RAM. I has SL 6.3 on it, and I ticked the encrypt VG during install. If I start a "normal" windows xp on it, its ~slow.. so.. I need a little performance boost :) Loud thinking/QUESTION: kcryptd could take ~20% (!) of CPU, but encryption is needed.. soo I was thinking that how c...
There are three main storage encryption possibilities under Linux. Ordered from lowest level to highest level, from fastest to slowest, from least flexible to most flexible: Dm-crypt to encrypt a whole filesystem (or more generally any storage device). You get the best performance, but you have to decide to use it wh...
Fast encryption for home directory with Scientific Linux (ala' RedHat)
1,679,406,126,000
We are using dm-verity for a squashfs root file system. Using kernel 4.8.4 everything was ok, after upgrading to kernel 4.14.14 mount fails, even though the veritysetup verify command validates the image. # veritysetup verify /dev/mmcblk0p5 /dev/mmcblk0p6 --hash-offset 4096 d35f95a4 b47c92332fbcf5aced9c4ed58eb2d5115ba...
By having a look at /proc/crypto I found there are two modules providing sha256: one from Atmel and the generic one: name : sha256 driver : atmel-sha256 module : kernel priority : 100 [...] name : sha256 driver : sha256-generic module : kernel priority : 0 By disabling ...
veritysetup verify successful but mount fails after upgrade to new kernel
1,679,406,126,000
I'm not sure how to debug this, but I've noticed if I am performing a task that requires a large amount of disk reads/write (such as updating a large postgres table) that periodically actual reads and write will fall to 0 while dm_crypt shows 99.9% IO usage in iotop. On top of this the whole DE will freeze every so o...
To fix this I had to edit vm.dirty_ratio and vm.dirty_background_ratio. The issue was I was writing to the disk faster than the disk could handle and the system froze whenever the cache was filled.
dm_crypt / kworker hogging IO and causing system freeze
1,679,406,126,000
I'm working on dm-crypt utilizing cryptsetup. I'm interested to understand if it's using a fixed block dimension to encrypt files. I explain it better: I created a LUKS envelop, formatted it with luksFormat, then open and mounted in file system. Then I normally write files in that encrypted folder. I want to understan...
Are you talking about the blocksize used by the cipher? Cryptsetup uses block ciphers, often with a 16 byte blocksize. Changing the cipher might change the blocksize, see /proc/crypto for available ciphers & details, and man cryptsetup. Cryptsetup has a fixed blocksize, 512 bytes, here's a little from it's FAQ: 2.18...
dm-crypt / cryptsetup which block encryption dimension use
1,679,406,126,000
/path/to/directory/ is a path that points within an encrypted volume, to an arbitrary depth. In a bash script I need to determine if the block device related to this path is a removable device. I'm using Arch Linux. I have looked at a lot of similar questions (such as these listed below and others) but did not find a ...
From the /dev/mapper path, the easiest way to get the disk name should be lsblk with -s to list devices in inverse order: $ lsblk -sl -o NAME /dev/mapper/<name> | tail -1 sda Easiest way from here is probably to check removable property from sysfs $ cat /sys/block/sda/removable 0 but I'd recommend using UDisks here,...
Determine if a given path is on a removable device, even if encrypted, via bash script
1,679,406,126,000
So I'm installing a new Arch with the document here for a whole system encryption. The first part I get confused is here which the document wrote: Warning: GRUB does not support LUKS2. Do not use LUKS2 on partitions that GRUB needs to access. But in the later part of the section, it told me to run the command crypts...
Create a partition on beginning of your Hard Disk Drive, it's size should be between 600 MB and 1GB, and in Linux setup mark that partition as /boot partition. You shouldn't encrypt the boot partition as none of your potentially sensitive data will be written to it. If you want to wipe the entire Hard Disk Drive befo...
Can't boot Arch Linux after installation with dm-crypt whole system encryption (BIOS)
1,679,406,126,000
I have LVM on the top cryptsetup on my Debian unstable amd64. A week ago after upgrade my initramfs changed and now I have to wait few minutes at the beginning of the boot before cryptsetup asked for password to unlock partition. There might be some problem with generated images as at the beginning there were just som...
My problem was in unconfigured network, which was required by dropbear. The actual problem with network was my ISP's dhcp server, which is alive, but not providing network setting for me, so I have to set network manually. In initramfs I had to wait for all tries of dhcp. It was in function configure_networking() in /...
Waiting long (few minutes) during boot for cryptsetup for password prompt
1,679,406,126,000
I store documents on btrfs partition built upon sparse dm-crypt device located on ext4 main partition on physical harddrive. When kernel panics (and this happens on daily basis on my ASUS P53E with 3.6 kernel :-( ) I loose recently modified files (always the files' contents got replaced with zeros). One way of prevent...
I'm not sure the disk drives write cache is going to fix the issue for you as it sounds like you are using a loop device. So there is still the page cache/file in between your Btrfs filesystem and the actual disk. The same type of issue exists for journaling filesystems detailed here for loop-AES. So when data is sync...
How to debug/audit which devices cache writes?
1,679,406,126,000
while installing my Gentoo system I encoutered a strange error. One of my disk is encrypted, I have done all the installation via ssh, so did I enter the encryption passphrase via ssh. Now I entered the password directly on the computer, and it did not work. (I tried it about six times, even plugged in the keyboard fr...
At boot time, you have a US keyboard layout until another layout is loaded. If you want to have a different layout at boot time, you need to include the keymap in your initrd/initramfs. For Gentoo, the Gentoo wiki has instructions on building an initramfs with a custom keymap. See also the discussion in bug #218920. A...
cryptsetup luksOpen only accepts password via ssh
1,679,406,126,000
I have a device that is encrypted using dm-crypt. This is a mini SD card that I use on my laptop. I've had some issues with my laptop freezing recently, and in the journal these messages come up: Mar 20 17:18:30 gorgonzola kernel: EXT4-fs (dm-0): warning: mounting fs with errors, running e2fsck is recommended Mar 20 1...
Are you trying to run fsck on the /dev/sd* (or whatever) device that refers to the actual SD or its partition, just like on an unencrypted device? If so, that device is fully encrypted, and that's why fsck cannot make any sense of it at all. If it found anything recognizable as a filesystem, that would be a sign of d...
Bad magic number in super-block: dm-crypt device
1,679,406,126,000
I'm on an embedded Linux device and trying to open an encrypted squashfs for my rootfs. The image is created on the host (build agent) and from there I'm able to open and work with the content, so I know the image is correct. From the embedded Linux's initramfs when I try to open the image I get the error: root# crypt...
My issue was caused by the fact I was using a musl-libc and lvm2 required glibc. After switching to glibc cryptsetup was able to load the proper backend for cryptsetup.
cryptsetup cannot initialize crypto backend from initramfs
1,666,571,108,000
I suspect there's a bug in Ubuntu's default whole disk encryption setup. Here's what happens, repeatably: I make a fresh install, Ubuntu 15.10 with whole disk encryption, overwriting the whole disk It boots and seems to work just fine A few reboots later, programs start crashing. "Ubuntu has experienced an internal e...
There have been constant reports of corruption bugs with ext4 file systems, with varying setups. Lots of people complaining in forums. The bug seems to affect more people with RAID configurations. However, they are supposedly fixed in 4.0.3. "4.0.3 includes a fix for a critical ext4 bug that can result in major data l...
Massive disk corruption on Ubuntu 15.10 with dm-crypt + LUKS full disk encryption?
1,666,571,108,000
I have a dual-boot(xubuntu/#!) setup LVM with dm-crypt+luks as follows /dev/sda1 = /boot (xubuntu) /dev/sda2 = /boot (#!) /dev/sda3 = encrypted LVM /dev/mapper/volgroup-xroot = / (xubuntu) /dev/mapper/volgroup-yroot = / (#!) /dev/mapper/volgroup-home = /home (/home/xubuntu & /home/crunchbang) /dev/mapper/volg...
You make this message disappear by setting your GRUB_CMDLINE_LINUX_DEFAULT variable in /etc/default/grub with crypt_opts=<whatever#1>,lvm=<whatever#2> The script in /usr/share you mention set the variable cryptlvm with . For further reference, my own GRUB_CMDLINE_LINUX_DEFAULT contains: crypt_opts=target=system,source...
boot fails with "cryptsetup: lvm fs found but no lvm configured" [dual boot(2xlinux LVM, dm-crypt+luks)]
1,666,571,108,000
I wanted to resize the FS on a machine but i ran into problems: Purpose: the LV of /home is too big, the LV of / is too small (they're on 1 VG.) - I need to put 10 GByte from /home to /!! Problem: gparted only shows this (can't see the LV's.. :): How can I put 10 GByte to / from /home if they're encrypted with LUKS?...
GParted doesn't support LVM at all (unless this has changed recently?). You'll need to use the command line tools. First, if you're booting from some rescue media, ensure that the volume group involved is active. The sequence will be something like cryptsetup luksOpen /dev/sda2 encrypted pvscan vgchange -ay /dev/mappe...
Resize LV's in a LUKS encrypted VG - Ubuntu 11.04
1,666,571,108,000
I'm trying to run cryptsetup benchmark --cipher on the entire list of ciphers included in /proc/crypto. I obtained the list from /proc/crypto by doing the following: cd ./Documents/; cat /proc/crypto | grep "name" | cut -c 16- | tee ciphers.txt Now, I'm trying to find a way to pass each cipher, one by one, through to ...
Your problem has nothing to do with dm_crypt. It's a simple shell programming question. First, you are committing cat abuse. Instead of cat /proc/crypto | grep "name", simply write grep name /proc/crypto (no quotation marks required). You could also combine the grep and cut into a single sed command. Not necessarily e...
Have Cryptsetup Benchmark --cipher run through list of all ciphers
1,666,571,108,000
My understanding is that dm-crypt serves to abstract the actual block device so that the read/decrypt and write/encrypt happen automatically. However, assuming a device mapping with target: crypt is created, it has a file system, and it is already mounted, is it possible to tell dm-crypt to ask for the key on every wr...
In principle, it'd be possible to have dm-crypt "forget" the key and require it to be retyped every time, but it'd be impractical and very inconvenient. Reads and writes to the filesystem don't necessarily correspond directly to user operations like "open a file" or "save a file". When a program opens a file, it doe...
Can dm-crypt be configured to ask for key on every read/write?
1,666,571,108,000
In shell script $crypsetup isLuks /dev/sda1 Above command returns 0 -> for luks partition (encrypted partition) 1 -> non luks partitions (non encrypted partition). I have implemented disk encryption using library APIs in CPP program. How can i check whether a partition is luks partition or not using crypsetup APIs?...
You can use the crypt_load function to do that. Quick "reimplementation" of cryptsetup isLuks could look like this: #include <libcryptsetup.h> #include <stdio.h> #include <stdlib.h> #define DEVICE "/dev/sda1" int main (void) { struct crypt_device *cd = NULL; int ret; ret = crypt_init (&cd, DEVICE); ...
How to implement "cryptseup isLuks" function using cryptsetup library APIs
1,666,571,108,000
I have a Debian 11 installation with the following partition layout: path format mount point /dev/nvme0n1p7 ext4 (no encryption) /boot (Debian 11) /dev/nvme0n1p8 dm-crypt LUKS2 LVM2 (named vg_main) /dev/mapper/vg_main-lv_swap swap - /dev/mapper/vg_main-lv_debian ext4 / (Debian 11) /dev/mapper/vg_main-l...
You might want to set up a ubuntu-kexec.target which would be essentially a stripped-down version of multi-user.target, with basically: [Unit] Description=Kexec an Ubuntu kernel from within an encrypted partition Requires=basic.target #You might get by with just sysinit.target here Conflicts=rescue.service rescue.t...
How to chainload another kernel with kexec inside a LUKS2 + LVM2 partition?
1,666,571,108,000
I have read `cryptsetup luksOpen <device> <name>` fails to set up the specified name mapping https://www.saout.de/pipermail/dm-crypt/2014-August/004272.html And tried cryptsetup open --type luks <device> <dmname> --key-file /root/luks.key still getting error 22 cryptsetup luksFormat <device> --key-file /root/luks....
It's a naming conflict, I already have /dev/mapper/data due to the previous testing, so have to test it with another name. cryptsetup open --type luks /dev/data new_name # 1st time sucess cryptsetup open --type luks /dev/data new_name # 2nd time fail
cryptsetup failed with code 22 invalid argument
1,666,571,108,000
On the Fedora wiki it is mentioned that LUKS offers this protection. LUKS does provide passphrase strengthening but it is still a good idea to choose a good (meaning "difficult to guess") passphrase. What is it exactly and how is it accomplished?
A similar phrase appears in other places (e.g., this Red Hat 5 page), where a bit more detail is given: LUKS provides passphrase strengthening. This protects against dictionary attacks. Just from that I would expect it to mean that the password is being salted and probably has other improvements applied to the ...
In regards to dm-crypt with LUKS, what is meant by "passphrase strengthening"?
1,666,571,108,000
How to download and install cryptsetup-luks-devel package for Debian? I can't find it. When I google I get this package only for CentOS.
On debian ,the package is called libcryptsetup-dev: This package provides the libcryptsetup development files. sudo apt install libcryptsetup-dev
Where to download cryptsetup-luks-devel package?
1,666,571,108,000
I plan to encrypt a user's /home directory, prefering dm-crypt over eCryptfs, which seems to read data x times faster. But encrypting the whole /home would be a problem for others, entering an encryption key at every login. Is it possible to separate /home/$USER as a partition?
Log out as that user, proceed as root. Create said additional partition with fdisk or parted. Make temporary mountpoint for that partition, say /mnt/tempuser. Mount it to that mountpoint. Rsync /home/$USER to /mnt/tempuser/ and then mv /home/$USER /home/originaluser. Mkdir /home/$USER and chown it to said $USER Now tr...
A separate partition for a user's /home directory?
1,666,571,108,000
I'm running Arch Linux (systemd) on several systems. Some have SSD storage, others have nvme storage devices and some use rotational HDD's. Some systems use dm-crypt to encrypt the filesystem. All systems run btrfs on /. I wish to have a bash script determine the physical device which hosts the root filesystem (/). Th...
BTRFS supports multiple devices, so what you can do is use btrfs fi show to get the list of block devices. Then use cryptsetup status to check if a given device is a LUKS container. If it is the command will output the underlining device. I wouldn't call this script-friendly, since you'll have to parse the output, but...
Find physical block device of root filesystem on an encrypted filesystem?
1,666,571,108,000
My disks (ZFS on Linux on encrypted LUKS) are not staying in standby and I'm not able to identify which process is waking them up. iotop is showing command txg_sync which is related to ZFS. So I tried fatrace. But even with fatrace -c I don't get any output. This is related to ZFS and a known issue. Next try was using...
With the following you are able to identify I/O per process: cut -d" " -f 1,2,42 /proc/*/stat | sort -n -k +3
How to identify which process is writing on encrypted disk with ZFS
1,666,571,108,000
Hello and thanks for clicking into this for a look. I noticed that in the arch wiki, under cryptdevice in dm-crypt you have this: cryptdevice This parameter will make the system prompt for the passphrase to unlock the device containing the encrypted root on a cold boot. It is parsed by the encrypt hook to identify wh...
You can use whatever you want for the dmname parameter, just make sure to use the same name when referring to the device at other places (e.g. in fstab) or use UUID. When opening the device manually using cryptsetup (cryptsetup luksOpen <device> <name>), you'll also need to specify a name, which also can be whatever y...
What is "dmname" in Arch linux grub config
1,666,571,108,000
When I tried to set up encryption using cryptmount-setup, it just returns without any feedback. It did not even created the crypto.fs file. I ran the commands: cryptmount nextcloud_data and cryptmount -l to show that the creation of the target was clearly unsuccessful, as follows. ------------------------------ Your f...
Cryptmount-setup tries to write to a partition that is mounted in read-only mode, that is why the command exits unexpectedly.
Cryptmount-setup is not working
1,295,896,722,000
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 ...
Quick answers first; see below for more in-depth discussion and documentation links for bash, ksh93 and zsh. Zsh mv Foo/*(DN) Bar/ or setopt glob_dots null_glob mv Foo/* Bar/ Case and underscores are ignored in the option name. set -o can also be used like in Korn/POSIX-like shells and dotglob (DotGlob, DOT_GLOB...)...
How do you move all files (including hidden) from one directory to another?
1,295,896,722,000
The Midnight Commander is a very helpful tool when we're using only the text mode. But sometimes it bothers me that I have to see all the hidden files inside a folder (files that begin with "."). I've tried to find how to do it changing some configurations by myself and then looking on the man page. But I didn't succe...
Choose Options from the menu bar, then Panel options. You have it right there, 5th option on the left column: "Show hidden files".
How can I stop seeing hidden files in the Midnight Commander?
1,295,896,722,000
I have for many years had my entire $HOME directory checked into subversion. This has included all my dotfiles and application profiles, many scripts, tools and hacks, my preferred basic home directory structure, not a few oddball projects and a warehouse worth of random data. This was a good thing. While it lasted. B...
Yes, there is at least one major pitfall when considering git to manage a home directory that is not a concern with subversion. Git is both greedy and recursive by default. Subversion will naively ignore anything it doesn't know about and it stops processing folders either up or down from your checkout when it reaches...
Are there pitfalls to putting $HOME in git instead of symlinking dotfiles?
1,295,896,722,000
How to match the hidden files inside the given directories for example If I give the below command it's not giving the result of the hidden files, du -b maybehere*/* how to achieve this simple using a single command instead of using du -b maybehere*/.* maybehere*/* as I need to type maybehere twice.
Take advantage of the brace expansion: du -b maybehere*/{*,.[^.],.??*} or alternatively du -b maybehere*/{,.[^.],..?}* The logic behind this is probably not obvious, so here is explanation: * matches all non-hidden files .[^.] matches files which names started with single dot followed by not a dot; that are only 2...
How to match * with hidden files inside a directory
1,295,896,722,000
I just edited the .zshrc file to configure Z shell on FreeBSD, for example to update the PATH system variable. path+=/usr/local/openjdk12/bin How do I make the changes take effect? Must I log out and log in again? Is there a way to immediately run that file?
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 make this more direct. Just tell zsh to relaunch itself: exec zsh If you run this at a zsh prompt, this replaces the curre...
How do I apply the changes to the .zshrc file after editing it?
1,295,896,722,000
I was wondering what the difference between these two were: ~/somedirectory/file.txt and ~/.somedirectory/file.txt It's really difficult to ask this on Google since I didn't know how to explain the . when I didn't even know what to call it. But can someone describe the difference between including the dot and exclud...
Under unix-like systems, all directories contain two entries, . and .., which stand for the directory itself and its parent respectively. These entries are not interesting most of the time, so ls hides them, and shell wildcards like * don't include them. More generally, ls and wildcards hide all files whose name begin...
What's so special about directories whose names begin with a dot?
1,295,896,722,000
This answer reveals that one can copy all files - including hidden ones - from directory src into directory dest like so: mkdir dest cp -r src/. dest There is no explanation in the answer or its comments as to why this actually works, and nobody seems to find documentation on this either. I tried out a few things. Fi...
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 (1 to 4) listed here with the files as source_files. . and .. are directories, respectively the current directory, and ...
cp behaves weirdly when . (dot) or .. (dot dot) are the source directory
1,295,896,722,000
I tried to display only hidden files but don't know how to do it. That is working (but matching also dots in other places) ls -la | grep '\.' Was trying adding ^ but didn't find the solution.
ls -ld .* will do what you want.
display only files starting with . (hidden)
1,295,896,722,000
Apparently you can rename file to .... If I were insane, how would I rename file to .. or .? Is such a filename even allowed? Backslash doesn't seem to disable dot's special meaning: $ mv test \. mv: `test' and `./test' are the same file
.. is not special, it is just that it already exists. On Unix, Dos and MS-Windows every directory has a directory . it links back to itself, and a directory .. it links to its parent directory (or self if root directory). If .. and . are special it is only because you can not remove them, or rename them (actually you ...
How to rename file to .. (dot dot)?
1,295,896,722,000
Situation : $ mkdir foo && touch foo/.test $ cp foo/* . zsh: no matches found: foo/* (or bash : cp: cannot stat ‘foo/*’: No such file or directory) I have a directory full of hidden folders and files. What is happening and what is the solution?
Disclaimer: This answer deals with Bash specifically but much of it applies to the question regarding glob patterns! The star character (*) is a wildcard. There are a certain set of characters that it will take the place of and the first character being a dot (.) isn't one of them. This is a special case just because ...
cp hidden files with glob patterns
1,295,896,722,000
Someone of our team wanted to recursively change the user permissions on all hidden directories in a users home directory. To do so he executed the following command: cd /home/username chown -R username:groupname .* We were pretty surprised when we realized, that he actually recursively changed the permissions of al...
I always get burned when I try using .* for anything and long ago switched to using character classes: chown -R username.groupname .[A-Za-z]* is how I would have done this. Edit: someone pointed out that this doesn't get, for example dot files such as ._Library. The catch all character class to use would be chown -R...
`command .*` acts on the parent directory [duplicate]
1,295,896,722,000
Due to work I have recently started using OS X and have set it up using homebrew in order to get a similar experience as with Linux. However, there are quite a few differences in their settings. Some only need to be in place on one system. As my dotfiles live in a git repository, I was wondering what kind of switch I ...
Keep the dotfiles as portable as possible and avoid OS dependent settings or switches that require a particular version of a tool, e.g. avoid GNU syntax if you don't use GNU software on all systems. You'll probably run into situations where it's desirable to use system specific settings. In that case use a switch stat...
How to keep dotfiles system-agnostic?
1,295,896,722,000
Initially I thought it was a coincidence, but now I see there's even a tag for it: all hidden file names start with a dot. Is this a convention? Why was it chosen? Can it be changed? Or in other words (as a related question @evilsoup suggested that implies the answer to a bunch of others): can I hide files without ren...
According to Wikipedia, The notion that filenames preceded by a . should be hidden is the result of a software bug in the early days of Unix. When the special . and .. directory entries were added to the filesystem, it was decided that the ls command should not display them. However, the program was mistakenly writte...
Why are filenames that start with a dot hidden? Can I hide files without using a dot as their first character?
1,295,896,722,000
I'm experiencing a strange behavior on some of our machines atm. At least, it seems strange to me and my colleagues and we didn't find any explanation for it :) [edit 1] Next paragraph seems to be wrong. See edit 2 at end. We're using bash and zsh here. So, when SSHing into some of the zsh-default-machines (plain ssh ...
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 interactive: /etc/zshrc ~/.zshrc login mode: /etc/zlogin ~/.zlogin Tips: Default shell opened in your terminal on Li...
SSHing into system with ZSH as default shell doesn't run /etc/profile
1,295,896,722,000
I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files (files that begin with a "."). The other obvious way is then do something like for file in `ls -a`; do However, iterating...
You just need to create a list of glob matching files, separated by space: for file in .* *; do echo "$file"; done Edit The above one can rewrite in different form using brace expansion for file in {.*,*}; do echo "$file"; done or even shorter: for file in {.,}*; do echo "$file"; done Adding the path for selected ...
proper way to iterate through contents in a directory [duplicate]
1,295,896,722,000
Recently I had a little mishap caused by a shell pattern that expanded in an unexpected way. I wanted to change the owner of a bunch of dot files in the /root directory, so I did chown -R root .* Naturally, the .* expanded to .. which was a bit of a disaster. I know in bash this behaviour can be changed by tweaking ...
Bash, ksh and zsh have better solutions, but in this answer I assume a POSIX shell. The pattern .[!.]* matches all files that begin with a dot followed by a non-dot character. (Note that [^.] is supported by some shells but not all, the portable syntax for character set complement in wildcard patterns is [!.].) It the...
Shell filename pattern that expands to dot files but not to `..`?
1,295,896,722,000
I can understand the rationale of hiding files and folders in the /home/user directory to prevent users from messing around with things. However, I do not see how the same rationale can be applied to files in the /etc, /boot and /var directories which is the domain of administrators. My question is why are some files ...
You've misinterpreted the primary rationale for "hidden files". It is not to prevent users from messing around with things. Although it may have this consequence for very new users until they learn what a "dot file" is (dot file and dot directory are perhaps more appropriate and specific terms than "hidden"). All b...
Why are some files and folders hidden?
1,295,896,722,000
I'm trying to list all the hidden files in a directory, but not other directories, and I am trying to do this using only ls and grep. ls -a | egrep "^\." This is what I have so far, but the problem is that it also lists hidden directories, when I don't want that. Then, completely separately, I want to list the hidde...
To list only hidden files: ls -ap | grep -v / | grep "^\." Note that files here is everything that is not a directory. It's not file in "everything in Linux is a file" ;) To list only hidden directories: ls -ap | grep "^\..*/$" Comments: ls -ap lists everything in the current directory, including hidden ones, a...
How to show only hidden directories, and then find hidden files separately
1,295,896,722,000
I want to back-up all files from my laptop partitions to external HDD. I ran, for example cp -a /med*/ravb*/*00 /med*/ravb*/M*L*/7.3GB_CP && echo "7.3GB BACKED UP PROPERLY" || echo "7.3GB FAILED TO BACK UP" The issue is that dot files are also getting included which I don't want. What should I do so as to ignore al...
Why not use rsync instead? It's made for the job! rsync -uan --progress --exclude=".*" <source> <destination> The above will list all the files to be archived without actually copying anything. Check that the list is correct, then run it again with the n option removed in order to copy the files (you could also rem...
how to copy or backup files ignoring dot files
1,295,896,722,000
For example, in ZFS under FreeBSD and ZoL, there is a magic .zfs dir inside of each zpool mountpoint and you can use zfs set snapdir=visible to make that .zfs dir visible. What makes me curious is: if that setting is set to "hidden", how is the .zfs dir actually hidden from the output of an ls -a or shell path-auto-co...
Well, how to do it is easy enough: ls gets its list from a syscall (or, on Linux, libc function) called readdir. Changing into a directory is done with a separate syscall, chdir. stat is also a different syscall, as are most of the other file operations. In short, "what's in this directory?" and "access this directory...
How are files/dirs hidden from ls -a while still being accessible otherwise in a POSIX compliant system?
1,295,896,722,000
I use Ubuntu 14.04 and in a terminal I became root with sudo su and I wanted to delete root's trash manually. It deleted everything except for a few files that start with a dot. Like .htaccess etc. So I went to that directory (which is "files") and I ran this command: rm -rf .* It did delete those files, BUT I also g...
.* matches all files whose name starts with .. Every directory contains a file called . which refers to the directory itself, and a file called .. which refers to the parent directory. .* includes those files. Fortunately for you, attempting to remove . or .. fails, so you get a harmless error. In zsh, .* does not mat...
How to delete all files in a current directory starting with a dot?
1,295,896,722,000
I want to delete all .swp files recursively. However: rm -r *.swp Gives: rm: cannot remove ‘*.swp’: No such file or directory Just to be sure, ls -all gives: total 628 drwxr--r--. 8 przecze przecze 4096 Aug 3 18:16 . drwxr--r--. 31 przecze przecze 4096 Aug 3 18:14 .. -rwxrwxr-x. 1 przecze przecze 108 Jul ...
Try to match the dot: $ rm -r .*.swp I hope this solve your problem.
rm wildcard not working
1,295,896,722,000
If I look at my home directory there are a large number of dot files. If I am creating a new program that needs a user configuration file, is there any guidance where to put it? I could imagine creating a new dot directory ~/.myProgramName or maybe I should add it to /.config or ~/.local.
The .config directory is a newish development courtesy of XDG that seems, deservedly, to have won favour. Personally, I don't mind a dot directory of your own. A bunch of separate dot files (ala bash and various old school tools) in the toplevel of $HOME is a bit silly. Choosing a single dot file is a bad idea, be...
Where should user configuration files go? [duplicate]
1,295,896,722,000
Is the behavior of .* to include . and .. defined in LSB or POSIX or some other specification?
Quoting from the Single Unix specification version 2, volume ”Commands & Utilities", §2.13.3: If a filename begins with a period (.) the period must be explicitly matched by using a period as the first character of the pattern or immediately following a slash character. (…) It is unspecified whether an explicit perio...
Is the behaviour of .* to include . and .. defined in LSB or POSIX or some other specification?
1,295,896,722,000
I want to delete many configuration folder in my home user folder but I can't figure out how to delete them. How can I delete a hidden folder?
You can remove hidden directories (with . at the beginning of the name) like normal directories: rm -rf .directory_name (r for recursive, f for force). To display hidden directories use -a option for ls: ls -a You can also use mc or some other file manager to remove them. Most of them will have option to display hid...
How can I delete a hidden folder?
1,295,896,722,000
I am aware of using .[!.]* to refer to all dotfiles in a directory with the exception of .., but how might one refer to all dotfiles except for .. and .git? I have tried several variations on .[!.||.git]* and .[!.][!.git]* and the like, but none refer to the intended files.
You can use the extended globbing in bash: shopt -s extglob ls .!(.|git) This also matches ., though, so you probably need ls .!(|.|git)
Copy all dotfiles except for `.git` and `..`
1,295,896,722,000
Whenever you type ls -a into the command prompt, you usually get all of your folders, files, and then you see that the first two entries are . and .. Just curious, but what is the significance of these two entries?
. is the relative reference for the current directory. .. is the relative reference for the parent directory. This is why cd .. makes the parent directory the new working directory.
When you type "ls -a", what is the significance of "." and ".."?
1,295,896,722,000
From time to time I need to find a culprit in an unknown dotfile and instead of trying to figure out which package is to be blamed (e.g. xfce4 or thunar?) and what is their naming convention (.app vs .application vs .some_old_name vs .config/app...), I just want to go for it the quick & dirty way: me@here:~$ grep -IR ...
Thanks to this wiki, I found there is this GLOBIGNORE variable: The Bash variable (not shopt) GLOBIGNORE allows you to specify patterns a glob should not match. This lets you work around the infamous "I want to match all of my dot files, but not . or .." problem: $ echo .* . .. .bash_history .bash_logout .bashrc .inp...
grepping dotfiles with -R correctly?
1,295,896,722,000
I wanted to move all files, including starting with dot (hidden) and folders (recursively). So I used the following commands shopt -s dotglob nullglob mv ~/public/* ~/public_html/ and it worked. But do I need to reset anything after doing shopt -s dotglob nullglob? Doesn't it change how commands like mv operate? Beca...
Yes, you would have to unset those options (with shopt -u nullglob dotglob) afterwards if you wanted the default globbing behaviour back in the current shell. You could just do mv ~/public/* ~/public/.* ~/public_html/ That would still generate an error without nullglob set if one of the patterns didn't match anything...
bash moving hidden files, reset dotglob?
1,295,896,722,000
Normally dot files are not included for wildcard expansion: % echo * Applications Desktop Documents Downloads Library Movies Music Pictures Public bin If I explicitly ask for dot files, I get them: % echo * .* Applications Desktop Documents Downloads Library Movies Music Pictures Public bin . .. .CFUserTextEncoding ....
With tcsh 6.17.01 and above: set globdot du -s -- * With older ones: du -s -- * .[^.]* ..?* (interestingly, that works better than its POSIX counterpart (* .[!.]* ..?*) because in tcsh (and in zsh in csh emulation (cshnullglob option)), contrary to POSIX shells, those pattern that don't match any file get expanded t...
How do I specify arguments to return all dot files, but not . and ..?
1,295,896,722,000
When I try to match all dot files in a directory with .* it seems to have a nasty side-effect: besides matching all (real) files and directories, it matches . and ... bash-3.2$ mv test/.* dest/ mv: rename test/. to dest/.: Invalid argument mv: test/.. and dest/.. are identical This seems really weird, since they ar...
You can use the GLOBIGNORE bash variable. GLOBIGNORE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in GLOBIGN...
How can I make bash not match `.` and `..` with `.*`
1,295,896,722,000
I am currently using the following ls alias: alias ls='ls -alhGkpsq --color=auto'. This results in following directory listing. [03:35] bryson@brys ~ :$ ls total 48K 4.0K drwx------ 4 bryson 4.0K Nov 2 03:34 ./ 8.0K drwxr-xr-x 3 root 4.0K Apr 19 2012 ../ 4.0K -rw------- 1 bryson 676 Nov 2 03:35 .bash_history 8....
Probably caused by your locale, but if you do: LC_COLLATE=C ls -F --color=auto -l The dot files are sorted correctly
Alphabetizing names in `ls` alias with .files not intermingled
1,295,896,722,000
rm -rf .* will only not end horribly because rm refuses to delete . and ... How do I exclude these special directories from a glob pattern? This is not solved by dotglob since I want to match only files beginning with a dot not all files.
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 restrict the set of filenames matching a pattern. If GLOBIGNORE is set, each matching filename that also matches on...
How do I match only dotfiles in bash? [duplicate]
1,295,896,722,000
Normally when I cat a file like this it's hard to read without colorizing. I've managed to get cat to use source-highlight like this: cdc() { for fn in "$@"; do source-highlight --out-format=esc -o STDOUT -i $fn 2>/dev/null || /bin/cat $fn done; }; alias cat='cdc' which now produces the following for a recog...
Define your cdc function as cdc() { for fn do if [[ "${fn##*/}" == .* ]] then source-highlight --src-lang=sh --out-format=esc -i "$fn" else source-highlight --out-format=esc -i "$fn" fi 2> /dev/null || /bin/cat "$fn" done } for fn do is ...
How can I make source-highlight colorize .dotfiles by default?
1,295,896,722,000
I'm trying to manage my dotfiles under version control. My dotfiles repos contains a xfce-base folder, this folder contains the .config/xfce4/.../xy-setting.xml stuff. I can stow, or better, symlink to the correct place, everything works as expected. But, when I open one of the xfce settings editors (Window Manager, ...
You are correct that GNU Stow doesn't support hard-linking currently. However I think you're also correct in that hard-linking probably isn't any better a solution than symlinking, because if an external application will happily replace a symlink with a normal file then it can certainly also break a hard link (i.e. r...
dotfiles: can/should(?) gnu stow make hard links, so I can still use xfce settings gui programs
1,295,896,722,000
I need an elegant solution to store my dotfiles on GitHub for easy access. I tried to create a dotfiles directory and symlink all the dotfiles into there. Then I tried adding the symlinks to git and committing in that directory, but git saves the links not the contents of the files it points to. Is there a way to do t...
I have no idea what the best approach is and elegance is certainly in the eye of the beholder, but I use the following for my dotfiles: A ~/.dotfiles directory that contains all of the dotfiles themselves. These are all managed in a git repo. A script, also in ~/.dotfiles that creates the required links into my home ...
Elegant Way To Store Dotfiles on GitHub
1,295,896,722,000
I have a directory where regardless of user or options selected, I would like it to always show hidden files. I know the -a option will show hidden files. I just want to automate the decision on using the option. Say I'm in /home/user I don't care to see the hidden files, but if I'm in /filestoprcess I want to see the...
The easiest way I can think of to do this would be to create a shell alias that maps to a function. Say we're using bash and add the following alias to your .bashrc: alias ls=ls_mod Now, add the ls_mod function below: ls_mod () { DIRS_TO_SHOW_HIDDEN=(dir1 dir2 dir3) for DIR in "$@"; do for CHECK in "$...
Is there a way to have ls show hidden files for only certain directories?
1,295,896,722,000
I'm new to XMonad and I'd like to understand what's going on in this config file. It is a working config file, nothing is broken. I understand what each setting does but I don't understand what's happening under main = .... Any explanation is appreciated. Also, in this setup, how would one go about changing/adding a k...
The =<< is the action composition in Haskell and requires knowledge of how monads work in Haskell and the related syntax. To try and understand exactly what's happening there, maybe look at the links (below) describing the =<<, >>=[1][2]. To add your own keybindings, you can add , keys = myKeys to your myConfig and th...
Please explain what's going on in my XMonad config file
1,295,896,722,000
Why the following doesn't include hidden files ? ls -a *vim* that will return ls: cannot access '*vim*': No such file or directory ls -a | grep vim .vim .vimrc
If you are explicitly looking for hidden files use a pattern that starts with dot, ls .*vim* Then there's no need for the -a flag.
How to ls with globbing for hidden files?
1,295,896,722,000
for f in ~/common/.*; do echo $f done The entries listed are, /home/sk/common/. #undesired /home/sk/common/.. #undesired /home/sk/common/.aliasrc And i am putting a ugly hack to skip processing . and .. to avoid this, if [[ $f == '/home/sk/common/.' || $f == '/home/sk/common/..' ]]; then ...
Here is a method using bash's extglob: shopt -s extglob for f in .!(|.); do echo "$f" done With extglob the pattern !(pattern-list) matches anything except for the given pattern. The pattern in the example says match everything that starts with . and is not followed by nothing or another single ..
for loop in bash lists dot and double dot folders [duplicate]
1,295,896,722,000
When constructing a pattern that matches a file name such as /home/user/project/.git, how does one match the . character "explicitly" -- that is, without the use of shopt -s dotglob? The manual at https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html states: When a pattern is used for filename ex...
First of all, I assume that you know what things like [b], ? and * mean in a pathname pattern.  (If you don’t, do more research.) At the risk of repeating what the others have said, you’re overthinking it.  Patterns that contain the string /. (i.e., a / immediately followed by a .) explicitly include the dot as a lite...
Bash pattern to match directories whose names begin with a dot (period), by being "explicit", instead of using "shopt -s dotglob"?
1,295,896,722,000
I am creating multiple files (.school_aliases and .git_aliases) to put my aliases in for organization. However, Vim doesn't highlight syntax for these files automatically like for .bashrc or .bash_aliases. Is there a way I could get Vim to do this automatically rather than just doing set syntax=sh?
You can use the following in your .vimrc: autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
Setting Vim to use shell syntax for dotfiles?
1,295,896,722,000
As title. I always do things on macOS, but now I have to learn some Virtual Machine and have installed Ubuntu 20.04. On macOS I put all dotfiles inside the folder ~/.config/. I did the same on Ubuntu, but it didn't work. Now I have to run tmux source ~/.config/tmux/tmux.conf everytime I enter a session, or I will not...
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. That's why it works for you on MacOS. However, the Ubuntu 20.04 repo looks like it's only at 3.0. If you can run 21.04 ...
Tmux doesn't read `~/.config/tmux/tmux.conf` by default, so where?
1,551,884,463,000
I only want echo $(date) to return the date not the backticked version. echo $(date) # should return Wed Mar 6 09:50:41 EST 2019 echo `date` # should return `date`
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 whoops that ">" means we're still in a strong quote. I cant process this. Oh whoops that ">" means were still in a strong q...
How do configure ZSH commands substition to not use backticks (`)?
1,551,884,463,000
I have two existing directories : foo: directory with dotfiles in it foo2: empty directory I would like to have a solution to copy all dotfiles in foo to foo2. I would like a solution that is not shell-dependent (bash, zsh, etc.). I would prefer not having to install rsync to do it (tar is ok). Weeks ago, I asked t...
I assume by "shell independent", you are restricting yourself to Bourne-type shells (not csh, etc) cp -r foo/.??* foo/.[^.] foo2
Shell-independent way to cp dotfiles from a folder to another [duplicate]
1,551,884,463,000
This answer on opening all files in vim except [condition]: https://unix.stackexchange.com/a/149356/98426 gives an answer similar to this: find . \( -name '.?*' -prune \) -o -type f -print (I adapted the answer because my question here is not about vim) Where the negated condition is in the escaped parentheses. Howeve...
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 walks the directory tree. If the file for which -prune is run is of type directory (possibly determined after symlink r...
Difference between GNU find -not and GNU find -prune -o -print
1,551,884,463,000
I was in user home directory , and wanted to rename the ssh folder into .ssh folder. I tried this. rachit@DESKTOP-ENS2652:~/ssh$ ls some-machine some-machine.pub rachit@DESKTOP-ENS2652:~/ssh$ cd .. rachit@DESKTOP-ENS2652:~$ ls ssh rachit@DESKTOP-ENS2652:~$ mv -R ssh .ssh mv: invalid option -- 'R' Try 'mv --help' for...
This mv ssh .ssh could move ssh into an (already existing) .ssh directory. Do this mv .ssh/ssh ./ to put it back. You would have seen .ssh if you had done ls -la If .ssh did not already exist, then mv .ssh ssh will make it "appear" when you do just ls -l
ssh directory disappears after `mv ssh .ssh`
1,551,884,463,000
Today I discovered that sudo ls shows hidden files (that is, those that have names starting with .) on OS X. This surprised me so much that I asked a question about this behaviour, which I still find somewhat strange and unexpected. Turns out, this behaviour goes back to 2BSD in 1979. Given that, now I’d like to ask t...
The POSIX standard says: "Filenames beginning with a ( '.' ) and any associated information shall not be written out unless explicitly referenced, the -A or -a option is supplied, or an implementation-defined condition causes them to be written." Being root is evidently not considered a condition which causes hidde...
sudo ls not showing hidden files on Linux
1,551,884,463,000
ls -d .* lists only hidden "items" (files & directories). (I think) technically it lists every item beginning with ., which includes the current . and above .. directories. I also know that ls -A lists "almost all" of the items, listing both hidden and un-hidden items, but excluding . and ... However, combining these ...
This has been answered over at Ask Ubuntu, which I will reproduce here: ls -d .!(|.) with Bash's extended globs (shopt -s extglob to enable) ls -d .[!.]* ..?* if not
How can I exclude . and .. when listing only hidden items?
1,551,884,463,000
I am trying to remove large amount of mails (mostly mail delivery failed) from my server using rm -rf /home/*/mail/new/* And I am getting -bash: /usr/bin/rm: Argument list too long I tried using find find /home/*/mail/new/ -mindepth 1 -delete But after 20 minutes it looks like it's not doing anything. How do I use ...
The problem is that /home/*/mail/new/* expands to too many file names. The simplest solution is to delete the directory instead: rm -rf /home/*/mail/new/ Alternatively, use your find command. It should work, it will just be slower. Or, if you need the new directories use a loop to find them, delete and recreate them...
Remove everything within directory using for loop
1,551,884,463,000
Say I have a folder ~/dot containing some files and directories, such as zshrc, Xresources, and emacs.d. How do I create symlinks to all of those in ~, but such that the symlinks begin with a dot (.zshrc &c.)? And how would I remove all already existing symlinks that would have been created by the answer to the first...
creating the symlinks cd ~/dot for file in *; do ln -sf dot/"$file" ~/."$file" done deleting the symlinks cd for dotfile in .*; do test -L || continue target="$(readlink "$dotfile")" [[ $target =~ ^dot/ ]] && echo rm "$dotfile" done
Symlinking all dot-files and -directories
1,551,884,463,000
I have a Tar file: testwebsite.tar I've placed it in the directory I would like to extract its contents to on my Web server which is mytestdirectory I run this command via PuTTY: tar -xvf testwebsite.tar Which results in the content being extracted but in this format: mytestdirectory/srv/test/www.testwebsite.com/ A...
You need to use the --strip-components option of tar; that's because the paths you don't need are contained in the tar archive. So for instance if the tar contains this: srv/test/www.testwebsite.com/index.html and you want to obtain this mytestdirectory/index.html, you need $ cd /path/to/mytestdirectory $ tar xf test...
Extracting the Contents of tar archive to parent directory issue resulting in creation of sub directories
1,551,884,463,000
I use git to track my dotfiles across multiple machines. I wrote a pretty simple script in the repo, which backs up any outdated existing dotfiles and then creates symbolic links to each of the up-to-date dotfiles. Here is the script: #!/bin/bash ############################ # makesymlinks.sh # This script creates sym...
Here's the output in your question annotated: drakeprovost@shatterdome:~/RoverCoreOS$ git clone https://github.com/DrakeProvost/dotfiles.git Cloning into 'dotfiles'... remote: Enumerating objects: 42, done. remote: Counting objects: 100% (42/42), done. remote: Compressing objects: 100% (30/30), done. remote: Total 42 ...
My dotfiles bash script somehow deleted its own directory?
1,551,884,463,000
I know we can config file explorer to hide hidden files, but in the open dialogue box of some program, it is not an option. I am just tired of scrolling through hidden folder and files in my home directory. Is there a way to move them into a sub folder and keep the applications working?
You would be going against alot of UNIX momentum and history renaming your the hidden folders in you home directory, I wouldn't do it. Not only do the existing programs expect those folders to exist but any applications you install in the future will just place more hidden folders in your home directory. I agree its a...
How to move hidden config files to sub folder in the home directory
1,551,884,463,000
I am trying to use rsync for creating backups of my computer. For this I would like to exclude all hidden directories and files but include specific sub-directories of those hidden directories. As an example, I have the following structure: .hidden_1/ sub_dir_1/ sub_file_1 sub_dir_2/ sub_file...
rsync -avh --include='/.hidden_1/' --include='/.hidden_1/sub_dir_1/***' --exclude='/.**' src/ dest --exclude='/.**' Exclude all hidden files and directories relative to the source directory and everything in those directories, i.e. .hidden_1/ and .hidden_1/sub_dir_1/, but not e.g. normal_folder/.hiddenfoo. The ** ma...
Rsync include specific sub-directories in hidden directories
1,551,884,463,000
I am a teacher and I use Linux which is great! But students are curious about this "new" operating system they do not know and in GUI they tweak program settings which affects hidden files inside /home/user: [profesor@240-kateder ~]$ ls -a . .dbeaver4 .gtkrc-2.0 .sane .. .dbeav...
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 good state, possibly deleting all extra dot files. Tell students about this script. If you have a number of computers, ...
Good way to prevent student from messing program settings in /home/user
1,551,884,463,000
How can ls be flagged to sort .-prefixed hidden directories and files in groups so that its output is sorted as visible directories, hidden directories, visible files, then hidden files? I currently have ls aliased to ls -lG --color --group-directories-first which groups directories first, but visible and hidden direc...
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, not after them, because a . sorts lower than most other characters.
Grouping hidden files and directories with ls
1,551,884,463,000
The echo command outputs differing results based on the expression passed to it. The working directory is /home/etc $ echo .*/ / ../ .cache/ .config/ .gnupg/ .local/ .mozilla/ .ssh/ $ echo ./* ./Desktop ./Documents ./Downloads ./Music ./Pictures ./Public ./snap ./Templates ./Videos $ echo .*/* .cache/event-sound-cac...
It is the shell that does it. Not echo. This may be more like what you are trying to do. ( shopt -s dotglob; echo * ) It lists all files, but not . and ... It works in bash.
Can echo be combined to produce a single result of .*/ and */?
1,551,884,463,000
Examples: .bashrc .config/fish/config.fish I would like to know which is more common and what pros and cons they each have. I imagine a dotfile would be easier to change, since it is right in the home directory, but it seems .config would be easier to carry around, since it is one directory with everything in it. D...
Dotfiles are the older form, and I believe avoiding them completely will be difficult unless you use a distribution that insists on patching every software included to use the .config directory tree instead of plain dotfiles. Many old applications will have a long history of using a particular dotfile; some may have t...
What is the difference between dotfile and dot config? [duplicate]