date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,574,504,450,000 |
I'm sure this is a dumb question, but I'm new to QEMU so please bear with me.
└──╼ $ qemu-aarch64 ./a.out
qemu-aarch64: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory
I'm assuming I just failed to install something, but I can't seem to figure it out and SO would probably shoot this question do... |
You need to install the relevant C library. Since Parrot OS is based on Debian, and provides arm64 binaries, the following should work:
Enable the arm64 architecture (this matches aarch64):
sudo dpkg --add-architecture arm64
Update the local repository caches:
sudo apt update
Install the arm64 C library:
sudo apt... | qemu-aarch64: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory |
1,574,504,450,000 |
I'm trying to compile zfs on my raspberry pi4, running CentOS 7.7 (64bit).
I followed the instructions provided here: https://github.com/zfsonlinux/zfs/wiki/Building-ZFS but can't get past the following error:
checking kernel source version... 4.19.86-v8+
checking kernel file name for module symbols... Module.symvers... |
Thanks to the folks over at https://github.com/zfsonlinux/ I managed to resolve the issue.
Looks like the kernel-devel package contained scripts that were compiled for x86 instead of arm64:
# file /usr/src/kernels/4.19.86-v8+/basic/fixdep
basic/fixdep: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamicall... | Compiling ZFS on aarch64 CentOS |
1,396,660,916,000 |
I was wondering if Unix systems use the GPU for the startup splash/loading screen because I've been having some trouble with an overheating Mac with graphics issues. Unix-type systems (such as MacOS 10.6, 10.10 and different versions of Ubuntu) show the splash screen, but never actually boot into the GUI (typically ju... |
The answer to your literal question is yes: all systems use the GPU to display startup messages and splash screens. That's because going through the GPU is the only way to display something on the monitor.
However, the answer to the question you meant to ask is no: the ways the GPU is used during startup and after the... | Do Unix systems and other similar systems use the GPU for the startup splash/loading screen (when there is one)? |
1,396,660,916,000 |
I installed Crunchbang Linux. I successfully installed the ATI drivers, and all works well. Except that the colors are bit weird. Hard to say what exactly is wrong, it is the notion that on another laptop (or windows on the same laptop) everything looks better. It's probably some combination of brightness/contrast/gam... |
You should check out Monica - it's a handy GUI frontend that let's you calibrate your monitor. Monica depends on fltk-devel AFAIK. Read the wiki article on color management under Linux.
A little bonus (and one of my favourite monitor tools) is Redshift which is the Linux equivalent of F.lux. It sets the temperature of... | Calibrate LCD display in laptop? |
1,396,660,916,000 |
I am using ElementaryOS with the default Drivers and my Gala process is constantly using tons of CPU (sometimes more than 200%).
I have looked everywhere but couldnt find a solution. I tried to install the proprietary ATI drivers but then I can't login in the system (black screen).
My graphic card is an ATI Mobility R... |
I think I finally fixed it!
I need to create a xorg.conf file and add set the correct driver to radeon; it was fbdev before.
Section "Device"
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
... | ElementaryOS Gala using more than 100% CPU constantly |
1,396,660,916,000 |
Update: see comment below, Switching Radeon 3450 tv out mode between component and svideo
I have this card that works in Windows, and in Grub it has color and looks fine, but in xorg I just get black and white from the component (RGB) cables. I have tried changing tv format with xrandr, but no change. I can change the... |
Partial answer:
The Radeon can have both an internal (part of the GPU) or an external (extra chip) decoder. They usually have registers where you can set which signals gets output on which DAC (digital/analog converter). As the encoders were meant for analog TVs, a usual setting "composite" (both luminance and chromin... | Switching Radeon 3450 tv out mode between component and svideo |
1,396,660,916,000 |
I've been researching on problems with ATI catalyst drivers and there is no fix as far as I can see. I have an ATI Radeon 7470m (HP Pavilion dm4). And I haven't managed to have a properly working distro.
Is there any Linux distro that behaves well with this card and allows me to have GNOME3 without burning my laptop?... |
It looks like you should burn your laptop:
Your card is not supported by any driver, closed or open source.
You need to use what is working for you at the moment and wait for AMD to start supporting your card via their drivers.
After screwing around with a HP/dv6 I vowed never to get ATI ever again (and mine even wo... | ATI friendly distro? |
1,396,660,916,000 |
I've installed AMD Catalyst 13.8 BETA2 by following these directions.
It works fine on the administrative user it was setup with, but a non-admin user gets the black screen on login.
Non-admin user works in software rendering mode but not hardware.
cat /var/log/Xorg.0.log
[ 42815.421] (EE) AIGLX error: failed to open... |
I think I'm starting to get what happened. One of the answers on the page you linked to tells you to run this:
cd /usr ; sudo ln -svT lib /usr/lib64
That will i) move you into the /usr directory and ii) create a link called lib64 (which will be /usr/lib64 if you run the ln command in /usr) pointing to /usr/lib. The c... | How to safely give non-root access to lib so that Catalyst hardware acceleration can function? |
1,396,660,916,000 |
On my system I'm unable to install the recommended graphics driver, so something must be wrong with my installation.
The GPU chipset is ATI ES1000, but the recommended driver is NVIDIA NVS300 downloaded from the server vendor's site.
The maximum graphics resolution of the onboard graphics controller ATI
ES1000 wit... |
The ES1000 is built-in to your motherboard, the NVS300 is an optional extra. Which is why are you getting an error message saying NVRM: No NVIDIA graphics adapter found!
The text you quoted says that if you want higher resolution than what the ATI ES1000 supports, then you can install an Nvidia NVS300, which is a com... | Unable to load the kernel module 'nvidia.ko' |
1,396,660,916,000 |
I have a 8,3 MacBook Pro with an onboard Radeon 6700M GPU alongside the integrated Intel Sandy Bridge GPU. I recently upgraded to FGLRX 8.930/12.1, and Catalyst Control Center seemed to look the same, there weren't any different options as opposed to 8.920/11.12. However, here it mentions that someone tested things ou... |
As of right now, FGLRX graphics switching will not work on mbp 8,x model. The only way to use fglrx for your model is through BIOS emulation mode, and because of that it will not work.
You can however get graphics switching to work on your model by setting up EFI boot. Doing so is not easy and requires a series of g... | Determining if GPU switching works? |
1,396,660,916,000 |
The time has come for me to upgrade my aging gpu (9800 gt). The AMD 7950 has caught my attention because of the attractive price with pleasing benchmarks. But it is common knowledge that AMD GPUs have poor support on Linux.
What sort of performance can I expect, with say, the latest version of Ubuntu? Will I have issu... |
A generally good experience. I did have KDE problems (some minor crashes, really rarely) with my Radeon 7870, but this never happened on Ubuntu with Unity.
Installing the driver is pretty straightforward. I used the AMD installer to generate the .deb files and installed them by hand. Then I generated the config file... | How well will the AMD Radeon HD 7950 gpu perform on Linux? |
1,396,660,916,000 |
I have a ATI Radeon 2400 XT, and a Nvidia GTX 580 in my debian computer. The 580 has 3 ports, but only 2 of them could be used at the same time. I bought the refurbished Radeon so that I could use another screen, but it was being ignored.
I reconfigured my bios so that the Radeon was the primary display, and the ttys ... |
I have fixed this by using nouveau, then setting the Radeon to be the output
| Nvidia and ATI gpu system for three monitors |
1,396,660,916,000 |
Installed a fresh Debian Wheezy to enjoy Gnome 3 but it starts in fallback mode. I suppose that's because the loaded drivers do not support 3D acceleration.
Installed packages I know are relevant:
xserver-xorg-video-ati
libgl1-mesa-dri
The Gnome 3 was working fine with Ubuntu 12.04, and I belive it was using the FOS... |
The firmware for your graphics card is missing. You have to explicitly install firmware-linux-nonfree from the non-free repository.
Add the non-free repository to /etc/apt/sources.list (or /etc/apt/sources.list.d/)
Run apt-get update as root
Install firmware-linux-nonfree with apt-get install firmware-linux-nonfree
... | How to configure FOSS ATI drivers on Debian Wheezy and ATI RS880 [Radeon HD 4250]? |
1,396,660,916,000 |
I've the ATI proprietary drivers. When I power on the computer and I do the login all works well, but when I run xorg I can't change tty or exit from xorg because if I try I see only a black screen (the monitor backlight stays on).
If I change tty (ctrl alt f2) I've the black screen, if then I
return to xorg (ctrl a... |
I've solved. I looked the log: backup framebuffer data, that it means that it changes framebuffer. I've thinked: "The framebuffer doesn't work maybe?". So I have try to change framebuffer using this: https://wiki.archlinux.org/index.php/Uvesafb and now it works.
And I think this is also the only way, for ATI proprieta... | Black screen when I move from X session to tty session |
1,314,200,977,000 |
Let's say I create a user named "bogus" using the adduser command. How can I make sure this user will NOT be a viable login option, without disabling the account. In short, I want the account to be accessible via su - bogus, but I do not want it to be accessible via a regular login prompt.
Searching around, it seems I... |
passwd -l user
is what you want.
That will lock the user account. But you'll still be able to
su - user
but you'll have to su - user as root.
Alternatively, you can accomplish the same thing by prepending a ! to the user's password in /etc/shadow (this is all passwd -l does behind the scenes). And passwd -u will un... | Disable a user's login without disabling the account |
1,314,200,977,000 |
How can I mount some device with read-write access for a given user?
|
There's no generic way to do exactly that. If the filesystem doesn't have a notion of file ownership, it probably has a mount option (uid) to decide which user the files will belong to. If the filesystem does have a notion of file ownership, mount it read-write, and users will be able to write every file they have per... | Mount device with r/w access to specific user |
1,314,200,977,000 |
I'm trying to set up remote access to D-Bus, and I don't understand how authentication and authorization are (not) working.
I have a D-Bus server listening on an abstract socket.
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-g5sxxvDlmz,guid=49bd93b893fe40d83604952155190c31
I run dbus-monitor to watch what... |
D-Bus isn't using the magic cookie file here; it's passing credentials over the UNIX domain socket (SCM_CREDENTIALS).
The magic cookie file is only one of several D-Bus authentication mechanisms. D-Bus implements a SASL-compliant interface (see RFC4422) to support a wide range of authentication mechanisms. One of th... | D-Bus authentication and authorization |
1,314,200,977,000 |
I'm currently trying to set up an SSH server so that access to it from outside the network is ONLY allowed using an SSH Key and does not allow access to root or by any other username/password combination.
At the same time, internal users inside the network, still need to be able to connect to the same system, but expe... |
So, it turns out the answer was actually way, way simpler than I thought it would be.
I do however have to thank '@jeff schaller' for his comments, if it hadn't of been for him I wouldn't have started looking into how the SSH 'Match' configuration works.
Anyway
The trick is to set your /etc/ssh/sshd_config file up as ... | Is it possible to have 2 ports open on SSH with 2 different authentication schemes? |
1,314,200,977,000 |
I've inherited the administration of a linux box in my workplace; it was set up by a colleague who is now gone. Recently, I added a new user to the system, and tried to give her ssh access as well; the way most people who use the machine access it. This, I can't get to work.
Here's what happens:
scmb-bkobe03m:~ xzha... |
If you're absolutely sure that you've restarted the SSH server or told it to reload its configuration file by sending it a SIGHUP…
Maybe the AllowUsers is in a Match section? If there is a previous Match directive, it might cause jonathan, arwen and the others to be only allowed in certain circumstances, as in
…
Match... | User denied ssh access while in AllowUsers list |
1,314,200,977,000 |
My error is:
mount.nfs4: access denied by server while mounting fileserver:/export/path/one
My question is:
where would the detailed log information be on the server (under systemd)?
More information:
I asked a similar question from the Ubuntu client perspective on AskUbuntu. My focus in this question is on the Arc... |
I was having exactly the same problem, with both client and server Arch linux. The solution was to use the hostname in /etc/exports instead of the IP address. I changed this:
/srv/nfs 192.168.10(rw,fsid=root,no_subtree_check)
/srv/nfs/media 192.168.10(rw,no_subtree_check)
/srv/nfs/share 192.168.10(rw,no_subtree_chec... | Where are NFS v4 logs under systemd? |
1,314,200,977,000 |
What I would like to do is be able to login and sudo commands immediately without entering a password again. It is very redundant to type my password twice in a row when I need to login and run a privileged command. I understand the security risk which requires us to reenter a password when we've been away for awhile... |
You can use pam_exec to invoke an external command. Beware that pam_exec runs in an environment that is under the control of the user who calls the login service, so don't invoke it from su, only from services with a predictable environment such as sshd or login.
sudo has no option to update a user's time stamp, only ... | How to automatically enter sudo's grace period upon CLI login? [duplicate] |
1,314,200,977,000 |
I am using Ubuntu 16.04.
There is a file located at /usr/share/polkit-1/actions/org.freedesktop.login1.policy which seems to control the permissions regarding shutdown/suspend/hibernate options.
In this file, the revelant options are in this format:
<defaults>
<allow_any>no</allow_any>
<allow_inactive>auth_adm... |
From section DECLARING ACTIONS of polkit - Authorization Framework:
defaults
This element is used to specify implicit authorizations for
clients.
Elements that can be used inside defaults includes:
allow_any
Implicit authorizations that apply to any client. Optional.
a... | Explanation of file - org.freedesktop.login1.policy |
1,314,200,977,000 |
I'm pretty new to the deployment world but this is what's going on. I have a new Ubuntu (Ubuntu 16.04.4 LTS) droplet from DigitalOcean. I installed and configured nginx and everything is working smooth. I turn it on and off with: service nginx start/service nginx stop but I need to be able to do this with a different ... |
With the visudo command you edited the file /etc/sudoers, which only applies if you prefix your commands with sudo, in your case sudo service nginx start.
| Trying to run "service nginx restart" from a non root user |
1,314,200,977,000 |
I have read the answer to this question:
https://stackoverflow.com/questions/4102763/apache-basic-authentication-except-for-those-allowed
It helped me understand how to not authenticate some users (according to the IP):
<Directory /var/www/files/>
Require valid-user
Allow from 192.168.1.2
Satisfy Any
A... |
Have you tried mod-auth external, it allows you to do your custom authentication mechanism for Apache.
It gives you access to environment variables such as IP, USER, PASS, etc.
You can write a script in a language that you are familiar with and go fetch the authentication data from your database.
The wiki has some exa... | Apache Authorization for the Allowed Users? |
1,314,200,977,000 |
I've been struggling for days with this now and can't find what I'm doing wrong.
I've got a website on a VPS server. Every night I make a backup of the database. It gets stored on my VPS server. I also want to send a copy to my NAS (Synology DS214play) at home. Both servers operate on Linux.
So I've logged into my VPS... |
When troubleshooting problems with daemons, you should always check the system logs.
In this particular case, if you check your system logs on the NAS host, you'll see something similar to:
Authentication refused: bad ownership or modes for directory /home/admin
The problem is shown in this output:
admin@NAS:~$ ls -a... | SCP command keeps asking password |
1,314,200,977,000 |
Possible Duplicate:
Creating a UNIX account which only executes one command
There is a shell script which has to be executed through an existing user account XXX. Now I have various other users which shall be able to execute only this script as well without getting access to the user account XXX. Is there a way to... |
If running the script is the only thing you want those other users to be able to do, then I'd go with using ssh keys.
Each user should have their own ssh key, so you won't get into a hassle when somebody no longer needs access. The public part of the key should be put into
~scriptuser/.ssh/authorized_keys
and in fro... | Allowing ssh, but only to execute a specific script [duplicate] |
1,314,200,977,000 |
I'd like to use a passwordless key to perform e.g. unison synchronization while being able to SSH into the server only with a password-protected key. The usual way of using scponly is changig the login-shell of my server account, but that is too global. Can an entry in authorized_keys achieve this instead?
|
You can use command keyword in authorized_keys to restrict execution to one single command for particular key, like this:
command="/usr/local/bin/mysync" ...sync public key...
Update:
If you specify a simple script as the command you may verify the command user originally supplied:
#!/bin/sh
case "$SSH_ORIGINAL_CO... | How to associate only one public key with a restricted shell like scponly? |
1,314,200,977,000 |
Does the root user bypass capability checking in the kernel, or is the root user subject to capability checking starting with Linux 2.2?
May applications check for and deny access for the root user, if certain capabilities are dropped from its capability set?
By default the root user has a full set of capabilities.
Th... |
The root user can be constrained in its set of capabilities. From capabilities(7):
If the effective user ID is changed from nonzero to 0, then the permitted set is copied to the effective set.
This implies that in the capability model, becoming the root user does not grant all permissions, unlike in the traditional... | Does the root user bypass capability checking? |
1,314,200,977,000 |
If the ls -l command gives me a permission string like
rwsr-s--x
What does the 's' mean? The only sources I found mention that it can be present sometimes but do not elaborate.
What does a '+' instead of a '-' mean? I have found mentions of 'extended permission' but nothing clear.
|
As explained by the very good and comprehensive wikipedia page on the subject :
+ (plus) suffix indicates an access control list that can grant additional permissions. Details are available with man getfacl.
Furthermore, there are three permission triads :
First triad : what the owner can do
Second triad : what th... | '+' and 's' in permission strings |
1,314,200,977,000 |
I don't like typing the password for sudo so I disabled it with
%sudo ALL=(ALL) NOPASSWD: ALL
Now I have a bad side effect that any shell script I run can silently execute sudo on my behalf.
The most typical use case would be intending to install experimental stuff to ${HOME}/local and forgetting to configure the PRE... |
In addition to Gilles' answer to the Can I block non-interactive sudo invocation? aspect of your question, I would suggest a work-around for this particular element of your situation:
I don't like typing the password for sudo so I disabled it
and
Now I have a bad side effect that any shell script I run can silently... | block scripted sudo |
1,314,200,977,000 |
I'm trying to use cURL to automate some processes that we usually do using a website.
I was able to login to the website using curl and the following command:
curl -k -v -i --user "[user]:[password]" -D cookiejar.txt https://link/to/home/page
However, when I'm trying to use the generated cookiejar.txt file for subseq... |
I was able to reach the desired page in the end.
It seems that I wasn't following the correct sequence of URL calls. Once I did that, the desired page was retrieved correctly.
Thank you very much for the quick responses !
| curl authentication works but I cannot reach other pages |
1,314,200,977,000 |
I am trying to manually connect between my laptop and phone. I have bluez-utils version 4.98-2ubuntu7 installed. When I run the agent on the terminal, I get:
asheesh@U32U:~$ sudo bluetooth-agent 4835
Pincode request for device /org/bluez/980/hci0/dev<id>
Authorizing request for /org/bluez/980/hci0/dev<id>
The pincode... |
This is just a workaround to the problem. Any suggestions on how to tackle the actual problem of bluetooth-agent stalling are welcome.
I used stdbuf to disable line buffering of STDOUT when running bluetooth-agent in the background. This updates the log file in real time, thereby letting me check and trigger the rest... | Why is bluetooth-agent getting stuck on authorizing? |
1,314,200,977,000 |
I have a remote server that I need to download Apache logs from.
I can manually scp into the server and get the files, but I'd like to put this in crontab. The only way to automate it is to include the password of the target server which I'd rather not do.
What would you recommend to scp into the other server, get fil... |
I would recommend creating a private/public key pair on the client machine, and copying the public key to the remote machine.
You can generate such a keypair with ssh-keygen and copy it to the remote machine using ssh-copy-id.
The logs are probably readable by all user accounts on the server (at least they are on my m... | Shell Script - how to scp into remote server and download files and protect password |
1,314,200,977,000 |
I'm working on a piece of automation that generates a list of allowed public keys and overwrites a server's user ~./ssh/authorized_keys. Is there a way to prevent a mistake in the automation to completely block me from accessing the host? I have some limitations, the server itself is from a VM image that gets updates ... |
sshd by default already checks ~/.ssh/authorized_keys and ~/.ssh/authorized_keys2. This is configurable with the AuthorizedKeysFile option in /etc/ssh/sshd_config, which can take a list of multiple files to check. From sshd_config(5):
AuthorizedKeysFile
Specifies the file that contains the public keys used for user... | Fallback for authorized_keys |
1,314,200,977,000 |
I've a very easy question. However I have been digging all the manuals for an answer for a full day already.
What I want is to configure Apache to give anyone read access to /var/www but restrict /var/www/private to my team only. I'm looking for the new solution of version 2.4. Thus not using deprecated directives lik... |
The default Apache settings for /var/www meet your requirements already. You can restrict access to /var/www/private using Require group team as you suggested, by adding the missing configuration as follows.
Require directives default to RequireAny so it can usually be omitted unless you need to change it as shown in... | Restrict access to subdirectory in Apache |
1,314,200,977,000 |
How can I give certain users authorization to start and stop certain services?
I am asking specifically about Fedora 19 systems with SELinux installed.
The utility to call for services administration is in this case systemctl.
What type of SELinux security policy do I have to write? Where? How? Any references?
|
RHEL doesn't yet have systemd, so the approach for Fedora 19 and RHEL will be dramatically different.
At any rate, what you are trying to do is not sanely possible. You'd have to create a separate login role for each user and grant it ability to execute systemd without transitioning into systemd domain -- at which poi... | SELinux policy to authorize some users to start / stop certain services |
1,314,200,977,000 |
I've upgraded my virtual machine from Opensuse 12.2 M3 to 12.2 Beta 1 and it hangs at the startup after the mysqld. However I can manually access a terminal and start kdm as root but kdm doesn't recognize my user? I have double checked the password and it's not a typo? I don't have special character like here http://w... |
It was my .xinitrc missing the line exec startkde and cannot start a windowmanager.
| kdm cannot authorize my user? |
1,323,032,234,000 |
I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this.
This way:
export PATH=~/opt/bin:$PATH
or this?
export PATH=$PATH:~/opt/bin
|
The simple stuff
PATH=$PATH:~/opt/bin
or
PATH=~/opt/bin:$PATH
depending on whether you want to add ~/opt/bin at the end (to be searched after all other directories, in case there is a program by the same name in multiple directories) or at the beginning (to be searched before all other directories).
You can add mult... | How to correctly add a path to PATH? |
1,323,032,234,000 |
In the terminal, I can type Ctrl + R to search for a matching command previously typed in BASH. E.g., if I type Ctrl + R then grep, it lists my last grep command, and I can hit enter to use it. This only gives one suggestion though. Is there any way to cycle through other previously typed matching commands?
|
If I understand the question correctly you should be able to cycle through
alternatives by repeatedly hitting Ctrl + R.
E.g.:
Ctrl + R
grep
Ctrl + R
Ctrl + R
...
That searches backwards through your history. To search forward instead, use Ctrl + S, but you may need to have set: stty -ixon (either by .bash_profile o... | How to cycle through reverse-i-search in BASH? |
1,323,032,234,000 |
I would like to display the completion time of a script.
What I currently do is -
#!/bin/bash
date ## echo the date at start
# the script contents
date ## echo the date at end
This just show's the time of start and end of the script. Would it be possible to display a fine grained output like processor time/ io tim... |
Just use time when you call the script:
time yourscript.sh
| How to get execution time of a script effectively? |
1,323,032,234,000 |
I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some forget.
I want a history that:
Remembers everything from every terminal
Is instantly accessible from every terminal (... |
Add the following to your ~/.bashrc:
# Avoid duplicates
HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; hi... | Preserve bash history in multiple terminal windows |
1,323,032,234,000 |
I have been looking at a few scripts other people wrote (specifically Red Hat), and a lot of their variables are assigned using the following notation
VARIABLE1="${VARIABLE1:-some_val}"
or some expand other variables
VARIABLE2="${VARIABLE2:-`echo $VARIABLE1`}"
What is the point of using this notation instead of just d... |
This technique allows for a variable to be assigned a value if another variable is either empty or is undefined. NOTE: This "other variable" can be the same or another variable.
excerpt
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted.
Otherwise, the value of parameter is... | Using "${a:-b}" for variable assignment in scripts |
1,323,032,234,000 |
What's the most concise way to resolve a hostname to an IP address in a Bash script? I'm using Arch Linux.
|
You can use getent, which comes with glibc (so you almost certainly have it on Linux). This resolves using gethostbyaddr/gethostbyname2, and so also will check /etc/hosts/NIS/etc:
getent hosts unix.stackexchange.com | awk '{ print $1 }'
Or, as Heinzi said below, you can use dig with the +short argument (queries DNS s... | How can I resolve a hostname to an IP address in a Bash script? |
1,323,032,234,000 |
This question is a sequel of sorts to my earlier question. The users on this site kindly helped me determine how to write a bash for loop that iterates over string values. For example, suppose that a loop control variable fname iterates over the strings "a.txt" "b.txt" "c.txt". I would like to echo "yes!" when fnam... |
If you want to say OR use double pipe (||).
if [ "$fname" = "a.txt" ] || [ "$fname" = "c.txt" ]
(The original OP code using | was simply piping the output of the left side to the right side, in the same way any ordinary pipe works.)
After many years of comments and misunderstanding, allow me to clarify.
To do OR you... | In a bash script, using the conditional "or" in an "if" statement |
1,323,032,234,000 |
I have a folder with some directories and some files (some are hidden, beginning with dot).
for d in *; do
echo $d
done
will loop through all files and directories, but I want to loop only through directories. How do I do that?
|
If you need to select more specific files than only directories use find and pass it to while read:
shopt -s dotglob
find * -prune -type d | while IFS= read -r d; do
echo "$d"
done
Use shopt -u dotglob to exclude hidden directories (or setopt dotglob/unsetopt dotglob in zsh).
IFS= to avoid splitting filenames co... | How do I loop through only directories in bash? |
1,323,032,234,000 |
I would like to change a file extension from *.txt to *.text. I tried using the basename command, but I'm having trouble changing more than one file.
Here's my code:
files=`ls -1 *.txt`
for x in $files
do
mv $x "`basename $files .txt`.text"
done
I'm getting this error:
basename: too many arguments Try basename ... |
Straight from Greg's Wiki:
# Rename all *.txt to *.text
for file in *.txt; do
mv -- "$file" "${file%.txt}.text"
done
*.txt is a globbing pattern, using * as a wildcard to match any string. *.txt matches all filenames ending with '.txt'.
-- marks the end of the option list. This avoids issues with filenames starti... | How do I change the extension of multiple files? |
1,323,032,234,000 |
Noone should need 10 years for asking this question, like I did. If I were just starting out with Linux, I'd want to know: When to alias, when to script and when to write a function?
Where aliases are concerned, I use aliases for very simple operations that don't take arguments.
alias houston='cd /home/username/.scrip... |
An alias should effectively not (in general) do more than change the default options of a command. It is nothing more than simple text replacement on the command name. It can't do anything with arguments but pass them to the command it actually runs. So if you simply need to add an argument at the front of a single c... | In Bash, when to alias, when to script and when to write a function? |
1,323,032,234,000 |
I'm working in Mac OSX, so I guess I'm using bash...?
Sometimes I enter something that I don't want to be remembered in the history. How do I remove it?
|
Preventative measures
If you want to run a command without saving it in history, prepend it with an extra space
prompt$ echo saved
prompt$ echo not saved \
> # ^ extra space
For this to work you need either ignorespace or ignoreboth in HISTCONTROL. For example, run
HISTCONTROL=ignorespace
To make this setting ... | How to remove a single line from history? |
1,323,032,234,000 |
How can I get the size of a file in a bash script?
How do I assign this to a bash variable so I can use it later?
|
Your best bet if on a GNU system:
stat --printf="%s" file.any
From man stat:
%s total size, in bytes
In a bash script :
#!/bin/bash
FILENAME=/home/heiko/dummy/packages.txt
FILESIZE=$(stat -c%s "$FILENAME")
echo "Size of $FILENAME = $FILESIZE bytes."
NOTE: see @chbrown's answer for how to use stat on BSD or macOS s... | How can I get the size of a file in a bash script? |
1,323,032,234,000 |
… or an introductory guide to robust filename handling and other string passing in shell scripts.
I wrote a shell script which works well most of the time. But it chokes on some inputs (e.g. on some file names).
I encountered a problem such as the following:
I have a file name containing a space hello world, and it w... |
Always use double quotes around variable substitutions and command substitutions: "$foo", "$(foo)"
If you use $foo unquoted, your script will choke on input or parameters (or command output, with $(foo)) containing whitespace or \[*?.
There, you can stop reading. Well, ok, here are a few more:
read — To read input li... | Why does my shell script choke on whitespace or other special characters? |
1,323,032,234,000 |
When I execute a program without specifying the full path to the executable, and Bash must search the directories in $PATH to find the binary, it seems that Bash remembers the path in some sort of cache. For example, I installed a build of Subversion from source to /usr/local, then typed svnsync help at the Bash promp... |
bash does cache the full path to a command. You can verify that the command you are trying to execute is hashed with the type command:
$ type svnsync
svnsync is hashed (/usr/local/bin/svnsync)
To clear the entire cache:
$ hash -r
Or just one entry:
$ hash -d svnsync
For additional information, consult help hash an... | How do I clear Bash's cache of paths to executables? |
1,323,032,234,000 |
Here is an example of using cut to break input into fields using a space delimiter, and obtaining the second field:
cut -f2 -d' '
How can the delimiter be defined as a tab, instead of a space?
|
Two ways:
Press Ctrl+V and then Tab to use "verbatim" quoted insert.
cut -f2 -d' ' infile
or write it like this to use ANSI-C quoting:
cut -f2 -d$'\t' infile
The $'...' form of quotes isn't part of the POSIX shell language (not yet), but works at least in ksh, mksh, zsh and Busybox in addition to Bash.
| How to define 'tab' delimiter with 'cut' in Bash? |
1,323,032,234,000 |
Is it "resource configuration", by any chance?
|
As is often the case with obscure terms, the Jargon File has an answer:
[Unix: from runcom files on the CTSS system 1962-63, via the startup script /etc/rc] Script file containing startup instructions for an application program (or an entire operating system), usually a text file containing commands of the sort that ... | What does "rc" in .bashrc stand for? |
1,323,032,234,000 |
I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working directory into a variable?
|
There's no need to do that, it's already in a variable:
$ echo "$PWD"
/home/terdon
The PWD variable is defined by POSIX and will work on all POSIX-compliant shells:
PWD
Set by the shell and by the cd utility. In the shell the value
shall be initialized from the environment as follows. If a value for
PWD is passed ... | How can I get the current working directory? [duplicate] |
1,323,032,234,000 |
In my ~/.bashrc file reside two definitions:
commandA, which is an alias to a longer path
commandB, which is an alias to a Bash script
I want to process the same file with these two commands, so I wrote the following Bash script:
#!/bin/bash
for file in "$@"
do
commandA $file
commandB $file
done
Even ... |
First of all, as ddeimeke said, aliases by default are not expanded in non-interactive shells.
Second, .bashrc is not read by non-interactive shells unless you set the BASH_ENV environment variable.
But most importantly: don't do that! Please? One day you will move that script somewhere where the necessary aliases are... | Why doesn't my Bash script recognize aliases? |
1,323,032,234,000 |
I want to have a shell script like this:
my-app &
echo $my-app-pid
But I do not know how the get the pid of the just executed command.
I know I can just use the jobs -p my-app command to grep the pid. But if I want to execute the shell multiple times, this method will not work. Because the jobspec is ambiguous.
|
The PID of the last executed command is in the $! shell variable:
my-app &
echo $!
| How to get the pid of the last executed command in shell script? |
1,323,032,234,000 |
I'm making a script to install my theme, after it finished installing it will appear the changelog and there will be "Press any key to continue" so that after users read the changelog then press any key to continue
|
You can use the read command. If you are using bash:
read -p "Press enter to continue"
In other shells, you can do:
printf "%s " "Press enter to continue"
read ans
As mentioned in the comments above, this command does actually require the user to press enter; a solution that works with any key in bash would be:
read... | How can I make "Press any key to continue" [duplicate] |
1,323,032,234,000 |
What can you do with the eval command? Why is it useful? Is it some kind of a built-in function in bash? There is no man page for it..
|
eval is part of POSIX. It's an interface which can be a shell built-in.
It's described in the "POSIX Programmer's Manual": http://www.unix.com/man-page/posix/1posix/eval/
eval - construct command by concatenating arguments
It will take an argument and construct a command of it, which will then be executed by the shel... | What is the "eval" command in bash? |
1,323,032,234,000 |
Is there a way to color output for git (or any command)?
Consider:
baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
... |
You can create a section [color] in your ~/.gitconfig with e.g. the following content
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
You can also fine control what you want to have coloured in what way, e.g.
[color "status"]
added = green
changed = red bold
... | How to colorize output of git? |
1,323,032,234,000 |
The following bash syntax verifies if param isn't empty:
[[ ! -z $param ]]
For example:
param=""
[[ ! -z $param ]] && echo "I am not zero"
No output and its fine.
But when param is empty except for one (or more) space characters, then the case is different:
param=" " # one space
[[ ! -z $param ]] && echo "... |
First, note that the -z test is explicitly for:
the length of string is zero
That is, a string containing only spaces should not be true under -z, because it has a non-zero length.
What you want is to remove the spaces from the variable using the pattern replacement parameter expansion:
[[ -z "${param// }" ]]
This ... | How can I test if a variable is empty or contains only spaces? |
1,323,032,234,000 |
I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command line, because color makes the output more useful and intuitive.
What options exist to add color to my terminal environment? What tricks do you use? What pitfalls have you encountered?
Unfortunately, sup... |
Here are a couple of things you can do:
Editors + Code
A lot of editors have syntax highlighting support. vim and emacs have it on by default. You can also enable it under nano.
You can also syntax highlight code on the terminal by using Pygments as a command-line tool.
grep
grep --color=auto highlights all matches. Y... | Colorizing your terminal and shell environment? |
1,323,032,234,000 |
I have a Linux instance that I set up some time ago. When I fire it up and log in as root there are some environment variables that I set up but I can't remember or find where they came from.
I've checked ~/.bash_profile, /etc/.bash_rc, and all the startup
scripts.
I've run find and grep to no avail.
I feel like... |
If you use the env command to display the variables, they should show up roughly in the order in which they were created. You can use this as a guide to if they were set by the system very early in the boot, or by a later .profile or other configuration file. In my experience, the set and export commands will sort t... | How to determine where an environment variable came from? |
1,323,032,234,000 |
Using version control systems I get annoyed at the noise when the diff says No newline at end of file.
So I was wondering: How to add a newline at the end of a file to get rid of those messages?
|
To recursively sanitize a project I use this oneliner:
git ls-files -z | while IFS= read -rd '' f; do if file --mime-encoding "$f" | grep -qv binary; then tail -c1 < "$f" | read -r _ || echo >> "$f"; fi; done
Explanation:
git ls-files -z lists files in the repository. It takes an optional pattern as additional param... | How to add a newline to the end of a file? |
1,323,032,234,000 |
I find myself repeating a lot of:
mkdir longtitleproject
cd longtitleproject
Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
|
This is the one-liner that you need. No other config needed:
mkdir longtitleproject && cd $_
The $_ variable, in bash, is the last argument given to the previous command. In this case, the name of the directory you just created. As explained in man bash:
_ At shell startup, set to the absolute pathname use... | Is there a one-liner that allows me to create a directory and move into it at the same time? |
1,323,032,234,000 |
I want to run a java command once for every match of ls | grep pattern -. In this case, I think I could do find pattern -exec java MyProg '{}' \; but I'm curious about the general case - is there an easy way to say "run a command once for every line of standard input"? (In fish or bash.)
|
That's what xargs does.
... | xargs command
| Execute a command once per line of piped input? |
1,323,032,234,000 |
If you've been following unix.stackexchange.com for a while, you
should hopefully know by now that leaving a variable
unquoted in list context (as in echo $var) in Bourne/POSIX
shells (zsh being the exception) has a very special meaning and
shouldn't be done unless you have a very good reason to.
It's discussed at len... |
Preamble
First, I'd say it's not the right way to address the problem.
It's a bit like saying "you should not murder people because
otherwise you'll go to jail".
Similarly, you don't quote your variable because otherwise
you're introducing security vulnerabilities. You quote your
variables because it is wrong not to (... | Security implications of forgetting to quote a variable in bash/POSIX shells |
1,323,032,234,000 |
Is there any easy way to pass (receive) named parameters to a shell script?
For example,
my_script -p_out '/some/path' -arg_1 '5'
And inside my_script.sh receive them as:
# I believe this notation does not work, but is there anything close to it?
p_out=$ARGUMENTS['p_out']
arg1=$ARGUMENTS['arg_1']
printf "The Argume... |
If you don't mind being limited to single-letter argument names i.e. my_script -p '/some/path' -a5, then in bash you could use the built-in getopts, e.g.
#!/bin/bash
while getopts ":a:p:" opt; do
case $opt in
a) arg_1="$OPTARG"
;;
p) p_out="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
... | Passing named arguments to shell scripts |
1,323,032,234,000 |
I found the .bashrc file and I want to know the purpose/function of it. Also how and when is it used?
|
.bashrc is a Bash shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt.
You put commands here to set up the shell for use in your particular environment, or to customize things to yo... | What is the purpose of .bashrc and how does it work? |
1,323,032,234,000 |
How can I delete a word backward at the command line? I'm truly used to some editors deleting the last 'word' using Ctrl+Backspace, and I'd like that functionality at the command line too.
I am using Bash at the moment and although I could jump backward a word and then delete forward a word, I'd rather have this as a... |
Ctrl+W is the standard "kill word" (aka werase).
Ctrl+U kills the whole line (kill).
You can change them with stty.
-bash-4.2$ stty -a
speed 38400 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
... | How can I delete a word backward at the command line (bash and zsh)? |
1,323,032,234,000 |
is there any way (what is the easiest way in bash) to combine the following:
mkdir foo
cd foo
The manpage for mkdir does not describe anything like that, maybe there is a fancy version of mkdir? I know that cd has to be shell builtin, so the same would be true for the fancy mkdir...
Aliasing?
|
Function?
mkcdir ()
{
mkdir -p -- "$1" &&
cd -P -- "$1"
}
Put the above code in the ~/.bashrc, ~/.zshrc or another file sourced by your shell. Then source it by running e.g. source ~/.bashrc to apply changes.
After that simply run mkcdir foo or mkcdir "nested/path/in quotes".
Notes:
"$1" is the first argu... | Combined `mkdir` and `cd`? [duplicate] |
1,323,032,234,000 |
I have an issue where if I type in very long commands in bash the terminal will not render what I'm typing correctly. I'd expect that if I had a command like the following:
username@someserver ~/somepath $ ssh -i /path/to/private/key
[email protected]
The command should render on two lines. Instead it will often wrap ... |
Non-printable sequences should be enclosed in \[ and \]. Looking at your PS1 it has a unenclosed sequence after \W. But, the second entry is redundant as well as it repeats the previous statement "1;34".
\[\033[01;32m\]\u:\[\033[01;34m\] \W\033[01;34m \$\[\033[00m\]
|_____________| |_|
... | Terminal prompt not wrapping correctly |
1,323,032,234,000 |
There is apparently a vulnerability (CVE-2014-6271) in bash: Bash specially crafted environment variables code injection attack
I am trying to figure out what is happening, but I'm not entirely sure I understand it. How can the echo be executed as it is in single quotes?
$ env x='() { :;}; echo vulnerable' bash -c "ec... |
bash stores exported function definitions as environment variables. Exported functions look like this:
$ foo() { bar; }
$ export -f foo
$ env | grep -A1 foo
foo=() { bar
}
That is, the environment variable foo has the literal contents:
() { bar
}
When a new instance of bash launches, it looks for these specially c... | What does env x='() { :;}; command' bash do and why is it insecure? |
1,323,032,234,000 |
I get the message There are stopped jobs. when I try to exit a bash shell sometimes. Here is a reproducible scenario in python 2.x:
ctrl+c is handled by the interpreter as an exception.
ctrl+z 'stops' the process.
ctrl+d exits python for reals.
Here is some real-world terminal output:
example_user@example_server:~$ ... |
A stopped job is one that has been temporarily put into the background and is no longer running, but is still using resources (i.e. system memory). Because that job is not attached to the current terminal, it cannot produce output and is not receiving input from the user.
You can see jobs you have running using the jo... | There are stopped jobs (on bash exit) |
1,323,032,234,000 |
I wrote the following script to diff the outputs of two directores with all the same files in them as such:
#!/bin/bash
for file in `find . -name "*.csv"`
do
echo "file = $file";
diff $file /some/other/path/$file;
read char;
done
I know there are other ways to achieve this. Curiously though, this ... |
Short answer (closest to your answer, but handles spaces)
OIFS="$IFS"
IFS=$'\n'
for file in `find . -type f -name "*.csv"`
do
echo "file = $file"
diff "$file" "/some/other/path/$file"
read line
done
IFS="$OIFS"
Better answer (also handles wildcards and newlines in file names)
find . -type f -name "*.... | Looping through files with spaces in the names? [duplicate] |
1,323,032,234,000 |
Most languages have naming conventions for variables, the most common style I see in shell scripts is MY_VARIABLE=foo. Is this the convention or is it only for global variables? What about variables local to the script?
|
Environment variables or shell variables introduced by the operating system, shell startup scripts, or the shell itself, etc., are usually all in CAPITALS1.
To prevent your variables from conflicting with these variables, it is a good practice to use lower_case variable names.
1A notable exception that may be worth k... | Are there naming conventions for variables in shell scripts? |
1,323,032,234,000 |
In bash all I know is that
rmdir directoryname
will remove the directory but only if it's empty. Is there a way to force remove subdirectories?
|
The following command will do it for you. Use caution though if this isn't your intention as this also removes files in the directory and subdirectories.
rm -rf directoryname
| How do I remove a directory and all its contents? |
1,323,032,234,000 |
I want to parse a variable (in my case it's development kit version) to make it dot(.) free. If version='2.3.3', desired output is 233.
I tried as below, but it requires . to be replaced with another character giving me 2_3_3. It would have been fine if tr . '' would have worked.
1 VERSION='2.3.3'
2 echo "2.3.3" ... |
There is no need to execute an external program. bash's string manipulation can handle it (also available in ksh93 (where it comes from), zsh and recent versions of mksh, yash and busybox sh (at least)):
$ VERSION='2.3.3'
$ echo "${VERSION//.}"
233
(In those shells' manuals you can generally find this in the paramete... | remove particular characters from a variable using bash |
1,323,032,234,000 |
Can I redirect output to a log file and a background process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to the background, like this:
java -jar myProgram.jar 2>$1 > output.log
job... |
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to... | Can I redirect output to a log file and background a process at the same time? |
1,323,032,234,000 |
What does <<< mean? Here is an example:
$ sed 's/a/b/g' <<< "aaa"
bbb
Is it something general that works with more Linux commands?
It looks like it's feeding the sed program with the string aaa, but isn't << or < usually used for that?
|
Others have answered the basic question: What is it? (Answer: It's a here string.)
Let's look at why it's useful.
You can also feed a string to a command's stdin like this:
echo "$string" | command
However in Bash, introducing a pipe means the individual commands are run in subshells. Consider this:
echo "hello world... | What does <<< mean? [duplicate] |
1,403,460,625,000 |
bcache allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives.
If I understand correctly,
an SSD* could be assigned to cache multiple backing HDDs, and then the resulting cached devices could be RAIDed with mdadm
or
multiple HDDs c... |
I think caching the whole md device make most sense.
Putting bcache to cache the whole md device sacrifices the whole idea of having raid, because it introduces another single point of failure.
OTH failurs of SSD disks are relatively rare, and bcache can be put into the writethrough/writearound mode (in contrast to t... | bcache on md or md on bcache |
1,403,460,625,000 |
I believe, that once I made sure my cache device state is "clean":
$ sudo cat /sys/block/bcache0/bcache/state
I can just physically remove it from the machine when it is powered off or boot with liveCD and clean the superblock with:
$ sudo dd if=/dev/zero of=<backing device for cache> bs=1024 count=1024
But I cannot... |
Suppose you've set up successfully a bcache, you are already working on it, put there a lot of important data too big to simply backup and start over, when you realized, that you'd better replace the caching device. This is how you can do it. This solution is based on a VM trials.
Lets say we are talking about the de... | How do I remove the cache device from bcache? |
1,403,460,625,000 |
I need to upgrade some drive firmware and I'd like to shut down bcache for the duration.
The docs show how to stop a bcache device:
stop
Write to this file to shut down the bcache device and close the backing device.
For me that will look like this:
echo 1 > /sys/block/bcache0/bcache/stop
and for the cache device:... |
Simply re-register each bcache device in the cache set (both backing and cache devices) to the kernel:
echo /dev/<path_to_device> > /sys/fs/bcache/register
Or, if the udev rules from bcache-tools are in place, then partprobe will automatically register the devices when they are scanned.
| How to restart a 'stopped' bcache device? |
1,403,460,625,000 |
I'm looking for ways to make use of an SSD to speed up my system. In “Linux equivalent to ReadyBoost?” (and the research that triggered for me) I've learned about bcache, dm-cache and EnhanceIO. All three of these seem capable of caching read data on SSD.
However, unless I'm missing something, all three seem to store ... |
To my best understanding, dm-cache does what you are asking for. I could not find a definite source for this, but here the author explains that he should have called it dm-hotspot, because it tries to find "hot spots", i.e. areas of high activity and only caches those.
In the output of dmsetup status you will find two... | SSD as a read cache for FREQUENTLY read data |
1,403,460,625,000 |
I have an LVM and I wanted to use bcache to cache one of its LVs. (Yes, I know I could use lvmcache, but I was having issues booting and I gave up using it.)
First, I used blocks to convert the LV to a bcache backing device (this seemed to actually work!):
blocks to-bcache /dev/my_vg/my_lv
I created a caching device... |
I managed to fix this by re-creating the superblock on /dev/sdc4. Looks like the --block 4k --bucket 2M was incorrect and that's why the cache device wasn't attaching.
I cleared the superblock, then ran:
make-bcache -C /dev/sdc4
Now when I did:
echo 'uuid' > /sys/block/bcache0/bcache/attach
it worked!
| Cannot attach cache device to backing device |
1,403,460,625,000 |
I've tried echoing to detach and stop. The device will remove itself, but will show up again on reboot. One time on reboot, it restored the mdadm raid I had as a backing device!
The other time I disabled the ramdrive that it was paired with, did a detach. And /dev/bcache0 came back up again after reboot.
There is no... |
If you want to permanently destroy the bcache volume, you need to wipe the bcache superblock from the underlying device. This operation is not exposed through the sysfs interface. So:
Stop the bcache device as usual with echo 1 > /sys/block/<device>/bcache/stop. On newer kernels this may fail with "Permission denied"... | How to remove bcache0 volume? |
1,403,460,625,000 |
I have 3 HDD and 1 SSD, I have successfully mounted all drives to bcache.
pavs@VAS:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 132G 35G 90G 28% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 8.0K 3.9G 1% /dev
tmpfs 786M 2.3M 784M 1% /run... |
I solved the same issue by setting congested_read_threshold_us and congested_write_threshold_us following bcache documentation:
Traffic's still going to the spindle/still getting cache misses
In the real world, SSDs don't always keep up with disks - particularly with
slower SSDs, many disks being cached by one SSD, ... | Optimizing bcache |
1,403,460,625,000 |
I'm aware of the differences between a cachepool and cachevol.
Cachepool separates the cache data and metadata into two separate volumes, whereas a Cachevol uses a single volume for both.
My question is, what is the benefit of using a cachepool instead of just using a cachevol? The only scenario I can think of that it... |
From my limited perspective, there really isn't a reason for everyone to be using a cachepool, and it's the result of blindly following enterprise tutorials for the sake of it.
Outside of using a separate physical drive for metadata and a separate physical drive for data, for the sake of improving throughput, I can't ... | LVMCache: Why use a cachepool instead of a cachevol? |
1,403,460,625,000 |
I recently bought a 240 GB SSD to speed up my computer with 1 TB HDD. I dual boot Windows and Linux. I want to use my new SSD in the most effective way. Reading through many sites led me to conclusion that, for Linux, bcache is the way to go. I want to make sure that my understanding of bcache is correct.
So, I wante... |
Ad question 1.
I mount only caching device and not any backing partitions and see
files, that are on those backing partitions
Not true - you mount the bcache device. It must internally be composed from at least one hdd device. The ssd cache is actually optional - so you still can access your data, even if your ssd... | Is bcache solution for my ssd use case? [closed] |
1,403,460,625,000 |
I recently bought a new laptop with a 16Gb mSATA SSD cache drive. I haven't used that one yet.
I have, however, opted for Ubuntu 13.04 with "Full Disk Encryption" for the main partition (is that what's called LUKS?).
With bcache making it's way into 3.10, I'd like to take advantage of the aforementioned cache drive.
A... |
To answer 1., the most sensible thing to do is to put bcache on top of two LUKS virtual devices. LUKS-encrypting a bcache device might work, but there's no guarantee LUKS will consistently put the same virtual sector in the same physical sector every time. You can encrypt both LUKS devices with the same keyfile and un... | BCache and disk encryption |
1,403,460,625,000 |
I'm using a setup I consider to be rather fragile and prone to failure involving LUKS, LVM, btrfs, and bcache. I have used btrfs for a long time, and have never experienced any significant issues with it. But, it doesn't support caching, nor does it handle erasure coding (i.e. RAID5 or 6 style redundancy).
I consider ... |
The roadmap for bcachefs mentions it:
Send and receive:
Like ZFS and btrfs have, we need it to. This will give us the ability
to efficiently synchronize filesystems over a network for
backup/redundancy purposes - much more efficient than rsync, and it'll
pair well with snapshots.
Since all metadata exists as btree ke... | Equivalent of `btrfs send` and `btrfs recv` for bcachefs |
1,403,460,625,000 |
I have a disk with a btrfs filesystem on top of bcache that was used in an old installation I no longer have (unintentionally nuked). When I plug in the drive, /dev/bcache0 doesn't show up and I'm not allowed to echo /dev/{dev} into /sys/fs/bcache/register to force it. I have the bcache module loaded, and when I try t... |
Mounted the bcache partition to a loop device with sudo losetup -f /dev/[DEVICE] -o 8192 The bcache data is probably only 1KiB or less, but the offset needs to align with the sector size of the disk, in this case 8KiB. This worked perfectly and I've been transferring files to a stable storage pool overnight.
If anyone... | Getting files off bcache disk from different computer |
1,403,460,625,000 |
I'm tryng to set
writeback_percent
at a value > 40 but it only accept value between 0 and 40.
If i set
echo 50 > /sys/block/bcache0/bcache/writeback_percent
then when i read the value
more /sys/block/bcache0/bcache/writeback_percent
i have 40.
For value<=40 the settings work fine.
My setting for cache type are ... |
This is hardcoded value in the bcache drive code - linux/drivers/md/bcache/writeback.h. The only way to change this limit is to rebuild the driver from source.
| Bcache writeback_percent max value |
1,403,460,625,000 |
I read somewhere that the algorithms used by LVM/bcache are much better than the algorithms implemented by the H-HDD/SSHD drives. Is it true?
|
It depends on hybrid drive type: new Seagate SSHD drives manufactured since late 2013 have far better caching than earlier models.
What is also important, bcache caching strategy is totally different than Seagate Adaptive Memory strategy, and while bcache is very fast in benchmarks, AM learns data topology and can out... | SSHD drive caching algorithm vs bcache/LVM |
1,403,460,625,000 |
I created a Raspberry Pi based bcache on SSD with a HDD based RAID 1 array. After populating the RAID with few TB of content, bcache showed 10% dirty cache. That would be expected, since I have /sys/block/bcache0/bcache/cache_mode set to writeback. However, it stays at 10% indefinitely. The device is running for days ... |
That appears to be expected behaviour.
Write-back mode is usually safe because the caching device is journalled. Bcache will rewrite all dirty data after (unexpected) reboots to the persistent backing device, in fact bcache doesn't even finish writing dirty data at shutdown as part of its design, it will always boot ... | Can bcache have non-zero dirty cache forever? |
1,403,460,625,000 |
I'm trying to compile the kernel from source on the system CentOS 7.
The output of uname -a is:
Linux dbn03 3.10.0-957.el7.x86_64 #1 SMP Thu Oct 4 20:48:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Here is how I download the source code and compile it:
wget "http://vault.centos.org/7.6.1810/os/Source/SPackages/kernel-3.... |
Try this instead:
rpm -ivh kernel-3.10.0-957.el7.src.rpm
cd ~/rpmbuild/SOURCES
rpmbuild -bp kernel.spec
cd ~/rpmbuild/BUILD/kernel-3.10.0-957.el7/linux-3.10.0-957.fc32.x86_64
make menuconfig
make bzImage
make modules
| Compiling kernel from source got a fatal error: too few arguments to function 'part_round_stats' |
1,403,460,625,000 |
I'm trying to setup bcache in an instance in google cloud using a raid of local SSDs as caching device but everything fails in the attach phase of the process. For testing purposes I created a new instance with blank disks (two SSDs and four Local SSDs). The objective is to have one regular SSD as backing device and f... |
After some detailed reviewing I realized the problem is with the block size from the different devices. When adjusted the make-bcache commands, everything worked as expected:
make-bcache --block 4k -B /dev/sdb
make-bcache --block 4k -C /dev/nvme0n1
| bcache fails to attach local ssd as caching device in google cloud |
1,403,460,625,000 |
After using a write-around bcache on the root device of an old laptop for more than a year (HD + SD card), I finally found out that some severe filesystem corruptions I was facing -- which lead me to resort to backups and reinstall everything twice (!!) -- were due to bcache corruption on the cache device after reboot... |
I found a workaround which proved itself over several updates in several machines already:
After the normal system & kernel upgrade, before the reboot, simply stop bcache:
echo 1 >/sys/fs/bcache/*/stop;sleep 2;sync;sync;shutdown -r now;logout
On the next reboot, bcache will be back on without any corruptions.
Most ce... | Corruption on BCache uppon Kernel Update/Upgrade |
1,403,460,625,000 |
I recall when setting up my system, I changed the sequential_cutoff parameter to zero by executing:
echo 0 | sudo tee /sys/block/bcache0/bcache/sequential_cutoff
Now, after many months I see it back to the default value of 4.0M. On the other side, the cache_mode parameter is still the way I set it, writeback. Is the ... |
For stuff like writeback, it is stored permanently on disk. However for stuff like sequential_cutoff, readahead, etc. those require you to reset them every boot (you can do this with a script / systemd service).
| bcache: is sequential_cutoff and other parameters supposed to be permanent? |
1,403,460,625,000 |
I heard that LVM/bcache can be used in Linux to store the most accessed files if there is a separate SSD drive.
With a hybrid drive (SSHD/H-HDD), can the flash area be manually used by LVM/bcache as well instead of the disk algorithms?
|
If you format a piece of the SSD drive to be used as a bcache cache, then it will not be available anymore to store any other filesystem, obviously. But nothing prevents you from using the remaining part of the SSD drive as you see fit.
This applies to for instance WD Black2
There are also other SSHD disks, like Seag... | Using the SSD area of a H-HDD drive with LVM/bcache |
1,403,460,625,000 |
I've got a setup that includes a bcache cache device serving multiple backing devices. I would like to know how much of it is currently in use because bcache only caches certain kinds of data.
|
The stats for the cache device of a certain bcache cache set can be queried using /sys/fs/bcache/$CSET_UUID/cache0/priority_stats.
Among other information, it contains the unused field.
| How can you check how much of a bcache cache is currently in use? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.