date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,642,817,338,000
The title was a question in an exam I had recently. I could not find the answer afterwards in the slides (also not on the web). In the course slides it is only described that the parent process holds the PIDs of its child process but not how it received them. My guess is that transmission of the IDs is directly done w...
My guess is that transmission of the IDs is directly done with the fork command or afterwards through signals. It’s the former: fork() returns the child PID to the parent. See Why does fork sometimes return parent and sometimes child? for more detail (and man 2 fork of course, and the POSIX definition). A process ca...
How does a parent process know the process IDs of the child processes it started?
1,417,719,191,000
I use a FUSE filesystem with no problems as my own user, but root can't access my FUSE mounts. Instead, any command gives Permission denied. How can I give root the permission to read these mounts? ~/top$ sudo ls -l total 12 drwxr-xr-x 2 yonran yonran 4096 2011-07-25 18:50 bar drwxr-xr-x 2 yonran yonran 4096 2011-07-...
It's the way fuse works. If you want to allow access to root or others users, you have to add: user_allow_other in /etc/fuse.conf and mount your fuse filesystem with allow_other or allow_root as options.
Why does root get Permission denied when accessing FUSE directory?
1,417,719,191,000
I know some filesystems present themselves through Fuse and I was wondering about the pros and cons to this approach.
I'm not positive if you mean real, on-disk filesystems or any filesystem. I've never seen a normal filesystem use FUSE, although I suppose it's possible; the main benefit of FUSE is it lets you present something to applications (or the user) that looks like a filesystem, but really just calls functions within your app...
What are the benefits and downsides to use FuseFS filesystems?
1,417,719,191,000
I try to sshfs mount a remote dir, but the mounted files are not writable. I have run out of ideas or ways to debug this. Is there anything I should check on the remote server? I am on an Xubuntu 14.04. I mount remote dir of a 14.04 Ubuntu. local $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu De...
The question was answered in a linux mailing list; I post a translated answer here for completeness. Solution The solution is to not use both of the options default_permissions and allow_other when mounting (which I didn't try in my original experiments). Explanation The problem seems to be quite simple. When you use ...
Mount with sshfs and write file permissions
1,417,719,191,000
I have the following on my /etc/fuse.conf file: # Set the maximum number of FUSE mounts allowed to non-root users. # The default is 1000. # #...
A better solution might be to add the user to the fuse group, i.e.: addgroup <username> fuse
Unable to use -o allow_other with sshfs (option enabled in fuse.conf)
1,417,719,191,000
when I run mount, I can see my hard drive mount as fuseblk. /dev/sdb1 on /media/ecarroll/hd type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2) However, fuseblk doesn't tell me what filesystem is on my device. I found it using gparted but I want to...
I found the answer provided by in the comments by Don Crissti to be the best lsblk -no name,fstype This shows me exactly what I want and I don't have to unmount the device, mmcblk0 └─mmcblk0p1 exfat See also, man page on lsblk
How do I find out what filesystem FUSE is using?
1,417,719,191,000
I have a directory that is always going to be storing text files that are rarely (think weekly) used. Naturally this is a great place to use compression. However, rather than having to use tar ever time I want to access a file, I would love it if I could "mount a compressed folder". Lets assume the folder is calle...
If read-only access is acceptable, then SquashFS is a good choice. However, it sounds like you want to be able to do in place updating as well. Btrfs may be an option for you. It is still considered somewhat experimental, but it does support transparent file compression, and is available to try in most distros. The ot...
On the Fly Compression for a Directory
1,417,719,191,000
UPDATE Please correct me if I'm wrong: For working on my computer, with a GNU/Linux Distribution named Debian, I know two ways to enter a command, start an application, open a file, etc.: a Command Line Interface where I enter text a Graphical User Interface [a.k.a GUI]: an interface which provides "windows", symbol...
This is my understanding of the situation, but I'm not an expert so it is less technical than the other answers. This is what I understand after using these systems for many years, I have not studied them in any detail. There are three main players here and between them they manage the mounts: FUSE: This is at the ce...
How does mounting on the GUI work "under the hood"
1,417,719,191,000
I'm trying to compile a C program and it tells me user@cu-cs-vm:~/Downloads/pa5$ make gcc -c -g -Wall -Wextra `pkg-config fuse --cflags` fusehello.c Package fuse was not found in the pkg-config search path. Perhaps you should add the directory containing `fuse.pc' to the PKG_CONFIG_PATH environment variable No pac...
I don't know which distro you are using, but you probably need to install libfuse-dev. The fuse header files are missing.
fuse is installed but compiler is saying "no package 'fuse' found
1,417,719,191,000
What is the syntax of the LoggedFS configuration file? The official documentation only had usage instructions for the loggedfs command and a configuration file example. Ok, it's XML, but what are all the possible tags and attributes and what do they mean?
I poked through Config.cpp, the file responsible for parsing the configuration. The example configuration actually does a pretty good job of capturing the available options -- there aren't very many When I refer to "the example output" below, I'm talking about this line (pulled at random from the sample page): 17:29:3...
LoggedFS configuration file syntax
1,417,719,191,000
Say I have a folder which is completely readable by my user. I want it to be mounted to my home folder. I can't use a symlink because I want the files to be exposed at ~/ and I want other programs "not to know" that it's a mount. Is there a fuse program that implements this? The issue with mount is that it requires ro...
You could set up /etc/fstab once, with the following entry: /path/to/original/dir /path/to/bind/dir none bind,rw,user,noauto 0 0 The mount options specify the following things, in order: bind indicates that this entry is a bind mount. rw specifies that the entry will be mounted in read-write mode. user allows a...
How to mount a local directory without root
1,417,719,191,000
mkdir ~/mnt/2letter echo PASSWORD | sshfs -o password_stdin www-data@localhost:/var/www/sites/2letter ~/mnt/2letter -o sshfs_sync,cache=no,password_stdin After this: $ ls -ld ~/mnt/2letter/ drwxr-xr-x 1 www-data www-data 4096 Jan 28 21:29 /home/porton/mnt/2letter/ I need to access /home/porton/mnt/2letter/ under my UI...
Try chucking in the two following options -o idmap=user,uid=<YOUR UID>
UID/GID with sshfs of Linux FUSE
1,417,719,191,000
How can I get the process ID of the driver of a FUSE filesystem? For example, I currently have two SSHFS filesystems mounted on a Linux machine: $ grep sshfs /proc/mounts host:dir1 /home/gilles/net/dir1 fuse.sshfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0 host:dir2 /home/gilles/net/dir2 fuse.sshfs rw,nos...
I don't think it's possible. Here's why. I took the naive approach, which was to add the pid of the process opening /dev/fuse to the meta data that fuse creates at mount time, struct fuse_conn. I then used that information to display a pid= field in the mount command. The patch is really simple: diff --git a/fs/fuse/f...
Find what process implements a FUSE filesystem
1,417,719,191,000
I have an embarrassingly parallel process that creates a huge amount of nearly (but not completely) identical files. Is there a way to archive the files "on the fly", so that the data does not consume more space than necessary? The process itself accepts command-line parameters and prints the name of each file created...
It seems tar wants to know all the file names upfront. So it is less on-the-fly and more after-the-fly. cpio does not seem to have that problem: | cpio -vo 2>&1 > >(gzip > /tmp/arc.cpio.gz) | parallel rm
Virtual write-only file system for storing files in archive
1,417,719,191,000
Say I created a FUSE filesystem called foo and mounted it at /mnt/foo. If I have a user called myuser that is running vi to open a file in /mnt/foo, what FUSE methods or data structure contains the info about the user and process? I'd want the actual name of the user/group and process, or the RUID and PID. I've been ...
During the call to a fuse operation you can call fuse_get_context() to get the current calling user id, group id, process id, and umask in a fuse_context Struct. struct fuse_context { struct fuse *fuse; uid_t uid; gid_t gid; pid_t pid; void *private_data; mode_t umask; }...
In FUSE, how do I get the information about the user and the process that is trying to read/write in the virtual file system? [closed]
1,417,719,191,000
I'm trying to mount various SD cards automatically with udev rules. I started with these rules, solved a problem with the help of this question, and now I have the following situation: ext4 and vfat formatted devices work perfectly, but when I plug in an exfat or an NTFS formatted disk I get the following line in moun...
TL;DR: udev and fuse are not really compatible After noticing that this problem not only occurs with exfat but also with NTFS formatted devices I started looking specifically for problems with udev and fuse. Some comments about the combination I found: I think that the fuse process is being killed. You cannot start ...
Mounting exfat with udev rules automatically
1,417,719,191,000
It's a bit indirect, but it's possible to mount a partition with a disk image using mount or losetup's "offset" parameter. I'm looking to be able to use fuse to do the same thing in user space Use Case My use case is building disk images on an autobuild server where the build job is not allowed to have root permissio...
It's possible to do with fuse, but would probably be cleaner with custom tools. Solution With apt-get-able tools the following kludge is possible: mkdir mnt xmount --in dd --out vdi disk.img mnt mkdir mnt2 vdfuse -f mnt/disk.vdi mkdir mnt3 fuseext2 -o "rw" mnt2/Partition1 mnt3 Explanation The basic idea is that fu...
How can I mount partitions in a full disk image (i.e. image with partition table) with fuse?
1,417,719,191,000
TL;DR Attempting to format a block device on my FUSE file system fails with EPERM at the open syscall. Permissions are set to 777 and the necessary ioctls are stubbed, but no logs are printed from within the FUSE handler. Background I'm writing a program to create virtual disk images. One of my criteria is that it mus...
If I understand correctly, you expose a block deice via your FUSE filesystem, which doesn't work for security reasons. In Unix-like systems, files are much more than just files. Letting an unprivileged user access arbitrary block devices is problematic because, by granting access to a block device corresponding to the...
EPERM when formatting block device on a FUSE filesystem
1,417,719,191,000
I would like to mount my Samsung Galaxy S7 to an folder using simple-mtpfs and I cannot do it as I used to (on previous Fedora and older Galaxy S4). If I simply plug S7 to my computer, I can browse it using Nautilius, but I cannot access it in terminal as ordinary folder, what is exactly what I want to achieve. Every ...
This is an old question, anyway, now in 2023 I can manage a Samsung phone with Android version 9 via Firefox as well as by command line (gnome-terminal) in Ubuntu Desktop 22.04.x LTS. When the phone is connected via USB (and mounted automatically), I find the path to it using this command, find /run/user/*/gvfs -maxde...
Mount Samsung Galaxy S7 using simple-mtpfs
1,417,719,191,000
Everything I've tried (always with superuser privileges) has failed: # rm -rf /path/to/undeletable rm: cannot remove ‘/path/to/undeletable’: Is a directory # rmdir /path/to/undeletable rmdir: failed to remove ‘/path/to/undeletable’: Device or resource busy # lsof +D /path/to/undeletable lsof: WARNING: can't stat(/path...
# rm -rf /path/to/undeletable rm: cannot remove ‘/path/to/undeletable’: Is a directory rm calls stat(2) to check whether /path/to/undeletable is a directory (to be deleted by rmdir(2)) or a file (to be deleted by unlink(2). Since the stat call fails (we'll see why in a minute), rm decides to use unlink, which expla...
Undeletable directory
1,417,719,191,000
I want sshfs connections to be terminated after some time, an hour at the maximum, and this means launching the at command with fusermount -u in the same command or script that I use to launch the sshfs mount. However I notice that the fusermount can fail if the files are in use, although I want the at command to work...
If you only want to free up the mount point, and don't care about terminating the SSH connection, you can run fusermount -z /mount/point. This performs a lazy unmount: the mount point is no longer associated with the mount, but the mount doesn't disappear until all open files on that mount are closed. If you only want...
Is there a user-level foolproof way to force termination of sshfs connections?
1,417,719,191,000
I'd like to recreate a feature of Mac OS X called sparse bundles (disk images made out of smaller files, making them easy to backup after a small change). For that I'm looking for a way to 'virtually' create a single file made by concatenation of smaller ones (big.file shouldn't use all this space, just link to .fil...
One way to do this would be to make each file an LVM physical volume, and join those physical volumes in a volume group and make an LVM logical volume using that space. But it's cumbersome: you need to associate the file with a loop device. dd if=/dev/zero of=0.file bs=1024k count=4 losetup /dev/loop0 0.file pvcreate ...
Virtual file made out of smaller ones (for mac-like sparse bundle solution)
1,417,719,191,000
Trying to use veracrypt (console) in WSL. I make a volume, seems to work OK... but when I try to mount it: Done: 100.000% Speed: 5.0 MiB/s Left: 0 s The VeraCrypt volume has been successfully created. m17awl@M17A:/media/mike$ veracrypt /mnt/e/test.vc /media/mike/rsync_vc_drive_e/ Enter password for /mnt/e/test.vc: ...
fuse is not supported in WSL 1 From WSL Issue #2869, a comment by therealkenc No Linux modules on WSL because no Linux kernel in WSL. fuse is compiled into WSL 2 From MSPoweruser article Windows Subsystem for Linux (WSL) 2 support coming to Windows 10 version 1903 and 1909 Full Linux kernel built into WSL 2 And f...
"modprobe fuse" on WSL?
1,417,719,191,000
I've heard that FUSE-based filesystems are notoriously slow because they are implemented in a userspace program. What is it about userspace that is slower than the kernel?
Code executes at the same speed whether it's in the kernel or in user land, but there are things that the kernel code can do directly while user land code has to jump through hoops. In particular, kernel code can map application memory directly, so it can directly copy the file contents between the application memory ...
Why is userspace slower than the kernel?
1,417,719,191,000
TL;DR When a fuse filesystem is mounted via the mount command, the environment variables are not passed to the fuse script. Why? Context I am trying to mount hdfs (hadoop file system) via fuse. This is easy on the command line: # Short example version: LD_LIBRARY_PATH=blah hadoop-fuse-dfs -onotrash dfs://ambari:8020 ...
You can write your own mount fuse helper, which then calls the real fuse script. In the simple case of an fstab entry like: dfs://ambari:8020 /mnt/hdfsfuse fuse.mydfshelper flag,flag,... then your script /usr/bin/mydfshelper is called with args dfs://ambari:8020 /mnt/hdfsfuse -o flag,flag,... So you just need to ...
LD_LIBRARY_PATH lost when using mount command
1,417,719,191,000
I'm trying to implement a toy file system and I'm struggling to understand how to correctly implement the readdir() operation in an efficient, scalable way. To understand the interface used by FUSE, I'm mainly reading the documentation of pyfuse3, but I don't think that my issues would be solved by using any other FUS...
For efficiency in the presence of concurrent modification and hardlinks, you need a cookie btree on the side. I'm not aware of another off_t approach that's correct under POSIX. I would guess this comment provides most of the answer: https://github.com/facebookexperimental/eden/blob/5cc682e8ff24ef182be2dbe07e484396539...
Correctly implementing seeking in FUSE readdir() operation
1,417,719,191,000
Kernel space device drivers usually implement directories and file that show through /sys or /proc. Can the long running user space programs do this as well? I have a daemon or long running program that needs to be able to be queried for some data and have some data set by external programs while it runs. I could do ...
I don’t think there’s any way to add /sys or /proc entries outside the kernel. For /sys it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures. You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo for details. You can see an implementation...
Can user space programs provide/implement sysfs or procfs files to pass data to and from a program?
1,417,719,191,000
I installed on Debian Wheezy zfs-fuse file system and enabled compression gzip-9 on one dataset ("storage/backup"). When I check if the compression is enabled on this dataset, it shows YES: $: zfs get compression storage/backup NAME PROPERTY VALUE SOURCE storage/backup compression gzip-9 local Ho...
It looks like zfs-fuse will update the compressratio data every 30 seconds with limited IO occurring but there is another trigger to the update as background IO or really large files cause the data update to occur sooner. I've put some test functions up on a gist. They require a clean (no files) file system that will...
zfs-fuse: enabling compression has no effect
1,433,760,573,000
I do not hold a deep understanding of computer science concepts but would like to learn more about how the utility encfs works. I have a few question regarding the concept of filesystem in regards to encfs. It is said that encfs is a cryptographic filesystem wiki link. 1)To encrypt the files encfs is moving around bl...
I think that behind your description, there is a misconception. The unencrypted data is not stored on the disk at any point. When you write to a file in the encfs filesystem, the write instruction goes to the encfs process; the encfs process encrypts the data (in memory) and writes the ciphertext to a file. The file n...
How to understand the filesystem concepts used by encfs?
1,433,760,573,000
I have the feeling that I cannot modify the date of symlinks on bindfs. See the following transcript of what I tried. On EXT4: nailor@needle:~$ mkdir /tmp/ex nailor@needle:~$ cd /tmp/ex nailor@needle:/tmp/ex$ touch realfile nailor@needle:/tmp/ex$ ln -s realfile linkfile nailor@needle:/tmp/ex$ stat realfile linkfile ...
Filesystems where you can't change the date of a symlink are common. This in itself is not a bug of bindfs or sshfs. Rsync is designed to cope with that. It ignores failures to change the time and other metadata of symbolic links if the underlying filesystem doesn't support it. Under Linux, rsync calls utimensat with ...
modify date of symlink on bindfs
1,433,760,573,000
When I run podman with --storage-opt ignore_chown_errors=true I am getting Error: kernel does not support overlay fs: 'overlay' is not supported over extfs at /home/user/.local/share/containers/storage/overlay: backing file system is unsupported for this graph driver
This is because on Debian you do not have a kernel driver for overlayfs: so you'll need to use a userspace filesystem driver for overlayfs. First make sure it's installed, sudo apt install fuse-overlayfs Then add this argument to podman (NOT podman run), --storage-opt mount_program=/usr/bin/fuse-overlayfs In your ca...
Error: kernel does not support overlay fs: 'overlay' is not supported over extfs
1,433,760,573,000
I found out about fuseiso a while ago but I need to mount UDF images, and it seems like fuseiso doesn't support it after failed attempts on my part to mount a UDF image with it. I need to be able to do this as a regular user for arbitrary images and I have to be able to unmount them as well, preferably with the mount-...
I use udisksctl loop-setup -f /full/path/to/iso for that from the udisks2 package. udisksctl loop-setup -f /media/myname/dvd/avatar/buch-1/AVATAR_BK1_VOL1_EUR.iso Mapped file /media/myname/dvd/avatar/buch-1/AVATAR_BK1_VOL1_EUR.iso as /dev/loop1. It mounts the iso in /media/$USER/. If not, you also need to type u...
mounting and unmounting UDF .iso images as a regular user
1,433,760,573,000
I've mounted a networked filesystem in GNOME by clicking on the icon in the left of Nautilus. However, when I use the terminal, I can't figure out how to access that filesystem. Is it possible?
Nautilus uses GVFS to mount networked filesystems. Unlike its predecessor GnomeVFS, GVFS includes a FUSE bridge so that non GVFS-aware applications can still access GVFS data. That means that there are two ways to do this: using the FUSE bridge, or using the native GVFS tools. Using the FUSE bridge According to man gv...
How can I access networked filesystems that I've mounted in Nautilus?
1,433,760,573,000
I'm trying to run the borg mount in Borg Backup, but it's saying that fusermount3 is not installed. fuse: failed to exec fusermount3: No such file or directory Googling this problem isn't helping. I have fuse installed: fuse is already the newest version (2.9.9-3). as is libfuse: libfuse2 is already the newest versi...
Figured it out: I had to install fuse3 sudo apt-get install fuse3
BorgBackup: fuse: failed to exec fusermount3: No such file or directory
1,433,760,573,000
After unmounting a remote file system with fusermount -u ~/sshfs_mount/ and then calling systemctl suspend my Arch Linux 4.20.2 froze for about 20 seconds. After those 20 seconds, the system became responsive again (it didn't suspend). Then I tried to suspend once more which succeeded this time. Checking out journalct...
My gut feeling on this is that there is some caching in sshfs which is still being flushed (many) seconds after you unmounted. It would be legitimate for a kernel thread to refuse to sleep while attempting to flush a cache, especially where that requires a network connection. I can't find documentation on whether ...
After fuse unmount: Freezing of tasks failed
1,433,760,573,000
I downloaded WSL (Windows Subsystem for Linux) and tried to run an AppImage, but received an error message that said AppImage needs FUSE to run When I tried the --appimage-extract and --appimage-extract-and-run options, neither of them worked. It seems that FUSE is not supported in WSL. How can I run an AppImage on W...
You don't mention which Ubuntu version you are using, but I'm guessing Ubuntu 22.04 since that release doesn't include FUSE by default. See this answer on Ask Ubuntu. I tested with the KeePassXC AppImage on WSL on both Ubuntu 20.04 and 22.04. It works fine on 20.04, but I get the same error as you on 22.04. To quo...
Running AppImage on WSL: How to resolve error requiring FUSE?
1,433,760,573,000
So I goofed when using sshfs and the folder I was using as a mountpoint for the server has been borked. The server wasn't unmounted correctly (I think due to a network drop out). consequently, when I ls my /Volumes/ where I had originally made the mountpoint folder I now get an I/O error: joehealey@Joes-MacBook-Pro:/V...
Simply using: umount /Volumes/mountpoint Has solved it. No idea why fsusermount -u wasn't an option for my install. Perhaps someone else will know(?). For full reference: Before joehealey@Joes-MacBook-Pro:/Volumes$ mount /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) map -hosts on /n...
Input/Output Error when rm/mkdir
1,433,760,573,000
I'm currently trying to write a couple of systemd/udev configuration files that will allow me to automount/unmount MTP Android devices on my Arch Linux laptop. It took me some time, but so far it works pretty well. Now, I would like for any user with fuse permissions to be able to unmount the device. So far, it's only...
The fuse group is intended to indicate who can mount FUSE filesystems. The intent is not that anyone in that group can unmount filesystems mounted by others. Only the user doing the mounting, or root, can unmount the filesystem. You can use sudo to authorize users in the fuse group to run an unmount command as the sa...
Allow any user in the fuse group to unmount
1,433,760,573,000
I wonder if there is something like "user specific /etc/fstab" for fusermount? ~/.fstab, ~/.config/fstab, something the like, which would work in cooperation with FUSE. I used sshfs foo.bar: foo.bar/ from the home dir to connect to the remote dir (there is foo.bar directory, and I have .ssh/config set accordingly). B...
There's no per-user equivalent of /etc/fstab. You can write a shell script that reads a file of your choice and calls the appropriate mounting command. Note that from the argument foo.bar, you have to deduce multiple pieces of information: the server location foo.bar, the directory on the server (here your home direct...
User specific fstab for fusermount
1,433,760,573,000
I want to be able to mount, say /home/$USER/workspace to /usr/local/workspace. Right now I'm using the python package pyfilesystem which uses fuse to do that. My problem is, that inside that mount I am not able to create symlinks. I don't even need symlinks going outside the mount, but even a symlink that normally is ...
After searching some more I stumbled upon proot which combines chroot with the ability to mount any directory into the new root. It supports any file operation inside its chroot, yes even symlinks, that will happily work even after proot unmounted the directory. It doesn't need root privileges and made my complicated...
Creating a local workspace for development/testing
1,433,760,573,000
If I have a script that relies on one of the following being present: overlayfs, aufs, unionfs - what is the best way to determine which is available from a bash script? I would like to use overlayfs, but fall back to aufs or unionfs if it is not available. I can look at the kernel version as a guess - but just beca...
Under Linux, you can see which filesystem types are available in the running kernel in the file /proc/filesystems. The content of this file is built in real time by the kernel when it's read, so it reflects the current status. The format of this file is a bit annoying: each line contains either 8 spaces followed by a ...
How do you determine filesystem availability from a bash script?
1,433,760,573,000
I'd previously used aufs2 in aufs-tools with some luck, but apparently this package has been "superseded" (this is strange term to use for a package which seems to have been removed only because it no longer compiles, but never mind). Okay, so I thought I would try to use unionfs-fuse. I can't for the life of me figur...
I suppose (but not tried) that the fuse option -o allow_other, also shown in the example in the unionfs-fuse's man page, could be of help. Edit Try this sudo mount -t aufs -o br:/mnt/disk1-pool=RW:/mnt/disk3-pool=RW \ none /mnt/union-pool that seems to work also without aufs-tools package.
How can I create a unionfs-fuse mount that is readable by all?
1,433,760,573,000
So I have a permission problem with my sshfs mount: root@server01:/mnt# sshfs -o uid=$(id -u www-data) -o gid=$(id -g www-data) user@host:/path mountpoint root@server01:/mnt# ls -Zlah total 12K drwxr-xr-x 3 root root ? 4.0K Nov 29 20:00 . drwxr-xr-x 23 root 1001 ? 4.0K Nov 29 13:03 .. drwxrwxrwx 1 ww...
sshfs = FUSE, you are mounting as root, then trying to access using another user. for a joke / test, you can sshfs as regular user, then switch to root, cd, ohh permission denied, how can root be denied, it's root... run sshfs as the user you want to access. update with example: **test**@mike-laptop4:/mnt$ sshfs [emai...
Owner of sshfs-mounted directory with 777 permission can't open it (no ACL, no SELinux)
1,433,760,573,000
I am going to implement a filesystem in FUSE, and later in the kernel. I am not sure what to make out of Direct IO. Different sources emphasize on different things that this flag supposedly implies. Is it safe for a filesystem to just ignore O_DIRECT? Read and write operations would proceed like normal. Open would ...
Per the open(2) man page: O_DIRECT (since Linux 2.4.10) Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directl...
Is it safe to ignore O_DIRECT?
1,433,760,573,000
In some distributions /dev/fuse is owned by root:fuse while in other distributions /dev/fuse is owned by root:root. I'm using CentOS which belongs to the former set of distributions. And I'm wondering if it is secure for me to change the ownership on /dev/fuse to root:fuse.
Since FUSE is "File System in User Space", this could derive in undesired mounts, or virtual file system structures in your system that you didn't foresee/want to be there at all. Changing ownership of devices implies that other users may use directly these devices without needing administrative rights (root/sudo). Ch...
Changing ownership on /dev/fuse - security issues?
1,433,760,573,000
While creating incremental backups is relatively simple (and can be automated, e.g. via rdiff-backup), in order to access a specific state of a file one first has to manually restore the backup, which is both not-simple and tedious if you need to browse through multiple states. So is there a FUSE which allows to trans...
$ apt-cache search rdiff fuse rdiff-backup-fs - Fuse filesystem for accessing rdiff-backup archives (untested). http://code.google.com/p/rdiff-backup-fs/
Is there a FUSE which permits transparently accessing incremental backups?
1,433,760,573,000
I have been trying now for several days to get my new server up and running. I am running CentOS with MergerFS to pool my drives and samba to host to my windows machines. All of this running in Proxmox as well. Over the weekend I got a couple of hard drives to start my server out with and am unable to get the shares t...
I was able to resolve the issue with just a simple setting change setsebool -P samba_share_fusefs=1 and then restarting the smb service.
SELinux + MergerFS (fuse) not working well together
1,433,760,573,000
I have some bridge host, which allows access to protected network. I connect to it using this command: ssh sergius@bridge_host -D 3128 Thus, I can turn on socks proxy in browser and it works. I can login to hosts on that network with this command: ssh -o 'ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p' sergius@...
I was answering similar question not a long time ago. I didn't try it, but this one should work for you: sshfs -o ProxyCommand="/bin/nc.openbsd --proxy localhost:3128 \ --proxy-type socks5 %h %p" sergius@$host: /home/sergius/work/SSHFS/$host/ The SSHOPT=VAL just the format of option you want to use. You need to rep...
HOWTO: sshfs via socks proxy
1,433,760,573,000
The Fuse packages that are available by default on CentOS 7.3 are a bit dated. The compilation process for Fuse 3 and s3fs should be pretty straight forward. Fuse compiles and installs fine: mkdir ~/src && cd src # Most recent version: https://github.com/libfuse/libfuse/releases wget https://github.com/libfuse/libfus...
Version 1.8 of s3fs doesn't support fuse3. I learnt it rather hard way. I edited s3fs configure script to replace fuse with fuse3 in the version check. configure script went well after that. However, s3fs compilation fails with some error around incompatibility with fuse functions used. (I don't have the exact compila...
s3fs refuses to compile on CentOS 7, why's it not finding Fuse?
1,433,760,573,000
I'm running GlusterFS using 2 servers (ST0 & ST1) and 1 client (STC), and the volname is rep-volume. I surfed the net, and read all articles explaining how to fix mounting issues but unfortunately nothing could help me. The first time I used the following command, it worked perfectly and I had write access: $ mount.gl...
I had the same problem, but I tried to mount the clients on the same servers and it worked perfectly. In your case it would be done by running the following command on ST0 and ST1 respectively: ST0: ~ root # mkdir /mnt/replica ST0: ~ root # mount.glusterfs ST0:/rep-volume /mnt/replica/ ST0: ~ root # echo 'ST0:/rep-vol...
GlusterFS replicated volume - mounting issue
1,553,706,533,000
I need help for a bash script that counts files and folders in a specified directory on a Linux system (Debian), but I want to exclude a specified folder. I have a main directory named workdir with different script files and folders. Inside workdir, I have a directory named mysshfs. I use fuse/sshfs to mount an extern...
You can use -prune to avoid descending into subdirectories. Try these commands instead: find workdir -path "*/mysshfs/*" -prune -o \( -type f -print \) | wc -l find workdir -path "*/mysshfs/*" -prune \( -type d -print \) | wc -l
bash count files and directory, summary size and EXCLUDE folders that are fuse|sshfs
1,553,706,533,000
Tried to install curlftpfs in debian 12 says that the package is missing. While I understand that the package is still not active developed I use often curlftpfs inside some virtual machines transfer to transfer between various fs eg. windows/linux VMs that pass files through filezilla server and so on. So to me would...
curlftpfs ships a single, simple binary package; you can safely install the Debian 11 version in Debian 12. Assuming you’re using amd64: wget http://deb.debian.org/debian/pool/main/c/curlftpfs/curlftpfs_0.9.2-9+b1_amd64.deb sudo apt install ./curlftpfs_0.9.2-9+b1_amd64.deb
Is curlftpfs missing in debian 12?
1,553,706,533,000
I can normaly mount/umount FTP as file system using following commands: └──> curlftpfs -o codepage=windows-1250 anonymous:[email protected] /home/marek/ftpfs └──> ls /home/marek/ftpfs/ 1 2 3 └──> fusermount -u /home/marek/ftpfs └──> ls /home/marek/ftpfs/ └──> But when I issue curlftpfs with strace then nothing is mou...
I am not familiar with this executable, but my guess is that it needs to run with privilege (probably suid root or similar). strace -f cannot run such a process with privilege unless strace itself is run as root and you may need the -u option.
exit status of command is different when it is run via strace
1,553,706,533,000
The following line: /path1 /path2 posixovl none 0 0 fails with the error: /sbin/mount.posixovl: invalid option -- 'o' Usage: /sbin/mount.posixovl [-F] [-S source] mountpoint [-- fuseoptions] This is because mount.posixovl uses a non standard mount syntax, and fstab will call it assuming default mount synta...
I wrote a wrapper for mount.posixovl that enables it to be used with fstab First, rename /sbin/mount.posixovl to something else, like /sbin/mount.posixovl.orig Finally, create a new file /sbin/mount.posixovl whith the following contents: #!/bin/bash # wrapper for mount.posixovl to conform with common mount syntax # wi...
Mount posixovl using fstab
1,553,706,533,000
Is it possible to do an overlay mount when one of the paths has a colon in it? All of the FUSE overlay mounting solutions I've looked at use a colon to separate the paths in the overlay, and I can't find a way to escape it.
Directory Structure Let's say we're trying to overlay foo:bar, and bar:baz. The mount point will be union foo └── a bar └── b foo:bar └── c bar:baz └── d union mergerfs No matter what escaping you try to do, you can see from the source that it won't work. Annoyingly if you try to guess a way to escape it: $ mergerfs ...
FUSE overlay mount with colon in path
1,553,706,533,000
I'm experimenting with different union/overlay filesystem types. I've found unionfs-fuse package in Ubuntu which allowed me to use unionfs mount command as non-root user. But it seems aufs, which is created to provided similar options as unionfs, cannot be used as non-root user. I need to give sudo password for aufs m...
In researching this the answer appears to be: no. In looking at the man page for aufs I don't see any options that would allow it to mount as anything but the root user. In looking at the filesystems that libfuse supports I don't see aufs listed there either. Lastly if you look at the userspace filesystems it's not...
Can aufs be used as fuse filesystem like unionfs-fuse?
1,553,706,533,000
When an encrypted directory is mounted using EncFS as a regular user, you cannot execute a script in it with sudo (as root): $ sudo /run/media/yeti/usbdrive/encfs/test.sh sudo: /run/media/yeti/usbdrive/encfs/test.sh: command not found This is a security feature, but how can I still grant root permissions to this moun...
Encfs uses fuse under the hood. It includes an -o option to pass options to fuse. Adding -o allow_root will allow root to access the filesystem in addition to the user mounting (also note the similar but exclusive allow_others flag). To use this option, you will need to enable it in fuse config. In /etc/fuse.conf,...
Sudo says "command not found" for script in EncFS (no root access to EncFS mount?)
1,553,706,533,000
I'm trying to load the fuse kernel module but for some reason it seems like it's not getting loaded. But I also don't get any error message. Can someone explain to me what's going on? root@my-host:~# modprobe fuse root@my-host:~# echo $? 0 root@my-host:~# lsmod | grep fuse root@my-host:~# modinfo fuse modinfo: ERROR:...
Generally, if loading a module succeeds but that module doesn’t appear in lsmod’s output, it’s because the module is built-in — i.e. it’s part of the main kernel image and is always available¹. To check whether that’s the case, look in /lib/modules/$(uname -r)/modules.builtin: grep fuse /lib/modules/$(uname -r)/module...
modprobe fuse doesn't seem to load module
1,553,706,533,000
I want to mount files that are hosted on an HTTP server such as a video file or an ISO file like NFS shares but with HTTP. For example there is a Linux ISO and I want to see it on my files and copy it to other disks from the server etc. How can I do this? Is it possible to use FUSE filesystem for this?
You are searching for something like https://github.com/fangfufu/httpdirfs While thinking about it, I realize that WebDAV is just an extension of http. As long as you stay on basic operations you might end up just using http functionality. With this prerequisite, mounting your server via WebDAV might be an option, too...
How to mount http files?
1,553,706,533,000
I often use sshfs to mount a remote directory tree (say myhost:~/workspace/) to a local one (say ~/workspace-mount/), and open remote files in a local editor. It's not that uncommon that I get disconnected and that the remote directory tree is unmounted without my realizing it. If I unwittingly save the open files i...
Use the reconnect flag. That will keep the filesystem mounted. If you are disconnected, processes with pending operations on the filesystem will hang and eventually fail with a generic I/O error, unless the connection is restablished. Depending on how you set it up, after you are disconnected you might actually be rec...
Is there any way to prevent writing to an unmounted mount point?
1,553,706,533,000
Dir created inside a loop fs denies access, but has correct permissions. init.sh - creates an fs image and mounts it (user and group ids are 1000): #!/bin/bash mkdir -p out-dir dd if=/dev/zero of=out-dir.img bs=1024 count=125 /sbin/mkfs.ext4 out-dir.img guestmount -o uid=$(id -u) -o gid=$(id -g) -a out-dir.img -m/de...
This is the option: -o default_permissions. guestmount --fuse-help: ... -o default_permissions enable permission checking by kernel
guestunmount: can't cd into a dir, but the permissions are ok
1,553,706,533,000
hello I have been installed libfuse and sshfs in my ubuntu and the kernel version is 4.4.0-38. And now I want to sshfs user@localhost:/dir /mnt. but it always shows the error message: read: Connection reset by peer How come it always happened? Is there anyway to mount a disk by fuse?
Running the pure ssh in debug mode (ssh -vvv user@localhost) will give you a guide what is wrong. In this case, you need to install the openssh-server package to have where to connect.
Can sshfs mount the local disks?
1,553,706,533,000
I'M trying to rsync between two dirs using: rsync -atO --ignore-existing /src 1.1.1.1:/target/ The target dir is mounted via cloudfuse and the source dir is a regular one. I get an error: rsync: failed to set times on "/target/somefile": Function not implemented (38) rsync error: some files/attrs were not transferred...
Apparently cloudfuse doesn't support setting modification times on existing files (the "not implemented" error). Hence you need to tell rsync not to try it: rsync -a --no-times --ignore-existing /src 1.1.1.1:/target/ The -t you supplied was implied by -a and needs to be turned off, hence --no-times. Also -0 makes no ...
rsync with cloudfuse
1,553,706,533,000
After updating the server with apt-get update && apt-get upgrade this command return an error command echo "the-password" | sshfs [email protected]:/var/www /remote_mount -o password_stdin OS Debian 3.2.60-1+deb7u3 x86_64 (wheezy) error fuse: device not found, try 'modprobe fuse' first modprobe fuse root@dyntest-am...
This post solves the problem.. Just need to update the kernel http://forums.debian.net/viewtopic.php?t=113906
sshfs - device not found
1,568,533,746,000
There do seem to be several questions already about moving /var to another directory or another partition or device. What I would like to do is move it to a fuse-pooled fs. My goal: To install Linux server onto a USB, and have a fuse fs to manage the mounted JBOD's. But I would like to move /var to the storage p...
Instead of moving /var to the pool, a better solution would be to move /var to the tmpfs. After reading this from Chris Newland, I am going to go with moving /var to tmpfs, and adding noatime to the root install drive. # /etc/fstab: static file system information. # <file system> <mount point> <type> <options> ...
Moving /var to fuse pooled fs
1,568,533,746,000
Here the type is fuseblk: $ mount /dev/sdb1 on /media/me/MY-DEVICE type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2) Can see below that the Partition Type is HPFS/NTFS and conents is exFAT. Why the difference?
The mount on /media is a FUSE mount - a userspace filesystem mount. The underlying filesystem being mounted by the FUSE driver could be anything, including filesystems that may not be supported by the kernel. The Gnome desktop makes use of it for mounting USB keys and other removable media. FUSE allows safe mounting o...
Difference in file system type on mount and Disk Utility
1,568,533,746,000
In the context of an application that transfers some files to an ovh storage, and I am experiencing some problems mounting a fuse file system. This is the structure of my mount point in fstab mystorage /mnt/openstack svfs username=my-user-name,password=my-password,tenant=my-tenant,region=BHS1,container=my-contai...
I think mount does not support this use of user with the default fuse security setting (or allow_root). I think the resulting permissions are the same as if you used sudo mount. To allow access by multiple non-root users, you could set allow_other, allowing access by any user. If this raised concerns, it would be po...
How mount a svfs file system with user permissions? (without sudo)
1,568,533,746,000
While attempting to create a program that reads some configuration before launching programs as a normal user and then as the root user, I noticed this odd behavior. I can't seem to find mention of it anywhere else. Normal filesystems use the effective UID/GID for access checks, but it looks like FUSE seem to check al...
As you have noticed, without the allow_root/allow_other options, other processes are not allowed to access the filesystem. This is not meant to protect your filesystem, but to protect the other processes. For this reason, if the accessing process has a shred of another identity, the access can't be allowed. That's the...
FUSE filesystems look at saved UID/GID?
1,568,533,746,000
Hello Linux FUSE (Filesystem in Userspace) support O_DIRECT? because I use fio benchmark to test fuse but it always shows errors when I use directIO Mine machine is Ubuntu 4.4.0-38 x86_64 fio_version = 2.14 Below is my config file [global] ioengine=libaio **direct=1** time_based runtime=60 ramp_time=30 size=64g group_...
Yes, since version 2.4: What is new in 2.4 ... Allow 'direct_io' and 'keep_cache' options to be set on a case-by-case basis on open. I'd venture one of several things is likely happening: Your version of fuse isn't new enough. The actual underlying file system doesn't support direct IO, and fuse is simply retu...
Does FUSE support O_DIRECT/directI/O
1,568,533,746,000
I have read that support for the exfat filesystem has been incorporated in the Linux kernel since kernel ver 5.4 was released in late 2019 - early 2020. I'm confused about what this means wrt the exfat-fuse package. AFAIK, the exfat-fuse package existed prior to kernel ver 5.4, and was the ad-hoc method for mounting ...
Fuse was added on 2005-09-09, that's probably Linux ~2.6.18, far earlier than Linux 5.4 Does incorporation of support for exfat filesystems mean that the exfat-fuse package is no longer required? Both can be used but exfat-fuse has essentially been deprecated and superseded. There is no mention of a filesystem-spec...
Kernel-mounted vs FUSE-mounted exfat filesystem
1,568,533,746,000
I have two Linux systems: NFSServer1 (RHEL) and NFSClient1 (Ubuntu). On NFSServer1, ntfs-3g driver and ldmtool is installed. The NTFS device partitions are mounted by executing the command: mount -t ntfs-3g -o ro,noatime $devPath $mountPath Note: The two partitions /dev/mapper/ldm_vol_VishalWDD-Dg0_Volume1 and /dev/ma...
FUSE is a filesystem in userland – due to context switching overhead, it's not ever going to be as fast as an in-kernel file system, and my guess is this hurts even more when you have to do very file-system intense things like a find on it. So. Either use the NTFS3 in-kernel driver (as available in Linux 5.15 and on,...
Slow reading of millions of files in Fuseblk partitions shared over NFS
1,568,533,746,000
Today on backup rsync give me an error about a dir($HOME.cache/doc/by-app) I have checked it and I see this First I go to the dir cd $HOME.cache/doc$ cd by-app/ I do ls and.. ls /bin/ls: error while loading shared libraries: libcap.so.2: cannot read file data: Error 21 I do cd.. cd .. I control the dir-tree and mad...
This folder/mountpoint is created by xdg-desktop-portal, which is what flatpak uses to access resources outside of the sandboxes it runs applications on: https://docs.flatpak.org/en/latest/desktop-integration.html#portals Without it you may break whatever you installed via flatpak.
very strange dir/file, what is?
1,568,533,746,000
I am FUSE mounting a remote FreeBSD machine with sudo sshfs -C user@remote-ip:/home/user/ /mnt/localmnt/ -o allow_other -o SmartcardDevice=/dev/hidraw7 to authenticate via an OpenPGP smartcard device. I've tried this as both root and non-root users. This ties up standard input instead of returning to shell like a re...
This question started with trying to authenticate sshfs with an OpenPGP smartcard, then was edited to its current form when I thought authentication was solved. My current problem was using -o SmartcardDevice=/dev/hidraw7, which started because otherwise I was getting a password prompt from the remote host. (Users hav...
sshfs appears to mount, but ls & cp on local mount-point hang?
1,568,533,746,000
after removing the default exfat-fuse package version 1.2.5 from my Debian Stretch system and replacing it with version 1.3.0, compiled from source, running mount using type exfat results to an unknown filesystem error. Checking with /proc/filesystems reveals that exfat is not listed. Manually mounting exfat drives wi...
Install or symlink it as /sbin/mount.exfat. (I checked strace -f mount -t nosuchfs nowhere nowhere. It tries /sbin/mount.nosuchfs, /sbin/fs.d/mount.nosuchfs, and /sbin/fs/mount.nosuchfs only). What's the worst that could happen :). If you forget and try to apt install exfat-fuse again, it's either going to give you ...
Configure mount to recognize self compiled fuse exfat
1,568,533,746,000
How can someone remove the fuse support from OpenBSD? Would it require to recompile the kernel? Or just a config modifications or remove some binaries? How?
Kernel support for FUSE # grep FUSE /sys/conf/GENERIC option FUSE # FUSE would need to be removed; assuming sys.tar.gz has been foisted onto the system and all the latest and greatest patches applied # cd /sys/conf # cp GENERIC NOFUSE # (echo /FUSE; echo d; echo w; echo q) | ed NOFUSE 4048 option ...
How to "fully" remove fuse support from OpenBSD?
1,568,533,746,000
I'm on debian 8 jessie with a 4.2.3 kernel. I can't seem to get fuse installed and working. When I install fuse with sudo apt-get install fuse I get MAKEDEV not installed, skipping device node creation. Also when I do sudo modprobe fuse I end up with modprobe: FATAL: Module fuse not found. I tried installing makedev b...
Resolved by enabling FUSE_FS module in kernel compile .config
Install fuse debian 8 jessie
1,391,274,358,000
The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current directory, their sizes, and the sum total of their sizes. I'd love to have similar functionality with my dir alias in bash, but ...
The following function does most of what you're asking for: dir () { ls -FaGl "${@}" | awk '{ total += $4; print }; END { print total }'; } ... but it won't give you what you're asking for from dir -R *.jpg *.tif, because that's not how ls -R works. You might want to play around with the find utility for that.
Show sum of file sizes in directory listing
1,391,274,358,000
I am trying to sum certain numbers in a column using awk. I would like to sum just column 3 of the "smiths" to get a total of 212. I can sum the whole column using awk but not just the "smiths". I have: awk 'BEGIN {FS = "|"} ; {sum+=$3} END {print sum}' filename.txt Also I am using putty. Thank you for any help. smit...
awk -F '|' '$1 ~ /smiths/ {sum += $3} END {print sum}' inputfilename The -F flag sets the field separator; I put it in single quotes because it is a special shell character. Then $1 ~ /smiths/ applies the following {code block} only to lines where the first field matches the regex /smiths/. The rest is the same ...
Using awk to sum the values of a column, based on the values of another column
1,391,274,358,000
I have a list of directories and subdirectories that contain large csv files. There are about 500 million lines in these files, each is a record. I would like to know How many lines are in each file. How many lines are in directory. How many lines in total Most importantly, I need this in 'human readable format' ...
How many lines are in each file. Use wc, originally for word count, I believe, but it can do lines, words, characters, bytes, and the longest line length. The -l option tells it to count lines. wc -l <filename> This will output the number of lines in : $ wc -l /dir/file.txt 32724 /dir/file.txt You can also pipe da...
How do you list number of lines of every file in a directory in human readable format.
1,391,274,358,000
Having the following in one of my shell functions: function _process () { awk -v l="$line" ' BEGIN {p=0} /'"$1"'/ {p=1} END{ if(p) print l >> "outfile.txt" } ' } , so when called as _process $arg, $arg gets passed as $1, and used as a search pattern. It works this way, because shell expands $1 in place of a...
Use awk's ~ operator, and you don't need to provide a literal regex on the right-hand side: function _process () { awk -v l="$line" -v pattern="$1" ' $0 ~ pattern {p=1; exit} END {if(p) print l >> "outfile.txt"} ' } Here calling exit upon the first match as we don't need to read the rest. Y...
Pass shell variable as a /pattern/ to awk
1,391,274,358,000
This one-liner removes duplicate lines from text input without pre-sorting. For example: $ cat >f q w e w r $ awk '!a[$0]++' <f q w e r $ The original code I have found on the internets read: awk '!_[$0]++' This was even more perplexing to me as I took _ to have a special meaning in awk, like in Perl, but it turned ...
Here is a "intuitive" answer, for a more in depth explanation of awk's mechanism see either @Cuonglm's In this case, !a[$0]++, the post-increment ++ can be set aside for a moment, it does not change the value of the expression. So, look at only !a[$0]. Here: a[$0] uses the current line $0 as key to the array a, takin...
How does awk '!a[$0]++' work?
1,391,274,358,000
Trying to understand the differences between the two functions gawk vs. awk? When would one use gawk vs awk? Or are they the same in terms of usage? Also, could one provide an example?
AWK is a programming language. There are several implementations of AWK (mostly in the form of interpreters). AWK has been codified in POSIX. The main implementations in use today are: nawk (“new awk”, an evolution of oawk, the original UNIX implementation), used on *BSD and widely available on Linux; mawk, a fast im...
Difference between gawk vs. awk
1,391,274,358,000
I'm looking for the simplest method to print the longest line in a file. I did some googling and surprisingly couldn't seem to find an answer. I frequently print the length of the longest line in a file, but I don't know how to actually print the longest line. Can anyone provide a solution to print the longest line in...
cat ./text | awk ' { if ( length > x ) { x = length; y = $0 } }END{ print y }' UPD: summarizing all the advices in the comments awk 'length > max_length { max_length = length; longest_line = $0 } END { print longest_line }' ./text
How to print the longest line in a file?
1,391,274,358,000
In python re.sub(r"(?<=.)(?=(?:...)+$)", ",", stroke ) To split a number by triplets, e.g.: echo 123456789 | python -c 'import sys;import re; print re.sub(r"(?<=.)(?=(?:...)+$)", ",", sys.stdin.read());' 123,456,789 How to do the same with bash/awk?
With sed: $ echo "123456789" | sed 's/\([[:digit:]]\{3\}\)\([[:digit:]]\{3\}\)\([[:digit:]]\{3\}\)/\1,\2,\3/g' 123,456,789 (Note that this only works for exactly 9 digits!) or this with sed: $ echo "123456789" | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta' 123,456,789 With printf: $ LC_NUMERIC=en_US printf "%'.f\n" 123456789 12...
Add thousands separator in a number
1,391,274,358,000
In my understanding, awk array is something like python dict. So I write down the code bellow to explore it: awk '{my_dict[$1] = $2} END { print my_dict}' zen And I got: awk: can't read value of my_dict; it's an array name. As the first column isn`t a number, how could I read the total content of the array or travers...
You can loop over the array's keys and extract the corresponding values: awk '{my_dict[$1] = $2} END { for (key in my_dict) { print my_dict[key] } }' zen To get output similar to that you'd get with a Python dictionary, you can print the key as well: awk '{my_dict[$1] = $2} END { for (key in my_dict) { print key ": "...
How to view all the content in an awk array?
1,391,274,358,000
I want to grep the output of my ls -l command: -rw-r--r-- 1 root root 1866 Feb 14 07:47 rahmu.file -rw-r--r-- 1 rahmu user 95653 Feb 14 07:47 foo.file -rw-r--r-- 1 rahmu user 1073822 Feb 14 21:01 bar.file I want to run grep rahmu on column $3 only, so the output of my grep command should look like t...
One more time awk saves the day! Here's a straightforward way to do it, with a relatively simple syntax: ls -l | awk '{if ($3 == "rahmu") print $0;}' or even simpler: (Thanks to Peter.O in the comments) ls -l | awk '$3 == "rahmu"'
How to run grep on a single column?
1,391,274,358,000
I need to remove the last character from a string in this command: sudo docker stats --no-stream 39858jf8 | awk '{if (NR!=1) {print $2}}' The result is 5.20% , I need remove the % at the end, giving 5.20. Is it possibile to do this in the same command?
Yes, with substr() you can do string slicing: ... | awk '{if (NR!=1) {print substr($2, 1, length($2)-1)}}' length($2) will get us the length of the second field, deducting 1 from that to strip off the last character. Example: $ echo spamegg foobar | awk '{print substr($2, 1, length($2)-1)}' fooba
Remove last character from string captured with awk [duplicate]
1,391,274,358,000
Given: there are 40 columns in a record. I want to replace the 35th column so that the 35th column will be replaced with the content of the 35th column and a "$" symbol. What came to mind is something like: awk '{print $1" "$2" "...$35"$ "$36...$40}' It works but because it is infeasible when the number of column is ...
You can do like this: awk '$35=$35"$"'
How to replace the content of a specific column with awk?
1,391,274,358,000
I have the following code that I run on my Terminal. LC_ALL=C && grep -F -f genename2.txt hg38.hgnc.bed > hg38.hgnc.goi.bed This doesn't give me the common lines between the two files. What am I missing there?
Use comm -12 file1 file2 to get common lines in both files. You may also needs your file to be sorted to comm to work as expected. comm -12 <(sort file1) <(sort file2) From man comm: -1 suppress column 1 (lines unique to FILE1) -2 suppress column 2 (lines unique to FILE2) Or using grep command you need to ad...
Common lines between two files [duplicate]
1,391,274,358,000
I have a file named Element_query containing the result of a query : SQL> select count (*) from element; [Output of the query which I want to keep in my file] SQL> spool off; I want to delete 1st line and last line using shell command.
Using GNU sed: sed -i '1d;$d' Element_query How it works : -i option edit the file itself. You could also remove that option and redirect the output to a new file or another command if you want. 1d deletes the first line (1 to only act on the first line, d to delete it) $d deletes the last line ($ to only act on the...
How do I delete the first n lines and last line of a file using shell commands?
1,391,274,358,000
I have the following file: id name age 1 ed 50 2 joe 70 I want to print just the id and age columns. Right now I just use awk: cat file.tsv | awk '{ print $1, $3 }' However, this requires knowing the column numbers. Is there a way to do it where I can use the name of the column (specified on the firs...
Maybe something like this: $ cat t.awk NR==1 { for (i=1; i<=NF; i++) { ix[$i] = i } } NR>1 { print $ix[c1], $ix[c2] } $ awk -f t.awk c1=id c2=name input 1 ed 2 joe $ awk -f t.awk c1=age c2=name input 50 ed 70 joe If you want to specify the columns to print on the command line, you could do somet...
How to print certain columns by name?
1,391,274,358,000
I have a big file and need to split into two files. Suppose in the first file the 1000 lines should be selected and put into another file and delete those lines in the first file. I tried using split but it is creating multiple chunks.
The easiest way is probably to use head and tail: $ head -n 1000 input-file > output1 $ tail -n +1001 input-file > output2 That will put the first 1000 lines from input-file into output1, and all lines from 1001 till the end in output2
Split a file into two
1,391,274,358,000
I have file1 likes: 0 AFFX-SNP-000541 NA 0 AFFX-SNP-002255 NA 1 rs12103 0.6401 1 rs12103_1247494 0.696 1 rs12142199 0.7672 And a file2: 0 AFFX-SNP-000541 1 0 AFFX-SNP-002255 1 1 rs12103 0.5596 1 rs12103_1247494 0.5581 1 rs12142199 0.4931 And would like a f...
This should do it: join -j 2 -o 1.1,1.2,1.3,2.3 file1 file2 Important: this assumes your files are sorted (as in your example) according to the SNP name. If they are not, sort them first: join -j 2 -o 1.1,1.2,1.3,2.3 <(sort -k2 file1) <(sort -k2 file2) Output: 0 AFFX-SNP-000541 NA 1 0 AFFX-SNP-002255 NA 1 1 rs12103 ...
How to merge two files based on the matching of two columns?
1,391,274,358,000
If I have two files (with single columns), one like so (file1) 34 67 89 92 102 180 blue2 3454 And the second file (file2) 23 56 67 69 102 200 How do I find elements that are common in both files (intersection)? The expected output in this example is 67 102 Note that number of items (lines) in each file differs. Nu...
In awk, this loads the first file fully in memory: $ awk 'NR==FNR { lines[$0]=1; next } $0 in lines' file1 file2 67 102 Or, if you want to keep track of how many times a given line appears: $ awk 'NR==FNR { lines[$0] += 1; next } lines[$0] {print; lines[$0] -= 1}' file1 file2 join could do that, though it does requ...
Find intersection of lines in two files [duplicate]
1,391,274,358,000
We know that we can get the second column of the line we want from a file using these two techniques: awk '/WORD/ { print $2 }' filename or grep WORD filename| cut -f 2 -d ' ' My questions are: What are the differences between the two commands above? Which one has the best performance? What are the advantages of u...
The most prominent difference between your two lines would be depending on the input. cut takes a single character in -d as the field delimiter (the default being TAB), and every single occurrence of that character starts a new field. awk, however, is more flexible. The separator is in the FS variable and can be an em...
What are the exact differences between awk and cut with grep? [closed]
1,391,274,358,000
echo -e 'one two three\nfour five six\nseven eight nine' one two three four five six seven eight nine how can I do some "MAGIC" do get this output?: three six nine UPDATE: I don't need it in this specific way, I need a general solution so that no matter how many columns are in a row, e.g.: awk always displays the la...
It can even be done only with 'bash', without 'sed', 'awk' or 'perl': echo -e 'one two three\nfour five six\nseven eight nine' | while IFS=" " read -r -a line; do nb=${#line[@]} echo ${line[$((nb - 1))]} done
How to print only last column?
1,391,274,358,000
I have an http link : http://www.test.com/abc/def/efg/file.jar and I want to save the last part file.jar to variable, so the output string is "file.jar". Condition: link can has different length e.g.: http://www.test.com/abc/def/file.jar. I tried it that way: awk -F'/' '{print $7}' , but problem is the length of...
Using awk for this would work, but it's kind of deer hunting with a howitzer. If you already have your URL bare, it's pretty simple to do what you want if you put it into a shell variable and use bash's built-in parameter substitution: $ myurl='http://www.example.com/long/path/to/example/file.ext' $ echo ${myurl##*/}...
How to get last part of http link in Bash?
1,391,274,358,000
I am trying to grep the ongoing tail of file log and get the nth word from a line. Example file: $ cat > test.txt <<EOL Beam goes blah John goes hey Beam goes what? John goes forget it Beam goes okay Beam goes bye EOL ^C Now if I do a tail: $ tail -f test.txt Beam goes blah John goes hey Beam goes what? John goes for...
It's probably output buffering from grep. you can disable that with grep --line-buffered. But you don't need to pipe output from grep into awk. awk can do regexp pattern matching all by itself. tail -f test.txt | awk '/Beam/ {print $3}'
Piping from grep to awk not working
1,391,274,358,000
I have a file which includes comments: foo bar stuff #Do not show this... morestuff evenmorestuff#Or this I want to print the file without including any of the comments: foo bar stuff morestuff evenmorestuff There are a lot of applications where this would be helpful. What is a good way to do it?
One way to remove all comments is to use grep with -o option: grep -o '^[^#]*' file where -o: prints only matched part of the line first ^: beginning of the line [^#]*: any character except # repeated zero or more times Note that empty lines will be removed too, but lines with only spaces will stay.
How can I remove all comments from a file?
1,391,274,358,000
How can I print all the lines between two lines starting with one pattern for the first line and ending with another pattern for the last line? Update I guess it was a mistake to mention that this document is HTML. I seem to have touched a nerve, so forget that. I'm not trying to parse HTML or do anything with it ot...
You can make sed quit at a pattern with sed '/pattern/q', so you just need your matches and then quit at the second pattern match: sed -n '/^pattern1/,/^pattern2/{p;/^pattern2/q}' That way only the first block will be shown. The use of a subcommand ensures that ^pattern2 can cause sed to quit only after a match for ^...
Print lines of a file between two matching patterns [duplicate]