date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,383,242,434,000 |
I recently bought a Synology nas server and installed a 4TB HDD.
Now when accessing the nas through ssh, I checked how much space I have on my root account, and I found out it was only 1.5 GB.
But when I access the Synology nas through the browser, it says I have 3.5 TB available.
Is it possible for me to access this... |
Did you enable homes for root ? If so it's still just a subfolder of your volume.
Basically all data is on your volumes, which means accessing via ssh, switching to a root user and df -h should give you a correct breakdown of your mounts.
| How to access Synology nas available hard disk space through ssh? |
1,383,242,434,000 |
I would like to set multiple keyboard shortcuts doing the same thing. My particular example is Volume Up/Down, I would like to retain the standard settings I have (Sound/VolumeUp - XF86AudioRaiseVolume, my laptop dedicated button) and I would like to add a second set (Tux+Up). How can I do that? Thanks a lot.
|
In Gnome just go to Settings->Keyboard and click the Shortcuts tab.
You can redefine your 'Sound and Media' shortcuts and you can define custom shortcuts to execute special commands. As long you not use the same shortcut more than once, but in this case you'll get a warning message.
| Dual keyboard shortcuts in Gnome |
1,383,242,434,000 |
If I call
fdisk /dev/sda
it names /dev/sda a disk, and dev/sda1 a partition.
On the other hand, if I call
pvdisplay
then /dev/sda2/ is a PV name.
Are PV and partition synonyms ? If not, what are the differences between the two ?
context: I want to resize a partition. I wonder if pvresize is the command to use.
|
Are PV and partition synonyms ?
No.
A PV is a block device used by LVM to store data. In your case that is a partition, but it doesn't have to be, it could be a complete drive, it could be a raid array.
I want to resize a partition. I wonder if pvresize is the command to use.
In general resizing a partition has tw... | Are PV (physical volume) and partitions the same thing? |
1,383,242,434,000 |
I have imaged a smaller drive to a larger drive. I now need to increase the size of the parition/volume group (correct term?). The drive has ~1.6 TiB of unallocated space which I want /dev/sdb3 to use then allocate that increase to /dev/cl/root. Below is some information cobbled together from google searching. The... |
First, you'll have to edit the partition table to actually extend the sdb3 partition. You might use gparted, parted, gdisk or fdisk for this.
If you use gdisk or fdisk, the changes are only written to the partition table when you tell the program to do it, so with a single gdisk/fdisk session, you can view the exact ... | Increase the size lvm2 partition to use all unallocated disk space |
1,383,242,434,000 |
I have been using UGET in order to download what I need. I've had no problems with it until I tried downloading a file with 4.5 GB of volume. 3.6 GB of it has been downloaded and UGET stops working and gets killed unexpectedly. I checked for volume deficiency (Baobab 1.8.2 on Ubuntu-Mate 14.04) and viewed no problem w... |
The very simple solution is now discovered. The crash occurred in uGet because of the fact that I had changed the download preferences so that the program would use aria2, but didn't notice that aria2 does not get installed by itself in the time of installation of uGet (the very big problem when people migrate from w... | Why uget stops working and exits unexpectedly? |
1,383,242,434,000 |
How can I resize logical volume to fit filesystem automagically?
|
To increase the size of a filesystem you must first grow the logical volume container and then increase the size of the filesystem within. When decreasing the size of a filesystem, shrinking the surrounding logical volume is done last.
A shorthand way of expanding a logical volume and the filesystem is contains can b... | How to resize logical volume to fit filesystem |
1,383,242,434,000 |
Every time I boot up my Debian machine the sound volume level is at 100 % (what is way too loud). I am using PulseAudio instead of Alsa.
How can I adjust the default sound volume level to an arbitrary value (e.g. 30 %)?
|
Run
pactl set-sink-volume @DEFAULT_SINK@ 30%
command as autostart.
The other way:
echo 'set-sink-volume @DEFAULT_SINK@ 20000' >> ~/.config/pulse/default.pa
| PulseAudio on Debian 9: How to adjust default sound volume level? |
1,383,242,434,000 |
I've created two volumes I wish to use to store content of two folders /etc/php and /var/www inside of container:
$ docker volume create dvwa_etcphp
$ docker volume create dvwa_www
I have a container, which I run using the command:
docker run --rm -it -p 80:80 vulnerables/web-dvwa --name dvwatest \
--mount type=volum... |
Can you try following the following format for creating:
docker run -it --mount type=volume,src=<VOLUME-NAME>,dst=<CONTAINER-PATH> --mount type=volume,src=<VOLUME-NAME>,dst=<CONTAINER-PATH> -p host_port:container_port --name myservice <IMAGE>
Edit: Creation command has been edited
The above worked for me:
docker run... | Docker volume mount using CLI command |
1,383,242,434,000 |
I can run bindsym button4 exec amixer -D pulse sset Master 5%+ and bindsym button5 exec amixer -D pulse sset Master 5%- to adjust the volume from a terminal session. However when I add the commands to my config for i3 like so:
bar {
#status_command i3status
#status_command i3blocks -c ~/.i3/i3blocks... |
Your i3 version is very old, you need to update it to at least 4.11 (bindsym for i3bar is mentioned in its release notes).
You can find the user's guide for your version here.
| i3wm amixer controls from i3status |
1,551,116,915,000 |
I have lot of available space in /home
df -h output
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 8,9G 2,1G 6,4G 25% /
tmpfs 499M 4,0K 499M 1% /dev/shm
/vol/home 2,7T 2,3T 403G 86% /home
Inside /home/user/project I have the following directories:
$ ... |
A symbolic link can be used to implement your filesystem map:
cd /
ln -s home/user/project
| Mount and/or simulate volumes with existing directories? |
1,551,116,915,000 |
I would like to install two OpenVZ templates, each one in a different logical volume. I have created a separate partition, made it a physical volume, assigned it a group volume and separated in two logical volumes vzprimary and vzsecondary, mounted on /vz/vzprimary and /vz/vzsecondary like this:
[root@primary lost+fou... |
You should have --private option for vzctl create:
vzctl create CTID --private /vz/primary
vzctl create CTID --private /vz/secondary
If each container has a dedicated partition, also consider specifying --layout simfs. ploop might be unneeded overhead.
| Setting up OpenVZ container private area |
1,551,116,915,000 |
I have a server using software RAID (raid1) and I need to increase my volume on my root partition. I've been googling around with no luck of finding out how I can do this. I have 2x1TB RAID1.
My df -h:
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 20G 0 100% /
/dev/root 20G 20G ... |
This is quite tricky to do on a live system. The organization you've chosen is very inflexible to resizing.
My recommendation is to move some large chunk of the root partition into /home and create a symbolic link.
If you really want to resize, here's a way to do it. I recommend practicing first in a virtual machine,... | How do I increase my root volume |
1,551,116,915,000 |
I am running out of space on a particular filesystem. I know this with the following command df -H
$ sudo df -H
Filesystem Size Used Avail Use% Mounted on
udev 4.1G 13k 4.1G 1% /dev
tmpfs 807M 73M 734M 10% /run
/dev/nvme0n1p1 106G 34G 68G 33... |
I found my answer in this link
I was unable to install (ubuntu 18, production box) so I downloaded the sources and built it from here. I ran the following commands
make
sudo make install
For my specific issue I ran this command
sudo nvme id-ctrl -v /dev/nvme1n1 > nvme1n1Log
The result was
NVME Identify Controller:
v... | Mapping between EC2 volume and your mounted filesystem |
1,551,116,915,000 |
Running the command:
amixer -D pulse sset Master 30%
should set the audio volume to 30% right?
When running:
amixer get Master
It returns saying the audio volume is 52%.
Any explanation or solution to my problem?
Thanks!
|
Pulseaudio has its own set of volume controls, and the pulse device is the converter that lets ALSA-only applications use Pulseaudio.
I very much doubt setting any mixer control on the pulse device does anything sensible. And I'm not sure which value reading mixer controls would return, possible the volume setting of ... | Amixer returning wrong audio value |
1,551,116,915,000 |
I have 2 logical volumes lv1 and lv2 which are part of the same volume group vg0. I have to remove 2 physical disks that are associated to the vg0. Can I do a lvremove, vgreduce and pvremove on lv1 without affecting the data on lv2.
|
Yes, you can lvremove LV1 without affecting data on LV2. That's why they are separate LVs.
Before vgreducing a PV out of the VG, you should check that the PV is reported as completely free by either the pvs or the pvdisplay command. If not, and you have other PVs in the VG with free space available, you can use the pv... | Can I delete a Logical Volume from a Volume group with out affecting data on an other logical volume in the same volume group |
1,551,116,915,000 |
in my rhel 7.6 machine I used the pvs command in order to display the Pfree values
pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel_rhel7 lvm2 a-- <39.00g 4.00m
/dev/sdc vg_fg lvm2 a-- <200.00g 0
/dev/sdd docker lvm2 a-- <110.00g 0
more correctly way to displ... |
You can use --select to filter pvs output. In this case --select vgname=<name> will do the trick:
# pvs --select vgname=test -o pv_free --unit=g --no-suffix --no-heading
0.07
(I also have 3 VGs and test has only one PV with 70 MiB of free space.)
Check pvs --select help for more options.
| pvs + how to get the values of pfree in Giga for specific Volume group |
1,551,116,915,000 |
we have the following disks from lsblk , all disks are not lvm
sdc 8:32 0 80G 0 disk /var/hadoop1
sdd 8:48 0 80G 0 disk /var/hadoop2
sde 8:64 0 80G 0 disk
sdf 8:80 0 80G 0 disk
sdc and sdd disks are full ( 100% used )
the status is t... |
Instead of adding disks on the level of operation system you can do this directly in hadoop. You can add them to the dfs.datanode.data.dir property. The format is
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///disk/c0t2,/disk/c0t3,/dev/sde,/dev/sdf</value>
</property>
I am not 100% sure hadoop ca... | is it possible to increase disk size by using/adding another clean disk |
1,551,116,915,000 |
I mounted a new ext4 storage volume to my server after I had already installed an application that primarily uses /home. This application needs to take advantage of the additional storage, so I want to remount the volume so that it's used by the /home directory. Can anyone confirm my steps below?
umount -v /mnt/volume... |
I assume that /mnt/volume_nyc1_01 is the mountpoint for the new ext4 volume. There is a line in /etc/fstab in which this volume is mounted on /mnt/volume_nyc1_01.
The steps you mention are not technically wrong, but if you follow them, you'll end up having an empty /home directory - since it's a new ext4 fs only lost+... | Remounting /home in a new volume |
1,551,116,915,000 |
I am using Debian 9 with xfce and I would like to hide an unmounted volume in the Desktop.
I tried to install udisk; however, I ran into a lot of problems.
Does anyone know an easy way to hide an unmounted volume?
|
This worked for me:
# cat /etc/udev/rules.d/99-hide-partitions.rules
KERNEL=="sda*", ENV{UDISKS_IGNORE}="1"
You should run udevadm control --reload (as root) after modifying any udev rules, and log out and in to your desktop environment.
| How to hide a specific unmounted volume |
1,551,116,915,000 |
I am on Fedora 38 with LXQt. The volume control has no effect on the volume: if I increase it or decrease it until it is mute, the volume always stays the same. The only way around I have found is to use pavucontrol, which is not straightforward. Moreover, whenever I click on the screen, or pause a video, the volume g... |
this sounds like your volume control might not be controlling the volume of the right device.
I don't run LXQt, but this post by cipricus has an image of what the selection dialog would look like:
Make sure you've selected "PulseAudio" (or Pipewire, if that's being offered). Pick the same sink you pick in pavucontrol... | Volume control not working on Fedora 38 |
1,551,116,915,000 |
So, I an EC2 instance and 2 volume with 8GB and 50GB. Initially 8GB was mounted to root device (/dev/sda1). I intended to switch root to 50GB. Here are the steps, I followed:
- Stop the instance
- De-attach 8GB
- De-attach 50GB
- Attach 50GB to instance using /dev/sda1
- Start the instance
Now, I see status checks 1/... |
Stop the instance
Detach the 8GB
Snapshot the 8GB
Create a new volume using the snapshot created of desired capacity, .e.g 50GB
Attach the new volume using /dev/sda1
Boot the instance
Grow the file system on /dev/sda1 (exact command depends on the file system, e.g. for xfs it is xfs_growfs), otherwise you will see on... | EC2 1/2 status checks while replacing the volume |
1,551,116,915,000 |
I have just install brightnessctl to control my screen brightness, but can only run it as root. Doing otherwise prints the suggestion I "get write permission for device files". What is the correct way to do this? I would also like to be able to set volume with amixer without root privileges, which I assume is the same... |
Many device access problems can be resolved through group membership changes.
You can find the device name by watching sudo journalctl --follow as you connect your device. OR ls -1 /dev >dev.before, connect the device, wait 10 seconds, ls -1 /dev >dev.after;diff dev.{before,after}.
Specifically, if ls -l shows that t... | How do I "get write permission for device files" in Linux? |
1,551,116,915,000 |
I tried following the instructions in:
Can't resize a partition using resize2fs
But nothing seemed to work.
The output of lsblk is:
[AWS root@archive ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 300G 0 disk
├─xvda1 202:1 ... |
I successfully resized the disk by doing the following:
After increasing the size of the image in AWS console from 150Gb to 300Gb, I executed the following commands:
[AWS root@archive ~]$ pvresize /dev/xvda4
Physical volume "/dev/xvda4" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
REBOO... | cannot resize disk on aws instance |
1,375,397,894,000 |
Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance,
alias vim='vim -X'
alias grep='grep -E'
alias ls='ls -G'
The problem is that if I want to use which to see where my vim/grep/ls/etc is coming from, the alias gets in the way:
$ which vim
vim: a... |
which is actually a bad way to do things like this, as it makes guesses about your environment based on $SHELL and the startup files (it thinks) that shell uses; not only does it sometimes guess wrong, but you can't generally tell it to behave differently. (which on my Ubuntu 10.10 doesn't understand --skip-alias as ... | How to use `which` on an aliased command? |
1,375,397,894,000 |
When I do
which pip3
I get
/usr/local/bin/pip3
but when I try to execute pip3 I get an error as follows:
bash: /usr/bin/pip3: No such file or directory
This is because I recently deleted that file. Now which command points to another version of pip3 that is located in /usr/local/bin but the shell still remembers th... |
When you run a command in bash it will remember the location of that executable so it doesn't have to search the PATH again each time. So if you run the executable, then change the location, bash will still try to use the old location. You should be able to confirm this with hash -t pip3 which will show the old loca... | Bash remembers wrong path to an executable that was moved/deleted |
1,375,397,894,000 |
I've compiled the last emacs version from the source code (v24.2) because the version installed on my machine is (quite) old for me (v21.3). I've done the usual:
$configure --prefix=$HOME
make
make install
Now I am testing emacs and realized that it still launches the previous version ... while my $HOME/bin path is s... |
The three possibilities that come to mind for me:
An alias exists for emacs (which you've checked)
A function exists for emacs
The new emacs binary is not in your shell's PATH hashtable.
You can check if you have a function emacs:
bash-3.2$ declare -F | fgrep emacs
declare -f emacs
And remove it:
unset -f emacs
Yo... | My `which` command may be wrong (sometimes)? |
1,375,397,894,000 |
What is the difference between where and which shell commands?
Here are some examples
~ where cc
/usr/bin/cc
/usr/bin/cc
~ which cc
/usr/bin/cc
and
~ which which
which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
/usr/bin/which
~ which where
/usr/bin/which: no where in (/usr/local... |
zsh is one of the few shells (the other ones being tcsh (which originated as a csh script for csh users, which also had its limitation, tcsh made it a builtin as an improvement)) where which does something sensible since it's a shell builtin, but somehow you or your OS (via some rc file) broke it by replacing it with ... | What is the difference between which and where |
1,375,397,894,000 |
If the which command is not available, is there another 'standard' method to find out where a command's executable can be found?
If there is no other 'standard' method available, the actual system I face currently is a bare Android emulator with an ash Almquist shell, if that means anything.
|
This should be a standard solution:
type
type -t
type -p
| Is there an alternative to the `which` command? [duplicate] |
1,375,397,894,000 |
I have installed node.js at custom location and added the location to the $PATH in .profile file.
$ node --version
v0.6.2
$ which node
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:~/Unix/homebrew/bin
$ cat ~/.profile
export PATH="$PATH:~/Unix/homebrew/bin"
Node.js itself runs well. The prob... |
This is happening because ~ has not been expanded. Your shell knows how to deal with this, but which does not (nor would most other programs). Instead, do:
export "PATH+=:$HOME/Unix/homebrew/bin"
Alternatively, stop using which, and use the (almost always superior) type -p.
Here is a demonstration of the issue:
$ ech... | How to add home directory path to be discovered by Unix which command? |
1,375,397,894,000 |
$ xdg-open
The program 'xdg-open' is currently not installed. You can install it by typing:
sudo apt-get install xdg-utils
$ sudo apt-get install xdg-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
xdg-utils is already the newest version.
0 upgraded, 0 newly insta... |
This sounds like your package database is screwed up. First I'd identify all the versions of xdg-open that you have on your system. The type should always be used for doing this task, never rely on which or whereis.
Example
Identify all xdg-open's.
$ type -a xdg-open
xdg-open is /usr/bin/xdg-open
Find out which packa... | xdg-open is installed yet also is not installed |
1,375,397,894,000 |
I would like to take the output of a which command, and cd to the parent directory. For example, say I have the following:
which someprogram
With output:
/home/me/somedirectory/someprogram
And I would like to cd to the directory that someprogram lives in:
cd /home/me/somedirectory
I'd like to accomplish this in one... |
Use dirname:
cd "`dirname $(which program)`"
| Output of which command used for input to cd |
1,375,397,894,000 |
I've been frustrated before with differences in output from the which command across different platforms (Linux vs. Solaris vx. OS X), with different shells possibly playing into the matter as well. type has been suggested as a better alternative, but how portable would that be?
In the past I've written functions whi... |
In the 21st century, especially if you're targeting machines that are likely to have bash or zsh, you can count on type being available. (It didn't exist in extremely old unices, as in, from the 1970s or early 1980s.) You can't count on its output meaning anything, but you can count on its returning 0 if there is a co... | What is the best way to detect (from a script) whether software is installed? |
1,375,397,894,000 |
which -a ruby gives me
/usr/ruby
/usr/ruby
/usr/ruby
It gives the same path three times. Why does this happen?
|
Check your path. It's not that hard to end up with duplicates in it. Example:
»echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:
»which -a bash
/bin/bash
/usr/bin/bash
This is because my /bin is a symlink to /usr/bin. Now:
»export PATH=$PATH:/usr/bin
»echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/lo... | Why does the "which" command give duplicate results? |
1,375,397,894,000 |
I just realized that my sysadmin has created a global alias for which:
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
The which manpage just says:
Stop processing options on the right if not on tty.
What does this mean?
|
Setup:
$ /usr/bin/which --show-dot a
./a
$ /usr/bin/which --show-tilde a
~/a
If you wanted the . version when run interactively, but the ~ version when redirected, you would could use this as an alias:
/usr/bin/which --show-tilde --tty-only --show-dot
Demo:
# interactive / on a tty
$ /usr/bin/which --show-tilde --tt... | What does which's --tty-only option do? |
1,375,397,894,000 |
Background
I log into a server to do scientific computations. It runs 'Scientific Linux version 7.4'.
In order to get access to different software I have to run a command like 'module load x'. For instance to use python I need to write 'module load python'. I don't know much about this module system but from what I ... |
You probably have an alias or a shell function called “conda”.
Type
type conda
and see what it says.
| "which" can't find location of executable even though it runs |
1,375,397,894,000 |
We booted up our CentOS (6.4 Final, kernel version 2.6.32.... i686) VM today (running on a Windows machine, yeah I know...) and for some bizarre reason the 'which' binary has gone missing. (Last week, everything was fine).
ls -la /usr/bin shows no which. Although another strange thing: there was a 'which-nodejs' symli... |
Solved with:
rpm -e --justdb --nodeps which
sudo yum install which
Still not sure what could have caused this problem though...
| Missing 'which' executable on CentOS |
1,375,397,894,000 |
I run which and get the following,
brendan$ which python
/opt/local/bin/python
brendan$ which -a python
/opt/local/bin/python
/usr/bin/python
brendan$ ls -l /opt/local/bin/python
lrwxr-xr-x 1 root admin 24 22 Jul 00:45 /opt/local/bin/python -> /opt/local/bin/python2.4
brendan$ python
Python 2.6.1 (r261:67... |
The one that gets output when you run which without -a is the one which will get executed. (and the second one with -a is preferred over the third one).
This doesn't take into account the shell's builtins, aliases, and functions which will run (from within the shell) before any other executable.
Therefore, it's bette... | How to determine which executable on my path will be run? |
1,375,397,894,000 |
I would like to use which with the system's default path, ignoring any embellishments from the user's shell configuration files.
Motivation
I am attempting to write a script to find the system's Ruby binary. Many Ruby developers use a Ruby version manager, which adds something like ~/.rvm/bin to the start of their $PA... |
command -pv uses a "default value for PATH".
$ which ruby
/home/mikel/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
$ command -pv ruby
/usr/bin/ruby
Unfortunately that doesn't work in zsh, so based on Stephane's comment, we could use getconf PATH:
$ PATH=$(getconf PATH) which ruby
or use command -v in place of which, as rec... | How do I use which(1) with the system's default $PATH? |
1,375,397,894,000 |
I am reading the source code of the Maven wrapper written for the Bourne shell. I came across these lines:
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then
# snip
expr when used with arg1 and arg2 and a : m... |
Classically, which was a csh script, and it printed an error message like no foo in /usr/bin:/bin and returned a success status. (At least one common version, there may have been others that behaved differently.) Example from FreeBSD 1.0 (yes, that's ancient):
if ( ! $?found ) then
echo no $arg in $path
en... | Does any implementation of `which` output "no" when executable cannot be found? |
1,375,397,894,000 |
In zsh, when I enter which git it shows:
git: aliased to noglob git
How do I find out which git binary it actually invokes? (eg: /usr/bin/git vs ~/bin/git). Basically I want to bypass the aliases when I use which.
|
For zsh, which is shorthand for whence -c, and supports other whence options. In particular:
-p Do a path search for name even if it is an alias,
reserved word, shell function or builtin.
So:
$ which git
git: aliased to noglob git
$ which -p git
/usr/bin/git
| How do I find the actual binary/script using 'which' in zsh? [duplicate] |
1,375,397,894,000 |
If I want to return the path of a given executable, I can run:
which mysql
Which returns for example:
/usr/bin/mysql
I'd like to return only:
/usr/bin
How can I do that?
|
executable=mysql
executable_path=$(command -v -- "$executable") &&
dirname -- "$executable_path"
(don't use which).
Of course, that won't work if $executable is a shell builtin, function or alias. I'm not aware of any shell where mysql is a builtin. It won't be a function or alias unless you defined them earlier, ... | How to return the directory of a given executable? |
1,375,397,894,000 |
I have an executable script test under the full path /home/sawa/foo/bar/test. The directory /home/sawa/foo/bar is within $PATH, and has priority over the default ones including /usr/bin. When I do
`which test`
to see whether this command is correctly recognized, it returns
/home/sawa/foo/bar//test
with the double sl... |
I would guess that you have /home/sawa/foo/bar/ on your path - i.e. a path with a trailing slash.
which is iterating over each element of $PATH and appending /argv[1] and checking for the existence of that file. That causes a double-slash - one from the $PATH part, and one from /argv[1].
A double-slash is no problem. ... | What does '//' mean in return from `which` |
1,375,397,894,000 |
Observation:
I have an executable named foo, located in /b/foo. It is compiled against an old header of a dynamic library, causing it to segfault when executed:
$ foo
Segmentation fault. // Expected behaviour.
Now, I compile a new version of foo to /a/foo against the new dynamic library that should execute just fine... |
Bash caches the location of commands. Use hash foo to force it to update the cache.
Also, which is a separate command that doesn't tell you where your shell is actually looking; it just consults the $PATH environment variable. In bash, you should use type instead:
$ type foo
foo is hashed (/a/foo)
| Linux/bash does not execute the executable that "which" tells me [duplicate] |
1,375,397,894,000 |
We are running: Red Hat Enterprise Linux release 8.5 (Ootpa). We allow the server to update weekly using "yum -y update". We recently began receiving the following errors when executing shell commands:
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
I am ... |
I placed unset which in .bashrc as a work around. This worked for both bash and php. This morning I commented the unset which from .bashrc. The issue no longer exists. I believe the issue was created and resolved by upstream code changes. Thank you @ilkkachu!
| sh: which: line 1: syntax error: unexpected end of file; sh: error importing function definition for `which' |
1,375,397,894,000 |
I am trying to run ipython from the bash (version 4.4.19) command line.
As a Python developer, I have various installations of ipython at various versions in various virtualenvs' paths, and so it is important to know which one I am running. Hence the $PATH is always changed when I change virtualenv, and this would a ... |
It looks like at some previous time in your bash session, the "wrong" executable is called an then its pathname is remembered by Bash (that's normal, such feature prevents further PATH lookups for already known commands).
To fix this you should run
$ hash -d ipython
This clears the remembered location of ipython, so... | Why is the "wrong" executable being run? [duplicate] |
1,375,397,894,000 |
I've made a fresh install of Debian Wheezy, and installed zsh to it. Few days after, I've done a vanilla installation of TeX Live 2014, so I added the necessary binary paths to my $PATH. Now I started writing little scripts so I would like to put them somewhere easily accessible, that is ~/bin.
My path looks like this... |
In a shell command like
PATH=~/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
the tilde is expanded to your home directory when the shell command is executed. Thus the resulting value of PATH is something like
/home/theconjuring/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:... | $PATH environment variable does not seem to be recognized |
1,375,397,894,000 |
I would like to make crontab run this script as a regular user:
#!/usr/bin/env bash
PIDFILE=wp-content/uploads/sphinx/var/log/searchd.pid
if ! test -f ${PIDFILE} || ! kill -s 0 `cat ${PIDFILE}`; then
`which searchd` --config /home/user/www/wordpress-page/wp-content/uploads/sphinx/sphinx.conf
fi
It simply rerun... |
It's probably because of the $PATH. Do this in your shell outside of crontab:
command -v searchd | xargs dirname
This command will return a directory where searchd is on your system or an error if you don't have searchd in your $PATH even in an interactive shell. Now do this at the top of your script you execute in ... | How to use which command in Crontab? |
1,375,397,894,000 |
ssh bobby@tony:~$ which tmux
/usr/bin/tmux
ssh bobby@tony:~$ sudo which tmux
/usr/local/bin/tmux
ssh bobby@tony:~$ echo $PATH ... |
It's because your root user has a different path.
sudo echo $PATH
prints your path. It's your shell that does the variable expansion, before sudo starts (and passes it as a command line argument, expanded).
Try:
sudo sh -c 'echo $PATH'
| Why `which tmux` and `sudo which tmux` return 2 different values? |
1,375,397,894,000 |
I have to find the uname file on a Debian machine, check from which package it is and delete it. When I use which to find it, I get /usr/bin/uname. When I try to check it by dpkg -S uname there is no such file. There is a /bin/uname though. What is the difference between them?
|
There’s no difference; in Ubuntu, bin is a symbolic link to /usr/bin, some Debian systems, and various other distributions, so binaries appear in both locations.
Packages can ship files in either location; to find the package providing a given binary, look for bin/ followed by the binary:
dpkg -S bin/uname
| What's the difference between two uname files |
1,375,397,894,000 |
Suppose I want a bash command to do something extra. As a simple example, imagine I just want it to echo "123" before running.
One simply way to do this would be to alias the command. Since we still need the original, we can just refer to it by its exact path, which we can find using which. For example:
$ which rm
... |
exit is a shell special built-in command. It was built with the shell interpreter, the shell knows about it and can execute it directly without searching anywhere.
On most shells, you can use:
$ type exit
exit is a shell builtin
You have to read source of the shell to see how its builtin implemented, here is link to ... | Where is `exit` defined? |
1,375,397,894,000 |
Scenario
I have a ProductivityScripts project on GitHub, and when I install Linux (Debian 9), I add this folder to PATH for ease of use.
I.e., I add the following line to ~/.bashrc:
export PATH="~/Dev/ProductivityScripts:$PATH"
It works. I can now run scripts from inside this folder by name from anywhere.
alec@my_hos... |
This is most likely due to ~ not acting as a variable inside double quotes in combination with which not doing its own expansion of the tilde.
Use
PATH="$HOME/Dev/ProductivityScripts:$PATH"
instead. HOME is an environment variable and expands as usual within double quotes. Note also that since PATH is already exporte... | Command 'which' not showing output for custom PATH locations |
1,375,397,894,000 |
I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that pushd is simply a command, just like cd, ls etc.
So why does which pushd give me nothing?
|
popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.
excerpt bash man page
DIRSTACK
An array variable (see Arrays below) containing the current
contents of the directory stack. Directories appear in the stack
in the orde... | Why can't I which pushd |
1,375,397,894,000 |
I am running Ubuntu 12.04, which came with Cmake v 2.8.7.
I had need for a more current CMake, so I downloaded the source for 12.8.12.1, built, and installed it per directions. The last step, make install I ran sudoed.
./bootstrap
make
sudo make install
Now I want to run it, but I find that the old version is still... |
You should use the type command to know what is really under its name, i.e.:
type cmake
That might be an alias that run a different version of cmake, or a function with a similar behavior or finally a previously hashed command that in not any more the first one in your PATH, as you experienced.
| 'which' reports one thing, actual command is another [duplicate] |
1,375,397,894,000 |
Example:
I have alias chrome='google-chrome'. I want which chrome to return the same thing which google-chrome returns, i.e.:
/usr/bin/google-chrome
Is that possible?
|
Should you really want which to behave this way, you can redefine it as a shell function that way :
which() {
if [ -n "$(type "$1" | grep "is aliased")" ]; then
command which $(type "$1" | awk '
{cmd=gensub("[\140\047]", "", "g" , $NF);print cmd}')
else
command which "$1"
fi
}
Note that while this... | Can I use which command on aliases? [duplicate] |
1,375,397,894,000 |
Why isn't export python=/usr/local/bin/python2.7 changing the path to python?
I am baffled by the following:
$ which python
/usr/bin/python
$ export python=/usr/local/bin/python2.7
$ which python
/usr/bin/python
I'm using OSX v10.12.
|
The program which determines the path of shell commands.
What you did in the second statement is set a variable named python.
Shell commands and variables are entirely different things.
What you'd might like to use is an alias.
alias python="/usr/local/bin/python2.7"
Note, that (except in zsh or tcsh, or if your whi... | Why doesn't "export" overwrite existing values? |
1,375,397,894,000 |
If I run sudo which abc I would expect it to search the superusers $PATH for the program 'abc', but it looks like it only searches a subset.
I can see this by running sudo echo $PATH and comparing the paths searched.
$ sudo which abc
which: no abc in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo echo $PATH
/usr/local/bin:/b... |
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
| Which is not searching full $PATH |
1,453,612,941,000 |
Let me give an example:
$ timeout 1 yes "GNU" > file1
$ wc -l file1
11504640 file1
$ for ((sec0=`date +%S`;sec<=$(($sec0+5));sec=`date +%S`)); do echo "GNU" >> file2; done
$ wc -l file2
1953 file2
Here you can see that the command yes writes 11504640 lines in a second while I can write only 1953 lines in 5 seconds... |
In a nutshell:
yes exhibits similar behavior to most other standard utilities which typically write to a FILE STREAM with output buffered by the libC via stdio. These only do the syscall write() every some 4kb (16kb or 64kb) or whatever the output block BUFSIZ is . echo is a write() per GNU. That's a lot of mode-switc... | How does `yes` write to file so quickly? |
1,453,612,941,000 |
How do I get read and write IOPS separately in Linux, using command line or in a programmatic way? I have installed sysstat package.
Please tell me how do I calculate these separately using sysstat package commands.
Or, is it possible to calculate them using file system?
ex: /proc or /sys or /dev
|
iostat is part of the sysstat package, which is able to show overall iops if desired, or show them separated by reads/writes.
Run iostat with the -d flag to only show the device information page, and -x for detailed information (separate read/write stats). You can specify the device you want information for by simply... | How to get total read and total write IOPS in Linux? |
1,453,612,941,000 |
I have a user of name x in tty1 and y in tty2. Now x wants to write some message to y and vice-versa.
Now I typed in tty1 terminal write y tty2
It is showing
write:write:you have write permission turned off
write:y has messages disabled
Same thing is showing when y's sending message to x instead it is 'x' in the last ... |
It seems that y has turned off messages.
In y's terminal, type:
$ mesg
is n
meaning y does not allow others to write to y's terminal. Then you should try:
$ mesg y
Note
This option y in above command is different with y user in your case.
From man mesg:
NAME
mesg - control write access to your terminal
SYNOP... | Sending message from one terminal user to another user |
1,453,612,941,000 |
I have a question about overwriting a running executable, or overwriting a shared library (.so) file that's in use by one or more running programs.
Back in the day, for the obvious reasons, overwriting a running executable didn't work. There's even a specific errno value, ETXTBSY, that covers this case.
But for quite... |
It depends on the kernel, and on some kernels it might depend on the type of executable, but I think all modern systems return ETXTBSY (”text file busy“) if you try to open a running executable for writing or to execute a file that's open for writing. Documentation suggests that it's always been the case on BSD, but i... | Overwriting a running executable or .so |
1,453,612,941,000 |
I'm trying to run a command, write that to a file, and then I'm using that file for something else.
The gist of what I need is:
myAPICommand.exe parameters > myFile.txt
The problem is that myAPICommand.exe fails a lot. I attempt to fix some of the problems and rerun, but I get hit with "cannot overwrite existing file... |
You must have "noclobber" set, check the following example:
$ echo 1 > 1 # create file
$ cat 1
1
$ echo 2 > 1 # overwrite file
$ cat 1
2
$ set -o noclobber
$ echo 3 > 1 # file is now protected from accidental overwrite
bash: 1: cannot overwrite existing file
$ cat 1
2
$ echo 3 >| 1 # temporary allow overwrite
$ ca... | How can I output a command to a file, without getting a blank file on error? |
1,453,612,941,000 |
The normal way to safely, atomically write a file X on Unix is:
Write the new file contents to a temporary file Y.
rename(2) Y to X
In two steps it appears that we have done nothing but change X "in-place".
It is protected against race conditions and unintentional data loss (where X is destroyed but Y is incomplete... |
The issue
You have a (mostly) exhaustive list of systems calls here.
You will notice that there is no "replace the content of this inode" call. Modifying that content always implies:
Opening the file to get a file descriptor.
optional seek to the desired write offset
Writing to the file.
optional Truncating old data,... | Atomically write a file without changing inodes (preserve hard link) |
1,453,612,941,000 |
I have a regular file and I changed its permission to 444. I understand that as the file is write protected, we can't modify or remove the contents of file but when I try to remove this file using rm, it generates a warning stating whether I want to remove a write protected file or not. My doubt is that isn't that dep... |
Because the standard requires it:
3. If file is not of type directory, the -f option is not specified,
and either the permissions of file do not permit writing and the
standard input is a terminal or the -i option is specified, rm
shall write a prompt to the standard error and read a line f... | Why rm gives warning when deleting a write protected file? |
1,453,612,941,000 |
I'm learning file operation calls under Linux. The read() and write() and many other functions use cache to increase performance, and I know fsync() can transfer data from cache to disk device.
However, is there any commands or system calls that can determine whether the data is cached or written to disk?
|
Read data is (directly) read from the cache only if it is already there. That implies that cached data was previously accessed by a process and kept in cache. There is no system call or any method for a process to know if some piece of data to be read is already in cache or not.
On the other hand, a process can select... | How to determine whether the data is written to disk or cached? |
1,453,612,941,000 |
I would like to find out how many write cycles I can get from my SD
card.
I have googled and found good answers like this but its too complicated for a normal person like me.
Say its a 64GB exfat formatted card.
Isn't it possible to just write a large 59GB random file to it. Delete it. Make a count. And repeat the who... |
I think your idea can work.
You can write the data directly to the drive's device node (eg /dev/sdd). The rm command is not possible or necessary (it doesn't really remove much data anyway, rm only updates the metadata in the file system. You might consider writing all ones on one cycle, followed by all zeroes on the ... | Stress (write) Test an SD card to destruction using a simple shell script |
1,453,612,941,000 |
I'm developing an embedded linux system running on a SD card.
To protect the SD against corruption I've used a read only root filesystem as well as an extra partition where I mount /home, also in read only mode. It is in /home where the program runs and performs read-write operations.
When the software needs to writ... |
The remount itself ought to be fairly safe, though of course its a less-tested path in the kernel than, say, write(2). You may be causing a few extra writes (to mark the filesystem dirty/clean, etc.) You can you use the block dump feature (/proc/sys/vm/block_dump) to find out if you're causing any extra writes.
It's a... | Is it dangerous to remount a partition rw/ro frequently? |
1,453,612,941,000 |
I have purchased a new HDD for my backups. Before entrusting the device with the job of keeping my data safe I want to make sure that it is in good condition. The drive is a new internal 3.5 inch SATA drive.
I started a destructive write test with badblocks using the following command.
(Important: DON'T just copy past... |
You need to add the -c option to do more than 64 blocks and probabky -b to specify a block size other than 1KiB. Right now you're doing 64KiB at a time, which is a lot of seeks.
Something like:
badblocks -c 2560 -b 4096 -wsv -t random /dev/«device»
ought to run much faster. That's 10MiB (= 4KiB × 2560) at a time; go ... | What data transfer / write speeds are to be expected for a badblock destructible write test? |
1,453,612,941,000 |
I want to use pipes on Linux as a synchronization primitive between a master process and a slave process. The classic way is to create two pipes, but I believe there's a way to use a single fd instead. Consider:
The slave creates r-w pipe.
Read end r is passed to the master.
When the slave is ready, it writes to w N ... |
I would not rely on this element of behaviour. Pipes are intended to be a continuous stream of data. Reads and writes cannot be matched against each other easily, the only real guarantee you should rely on is that the first bytes in will be the first bytes out.
The reason for the manual comment regarding buffer pagi... | How do I feed data to a pipe until it's full, no more no less? |
1,453,612,941,000 |
If I use:
strace echo 'a
b
c' > file
The bottom lines are:
write(1, "a\nb\nc\nd\n", 8) = 8
but in
strace echo 'a
b
c
d' > /dev/pts/0
These lines are:
write(1, "a\n", 2) = 2
write(1, "b\n", 2) = 2
write(1, "c\n", 2) = 2
write(1, "d\n", 2) ... |
This is very simple.
The external echo command that you are running from strace is very probably the one from GNU coreutils. This is written in the C programming language, and uses the C runtime library functions such as putchar() and fputs() to write what it needs to write to the program's standard output.
In the C ... | Why does terminal takes input line by line? |
1,453,612,941,000 |
I am writing unit tests and would like to test some code's handling of the case where a call to write(2) returns zero. As ever, it would be nice to keep the test as authentic as possible.
I can use a file-descriptor of any kind for this purpose, as long as it returns zero on a call to write(2). I can also pass in pret... |
If influencing the actual input is difficult (such as reacting on a disc error), you should make a thin wrapper around the function, that depends on some global state. In this case I would put such a wrapper around write() to return 0 or the actual return from write().
If the overhead of the wrapper is too big use som... | Forcing write(2) to return 0 |
1,453,612,941,000 |
I need to format a luit command so I can write a file that I'm trying to fix the encoding for. What I have right now is luit -encoding gbk cat santi.txt, but I would like this to have the output written in a text file.
Backstory, I am having trouble reformatting a text document that was originally Chinese characters. ... |
luit -c <infile >outfile
the -c switch makes luit act like as a simple interpreter from stdin to stdout without its wrapping a child (your shell by default) in a pty and handling its i/o instead.
if you also do:
luit -olog /dev/tty -c <infile >outfile
luit will write to both your terminal and the outfile.
basically ... | How to write a luit command that outputs a file |
1,453,612,941,000 |
In the mp3gain manpages, you can read the following:
-t mp3gain writes modified mp3 to temp file, then deletes
original instead of modifying bytes in original file (This is
the default in Debian)
-T mp3gain modifies bytes in original file instead of writing to
... |
Your question suggests that Debian uses temp files for all writes, which isn't the case. This is simply the default for mp3gain.
In version 1.4.3-2, the package maintainer (Stefan Fritsch) decided that as writing to a temp file is much quicker on ReiserFS, then this would be the default on Debian. This was sourced fr... | Why does Debian prefer a temp file replacing the original over modifying bytes in original file? |
1,453,612,941,000 |
Hello GNU/Linux newbie here.
I want to write two variables in a two-columns tab-separated file. In my code, the variables are $sample_name and $file.
I use the commands:
touch to create the file and
echo -e $sample_name $file | column -t >> $output_file to write each line. Although this results in an one-column file.... |
You don't need to use column -t (in fact, that's going to expand your tabs with spaces so that the columns align correctly no matter the widths). Just use printf. And remember to double-quote your variables. e.g.
for file in "$path/"*.g.vcf; do
sample_name=$(echo "$file" | grep -P 'HG(\d+)(?=.g)' -o)
printf "%s... | Write two variables in a two-column file (tab-separated) |
1,453,612,941,000 |
I have a file which looks like this:
**********************************
Some notes are here
Year Month Day Hour Minute Second
. . . . . . . . . . . . . . . . .
Undertneath this, I would like to have dates appear using the following code
#!/bin/bash
for timestamp in (1262300400..1264978800..600)
do
date -d @"$timesta... |
Redirecting using > would create the output file that you redirect to, or, if it already exists, would truncate it to zero size. Any writes to the file would start at the beginning of the file and data would be written sequentially. This is not what you want to do.
Redirecting using >> would create the output file, or... | write in file starting from certain line |
1,453,612,941,000 |
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("If I had more time, \n");
write(STDOUT_FILENO, "I would have written you a shorter letter.\n", 43);
return 0;
}
I read that
I/O handling functions (stdio library functions) and system calls perform buffered operations
for increased performance... |
printf (of my specific libc) internally does a newfstatat() syscall on the stdout file descriptor (which is 1).
The kernel fills in the st_mode fiels with S_IFREG if it's a regular file you're piping into, and s_IFCHR if it's a character device (like a pseudo-terminal).
How I figured out:
gcc -o foo foo.c # compile yo... | How `stdio` recognizes whether the output is redirected to the terminal or a disk file? [duplicate] |
1,453,612,941,000 |
I need to synchronize an IO pin value with a write to a serial port from user space (because I wasn't yet able to do it from kernel space - see my other question). My code (leaving out error checking) is as follows:
char buf[3] = {'U','U','U'};
int fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY); // supposed to be blocking... |
For tty devices, you must use tcdrain() on the file descriptor.
| Knowing when a write() on a serial port has finished transmitting data |
1,453,612,941,000 |
I have an ssh account on a server. Someone is spamming me with write messages. So I can't run any command in an interactive login. Is there anyway I can prevent them from sending me write messages or any way I could just have a session without incoming write messages and do my things? I think they are just sending wri... |
From man 1 write:
You can prevent people (other than the superuser) from writing to you
with the mesg(1) command. Some commands, for example nroff(1) and
pr(1), may automatically disallow writing, so that the output they
produce isn't overwritten
From man 1 mesg:
mesg [option] [n|y]
The... | How to block messages from write? |
1,453,612,941,000 |
Can we use read(), write() on a directory just like on any other file in Unix/Linux? I have a confusion here because directories are also considered as files.
|
Some filesystems allow to use read() on directories, but this must be seen as a mistake since the data structures in such a directory may be undocumented.
You never can use write() since this would destroy the integrity of the affected directory.
The official interfaces for directories are opendir(), closedir() readdi... | Can we use read(), write() on a directory in unix/linux? |
1,453,612,941,000 |
I am having trouble with writing case $1 in a bash file. I tried with
cat <<EOT > /etc/init.d/startup.sh
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
case "$1" in
start)
bash /root/install.sh >> /root/installation_log.txt 2>&1
;;
stop|restart|reload)
;;
esac
EOT
But the problem ... |
Quote the EOF terminator passed to the << operator (in any way):
cat << 'EOT' > file
$var
EOT
Or
cat << \EOT
cat << EO\T
cat << "E"'O'T
cat << ""EOT
That's the documented and standard way to prevent any type of expansion inside the here-document.
| How to write text containing $var to a bash file? [duplicate] |
1,453,612,941,000 |
I recently got myself a Raspberry Pi 2 to learn a couple of things in my spare time. It is now running on Raspbian and I control it remotely via ssh from a laptop with Linux Mint 17.2 installed.
Now I would like the Pi to automatically tell the laptop that it is online after a reboot so that I know that I can connect ... |
Most likely this is because your startup script will run in a root environment by default.
Assuming that you're using ~/.ssh/id_rsa.pub as your mode of authentication (You never mentioned that you're using a password and using such a thing while automate is often a bad idea anyway, so i'll assume key authentication).
... | No output when running script on startup (but correct output if run manually) |
1,329,822,011,000 |
I'm wondering what the output of lsattr means.It prints so oddly as follows,when I have tried: lsattr /usr.
$ lsattr /usr
-----------------e- /usr/local
-----------------e- /usr/src
-----------------e- /usr/games
--------------I--e- /usr/include
--------------I--e- /usr/share
--------------I--e- /usr/lib
-------------... |
The man page for chattr contains all the info you need to understand the lsattr output.
excerpt
The letters 'aAcCdDeFijmPsStTux' select the new attributes for the files: append only (a), no atime updates (A), compressed (c), no copy on write (C), no dump (d), synchronous directory updates (D), extent format (e), case... | What's the meaning of output of lsattr |
1,329,822,011,000 |
Getfattr dumps a listing of extended attributes for a selected file.
However, getfattr --dump filename only to dumps the user.* namespace and not the security.*, system.*, and trusted.* namespaces. Generally, there are no user namespace attributes unless you attached one to a file manually.
Yes I know I can get th... |
I hate to do this but the answer is (after more research):
getfattr -d -m - file
I apparently missed this in my reading of the man page:
-m pattern, --match=pattern
Only include attributes with names matching the regular expression pattern. [...]
Specify "-" for including all attributes.
| How do I get a dump of all extended attributes for a file? |
1,329,822,011,000 |
I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself.
This does not work:
cp -v --attributes-only A B
cp: omitting directory `A'
Note: It does not have to be cp.
|
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owne... | How to clone/copy all file/directory attributes onto different file/directory? |
1,329,822,011,000 |
I'm trying to work out whether or not, or rather to what extend, xattrs are supported in FreeBSD using ZFS. I've read some conflicting information.
zfs get xattr lists it as on (default) for /, /usr and /var, but as off (temporary) for all other datasets, including children of those mentioned above.
Running zfs set x... |
As you have found, xattrs will work, but there are rough edges.
Sometimes you have to approach open source code like an Anthropologist. If this isn't helpful in itself, maybe this will provoke some better contributions (or eventually code fixes!)
I found this in the source code:
https://github.com/freebsd/freebsd/blob... | State of ZFS xattr support in FreeBSD |
1,329,822,011,000 |
Can I use find to find all files which have extended attributes set? Let's say, I want to find all files with +i, immutable attribute in /foo and its subfolders.
I could not find any, mention of extended attributes in man find.
Is there any other way to find all files with attributes
I am using Debian Wheezy
|
find itself doesn't support extended atttribute but you can use such as:
find ~/ -type f -iname "*" -exec lsattr {} + | grep -v -- '-------------'
| find files with extended attributes [duplicate] |
1,329,822,011,000 |
I know you can set or unset the hidden flag of a folder/file by doing chflags hidden foo.txt and chflags nohidden foo.txt.
But is there anyway of telling whether the folder/file is currently hidden or not?
I don't want to just determine if the folder/file is beginning with a dot.
|
According to the ls man page, you should be able -O option combined with the -l option to view flags with ls. For example:
ls -Ol foo.txt
-rw-r--r-- 1 harry staff - 0 18 Aug 19:11 foo.txt
chflags hidden foo.txt
ls -Ol foo.txt
-rw-r--r-- 1 harry staff hidden 0 18 Aug 19:11 foo.txt
chflags nohidden foo.txt
ls -Ol foo.tx... | Tell if a folder/file is hidden in Mac OS X |
1,329,822,011,000 |
I have a small question about extended file attributes. Assume I label my files with metadata in extended attributes (e.g. to account for the integrity - but this does not matter for my question). The questions that arise now:
Where are these attributes stored? Surely not in the inode I guess, but in what location - ... |
The answer to you question is filesystem specific. For ext3, for example, have a look at fs/ext3/xattr.c, it contains the following description:
16 /*
17 * Extended attributes are stored directly in inodes (on file systems with
18 * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
... | How are extended attributes stored and preserved? |
1,329,822,011,000 |
What is the relation and the difference between xattr and chattr? I want to know when I set a chattr attribute in Linux what is happening inside the Linux kernel and inode metadata.
|
The attributes as handled by lsattr/chattr on Linux and some of which can be stored by quite a few file systems (ext2/3/4, reiserfs, JFS, OCFS2, btrfs, XFS, nilfs2, hfsplus...) and even queried over CIFS/SMB (when with POSIX extensions) are flags. Just bits than can be turned on or off to disable or enable an attribut... | Difference between xattr and chattr |
1,329,822,011,000 |
My os: debian9.
The filesystem on my disk:
$ sudo blkid | awk '{print $1 ,$3}'
/dev/sda2: TYPE="ext4"
/dev/sda1: TYPE="vfat"
/dev/sda3: TYPE="ext4"
/dev/sda4: TYPE="ext4"
/dev/sda5: TYPE="swap"
Now to chattr +i for my /etc/resolv.conf :
sudo chattr +i /etc/resolv.conf
chattr: Operation not supported while reading fl... |
Your /etc/resolv.conf is probably a symlink.
See this explanation for further information.
You could try:
chattr +i "$(realpath /etc/resolv.conf)"
Does the root mountpoint support Access Control Lists (acl)
or Extended Attributes?
Check it via:
findmnt -fn / | grep -E "acl|user_xattr" || echo "acl or user_xattr mount... | How to set `chattr +i` for my `/etc/resolv.conf `? |
1,329,822,011,000 |
I'm trying to secure my authorized_keys file to prevent it from being modified. I run this:
[root@localhost]# chattr +i authorized_keys
chattr: Inappropriate ioctl for device while reading flags on authorized_keys
I think it may be due to the filesystem:
[root@localhost]# stat -f -c %T /home/user/
nfs
there is a wa... |
NFS doesn't have a concept of immutable files, which is why you get the error. I'd suggest that you just remove write access from everyone instead, which is probably close enough for your purposes.
$ > foo
$ chmod a-w foo
$ echo bar > foo
bash: foo: Permission denied
The main differences between removing the write b... | `chattr +i` error on NFS |
1,329,822,011,000 |
How can we lock a symlink so it cannot be deleted?
With a normal file/directory chattr +i /file/location can achieve this but doing so with a symlink we get chattr: Operation not supported while reading flags on my-file.
There is a similar question, How to set `chattr +i` for my `/etc/resolv.conf `?, but without a sol... |
This doesn’t provide a solution, but it explains why chattr can’t make a symlink immutable.
On Linux, immutable attributes are part of a set of flags which are controlled using the FS_IOC_SETFLAGS ioctl. Historically this was implemented first in ext2, and chattr itself is still part of e2fsprogs. When it attempts to ... | How to make a symlink read only (`chattr +i /location/symlink`)? |
1,329,822,011,000 |
I'm ssh'ed into a local Centos 7 docker container* and I'm trying to run
sudo chattr +i file1
but I'm getting an error:
chattr: Operation not permitted while setting flags on file1
What's going on here? What flags is it talking about? Is there a workaround?
Changing the +i to +a also makes the command fail with th... |
This is related to capabilities thing: chattr requires CAP_LINUX_IMMUTABLE which is disabled in docker by default. Just add --cap-add LINUX_IMMUTABLE to docker container start options to enable it.
Here's an example:
user@test:~$ docker run --cap-add LINUX_IMMUTABLE -it bash
bash-5.0# cd home
bash-5.0# touch test
bash... | In docker, "chattr: Operation not permitted while setting flags on file" |
1,329,822,011,000 |
I downloaded a .pem file and my Mac OS X (10.8.2) added an @ sign at the end of the file permissions. This is causing file permission issues. I can't seem to remove the quarantine flag. I even tried the command
xattr -d <filename>.pem
but that didn't work
|
xattr -d requires you to specify which attribute you want to remove. You can find this out by listing the file attributes by passing ls the -@ flag as in:
ls -l@ filename
Once you know what the attribute is, you can target it for removal with -d or you can use the following to clear all attributes:
xattr -c filename... | how to remove quarantine from file permissions in os x |
1,329,822,011,000 |
I was trying to remove some old history from my .bash_history file, but I was receiving this message:
[john ~] /home/john $ mv .bash_history .bas
mv: impossible to move `.bash_history' to `.bas': Operation not permited
I suspected the file/directory permission:
[john ~] /home/john $ ls -ld .bash_history .
drwxrwx--T+... |
The a attribute means that the file is append-only: you can't overwrite it or delete it, only append data to it. This is explained in the chattr man page. Only root can remove the attribute.
The practical consequence is that you can't erase your old history lines. This is presumably intended as a security measure by y... | What does the 'a' attribute in lsattr mean? |
1,329,822,011,000 |
I imagine that adding n xattrs of length l of to f files and d directories may generate costs:
storage
path resolution time / access time ?
iteration over directories? (recursive find over (fresh after reboot not-cached) filesystem?)
I wonder what are those costs?
E.g. if tagging all files would significantly impact... |
For ext4 (I can't speak for BtrFS), storing small xattrs fit directly into the inode, and do not affect path resolution or directory iteration performance.
The amount of space available for "small" xattrs depends on what size the inodes are formatted as. Newer ext4 filesystems use a default inode size of 512 bytes, o... | What are costs of storing xattrs on ext4, btrfs filesystems? |
1,329,822,011,000 |
When I modify a file, the file capabilities I had set earlier are lost. Is this the expected behavior?
I first set a file capability:
$ setcap CAP_NET_RAW+ep ./test.txt
$ getcap ./test.txt
./test.txt = cap_net_raw+ep
As expected I found the file capability is set.
Then I modify the file.
$ echo hello >> ./test.txt
N... |
Yes it is expected behaviour. I don't have a document that says it but you can see in this patch from 2007
When a file with posix capabilities is overwritten, the
file capabilities, like a setuid bit, should be removed.
This patch introduces security_inode_killpriv(). This is
currently only defined for c... | Linux File Capabilities are lost when I modify the file. Is this expected behavior? |
1,329,822,011,000 |
I have written a short shell script that simply wraps setfattr in a slightly more convenient form for setting the extended attribute that corresponds to a free-text comment:
#!/bin/sh
test "$2" && setfattr -n user.xdg.comment -v "$2" "$1"
getfattr -d -m '^user.xdg.comment$' "$1"
For storing US ASCII comments as xattr... |
I got a bit curious reading this questoion, so let’s do some “forensics”:
First trying the opposite:
How is åäöåä encoded in Base64?
$ echo åäöåä | base64
w6XDpMO2w6XDpAo=
This clearly looks a lot like the 0sw6XDpMO2w6XDpA== that you’ve got. There’s an extra 0s at the beginning, and the end doesn’t exactly match. Sup... | What is this seemingly base64 data set by setfattr? |
1,329,822,011,000 |
I have coreutils installed via MacPorts on my Mac running OS X 10.8.4. I have ls set to use the coreutils version of ls [(GNU coreutils) 8.21] when available:
if [ -e /opt/local/libexec/gnubin ]; then
alias ls='/opt/local/libexec/gnubin/ls --color=auto'
else
alias ls='/bin/ls -G'
fi
When I run ls -l in a dire... |
I believe Mark Cohen’s comment is correct: this functionality seems to be absent from the coreutils version of ls. I didn’t actually have a good reason to be using coreutils ls, so I’ve switched back to the built-in BSD version.
| See extended attributes with coreutils ls on Mac |
1,329,822,011,000 |
I'm trying to keep a bunch of plain text files compressed using the extended attribute option - c on a debian ppc64 system. I ran the following commands:
# mkfs.ext4 /dev/test/compressed
# mount /dev/test/compressed /mnt/compressed/
# mkdir /mnt/compressed/some/txts/
# chattr +c /mnt/compressed/some/txts/
# df -l
# c... |
Makes sense to have a look at the man page of the programs you use:
BUGS AND LIMITATIONS
The c', 's', andu' attributes are not honored by the ext2 and ext3 filesystems as implemented in the current mainline Linux kernels.
This is not supposed to mean "ext4 works" I guess.
| What does the command "chattr +c /some/dir/" do? |
1,329,822,011,000 |
I have two machines, one Debian, one Ubuntu, both on ext4 with extended file attributes enabled in fstab. getfattr and setfattr are installed and work perfectly on both machines locally. However, unison (version 2.40.102) doesn't sync extended file attributes by default.
I googled around and found this blog post with ... |
In case anyone runs into the same issue as I did in the future - unison doesn't work with extended file attributes. One way to go around it is the copyprog + copythreshold=0 hack (see the profile in the original question), but this doesn't solve the problem of unison not noticing changes in xattr's. As I mentioned in ... | Unison and extended file attributes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.