date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,339,864,677,000 |
I am working on prototyping a product using 3.18 Linux kernel.
I am trying to understand the ways to harden Linux Kernel? I am referring a documentation. The document refers to numerous configuration options that should be taken care of? Is that all to hardening the Kernel? Or are there other things that I should tak... |
There exists the GrSecurity patchset, you can find the 3.18 kernel version patches here: http://deb.digdeo.fr/grsecurity-archives/kernel-3.18/
Gentoo has a good page on setting of GrSecurity patches here: https://wiki.gentoo.org/wiki/Hardened/Grsecurity2_Quickstart you must patch the kernel and the compile with certai... | Ways to Harden Linux Kernel? [closed] |
1,339,864,677,000 |
I'm working on a BeagleBone Black shipped with Debian. Started reading the Securing Debian page, and part way through I see in a chapter 3 section 3.6.1 Removing Perl. Doing a quick google search gives three 2016 security advisories in the first five results:
DSA-3628-1
DSA-3501-1
DSA-3441-1
The document even state... |
Removing perl may harm your system, because there a ton of programs witch depend on it, to keep your system secure its better to include the following line:
deb http://security.debian.org/ jessie/updates main contrib non-free
on your sources.list to upgrade/patch the vulnerable packages through apt as soon as possibl... | Is Removal of Perl the Recommendation for Hardening a System? [closed] |
1,339,864,677,000 |
This is about a cPanel server which, like most servers, is under constant attack from lands afar. Considering that I only host to clients in the US and Canada, there is less of a reason to allow full access to Asia and South America, among other areas.
Too many firewall rules can increase latency, or worse, crash your... |
Alright, I've not gotten any good responses and it took trial and error, as well as monitoring to determine what works to achieve this.
I found some things were said to be needed, so the example up above might not work on all systems because a full path should be used on the executables. Also, when specifying a range ... | Using IPTables to Block Ports to Class A Subnets While Allowing Web Ports (80/443) |
1,339,864,677,000 |
I read this in "RH413 Red Hat Server Hardening" course that we mount the filesystems with nodev which then does not allow the special files/devices to be mounted from it. However, it did not show an example.
I, however, did the following thing on my RHEL machine and I found that we cannot associate the special charact... |
Firstly...
I found that we cannot associate the special character device with any file created by dd command
The experiment you have shown does not create a file with dd, it tries to write to a special character device using dd.
1) What are device files?
Device files can be thought of as a link to a device in your ... | What is the default behaviour when we mount filesystem with `nodev` option? |
1,339,864,677,000 |
My VPS hosting company injects "extras" into new Debian (and other) VPS images - scripts, network config, telemetry, etc.
How can I compare a new VPS against the official image, to see what changes were made by the hosting company?
|
Obviously, the easiest way is to just ask them. They should document this?
Absent that, start by looking under /usr/local for things; it might be limited to those.
Check if they installed any packages that aren't in any repositories; the easiest way to do that, in my opinion, is to fire up aptitude and look under the ... | Detect changes made to VPS linux image by hosting company |
1,339,864,677,000 |
Is it safe to uninstall su in favor of sudo to harden Arch Linux?
Have you got an opinion on whether this is a good or bad idea?
I read the Arch Linux Wiki articles Security, Su and Sudo. I also searched for further resources with regards to this matter but couldn't find any substantial information.
|
Removing setuid/setgid from system applications isn't done routinely (though there are occasional guidelines which do suggest just that). Doing this invalidates the package configuration, making it necessary for someone to make special-cases when investigating discrepancies between package content and the installed s... | Is it safe to uninstall `su` in favor of `sudo` to harden Arch Linux? [closed] |
1,339,864,677,000 |
Let's assume that I have created a linux image with a filesystem that is inherently readonly (like SquashFS) and disabled swap. From readonly I mean the main filesystem and all its content is readonly and it is mounted readonly as well, and only directories that need to be writable such as /tmp is redirected to anothe... |
Given your scenario, where the main filesystem is mounted as read-only and only specific directories like /tmp are writable, the short answer is yes, someone with root access could potentially redirect access from files in the read-only part of the system to another file in the writable section. Here's how:
Symbolic o... | Is it possible to redirect files in a readonly filesystem? |
1,339,864,677,000 |
I try to hardening my server. For doing so, I got a general question: Should I install kernel security patches like selinux and an Anti-Virus with Intrusion Detection Firewall? Does it make sense to combine it or just one of them?
I mean, the patches are known to secure local things like processes etc. from turning in... |
If you are concerned about system integrity, then selinux or grsecurity (or the various similar security packages) are very powerful. Unfortunately, mastering their policies is far from trivial. (Any decent distro that includes SELinux will have predefined policies for all kinds of things, though.) Grsecurity policies... | kernel security and IDS Firewall + AV together or not? |
1,339,864,677,000 |
I use iptables to secure my server. The default policies for all chains in the filter table have been set to DROP
# iptables -t filter -L | grep -i \ (policy
Chain INPUT (policy DROP)
Chain FORWARD (policy DROP)
Chain OUTPUT (policy DROP)
I wonder if it is useful to also set the policies to DROP for mangle, raw and s... |
No, you shouldn't set these policies on the other tables to DROP, these tables are not meant to filter.
You may want to try it on a local machine, where you have local access even if you block the network.
| Is it useful to set the policies to DROP for all tables in Iptables? |
1,339,864,677,000 |
I read somewhere (I forgot where) that the following should be set if I want to harden my linux, which is Ubuntu 18.04 in my case.
However, using these values somehow caused a 504 Gateway Time-out for my nginx, which is used as a reverse proxy for my asp.net core app.
I have no background in linux and all I did is cop... |
NSSWITCH.CONF
All of these settings are files, which means everything is stored on the local computer.
Ex: passwd:files -- all login accounts are stored in /etc/passwd. There is no external user authentication (On Windows, this might be AD), LDAP, Kerberos, etc.
If this is what you expect, then those settings are corr... | Hardening of nsswitch.conf and sysctl.conf |
1,549,815,353,000 |
In Linux, how do /etc/hosts and DNS work together to resolve hostnames to IP addresses?
if a hostname can be resolved in /etc/hosts, does DNS apply after /etc/hosts
to resolve the hostname or treat the resolved IP address by
/etc/hosts as a "hostname" to resolve recursively?
In my browser (firefox and google chrome)... |
This is dictated by the NSS (Name Service Switch) configuration i.e. /etc/nsswitch.conf file's hosts directive. For example, on my system:
hosts: files mdns4_minimal [NOTFOUND=return] dns
Here, files refers to the /etc/hosts file, and dns refers to the DNS system. And as you can imagine whichever comes first wins.... | How do `/etc/hosts` and DNS work together to resolve hostnames to IP addresses? |
1,549,815,353,000 |
How do I get a remote host IP address if I don't have ping, and don't have any bind utilities like dig, nslookup, etc?
I need an answer that does not include 'install X' or 'use sidecar container'. I am looking for something that relies on nothing more than bash and the basic shell commands.
|
Use getent:
$ getent hosts unix.stackexchange.com
151.101.193.69 unix.stackexchange.com unix.stackexchange.com
| How to get remote host DNS address from a super-slim host (docker) without ping or bind-utils? |
1,549,815,353,000 |
I use GNOME Boxes on a laptop. The guest machines get the Internet connection automatically with default settings whenever the laptop moves between networks (Ethernet, Wi-Fi in different locations, or a cellular phone as a USB modem).
The guest machines are not bridged with the host and are not visible on the host's L... |
In the default "user mode" networking, QEMU uses only the first DNS nameserver from the host machine. So, if that nameserver doesn't resolve properly, QEMU will not fallback to any other nameservers which may be configured as secondary at the host. It results in the apparent loss of Internet connection by the guests w... | Why DNS stops resolving under QEMU "user networking" when the host roams to a particular network? |
1,549,815,353,000 |
I'm using LXC containers, and resolving CONTAINERNAME.lxd to the IP of the specified container, using:
sudo resolvectl dns lxdbr0 $bridge_ip
sudo resolvectl domain lxdbr0 '~lxd'
This works great! But the changes don't persist over a host reboot.
(I've described 'things I've tried' as answers to this question, which h... |
The LXD docs describe a solution:
Put this in /etc/systemd/system/lxd-dns-lxdbr0.service:
[Unit]
Description=LXD per-link DNS configuration for lxdbr0
BindsTo=sys-subsystem-net-devices-lxdbr0.device
After=sys-subsystem-net-devices-lxdbr0.device
[Service]
Type=oneshot
ExecStart=/usr/bin/resolvectl dns lxdbr0 BRIDGEIP
... | Persist resolvectl changes across reboots |
1,549,815,353,000 |
I upgraded a few machines to Debian Buster and everything went well so far—although when running apt upgrade before apt full-upgrade I ran into a
Temporary failure in name resolution. This was fixable and only an issue during the process and did not occur when doing a one-step apt dist-upgrade. However one machine sh... |
Installing nslookup pointed me to the source of the problem: resolv.conf was simply not parseable. I copied the contents from the original file into a new one and everything works. Same content, same permissions. But diff shows a difference where is none. Apparently there is some invisible character breaking the file ... | Temporary failure in name resolution after upgrade to Debian Buster |
1,549,815,353,000 |
I would like to be able to get the public IPs of the websites I am accessing with my PC in a way such as:
www.google.es - public IP1
www.cdn.facebook.com - public IP2
and so on. I think this should be done by logging DNS traffic, so I tried using wireshark as part of a solution I found in another answer:
tshark -f ... |
You can install DNSmasq locally and add this option to the conf file log-facility=/var/log/dnsmasq.log log-queries then set your system to use 127.0.0.1 or ::1 as the DNS resolver its work for me.
Then extract data as any format you want and do what ever you want with it
or install Bind locally. Most distros default i... | Get public IPs of accessed webpages? |
1,549,815,353,000 |
tl;dr: accessing 0.0.0.0:port (eg. curl http://0.0.0.0:443) gets redirected(internally) to 127.0.0.1:port (where port is any port number) (eg. the previous curl command is the same as curl http://127.0.0.1:443); why does this happen and how to block connections destined to 0.0.0.0 ?
UPDATE2: I've found a way to block ... |
Why this happens is explained in Connecting to IP 0.0.0.0 succeeds. How? Why? — in short, packets with no destination address (0.0.0.0) have their source address copied into their destination address, and packets with no source or destination have their source and destination addresses set to the loopback address (INA... | Why accessing 0.0.0.0:443 gets redirected to 127.0.0.1:443 on Linux and how to disallow it? |
1,549,815,353,000 |
According to Debian's RPi3 image wiki, I should be able to ssh into a Raspberry-Pi, with just the hostname. I shared internet from my Debian laptop, WiFi to the a Raspberry-Pi over Ethernet, but the hostname never resolved.
What kind of settings/configuration do either the client and server or the network need for LAN... |
Enable Link-Local Multicast Name Resolution (LLMNR) on the RPi. Edit /etc/systemd/resolved.conf and set LLMNR=true. Enable and start the systemd service system-resolved: systemctl --now enable systemd-resolved. No DNS server is needed, but name resolution only works on the local net. Make sure there are no duplicate h... | Linux/Windows client resolve Linux hostname on LAN |
1,549,815,353,000 |
I have a headless music server (raspbian buster) running a storage server (minimserver) and a player (upmpdcli) on the same machine. When it's playing, it's fetching the music files via its LAN address. So the music is played and browsed through URLs like: http://192.168.1.108:9790/minimserver/...
Even though playlist... |
Add the interface address to the lo (loopback) adaptor as well:
sudo ip addr add 192.168.1.108/32 dev lo
The kernel will do the right things.
| Resolving own LAN IP when the network goes down |
1,549,815,353,000 |
I was following this tutorial to the letter and when I entered my domain name in the browser, I get my page. Except the fact that the browser never masks the domain to www.example.com, instead it changed the domain I just entered and showed me the subfolder preceded by the IP address, for example: 211.232.01.23/websit... |
Please put .htaccess file under public_html folder with below code :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Then try to acc... | Apache httpd on CentOS doesn't mask IP to domain |
1,549,815,353,000 |
After upgrading Debian11/KDE to Debian12, restarting and running sudo apt-get upgrade it shows errors like Could not resolve ftp.XX.debian.org. These also show when running sudo apt-get update. I then tried to open websites in the Firefox-esr browser and it can't open any (it shows the "Hmm. We're having trouble findi... |
With journalctl | tail -n 100 I found this error (which didn't show at first):
nm-openvpn: write to TUN/TAP : Invalid argument (fd=-1,code=22)
To solve this problem (in KDE) right click the tray icon of NetworkManager (if you have imported your VPN config to it or set the VPN up in there)
->Configure Network Connectio... | Can't resolve domain names after upgrading to Debian 12 |
1,549,815,353,000 |
I am using VirtualBox on Windows now.
The network is roughly like this:
[Fedora 37 VM] -- NAT network -- [Windows Host] ---- intranet ---- internet
I use DNS on intranet to resole host.domain names like both some.host.on.intranet and www.yahoo.co.jp .
On my windows host, this is OK.
But I am not so luky on my Fedora... |
You can't use .local like that. It's reserved for Multicast DNS (mDNS) lookups in an environment without managed DNS servers.
It's actually reserved for use with the full set of Zeroconf technologies, but the one relevant here is mDNS.
| Fedora VM behind NAT can not ping host.domain name on intranet |
1,549,815,353,000 |
We are using a Raspberry Pi which has a Lidar connected to the ethernet port. The problem is that the mdns4_minimal resolves $(hosname).local into two IPs. One IP is obtained from the ethernet port (from Lidar) and another from WiFi. This results in a problem with ROS that some nodes get the Lidar's IP address instead... |
First of all, you can specify the name resolution priority (or rather, order) in /etc/nsswitch.conf.
For example, on a Raspbian 11 (bullseye) Pi, the relevant section of the /etc/nsswitch.conf looks like this:
hosts: files mdns4_minimal [NOTFOUND=return] dns
For example, if you put dns before mdns4_minimal, ... | Change priority of mdns4 hostname resolution |
1,549,815,353,000 |
I have a statically linked busybox and want to be able to write busybox telnet foo. How do I specify the address of "foo"?
Do I really need /etc/nsswitch.conf and the corresponding dynamic libraries, or does busybox contain some own simple mechanism to consult /etc/hosts?
|
Looking into my openWRT, I do not have any libnss* libraries installed. It seems that only libuClibc is used for that. libc.so.0 is a symlink to it.
root@RuiWifi:/lib# grep -ri hosts *
libc.so.0:/etc/hosts
libuClibc-0.9.33.2.so:/etc/hosts
uClibc is an implementation of the standard C library that is much
smaller ... | Name resolution in busybox |
1,549,815,353,000 |
I have installed Debian on a dedicated server. The company that leases this server gave me 3 addresses:
DMZ IP
Mask
Gateway
The server cannot resolve hostnames. So when I use ping with IP- it works. When I use ping with hostname- it doesn't.
I think I should put something in
/etc/resolv.conf
But I don't know what... |
No, a gateway is a router. You'll want to specify name servers. For example:
nameserver 209.244.0.3
nameserver 209.244.0.4
Or whichever name servers you want to use. Your hosting provider probably has name servers very, very close to your server. Those might be the best option, and you should ask them the IP addresse... | How to enable hostname resolving in Debian? [closed] |
1,549,815,353,000 |
My scenario
Relevant entries in my /etc/hosts (I have them written in the same order you see them here)
172.22.5.107 www.wordpress-rend-adri.com
192.168.1.116 www.wordpress-rend-adri.com
I use my laptop in my house and school, hence I'm always dealing with 2 address spaces:
192.168.1.0/24
172.22.0.0/16
So I ha... |
I have done a few tests on my debian/wsl
~$ uname -a
Linux DESKTOP-OMM8LBC 4.4.0-17763-Microsoft #864-Microsoft Thu Nov 07 15:22:00 PST 2019 x86_64 GNU/Linux
# /etc/hosts
172.22.5.107 www.wordpress-rend-adri.com # Unreachable IP from my LAN
216.58.198.164 www.wordpress-rend-adri.com # IP for www.google.com
192.168.... | Different IP:hostName mappings for same host in `/etc/hosts`. Why does this work? |
1,549,815,353,000 |
I have an Ubuntu 16.04.2 LTS host. It is configured to use dnsmasq for DNS forwarding, rather than use resolv.conf populated with nameservers. The configuration is standard wherein resolv.conf just has:
nameserver 127.0.0.1
search redacted.searchfield.com
The host's configured /etc/resolv.dnsmasq has 4 nameservers co... |
I have decided to stop resolvconf and have noticed that after restarting dnsmasq the correct nameservers are written/consumed in /var/run/dnsmasq/resolv.conf.
| Host configured with both resolvconf and dnsmasq, restarting dnsmasq keeps pointing to old servers |
1,549,815,353,000 |
I recently updated my system, but noticed that on reboot, systemd-resolved always fails. So I cannot access any websites even though I have internet connection.
I have included an error message that I'm getting (I could not find any other post mentioning this exact error either).
Is anyone facing the same problem or h... |
I found the issue after I enabled the debug flag for systemd logs. I followed answer specified here: https://unix.stackexchange.com/a/432077/556205.
After setting the flag, I was able to see a concrete error message: libsystemd-shared-251.8-586.fc37.so: cannot open shared object file: No such file or directory.
I then... | Facing issue with systemd-resolved after update |
1,549,815,353,000 |
I installed some updates on my Ubuntu Desktop 21.04 through app "Software and Updates", I don't know what kind of software was updated. Internet had worked without problems before I rebooted the system. Computer has no internet access from any wi-fi, my other devices do have. When I do ping google.com, I get ping: goo... |
It seems like the problem was ProtonVPN. I don't know what exactly solved the issue, but what I did was:
sudo ifconfig pvpnksintrf0 down
sudo ifconfig ipv6leakintrf0 down
sudo apt-get remove protonvpn
rm -rf ~/.cache/protonvpn
rm -rf ~/.config/protonvpn
systemctl restart systemd-resolved.service
| Ubuntu, network problem |
1,549,815,353,000 |
I'm trying to complete the setup of my Bind9 DNS server.
Both Systems are running Debian Stretch. The serving machine (192.168.0.113) is a VM host and the client machine (192.168.0.104) is its virtual guest.
The server seems to be running without complaint, but I'm getting some confusing results. The host command re... |
As pointed out in the comments by Johan Myréen, my issue appeared to be caused by the use of a reserved TLD. Since I'm not making use of mDNS, switching from .local to .com allowed my name resolutions to work properly.
| Host command successful but DNS won't resolve |
1,342,641,878,000 |
How can I find out when a device is connected to my FreeBSD machine? Lets say I plug in a USB device, HDMI device, Bluetooth or something like that.
Can I have a console output to say [device] and gives some output about the device?
|
All other answers are good, if you want only to check if a device is connected (checking kernel messages with dmesg, check in /var/log files and use some tools like usbconfig, pciconf or camcontrol).
But, if you want more (handle a message and execute a program or something like that when you plug your device), you ca... | Find when new hardware is connected on FreeBSD |
1,342,641,878,000 |
I am running VirtualBox (using the Qiime image http://qiime.org/install/virtual_box.html)
The physical hardware is a 32 core machine. The virtual machine in VirtualBox has been given 16 cores.
When booting I get:
Ubuntu 10.04.1 LTS
Linux 2.6.38-15-server
# grep . /sys/devices/system/cpu/*
/sys/devices/system/cpu/kern... |
QIIME came out with a new virtualbox image (version 1.5), which works.
If no one finds the answer to the problem above I will close the question in a week.
| VirtualBox guest: 16 CPUs detected but only 1 online |
1,342,641,878,000 |
I am using usbip and a raspberry pi to extend the range of a wireless keyboard to a computer that is just a tad too far away for the keyboard to work reliably on its own.
Sometimes the USB receiver of the keyboard is reconnected and used elsewhere, but when it is reconnected to the raspberry pi the USBIP connection is... |
When a device that is bound and attached remotely is unplugged, the device is automatically detached on the client and unbound on the host. After that the state is the same as if it was never bound or attached.
The usbip commands for binding (on the host) and attaching (on the client) may be run repeatedly with the sa... | Use USBIP for devices that are being removed and reconnected |
1,342,641,878,000 |
I have Ubuntu 12.04.1 LTS 64-bit on a PowerEdge 2900. My current setup has two 300GB disks (no RAID), but I want migrate the system to three new 600GB disks. I'm trying to connect the new disks, make a RAID5 array, and copy my partitions to the new RAID, but i'm not sure if the server has hot-plug support or, in parti... |
Proper SAS/SATA connectors are hot plug safe, so as long as you are using those connectors both for data and power ( not the usual PC molex power connector ) then you won't hurt anything plugging them in.
| How to check if hot-swap or hot-plug are activated on my Linux machine |
1,342,641,878,000 |
I plugged in a PS/2 mouse while inside my Gnome desktop, but Linux doesn't recognize it.
Linux will only recognize the PS/2 mouse if it is plugged in before booting the machine (like a normal scenario).
In this case, I forgot to plug in the mouse, plugged it in when I got to the desktop, but realized that it doesn't w... |
That's just the way that the PS/2 port works. Unlike the USB, the PS/2 was not designed to be hot-plugged. If you need the hot-plugging capability, use a USB mouse. Otherwise, there is no guarantee that any solution will work consistently.
| How do you force Linux to detect a PS/2 device (e.g. mouse) on demand? |
1,342,641,878,000 |
I have an external eSATA-hdd on an OpenSUSE 12.2 system. The external hdd has an LVM on a dm-crypt partition.
I mount it by powering it up and then doing
rescan-scsi-bus.sh
cryptsetup -v luksOpen
vgchange -ay
mount
Now when I want to power the hdd down, I do
umount
vgchange -an extern-1
cryptsetup -v remove /dev/... |
Yes, you can find the information in /sys/block/$DEVICE/slaves. If you only have the canonical name you can use readlink to get the details, e.g:
devdm="$(readlink -f /dev/mapper/extern-1-crypt)"
dm="${devdm#/dev/}"
ls /sys/block/$dm/slaves/
If you want to remove all you can just utilize directly the sys filesystem:
... | Detecting the device of a crypto mount |
1,342,641,878,000 |
I have setup a basic udev rule to detect when I connect or disconnect a mDP cable.
The file is /etc/udev/rules.d/95-monitor-hotplug.rules
KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/var/run/gdm/auth-for-vazquez-OlbTje/database", RUN+="/usr/bin/arandr"
It should just launch arandr when the... |
An udev rule applies to the add action by default. The udev rule is on a graphics card, not on a monitor; so it runs when a graphics card is added to the system, which in practice means at boot time.
Plugging in a monitor results in a change action, not an add action. You can observe this by running udevadm monitor an... | udev monitor hotplug rule not running |
1,342,641,878,000 |
I am wondering how I can configure an Arch Linux system to mount an external hard disk when it is plugged in (as opposed to have it plugged in at startup).
In order to to that, I added
/dev/sdb1 /mnt/E auto rw,users,umask=0000 0 0
to my /etc/fstab file.
Although I specified auto, it wouldn't automatically mount the ... |
For read/write access you will need a read-write NTFS driver like the ntfs-3g package from extra repository.
After installation with sudo pacman -S ntfs-3g you are able to mount your NTFS partitions the usual way with sudo mount /path/to/ntfs /mount/point. This is possible due to a symlink of /usr/bin/mount.ntfs to /u... | How do I configure an Arch Linux system to automatic mount an external harddisk when it is plugged in? |
1,342,641,878,000 |
cfgmgr is a command under AIX/ksh that checks for new hardware; e.g. new HDD's that have been added without a shutdown.
Question: Are there any similar commands under Linux? If "fdisk -l" doesn't recognize the new HDD (only after reboot). Or is Linux different from AIX, and this command is not needed?
|
In general, with modern hardware, a modern kernel, and a modern distribution, hardware recognition should happen automatically.
There is, however, a program called "kudzu" which will do what you want — attempt to detect new hardware, and add the appropriate configuration. I think, because of the changes in modern syst... | cfgmgr like command under Linux? |
1,342,641,878,000 |
I am working on an embedded Linux system, which is using kernel-5.10.24.
As the system resource is limited, so I want to minimize the CPU/memory/storage usage.
From ps -ax I found 2 kernel threads as follows,
14 root 0:00 [cpuhp/0]
15 root 0:00 [cpuhp/1]
I think they are used for CPU hotpluging, and t... |
Not really an answer, but wanted to add something. You must have tried these already, but see below just in case you missed.
If you have top(1), you can check their resource usage. Or you can use /proc/[pid]/status etc. to check them. Either way, you'd see they aren't resource hungry, and mostly in sleeping (S) state.... | How to disable CPU hotplug feature (and kernel thread) in Linux-5.10.24 |
1,342,641,878,000 |
Right now I'm trying to install Battlefield 2 from CD-ROM on my Linux computer (I know Battlefield 2 is a little old now but I couldn't care less). Of course, it needs to be run under Wine, and luckily for me Wine isn't the issue yet. The issue is that once the installer asks for Disk 2 to be inserted, it doesn't get ... |
Wine has a wine eject command to address this. When it's time to switch disks, simply fire up another terminal and wine eject, then plug in the second disk.
It is noteworthy that the appropriate $WINEPREFIX must be set for this command to work properly.
| Hotswapping CDs on Linux |
1,342,641,878,000 |
Is it possible to change the number of VCPUs on a KVM virtual machine on Linux without stopping it first? The Linux kernel has calls for addition and removal of CPUs (CPU hotplug in the Kernel) for physical machines (on hardware that supports that) but I can't find anything on VMs and how to allocate more/fewer resour... |
In order to change the VCPU allocation, you do
sudo virsh setvcpus [vm_name] [num_vcpus] --current
From within the machine, running
sudo udevadm monitor -k
You'll see a series of messages similar to
KERNEL[836.518069] add /devices/system/cpu/cpu4 (cpu)
KERNEL[836.518095] bind /devices/system/cpu/cpu4 (cpu)
... | Change CPU count on live Linux VM |
1,342,641,878,000 |
Many questions are tagged : hot-plug . However , No wiki found in : Tag info
I've read this:
Modularized USB drivers are loaded by the generic /sbin/hotplug
support in the ker- nel, which is also used for other hotplug devices
such as CardBus cards.
Therefore , Could we say that hotplug is the responsible on lo... |
From the kernel documentation:
The hotplug mechanism asynchronously notifies userspace when hardware is
inserted, removed, or undergoes a similar significant state change.
There is an event variable for modules, called DRIVER, that suggests a driver for handling the hotplugged device.
| What's hotplug? |
1,342,641,878,000 |
I want to run some scripts at boot. I tried a lot of things but couldn't achieve.
Here is the OpenWRT boot sequence : https://openwrt.org/docs/techref/preinit_mount
After taking a look at this link i tried to make some changes to my /etc/init.d , i added my script in /etc/init.d. It looks like this :
avahi-daemon ... |
I solved my problem. After inspecting carefully the boot sequence , i created my script in /etc/init.d and made a symlink in /etc/rc.d after that my script ran at boot.
| Hotplug at boot in OpenWRT |
1,342,641,878,000 |
I have a linux media player that was very common before android's age. It is a MIPS running Linux Venus 2.6.12.6 and has 2 sata, 2 usb and 1 sdcard port. Since the flash memory is very limited, I installed optware, ssh and nano on sdcard and put in
ln -s /tmp/usbmounts/sdb1/opt /opt
The sdcard can remain plugged for ... |
Better to explicitly say that this is a shell script and I wish to use ${@} instead of $*:
#!/bin/sh
mount -o remount,rw /
echo ${@} >/tmp/log.txt
echo >>/tmp/log.txt
env >>/tmp/log.txt # if /tmp is writable or tmpfs
exec /sbin/sbin/hotplug "${@}"
If the system is sane, this should work. Many embedded, however, are n... | Embedded linux hotplug changed mount point |
1,337,765,244,000 |
Java community use 4 spaces as the unit of indentation. 1
Ruby community use 2 spaces that is generally agreed-upon. 2
What's the standard for indentation in shell scripts? 2 or 4 spaces or 1 tab?
|
There is no standard indentation in shell scripts that matters.
Slightly less flippant answer:
Pick a standard in your team that you can all work to, to simplify things.
Use something your editor makes easy so you don't have to fight to stick to the standard.
| What's the standard for indentation in shell scripts? [closed] |
1,337,765,244,000 |
Selecting lines in nano can be achieved using Esc+A. With multiple lines selected, how do I then indent all those lines at once?
|
Once you have selected the block, you can indent it using Alt + } (not the key, but whatever key combination is necessary to produce a closing curly bracket).
| How to indent multiple lines in nano |
1,337,765,244,000 |
When I am in vim I can change the tab size with the following command:
:set ts=4
Is it possible to set tab size for cat command output too?
|
The first command here emulates the formatting you see in vim. It intelligently expands tabs to the equivalent number of spaces, based on a tab-STOP (ts) setting of every 4 columns.
printf "ab\tcd\tde\n" |expand -t4
Output
ab cd de
To keep the tabs as tabs and have the tab STOP positions set to every 4th... | Change tab size of "cat" command |
1,337,765,244,000 |
I am using vim 7.2 from putty terminal.
Even if I run set noai it seems vim still trying to indent code.
I am copying my code from Notepad++ to vim.
following is from Notepad++
and following what I got in vim:
I don't have any tab in my file.
As a workaround I am opening old vi run set noai paste save and open in vi... |
This has nothing to do with the noai option. What you are experiencing, is a little trouble copy-pasting a load of text with existing indents to vim.
What I usually do (I have this 'problem' a lot), is bind F4 to invpaste and then, before I paste stuff into vim, hit that key. It makes the problem go away.
nnoremap <F4... | vim auto indenting even after setting noai option |
1,337,765,244,000 |
Say I'm writing a .bashrc file to give me some useful information in my login terminals and I'm telling it to run the cal command (a nice one). How would I go about shifting the calendar produced to the right to match the formatting of the rest of my .bashrc "welcome message"?
|
cal | sed 's/^/ /'
Explanation
cal |: pipe the output of cal to…
sed 's/^/ /' sed, which will look for the start of lines ^, replacing with spaces. You can change the number of spaces here to match the required formatting.
Edit
To preserve the highlighting of the current day from cal, you need to tell it t... | Shifting command output to the right |
1,337,765,244,000 |
Sometimes I edit others source code where the prevailing style is to use tabs. In this case, I want to keep the existing convention of using literal tabs.
For files I create myself, and files that use spaces as the prevailing indent style, I wish to use that instead.
How can I do this in vim?
|
You can use something like this in your ~/.vimrc to adjust to use spaces/tabs as appropriate:
" By default, use spaced tabs.
set expandtab
" Display tabs as 4 spaces wide. When expandtab is set, use 4 spaces.
set shiftwidth=4
set tabstop=4
function TabsOrSpaces()
" Determines whether to use spaces or tabs on the... | In Vim, how can I automatically determine whether to use spaces or tabs for indentation? |
1,337,765,244,000 |
My goal is to set Kate up to work properly on Python files but to use different settings (tabs not spaces) on other documents. I'm sure others are doing this, but I can't figure out a convenient solution. I appreciate any advice.
Kate has settings for indentation here:
Click the Settings menu
Click "Configure - Kate"... |
There are multiple ways to achieve what you want. In order, Kate is doing the following:
Kate reads the settings that are configured globally in the config dialog in the Indentation tab.
Kate reads optional session data, i.e. if you use sessions and manually chose settings in a file, these settings should be restored... | How do I make Kate indent with spaces on Python files but use tabs for text files and other files? |
1,337,765,244,000 |
I am using GNU Indent to format C code in my project.
By default backup files are created ending with a ~.
I don't want to have any backup files created, is there a way to disable it?
|
Looking through the man page for indent and the official GNU documentation I only see 2 methods for controlling this behavior.
The environment variables:
SIMPLE_BACKUP_SUFFIX
VERSION_WIDTH
I tried various tricks of setting the width to 0 and also setting the SIMPLE_BACKUP_WIDTH to nothing (""). Neither had the desir... | Disable GNU Indent backup files |
1,337,765,244,000 |
I often run into situations like this:
title : Jekyll Bootstrap
tagline: Site Tagline
author :
name : Name Lastname
email : [email protected]
github : username
twitter : username
feedburner : feedname
Where the arguments are not lined up well, is there a standard way in vim for to have it formatted with eac... |
The Tabularize plugin for vim can do exactly what you want. It comes down to typing Tabularize /:
This will probably not keep the indentation on the left however.
Edit on your updated question:
I was not able to do that with Tabular directly, but I was able to do this with a second command, which is a search and repla... | Indent the middle of multiple lines |
1,337,765,244,000 |
How can I indent source code based on a couple of simple rules?
As an example, I've used sed and ask to transform a selenium HTML source table to the following rspec like code. How could I consistently indent lines between describe and end ? Ideally I would like to be able to add indenting to
describe "Landing" do
v... |
With awk:
awk '
/^end/ { sub(" ", "", indent) } # Or { indent = substr(indent, 3) }
{ print indent $0 }
/^describe/ { indent = indent" " }
' <file
| How to use awk to indent a source file based on simple rules? |
1,337,765,244,000 |
I want to indent multiple files which are poorly indented and indent them properly as would vim do when I type gg=G.
Is there someway to enter the = command or its alias in the command mode? i.e after a :?
If that is possible I can use the bufdo command like in this question.
|
You can run any normal command with :normal, e.g. :normal =G.
If the files are C source code, it may be easier to use the external program indent.
| Indenting multiple files |
1,337,765,244,000 |
When indenting a block of code in Kate (3.11.2), spaces used for alignment are replaced by tabs, ruining all alignments and putting me in the hell of restoring all these spaces.
Example:
if (true)
{
—→$foo = 'bar'.
—→•••••••'baz';
}
(—→ are tabs, • spaces)
I indent using two characters wide tabs. The problem is when ... |
Being a Kate developer, the answer is as follows:
Kate's indentation system supports the concept of indentation and alignment:
Alternatively, an array of two elements can be returned:
return [ indent, align ];
In this case, the first element is the indentation depth as above with the same meaning of the special v... | Kate replaces alignment spaces by tabs |
1,337,765,244,000 |
Is there a way to make cperl mode in emacs use all tabs for indentation instead of spaces? I've tried setting indent-tabs-mode, and cperl-tab-always-indent. Here is my .emacs file:
(defalias 'perl-mode 'cperl-mode)
(setq cperl-tab-always-indent t)
(setq inhibit-splash-screen t)
(cua-mode t)
(setq cua-auto-tabify-recta... |
The right answer is not to use tabs. But ok, just for the sake of knowing how it's done…
CPerl uses the default Emacs settings for tab usage, and the Emacs default is to use tabs. So you're already getting tabs. Note that the default amount of indentation is 2 spaces, and the default tab width is 8 columns, so you nee... | Emacs cperl mode - how to use tabs for indentation instead of spaces |
1,337,765,244,000 |
How can I indent a file such as its first line?
Example:
A file containing
x=1+2+3+4+
5+6+7+8
+9+10+12
should be converted to
x=1+2+3+4+
5+6+7+8
+9+10+12
I need this inside a shell-script on a Linux system. One-liners are preferred.
|
One way using perl:
perl -pe 'if ($. == 1) { m/^(\s*)/; $space = $1 || q{}; next } s/^\s*/$space/' infile
It yields:
x=1+2+3+4+
5+6+7+8
+9+10+12
| Indent like first line |
1,337,765,244,000 |
When i'm in Insert mode at vim, and press Shift+Insert to paste my code to my file, vim disassembles my indentation , Such as:
Question: How can i solve this problem?
|
Vim is acting as if you had typed all of your pasted code by hand, so Vim will add additional indentation and otherwise change whitespace as it normally would, such as with your autoindent setting. To paste code in Vim:
:set paste to enable paste mode.
Paste your code.
:set nopaste to disable paste mode so your norma... | vim disassembles my indentation [duplicate] |
1,337,765,244,000 |
I'm searching a large number of text files which are organized in various subdirectories. I can run a command such as grep -lr foobar ./, and I get results like the following:
./dirA/dirA.A/abc.txt
./dirA/dirA.A/def.txt
./dirA/dirA.A/dirA.A.A/ghi.txt
./dirA/dirA.B/jkl.txt
./dirB/mno.txt
I would like some way to displ... |
I found a solution using a version of tree which is newer than what was installed on my system. Version 1.8.0 of tree (released 11/16/2018) introduced the --fromfile parameter, which reads a directory/file listing from a file (or stdin) rather than the filesystem itself and generates a tree representation:
$ grep -rl ... | Display `grep -lr` results as a tree |
1,337,765,244,000 |
When I try to format my C code using GNU Indent, it doesn't seem to deal with multiple levels of nested indentation. Specifically, it seems to collapse the second level of indentation.
For example, if this is the code I start with:
#include <stdio.h>
int main(int argc, char *argv[])
{
int n;
if (argc > 1) {
... |
It uses mixed spaces and (8-space) tabs to indent with. You can see that with this minimal example:
int main() {
if (true) {
while (false) {
puts("");
}
}
}
If I run that through indent -kr and then hexdump -C, I get this:
$ indent -kr < mini.c |hexdump -C
00000000 69 6e 74 20 6d ... | Why does GNU Indent collapse one level of indentation? |
1,337,765,244,000 |
I recently came across the following statement (source; emphasis added):
For shell scripts, using tabs is not a matter of preference or style; it's how the language is defined.
I am trying to make sense of this claim. Of course, it is somewhat loosely worded1, but I would like to know if there is any truth to it.
I... |
As I understand it, the claim is being made specifically in the context of here-documents, and the <<- form specifically strips leading tabs:
If the redirection operator is "<<-", all leading <tab> characters shall be stripped from input lines and the line containing the trailing delimiter.
Note that the second scri... | Does bash (or zsh) "officially" mandate the use of tabs for indentation in scripts? |
1,337,765,244,000 |
How can I add wrappers to a file based on a pattern?
For instance I have the following:
...
find(css_policy_form_stage3).click
with_ajax_wait
expect(css_coverage_type_everquote).to be_visible
end
with_ajax_wait
expect(css_coverage_type_everquote).to be_visible
end
end
it "Stage 3" do
select(cover... |
Here's one way with sed:
sed -E '/with_ajax_wait/,/end/{ # if line is in this range
H # append to hold space
/end/!d # if it doesn't match end, delete it
//{ # if it matches
s/.*// #... | How to add "wrappers" around methods in source code based on a pattern, using sed, awk, grep and friends |
1,337,765,244,000 |
I'm using only TAB for indent, so I configure Vim for using only them:
set autoindent
set noexpandtab
set tabstop=4
set shiftwidth=4
But some files (.py) still using spaces. I've search for it and found:
filetype plugin indent on
But this has not help, and I've try:
au FileType python setlocal noexpandtab
But this ... |
Some vim syntaxes set certain settings when the file is opened. As you've found, you can get around this by using an autocmd to set the setting after the syntax has finished.
To get the autocmd to apply on all file types, use a *. For example:
autocmd FileType * set noexpandtab
| (Vim) How to use TAB for indentation in all file types? |
1,337,765,244,000 |
How can I configure ~/.emacs so that I indent how nano does by default?
Uses a tab character instead of 5 spaces
I can add as many tabs to a line as I please
|
I added the following to ~/.emacs:
(setq-default indent-tabs-mode t)
(setq backward-delete-char-untabify-method nil)
(setq indent-tabs-mode t)
(defun my-insert-tab-char ()
"Insert a tab char. (ASCII 9, \t)"
(interactive)
(insert "\t"))
(global-set-key (kbd "TAB") 'my-insert-tab-char) ; same as Ctrl+i
| How to make 'emacs' indent with tabs exactly how 'nano' does...? |
1,337,765,244,000 |
I have several empty inline function definitions in C++ like so:
class C
{
void foo(){}
void bar(){}
};
now if I run indent -st -i4 -nut test.cc in order to just fix the indentation I get
class C
{
void foo ()
{
}
void bar ()
{
}
};
But I just want to fix the indentation without movi... |
Looking at man indent I see using -brf will put braces on the function definition line. If you want it on the if-line as well, you'll need -br.
If your PAGER environment variable is less you can search through man indent with / and the text. So if you do man indent, followed by /braces<ENTER> You'll be able to hop bet... | How do I keep 'indent' from moving curly braces to the next line? |
1,337,765,244,000 |
I am using Emacs for Python developement. My team is using Tab indentation, so I must do the same. The problem is that I can't figure out how to make python-mode use tabs instead of spaces. I want Emacs to automatically indent my line to the correct level when I press Ctrl-j.
|
You'll want to add the following to your .emacs file:
(add-hook 'python-mode-hook
(lambda () (setq indent-tabs-mode t))
| Use tabs for indentation in Python mode |
1,337,765,244,000 |
Given this code:
#!/bin/bash
_DATABASES=(
"secretX"
"secretmin"
"secretcopyijui"
"secretcroma"
"secretdemo"
"secretdicopy"
"secretflashcolo"
"secretmdat"
"secretneton"
"secretprintshar"
"secretrealjet"
"secretsolumax"
... |
The ={motion} operator can be defined by a number of settings ('equalprg', 'indentexpr', 'lisp'), but when all those are unset, it falls back to using C indenting. This is what is happening here.
C indenting is meant for the C language, and mostly takes its cues on the C curly braces { ... } and identifiers such as if... | Vim autoindent stops indenting multiline array in bash after 20 lines |
1,337,765,244,000 |
I don't want to use tabs for indent, so I add (setq-default indent-tabs-mode nil) in my emacs init file.
With the setting indents are created by spaces in web-mode, but it doesn't change already existing tabs to spaces.
Is there a config like overwrite-tab-indent-by-space-indent?
Or must I replace tabs to spaces by co... |
To untabify the whole buffer upon opening a file that uses web-mode, you could add something like this to your init file:
(add-hook 'web-mode-hook
(lambda () (untabify (point-min) (point-max))))
This assumes that web-mode is the name of the mode you want this setting to apply to; adjust to taste.
| How to replace tab's indent by space's indent with web-mode in Emacs |
1,337,765,244,000 |
I'm having some difficulty with the vim reindent files (with gg=G).
When I have a larger file (not that large, maybe less than 400 lines of code) I think Vim is having trouble to indent some lines correctly since the line on which the indention of the line afterwards depends is lots of lines above (I assume so, becaus... |
The number of lines to scan to find the indentation of the corresponding \begin{...} is limited, but it can be controlled by the (unfortunately undocumented) global variable g:tex_max_scan_line, which defaults to 60.
See the variable definition in the indent/tex.vim shipped with the Vim runtime.
You can increase it to... | Vim re-indent file, hardcode some indents |
1,337,765,244,000 |
I need grep's output to be indented with tabs/spaces.
This is the plain, un-indented version: MyCmd | grep "id:"
I tried this without success:MyCmd | grep "id:" | echo " "
|
You could do it with awk instead of grep if that's acceptable:
MyCmd | awk '/id:/ {print " " $0}'
or if you need grep, sed could help:
MyCmd | grep "id:" | sed -e 's/^/ /'
The awk version does its own pattern match for lines that contain "id:" and then will print the spaces before the line. The sed version does... | How to indent grep's output? [duplicate] |
1,337,765,244,000 |
Often I have code that I want to align based on similar structure of lines, not just the left-side auto indent. Is there a script out there that can do something like this? Here is an example of what I want to do. Given:
self.colorOfBackground =? colorOfBackground
self.colorOfLineForTime =? ... |
This will give you the expected result
File.txt :
self.colorOfBackground =? colorOfBackground
self.colorOfLineForTime =? colorOfLineForTime
self.marginOnBottom =? marginOnBottom
self.marginOnTop =? marginOnTop
When below command is used :
sed 's/^[[:blank:]]*//' File.txt | column -t -s " "
This command will remove ... | Script for formatting code into columns |
1,337,765,244,000 |
I need a way to auto-indent blocks on a C source file within the
terminal. According to the norms.
Before:
int main() {
puts("Hello world");
}
After:
int main()
{
puts("Hello world");
}
|
The classic Unix tool for this job is indent (e.g., GNU
indent). Called in K&R mode, it
will indent your example code as you asked (assuming you actually want
puts indented):
$ indent -kr <sample.c
int main()
{
puts("Hello world");
}
A more modern solution may be clang-format
(http://clang.llvm.org/docs/ClangForm... | Command that indents lines of a C source file |
1,337,765,244,000 |
I tried to change all the indentation settings to fix another problem yesterday, but now I have the following problem and I don't know which setting causes it.
If I select lines and type Tab, I would expect the selected lines to be indented. Instead, the selection is replaced with a tabulation. For example, I start wi... |
From the main window, settings -> Configure Kate. In the sidebar, go to Editing and there go the the tab Indentation.
Under Indentation Actions select Increase indentation level if in leading blank space (this is the default action).
| Kate replaces text instead of indenting when typing Tab on selected lines |
1,470,401,192,000 |
I'm trying to clarify which is the most useful (in terms of functionality) method of interacting with devices in Linux. As I understand, device files expose only part of functionality (address blocks in block devices, streams in character devices, etc...). ioctl(2) seems to be most commonly used, yet some people says... |
ioctl tends to go hand-in-hand with a /dev entry; your typical code would do
fd=open("/dev/mydevice",O_RDRW);
ioctl(fd,.....);
This is perfectly standard Unix behaviour. Inside the kernel driver you can put access controls (eg only root can do some things, or require a specific capability for more fine grained acces... | Usage difference between device files, ioctl, sysfs, netlink |
1,470,401,192,000 |
I have an Arduino Uno attached over USB, using the cdc_acm driver. It is available at /dev/ttyACM0.
The convention for the Arduino's serial interface is for the DTR signal to be used for a reset signal—when using the integrated serial-to-USB adapter, the DTR/RTS/DSR/CTS signal; or, when using an RS-232 cable, pins 4 o... |
When a userland process is opening a serial device like /dev/ttyS0 or /dev/ttyACM0, linux will raise the DTR/RTS lines by default, and will drop them when closing it.
It does that by calling a dtr_rts callback defined by the driver.
Unfortunately, there isn't yet any sysctl or similar which allows to disable this anno... | How to prevent DTR on open for cdc_acm? |
1,470,401,192,000 |
I'm trying to write a tun/tap program in Rust. Since I don't want it to run as root I've added CAP_NET_ADMIN to the binary's capabilities:
$sudo setcap cap_net_admin=eip target/release/tunnel
$getcap target/release/tunnel
target/release/tunnel = cap_net_admin+eip
However, this is not working. Everything I've read say... |
I experienced the same issue when writing a Rust program that spawns a tunctl process for creating and managing TUN/TAP interfaces.
For instance:
let tunctl_status = Command::new("tunctl")
.args(&["-u", "user", "-t", "tap0"])
.stdout(Stdio::null())
.status()?;
failed with:
$ ./targ... | Why is CAP_NET_ADMIN insufficient permissions for ioctl(TUNSETIFF)? |
1,470,401,192,000 |
I was reading the rmlint manual, and one of the duplicate handlers are clone and reflink:
· clone: btrfs only. Try to clone both files with the BTRFS_IOC_FILE_EXTENT_SAME ioctl(3p). This will physically delete duplicate extents. Needs at least kernel 4.2.
· reflink: Try to reflink the duplicate file to the original. ... |
The differences are somewhat subtle.
Reflink deletes the duplicate file and creates a new file in its place which is a clone of the original file. The metadata of the duplicate is lost, although rmlint does its best to preserve the metadata via some trickery with touch -mr.
Clone uses the BTRFS_IOC_FILE_EXTENT_SAME i... | What does a rmlint's "clone" for btrfs do? |
1,470,401,192,000 |
I ran into the error
device-mapper: reload ioctl on osprober-linux-nvme0n1p7 failed: Device or resource busy
while compiling the kernel in Ubuntu Studio. I use ZFS for my main drive.
Apparently, this is a bug: [zfs-root] "device-mapper: reload ioctl on osprober-linux-sdaX failed: Device or resource busy" against... |
According to the launchpad thread you linked to, it is a cosmetic error caused by os-prober not properly ignoring ZFS-managed drives, and if you're not dual-booting you can safely make the message go away with apt purge os-prober. See also here.
| device-mapper: reload ioctl on osprober-linux-nvme0n1p7 failed: Device or resource busy |
1,470,401,192,000 |
I want to use the ioctl EVIOCGRAB function in a C based program, and from googling around I have found various bits of example source code that use the function, but I am struggling to find explicit documentation that correctly describes how to correctly use it.
I see that from ioctl(2), ioctl function is defined as
i... |
A definitive explanation you can at least find in the kernel sources, more specifically drivers/input/evdev.c:
static long evdev_do_ioctl(struct file *file, unsigned int cmd,
void __user *p, int compat_mode)
{
[…]
switch (cmd) {
[…]
case EVIOCGRAB:
if (p)
... | Where do I find ioctl EVIOCGRAB documented? |
1,470,401,192,000 |
I am writing some code around libgpiod's interface. For example, I want to set a line to output high. Under the hood, libgpiod opens an fd provided by the kernel for the line, and then calls ioctl(fd, GPIO_V2_LINE_SET_VALUES_IOCTL, ...).
My questions are:
Is this particular ioctl() call (with the GPIO_V2... argument)... |
GPIO_V2_LINE_SET_VALUES_IOCTL seems safe enough; it matches the expected use of ioctl, “manipulat[ing] the underlying device parameters of special files”. It is implemented in linereq_set_values, which acquires a lock, but I don’t think that lock can block for an indefinite amount of time (its users are all non-block... | Are ioctl calls blocking? |
1,470,401,192,000 |
I'm messing with TIOCSTI which shoves data into the terminal's input buffer. I want to be able to capture this data before it arrives at the shell or redirects it to a file.
To better illustrate what I'm trying to do:
gcc -x c -o pusher.bin - <<PUSHER
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
in... |
It seems script is the solution, as mentioned by A.B. With -e you even get the return code of the program. cat -vet shows more explicitly the carriage return ^M and newline $.
$ script -q -e out -c ./pusher.bin >/dev/null; echo $?
0
$ cat -vet out
Script started on Mon Dec 21 10:54:40 2020$
echo 'Catch me if you can'^... | How can I run a program in its own tty? |
1,470,401,192,000 |
Am I right that all input typed from the keyboard goes through a controlling terminal? That means that if a program is run without a controlling terminal, it won't be able to receive any user input. Is that right for every kind of program in Linux?
UPDATE #1: To clarify the question, my pager module for Python crashes... |
No. Terminal applications read keyboard input from the device file (on Linux, something like /dev/ttyS0 or /dev/ttyUSB0... for a serial device, /dev/pts/0 for a pseudo-terminal device) corresponding to the terminal with the keyboard you're typing on.
That device doesn't have to be the controlling terminal of the proce... | Does keyboard input always go through a controlling terminal? |
1,470,401,192,000 |
I am working on a C program which gets the timestamping information for a given network interface, like my own version of ethtool. My goal is to get the information printed by $ ethtool -T myNetIf. Something like:
Time stamping parameters for myNetIf:
Capabilities:
hardware-transmit (SOF_TIMESTAMPING_TX_HARDWA... |
This is embarrassing: I have reviewed my code and found that I did fail to properly initialize a struct, just not in quite the way I expected. I also didn't provide the full context needed to solve the problem, since I thought I had ruled out the possibility of junk values left over from before allocation.
The sample ... | How does the Linux Kernel store hardware TX and RX filter modes? |
1,470,401,192,000 |
I've run into an error stemming from lacking permissions when using the CDIO library to issue an eject command to my USB CD-ROM drive. I always get an error message like this:
INFO: ioctl CDROM_SEND_PACKET for command PREVENT ALLOW MEDIUM REMOVAL (0x1e) failed: Operation not permitted
The ioctl call is part of the cd... |
OK, after a hint from one of the maintainers of libcdio, I found out that the version I installed was out of date and contained a bug based on improper use of O_RDWR vs. O_RDONLY. After the update, suddenly everything works fine. Nevertheless thank you for your hints!
| How to I set the permissions necessary to make the ioctl CDROM_SEND_PACKET command run? |
1,470,401,192,000 |
I've got a USB 2.0 CD/DVD drive, which is (amongst other use cases) used to play music CDs. But: The drive seems to ignore CDROMPLAYMSF commands.
The host is a Raspberry Pi 3B with the current version of Raspbian. I'm using libcdaudio for audio CD playback, which in turn issues the necessary ioctl commands, including ... |
Originally CD ROM drives (in the IDE era) had an analog audio connection to the motherboard. The SCSI commands PLAY, STOP, SCAN and their variants would then play audio CDs to this analog output just like a standalone CD player.
The CDROMPLAYMSF ioctl issues one of those SCSI commands, namely PLAY AUDIO MSF. MSF defi... | What does the ioctl CDROMPLAYMSF command do exactly? |
1,470,401,192,000 |
I try to make an ioctl() call from bash. This is very easy to do in C, so there are tools ( https://github.com/jerome-pouiller/ioctl ) which wrap this functionality.
But it would make the distribution of my script a lot harder, because I would have to distribute that tool along with it.
Is there any other tool that is... |
The ioctl system call takes a parameter list that varies a lot depending on the request. Many requests take structured data as input or produce structured data as output. This makes it awkward to use from the shell. There are of course commands that wrap around a specific ioctl request or a specific set — for example ... | Any tool to do ioctl() from bash? |
1,470,401,192,000 |
According to ioctl_fideduperange,
The maximum size of src_length is filesystem dependent
and is typically 16 MiB.
However, I've been able use src_length of > 1 Gib successfully with a single call to ioctl. Is that warning about 16 MiB just a complete exaggeration, at least for btrfs?
Also, according to the VFS docu... |
Older versions of btrfs (e.g., 4.15) had a 16 MiB limit per FIDEDUPERANGE call, and would silently cut oversized requests down to 16 MiB. I forget exactly when the change happened, but the current version of btrfs (i.e., 5.16) loops in 16 MiB chunks. I think linux (not btrfs, now) still silently cuts down requests o... | FIDEDUPERANGE ioctl doesn't behave as expected on btrfs |
1,470,401,192,000 |
My assumption is that sysfs is built using ioctl queries, meaning all the information you would want (or at least most of it) is already available by simply reading files on sysfs. I notice some programs (e.g., hdparm) still use ioctl calls rather than simply hitting sysfs , and I'm curious if there's a reason for tha... |
As rightly asserted by Tilman in comments, sysfs and ioctl both provide userland access to kernel data structures.
Since the kernel does not need system calls to access to its own data, neither is the sysfs tree built resorting to ioctl calls, nor any user action on its files will translate into ioctl calls.
You writ... | Is there ever a reason to query ioctl for hardware info when we have sysfs? |
1,470,401,192,000 |
The prototype of ioctl in linux driver modules is
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
but inside sys/ioctl.h it is
int ioctl(int fd, int request, void *argp);
The first argument type is different, is th... |
In ${kernel_root}/fs/ioctl.c (in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3 is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl system ca... | mapping of ioctl to its definition |
1,470,401,192,000 |
Can anyone explain the core difference between HDIO_GETGEO and HDIO_GET_IDENTITY?
From the Linux documentation and this document titled: Summary of HDIO_ ioctl calls., I know that the former is for "getting device geometries" and the latter for "getting IDE identification info".
In the HDIO summary document, it is ... |
GETGEO returns bios drive geometry, which is obsolete. IDENTITY returns the raw ATA device identification sector. You shouldn't use either one. Instead, simply read from the files /sys/block/sda/size and /sys/block/sda/queue/hw_sector_size. The former gives the size in "sectors" as if the sector size were 512 bytes, e... | HDIO_GETGEO and HDIO_GET_IDENTITY in Linux using C++ |
1,470,401,192,000 |
Does anyone know if uname() makes an ioctl() call directly or indirectly? I reviewed the source, however didn't see that it does. I also used strace and did not see the kernel call made.
Thanks
strace uname
execve("/usr/bin/uname", ["una... |
The system call involved is … uname! You can see it in your trace:
uname({sysname="Linux", nodename="debian", ...}) = 0
It provides the operating system name, release, version etc.
| uname: what ioctl does it use? |
1,470,401,192,000 |
As pointed out in this question, the prototype for the ioctl function inside a Linux kernel module is:
(version 1)
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
(version 2)
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
I would like to use them in a kernel modu... |
Are both the above prototypes suitable in this case? If yes, why? If no, how to choose the right one?
They are not both suitable. Only version 2 is currently available in the kernel, so this is the version that should be used.
What header/source file(s) contain these prototypes? In other words: what is the offic... | Two different function prototypes for Linux kernel module ioctl |
1,470,401,192,000 |
I am unable to set or view file attributes using lsattr and chattr commands on Reiser File System. Following result is observed:
chattr +i Temp.txt
chattr: Inappropriate ioctl for device while reading flags on Temp.txt
lsattr Temp.txt
lsattr: Inappropriate ioctl for device While reading flags on Temp.txt
Is there a ... |
According to a mailing list question from 2003, Reiserfs doesn't support chattr. Granted that was a long time ago, but given your error above, it seems likely that it still doesn't.
| Inappropriate ioctl for device while reading flags on <file> |
1,455,343,387,000 |
In output of iostat there is a steal field, according to man page the field is used to:
Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
But what does that mean? Does it means the kernel itself is too busy to manage a cpu, ... |
The hypervisor means the layer that manages a virtual environment, like VMware, XEN or VirtualBox.
So the steal field, should be an interesting field to monitor, to detect problems or oversubscription of a virtualised environment. The field itself means the time the VM CPU has to wait for others VMs (virtual machines... | iostat - What does the 'steal' field mean? |
1,455,343,387,000 |
os: centos7
test file: a.txt 1.2G
monitor command: iostat -xdm 1
The first scene:
cp a.txt b.txt #b.txt is not exist
The second scene:
cp a.txt b.txt #b.txt is exist
Why the first scene don't consume IO, but the second scene consume IO?
|
It could well be that the data had not been flushed to disk during the first cp operation, but was during the second.
Try setting vm.dirty_background_bytes to something small, like 1048576 (1 MiB) to see if this is the case; run sysctl -w vm.dirty_background_bytes=1048576, and then your first cp scenario should show I... | why linux cp command don't consume disk IO? |
1,455,343,387,000 |
From iostat man pages:
rrqm/s
The number of read requests merged per second that were queued to the device.
wrqm/s
The number of write requests merged per second that were queued to the device.
r/s
The number (after merges) of read requests completed per second for the device.
w/s
The number (after merges) of... |
A merge happens when two i/o requests can be collapsed into one single longer-length request. For example, a write to block 1234 followed by a write to block 1235 can be merged into a single i/o request for block 1234 of length 2 blocks. As this sort of situation can be fairly common it is worth putting the effort in ... | iostat: what is exactly the concept of merge |
1,455,343,387,000 |
I read /dev/sda using a 1MiB block size. Linux seems to limit the IO requests to 512KiB an average size of 512KiB. What is happening here? Is there a configuration option for this behaviour?
$ sudo dd iflag=direct if=/dev/sda bs=1M of=/dev/null status=progress
1545601024 bytes (1.5 GB, 1.4 GiB) copied, 10 s, 155 MB... |
Why is the size of my IO requests being limited, to about 512K?
I posit that I/O is being limited to "about" 512 KiB due to the way it is being submitted and various limits being reached (in this case /sys/block/sda/queue/max_segments). The questioner took the time to include various pieces of side information (such... | Why is the size of my IO requests being limited, to about 512K? |
1,455,343,387,000 |
I have a web server (specs below) with 12 TB of storage. I am moving massive amounts of csv files packaged in TAR's to the server, then extracting on the server. The problem is that when extracting the TAR files, the server become so slow that it's almost unusable. I'm not doing anything crazy, generally running 2-4 e... |
The ionice command is "nice for IO" and will run a command with different IO priorities, so it will (or won't) yield to other processes that want to use the disk.
ionice -c 3 tar xf ...
will run the tar command with "idle" priority, so it only uses the disk when nobody else wants to. That will prevent it interfering ... | Linux - Extracting Tar dramatically slows down server |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.