date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,414,755,363,000 |
By using ls -lh we can get the file size.
Is there any way I can check if the file size is greater than 1MB to then print a message like below? I may have files with different sizes like 100mb, 1gb, 10gb, 100kb.
if [ $FileSize > 1MB ];
then
echo "File size is grater than 1MB"
fi
Is there a way I can check the fil... |
Using find on a specific file at $filepath:
if [ -n "$(find "$filepath" -prune -size +1000000c)" ]; then
printf '%s is strictly larger than 1 MB\n' "$filepath"
fi
This uses find to query the specific file at $filepath for its size. If the size is greater than 1000000 bytes, find will print the pathname of the fi... | Check if the file size greater than 1MB using IF condition |
1,414,755,363,000 |
Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify it or generate a new file descriptor where file offsets are relative to the beginning of the range and end at the end o... |
One way of doing this is to use a loop device. This approach does have two requirements which may make it less useful: you need to be root to set it up, and the non-cooperating subprocess must be able to write to a block device. Oh, and it doesn’t deal with conflicting changes.
To set the loop device up, run
losetup -... | Is there a Linux system call to create a “view” of a range of a file? |
1,414,755,363,000 |
I have a script that uses gnu parallel. I want to pass two parameters for each "iteration"
in serial run I have something like:
for (( i=0; i<=10; i++ ))
do
a = tmp1[$i]
b = tmp2[$i]
done
And I want to make this parallel as
func pf()
{
a=$1
b=$2
}
export -f pf
parallel --jobs 5 --linebuffer pf ::: <what to ... |
Omitting your other parallel flags just to stay focused...
parallel --link pf ::: A B ::: C D
This will run your function first with a=A, b=C followed by a=B, b=D or
a=A b=C
a=B b=D
Without --link you get full combination like this:
a=A b=C
a=A b=D
a=B b=C
a=B b=D
Update: As Ole Tange metioned in a comment [since ... | GNU parallel - two parameters from array as parameter |
1,414,755,363,000 |
For some reason my Fedora 25 FRESH install is not using wayland by default. I know this because of
$: loginctl show-session 3 -p Type
Type=x11
If I was using Wayland by default that should say wayland or weston. I'm very confused why this fresh install of fedora 25 is not sporting wayland by default. I looked over th... |
Nvidia does not yet support Wayland, so Fedora 25 falls back to X11. From the Nvidia forum I see someone has used packages from the in-development Fedora 26 plus some patches to get it working, but notes "I have tested it with local builds and it runs like crap, personally I wouldn't bother trying it in F25."
Hopefull... | Fedora 25 is NOT using wayland by default! |
1,414,755,363,000 |
If I want to check if I got to the max of the nproc value should I do:
ps -ef | wc -l
Or
ps -efL | wc -l
Does nproc in limits.conf refers to number of processes or number of threads?
|
On Linux it refers to the number of threads. From setrlimit(2) (which is the system call used to set the limits):
RLIMIT_NPROC
The maximum number of processes (or, more precisely on Linux, threads) that can be created for the real user ID
of the calling process. Upon encountering this limit, fork(... | Does nproc in limits.conf refers to number of processes or number of threads? |
1,414,755,363,000 |
I have multiple systemd services that require a generated EnvironmentFile. I have a shell script which generates this Environment file, but since I need that environment file before any Exec... commands execute, I cannot use ExecStartPre=generate_env_file.sh . Therefore, I have another service (generate_env_file.ser... |
RemainAfterExit=true is the way to go. In this case Systemd starts the service and Systemd considers it as started and live. However this doesn't cover the use case of executing systemctl restart generate_env_file.service. In this case systemd will re-execute your service. To solve this, you could create a marker file... | systemd oneshot Requirement to execute only once |
1,461,445,157,000 |
Is there a CPU/RAM overhead associated with using loop-mounted images versus using a physical partition under Linux?
|
On Linux <4.4, there is significant overhead when using loop devices on Linux: data accessed through the loop device has to go through two filesystem layers, each doing its own caching so data ends up cached twice, wasting much memory (the infamous "double cache" issue)
Aside from casual use, other alternatives would ... | Overhead of using loop-mounted images under Linux |
1,461,445,157,000 |
A mount point /mnt/sub is shadowed by another mount point /mnt. Is it always possible to access the mounted filesystem?
Root access is a given. The system is a reasonably recent Linux.
Example scenario: accessing the branches of an overlay root
The basic sequence of operations is:
mount device1 /mnt/sub
mount device2 ... |
# unshare --mount # this opens a sub-shell
# cd /
# umount /mnt
do what thou wilt
# exit # close the sub-shell
| Accessing a shadowed mount point |
1,461,445,157,000 |
On a Debian Jessie system:
$ ls -al ~/.gnupg/
total 58684
drwx------ 2 username username 4096 Nov 28 20:52 .
drwxr-xr-x 50 username username 4096 Nov 28 19:33 ..
-rw------- 1 username username 9602 Jun 24 22:47 gpg.conf
-rw-r--r-- 1 username username 18 Jun 25 21:07 .#lk0xb7f2fa50.hostname.5551
-r... |
They are (as the "lk" suggests) lock files. A comment in the gnupg sources says
This function creates a lock file in the same directory as
FILE_TO_LOCK using that name and a suffix of ".lock". Note that on
POSIX systems a temporary file ".#lk..pid[.threadid] is
used.
and also states that there is a cleanup f... | Files starting with .#lk0xb in ~/.gnupg directory - what are they? |
1,461,445,157,000 |
I read this post.
Are file descriptors the same as file handle?
While trying to configure the linux kernel, it asks open by fhandle syscalls (FHANDLE) [Y/n/?].
Why is this option provided? Does it affect performance of kernel or compiling time or just to have a uniform method of accessing files?
|
A FILE structure in C is typically called the file handle and is a bit of abstraction around a file descriptor:
The data type FILE is a structure that contains information about a
file or specified data stream. It includes such information as a file
descriptor, current position, status flags, and more. It is mo... | File handles and filenames |
1,461,445,157,000 |
I was going through an article on GNU which goes something like below
There really is a Linux, and these people are using it, but it is just
a part of the system they use. Linux is the kernel: the program in the
system that allocates the machine's resources to the other programs
that you run. The kernel is an e... |
I believe the bit you're referring to is covered here on the Free Software Foundation (FSF) website:
http://www.gnu.org/gnu/linux-and-gnu.html
According to the FSF their contention is that Linux is just a Kernel. A usable system is comprised of a Kernel + the tools such as ls, find, shells, etc. Therefore when refe... | What exactly do we mean when we say we are using Linux? |
1,461,445,157,000 |
my server has been running with Amazon Ec2 linux. I have a mongodb server inside. The mongodb server has been running under heavily load, and, unhappily , I've ran into a problem with it :/
As known, the mongodb creates new thread for every client connection, and this worked fine before. I don't know why, but MongoDB ... |
Your issue is the max user processes limit.
From the getrlimit(2) man page:
RLIMIT_NPROC
The maximum number of processes (or, more precisely on Linux, threads) that can be created for the real user ID of the calling process. Upon encountering this limit, fork(2) fails with the error EAGAIN.
Same for pthread_creat... | Linux max threads count |
1,461,445,157,000 |
I want to list usb ports in linux and then send a message to the printer connected to it. That message is sensed by the printer to open the cash drawer. I know I can use echo - e and a port name, but my difficulty is finding the port name. How can I list the available ports or the ports that are currently used?
|
The lsusb command will yield the list of recognised usb devices. Here is an example:
$ lsusb
Bus 002 Device 003: ID 1c7a:0801 LighTuning Technology Inc.
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 04ca... | List USB ports in linux |
1,461,445,157,000 |
I had been using Arch Linux 64 bit on a Gateway P6860FX for about two years, and recently switched to Ubuntu (also 64 bit). When I type on the keyboard, my left hand feels a lot more warmth than before, and the air coming out of the exhaust port is definitely hotter. (Odd, right now there's no extra heat at all...b... |
As geekosaur and Tshepang are saying: Assuming that both distributions are using the same kernel, remaining differences should boil down to default configuration settings.
It could be worth exploring a bit before switching distributions (changing settings is presumably quicker than installing a new OS), I suggest
Ch... | Why does one linux distro run hotter than another on laptop? |
1,461,445,157,000 |
Is there a bash/ksh/any shell script IDE.
Don't you get annoyed when you forget the space inside if or I don't know, some minor syntax mistakes you do from time to time, but takes you a long time to figure it out(especially when one is tired).
I knew about some suggestion listed below, but I'm looking for something l... |
Just about every editor support syntax highlighting for shell - this can help you spot problems.
In addition, you can put set -x and set -e at the top of your scripts. The -x tells the shell to print out every command before it executes it. The -e tells the shell to terminate the script if any errors occur. These shou... | Bash script IDE |
1,461,445,157,000 |
I'm curious about the file or symlink /etc/mtab. I believe this is a legacy mechanism. On every modern linux I've used this is a symbolic link to /proc/mounts and if mtab were to be a regular file on a "normal" file system /etc there would be challenges in making software work with mount namespaces.
For a long time I'... |
Should the use of /etc/mtab now be considered deprecated?
Depends on who you ask. If you ask the authors of mount on Linux, yes; since 2018 it says
… is completely disabled in compile time by default, because on current Linux systems it is better …
I think that's pretty strong a statement. Prior to that, /etc/mtab... | Should the use of /etc/mtab now be considered deprecated? |
1,461,445,157,000 |
When slave side of pty is not opened, strace on the process, which does read(master_fd, &byte, 1);, shows this:
read(3,
So, when nobody is connected to the slave side of pty, read() waits for data - it does not return with a error.
But when slave side of pty is opened by a process and that process exits, the read() ... |
On Linux, a read() on the master side of a pseudo-tty will return -1 and set ERRNO to EIO when all the handles to its slave side have been closed, but will either block or return EAGAIN before the slave has been first opened.
The same thing will happen when trying to read from a slave with no master. For the master si... | Why blocking read() on a pty returns when process on the other end dies? |
1,461,445,157,000 |
GTK applications mark files as recently used by adding them to the XML in ~/.local/share/recently-used.xbel, but I am frequently working with files from terminal-driven applications like latex, and these are not marked in the GTK list and hence not available from the "Recent" bookmark in GUI file browsers/pickers etc.... |
The following Python script will add all the files given as arguments to the recently-used list, using GIO:
#!/usr/bin/python3
import gi, sys
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio, GLib
rec_mgr = Gtk.RecentManager.get_default()
for arg in sys.argv[1:]:
rec_mgr.add_item(Gio.File.new... | Can I mark files as recently-used from the command line? |
1,461,445,157,000 |
I am having troubles writing an expect script. I want to do something equivalent to the following bash instruction:
iplist=$(cat iplist.txt)
I've tried using set in all the ways that I know but it is still not working. Is there another way or is just that I'm not using it the right way?
set iplist=$(cat iplist.txt)
... |
TCL can read(n) a file directly; this is both more efficient and more portable than forking out to some command.
#!/usr/bin/env expect
proc slurp {file} {
set fh [open $file r]
set ret [read $fh]
close $fh
return $ret
}
set iplist [slurp iplist.txt]
puts -nonewline $iplist
This also (if necessary) ... | How do I use 'expect' to read the contents of a file into a variable? |
1,461,445,157,000 |
Unfortunately timedatectl set-timezone doesn't update /etc/timezone.
How do I get the current timezone as Region/City, eg, given:
% timedatectl | grep zone
Time zone: Asia/Kuala_Lumpur (+08, +0800)
I can get the last part:
% date +"%Z %z"
+08 +0800
How do I get theAsia/Kuala_Lumpur part withou... |
In this comment by Stéphane Chazelas, he said:
timedatectl is a systemd thing that queries timedated over dbus and timedated derives the name of the timezone (like Europe/London) by doing a readlink() on /etc/localtime. If /etc/localtime is not a symlink, then that name cannot be derived as those timezone definition ... | Get current timezone as `Region/City` |
1,461,445,157,000 |
I would like to specify a specific identity file based on the user I am ssh'ing as to a server.
For example when ssh as user1 from host 1 to host 2 as user1
[user1@host1 ~]$ ssh user1@host2
I would like to use a certain identity file. However when I ssh as user1 from host1 to host2 as user2, I would like to use a di... |
You should be able to do this with the Match directive e.g.
Host host2
HostName host2.some.dom.ain
Match user user1
IdentityFile ~/.ssh/id_user1
Match user user2
Identityfile ~/.ssh/id_user2
| Specify Specific Identity file when ssh'ing as certain user in ~/.ssh/config |
1,461,445,157,000 |
I am trying to understand how Xorg works.
I have created the following image to show my understanding (this image shows the state of the components after you press Ctrl+Alt+F7):
The following is the explanation of the image:
/dev/tty7 is the controlling terminal for Xorg.
Xorg directly talks to the VGA driver to dra... |
Your description doesn't quite match your diagram, and is more correct than your diagram.
The X server does not use the tty driver for either input or output. It reads inputs directly from the drivers for the various input devices and sends output directly to the graphics card drivers.
You can list the input devices w... | How does Xorg work? |
1,461,445,157,000 |
I have some normal x86_64 desktop Linux installed in a single ext4 root partition† on some 500GB HDD.
Now if I want to migrate this installation to a 500GB SSD (rest of the system stays the same), do I just clone the disk and run genfstab (I know that from the Arch installation guide, do I even need that?) and done?
O... |
After some research, I found that ext4 is apparently quite usable on SSDs, so I went with the clone approach. Here is what I did, step by step:
Install the SSD
Boot from a USB and clone the HDD to SSD with dd
Change the UUID of the new filesystem. I missed that one at first, which caused funny results as grub and oth... | How can I migrate a Linux installation from HDD to SSD? |
1,461,445,157,000 |
I looking into writing my own init.d scripts to control several services running on my Linux server. I came across an example online which contained:
nohup $EXEC_SCRIPT 0<&- &> $LOG_FILE & echo $! > $PID_FILE
From what I understand:
nohup Catches the hangup signal
$EXEC_SCRIPT is a variable containing the command t... |
These are redirections.
0<&- closes the file descriptor 0 (standard input).
&> redirects both stdout and stderr (in this case to the logfile)
Are you sure there was no echo before $!? $! would be interpreted as a command and most probably result in a
-bash: 18552: command not found
| Linux init script what does 0<&- &> achieve |
1,461,445,157,000 |
One of my folders contains files in the following format:
3_20150412104422154033.txt
3_2015041211022775012.txt
3_20150412160410171639.txt
3_20150412160815638933.txt
3_20150413161046573097.txt
3_20150413161818852312.txt
3_20150413163054600311.txt
3_20150413163514489159.txt
3_2015041321292659391.txt
3_201504141245287474... |
You can use awk and its string comparison operator.
ls | awk '$0 < "3_20150415"'
In a variable:
max=3_20150414 export max
ls | LC_ALL=C awk '$0 <= ENVIRON["max"] "z"'
concatenating with "z" here makes sure that the comparison is a string comparison, and allows any time on that day since in the C locale, digits sort ... | Get files with a name containing a date value less than or equal to a given input date |
1,461,445,157,000 |
I'm facing a very annoying problem that I noticed a week from now and for which I can't find an answer: my network suddenly stops responding, usually coming back exactly 25 seconds later. I was using kernel 3.10.4 and now migrated to 3.11-rc4 to see if something changed, but no, the behavior is the same. And since it ... |
The symptoms are consistent with an IP address conflict. An IP address conflict arises when your machine and some other machine on the same network are trying to use the same IP address.
On a local link network, addressing is based on MAC addresses. Every Ethernet card has its own MAC address (barring gross misconfigu... | Strange temporary network outage in Linux |
1,461,445,157,000 |
I tried out Red Hat, Ubuntu, Kali Linux. While working on them I searched for the difference between the distributions of Linux. One thing I got was the difference in Package Management, (.rpm and .deb). But I don't think it's only the difference.
Secondly, while trying some commands on Kali Linux (like quotacheck), ... |
comparing distros
I'd start first with the comparison of Linux distributions on the wikipedia page titled: Comparison of Linux distributions. Distrowatch is another good resource for comparing Linux distros.
The site Digital Inspiration also has a good article titled: Which is the Best Linux Distribution for your Desk... | How to get differences between different distributions of linux |
1,461,445,157,000 |
I have a PCI-attached SATA controller connected to a (variable) number of disks on a machine with a Linux 2.6.39 kernel. I am trying to find the physical location of the disk, knowing the PCI address of the controller.
In this case, controller is at address 0000:01:00.0, and there are two disks, with SCSI addresses 6:... |
I think you can get what you want by cross referencing the output from lshw -c disk and this command, udevadm info -q all -n <device>.
For example
My /dev/sda device shows the following output for lshw:
$ sudo lshw -c disk
*-disk
description: ATA Disk
product: ST9500420AS
vendo... | Match PCI address of SATA controller and SCSI address of attached disks |
1,461,445,157,000 |
In my Redhat Linux, I am getting the following error when executing the ls command.
# ls
ls: sugar.sql: Value too large for defined data type
|
From http://www.gnu.org/software/coreutils/faq/#Value-too-large-for-defined-data-type -
It means that your version of the utilities were not compiled with large file support enabled. The GNU utilities do support large files if they are compiled to do so. You may want to compile them again and make sure that large fil... | Why isn't the ls command listing huge filesizes? |
1,461,445,157,000 |
I have a few Linux servers that lack necessary sudo or root permissions, and I'm feeling kind of stuck with my options:
hand-compile packages to a ~/local/ folder or some equivalent
work with sysadmins to get some old version of whatever tool I'm wanting installed, likely never to be upgraded again
try to roll my own... |
Do you know pkgsrc? It's a framework (using Makefiles and some pkg_* tools) for compiling packages that also facilitates non-root building of packages (and their dependencies) very much.
So, referring to your choices, it's the "homebrew" thing but already built and proven, with lots of packages. There's a guide, too.... | Is there a Homebrew-equivalent for limited access user accounts in Linux? |
1,461,445,157,000 |
I have 15 identical Linux RH 4.7 64-bit severs. They run cluster database (cluster is application level). On occasion (every month or so) a random box (never the same though) freezes.
I can ping the box and ping works. If I try to ssh in the box I get:
ssh_exchange_identification: Connection closed by remote host
SSH... |
It sounds like your kernel panicked in some way such that sshd couldn't send the server keys. Possibly, the kernel was wedged in such a way that the network stack was still up, but the vfs layer was unavailable.
When I experienced similar problems on a RHEL4 system, I set up the netdump and netconsole services, and a... | Debugging Linux machine freezes |
1,461,445,157,000 |
I have the following problem: On every machine running Postgresql there is a special user postgres. This user has administrative access to the database server.
Now I want to write a Bash script that executes a database command with psql as user postgres (psql shall execute as user postgres, not the script). So far, th... |
Use a subshell: (su -c 'psql -U postgres -c "<command>"' postgres) > file
Inside the subshell you can drop permissions to do your work, but output is redirected to your original shell which still has your original permissions.
| How to run part of a script with reduced privileges? |
1,461,445,157,000 |
I want to make my Fedora Linux capable of following :
Use Linux for complete development platform without requiring any other OS installation but still able to build and test programs under different platforms.
Completely replace Windows machine for all the other work e.g. Office, Paint, Remote Desktop, etc.
Can y... |
You can easily do cross-platform development whether you are a systems programmer, a web developer or a desktop application developer. If you are into systems, then any utilities and/or drivers you write for linux are likely to work well for other *nix with very minimal modifications. Provided that you write standard ... | Linux as a complete development platform? |
1,461,445,157,000 |
What I want
I have a systemd service that I would like to have stopped before suspend/shutdown, and start up again after resume.
System details
System details below.
$ lsb_release -dc
Description: Ubuntu 20.04.1 LTS
Codename: focal
$ systemd --version
systemd 245 (245.4-4ubuntu3.3)
+PAM +AUDIT +SELINUX +IMA +APP... |
The need for an After= or Before= can finally be seen in examples from archlinux (a remarkable source of help as usual). Based on that link, there are two solutions to running a command on suspend and resume.
One method is to use two units, say mysyssuspend and mysysresume. The following examples just run the date com... | Stop systemd service before suspend, start again after resume |
1,461,445,157,000 |
Per the IPv6 standard, Linux assigns IPv6 link local addresses to interfaces. These interfaces are always assigned /64 addresses. Is this correct? I would think they should be /10. Why are they assigned /64 addresses?
|
The address space allocated to link-local addresses is fe80::/10, but the next 54 bits are defined to be all zeroes, so the effective range is fe80::/64. Which puts it in line with the usual custom for IPv6 addresses.
RFC 4291:
2.5.6. Link-Local IPv6 Unicast Addresses
Link-Local addresses are for use on a single... | Linux assigns an fe80::/64 address to an interface. Shouldn't that be fe80::/10? |
1,461,445,157,000 |
Can someone explain the following rule for filtering traffic to loopback interface?
# Allow all loopback (lo0) traffic and reject traffic
# to localhost that does not originate from lo0.
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -s 127.0.0.0/8 -j REJECT
The way I interpret it:
accept all incoming packets to loopback... |
What the rules mean is exactly what you are describing,
all packets accepted from the loopback interface.
No packets with the loopback address accepted from other sources.
It does not means per se data coming from the loopback interface has to go through additional filtering; what does it means is that the rule 2) i... | Iptables rule for loopback |
1,461,445,157,000 |
Only sometimes, I forget to make a backup of a given linux file such as /etc/rc.local, /etc/rsyslog.conf, /etc/dhcpcd.conf, etc, and later wish I did. Distribution agnostic, is there a good approach to later getting a copy of an unf'd up copy?
|
While the topic of configuration files backup/versioning might seem simple on the surface, it is one of the hot topics of system/infrastructure administration.
Distribution agnostic, to keep automatic backups of /etc as a simple solution you can install etckeeper.
By default it commits /etc to a repository/version co... | How to get copies of default Linux etc files |
1,461,445,157,000 |
I have read that the ps command can take flags in two format:
The Unix format in which you should precede the flags
with a dash.
The BSD format in which you should not precede the flags with a
dash.
Now does the same flags can be used with both formats, for example do the following commands mean the same things:
ps ... |
The manpage answers your question:
Options of different types may be freely mixed, but conflicts can appear. There are some synonymous options, which are functionally identical, due to the many standards and ps implementations that this ps is compatible with.
Note that ps -aux is distinct from ps aux. The POSIX and U... | Confused about the meaning of Unix vs. BSD flags format for the "ps" command |
1,461,445,157,000 |
Multiple sessions of the same user. When one of them gets to the point that it can no longer run new programs, none of them can, not even a new login of that user. Other users can still run new programs just fine, including new logins.
Normally user limits are in limits.conf, but its documentation says "please note ... |
nproc was the problem:
[root@localhost ~]# ps -eLf | grep pascal | wc -l
4068
[root@localhost ~]# cat /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 4096
root soft nproc ... | How can I tell which user limit I am running into? |
1,461,445,157,000 |
You know when you have a pdf, which is a scan of a document and it's a really huge file, because it just stores the picture of the scanned document?
And there are OCR tools which can help you to make a proper document which just stores the text?
Well, I need the reverse of that! Let's say I have a perfect pdf documen... |
You could test out if image based PDF's are polluted as well. First convert PDF to (multipage) TIFF, e.g. with ghostscript:
gs -sDEVICE=tiffg4 -o sample.tif sample.pdf
Then convert the TIFF to PDF, e.g.:
tiff2pdf -z -f -F -pA4 -o sample-img.pdf sample.tif
This result in a PDF file where the pages are images instead ... | How can I rasterize all of the text in a PDF? |
1,461,445,157,000 |
I have been reading on
OnCalendar=
Sadly, I found no info on how to schedule an event on a day other way than defining a day of the week, which would make it run every week at the rarest.
I need it to run every, say, 14 days. And at a specified hour (say, 4am). Is this possible with systemd?
|
I need it to run every, say, 14 days. And at a specified hour (say, 4am). Is this possible with systemd?
The easiest way to get approximately every 14 days is to make it twice a month.
[Install]
WantedBy=default.target
[Unit]
Description=Every fortnight.
[Timer]
OnCalendar=*-*-1,15 4:00:00
Unit=whatever.service
T... | systemd timer every X days at 04:00 |
1,461,445,157,000 |
I'm looking forward to download a Linux Kernel to get to know how to modify it and how to compile it.
I am using Debian distribution and I'm interested in the Debian-modified Linux Kernel rather than in the vanilla Kernel form kernel.org.
Doing some research I found out there are mainly two ways for achiving this purp... |
In Debian terminology, when you run
apt-get source linux-image-3.19.0-trunk-amd64
(or the equivalent apt-get source linux), you're actually downloading and extracting the source package. This contains the upstream code (the kernel source code downloaded from kernel.org) and all the Debian packaging, including patches... | Get kernel source: apt-get install vs apt-get source |
1,461,445,157,000 |
I'm using Debian and I want to remap my keyboard because it has some problem. I googled and found xmodmap. But it doesn't work in graphicless mode, like tty1.
|
Linux uses two independent keyboard mappings. One for the graphical mode X and one for the console.
You usually change the first one with setxkbmap (or xmodmap) and the second one with loadkeys. All those tool have a fine manpage.
For loadkeys you can find the existing keymaps under /usr/share/kbd/keymaps.
The descrip... | Remap keyboard on the Linux console |
1,461,445,157,000 |
Debian on external USB SSD drive. There was some error in dmesg log file:
...[ 3.320718] EXT4-fs (sdb2): INFO: recovery required on readonly filesystem
[ 3.320721] EXT4-fs (sdb2): write access will be enabled during recovery
[ 5.366367] EXT4-fs (sdb2): orphan cleanup on readonly fs
[ 5.366375] EXT4-fs (sdb... |
You can instruct the filesystem to perform an immediate fsck upon being mounted like so:
Method #1: Using /forcefsck
You can usually schedule a check at the next reboot like so:
$ sudo touch /forcefsck
$ sudo reboot
Method #2: Using shutdown
You can also tell the shutdown command to do so as well, via the -F switch:
... | How to repair a file system corruption? |
1,406,248,737,000 |
I have been trying for a while to view files, hidden by a mount on my device sporting Debian 6, to no avail, and being new to Linux, I am compelled to ask the question: How do you view files hidden by a mount on Debian 6?
I have gone over the many duplicates I came across as I was drafting this question the first 1 or... |
As I understand it, you want to see the files, if any, hidden by the mount /dev/sda1 /tmp/somefolder command. Assuming that /tmp is part of the / filesystem, run:
mount --bind / /tmp/anotherfolder
ls /tmp/anotherfolder/tmp/somefolder
If /tmp is not part of / but is a separate filesystem, run:
mount --bind /tmp /tmp/... | How to view files hidden by a mount on Debian 6 |
1,406,248,737,000 |
I read this from here:
The most useful combination is the Alt+SysRq/Prnt Scrn + R-E-I-S-U-B.
The above basically means that while you press and hold Alt+SysRq/Prnt Scrn and press R, E, I, S, U, B giving sufficient time between each of these keys to ensure they perform the required job.
My question is: How long shoul... |
Forget about REISUB. I don't know who invented this, but it's overly complicated: half the steps are junk. If you're going to unmount and reboot, you only need two steps: U and B. At most three steps E, U, B.
Alt+SysRq+R resets the keyboard mode to cooked mode (where typing a character inserts that character). That's ... | How long should I wait between keystrokes when doing SysRq + REISUB? |
1,406,248,737,000 |
After I use Jack, the PulseAudio outputs and inputs are replaced by a dummy device. I've tried to kill PulseAudio and reload Alsa, but the only way I can use an Alsa-based application again is to reboot. I know that there must be a way to fix the problem without rebooting. I have had this problem in multiple Linux dis... |
The solution turned out to be simpler than it appeared. The output of fuser -v /dev/snd/* revealed jackd was silently hogging the audio card even after QjackCtl supposedly killed it. Running killall jackd fixed the problem. The problem wasn't with PulseAudio, but rather jackd running invisibly in the background.
| How to restart Alsa/PulseAudio after using Jack |
1,406,248,737,000 |
I'm trying to decide between "jailing" certain applications and I know the trade-offs of KVM versus LXC and how I can use them both.
Lately I came across UML (User-Mode Linux) again and was wondering how it compares with respect to security and resource consumption (or overhead, if you will).
Where can I find a compar... |
Best Disk I/O: LXC > KVM > UML. No overhead to speak of with LXC, KVM adds a layer of indirection so it will be slower (but you could also use it with raw disks), UML will be much slower.
Least CPU overhead: LXC > KVM > UML. No overhead to speak of with LXC, small overhead with KVM, bigger overhead with UML.
Strict s... | Which one is lighter security- and CPU-wise: LXC versus UML |
1,406,248,737,000 |
CentOS / RHEL 6
I recently learned that there's a ifcfg directive called IPV4_FAILURE_FATAL exists for use in the files located here: /etc/sysconfig/networking-scripts/ifcfg-*. But I'm having a difficult time finding information about it.
What does it do?
Under what circumstances would I ever want it set to "yes"?... |
From the Fedora Project's wiki page on Anaconda Networking:
If both IPv4 and IPv6 configuration is enabled, failing IPv4
configuration of activated device means that activation is considered
as failing overall (which corresponds to Require IPv4 addressing for
this connection to complete checked in nm-c-e or
I... | What is the IPV4_FAILURE_FATAL ifcfg directive and under what scenarios would I want to use it? |
1,406,248,737,000 |
I'm working on a curses GUI that is supposed to start up automatically on boot-up in the default linux terminal (I have no X server installed). I have this working great, but I have a problem where shortly after my curses application starts, the OS will dump some information to the terminal, which messes up my GUI. ... |
You can use the command dmesg -n1 to prevent all messages, except panic messages, from appearing on the console.
To make this change permanent, modify your /etc/sysctl.conf file to include the following setting (the first 3 is the important part).
kernel.printk = 3 4 1 3
See this post for information on the kernel.pr... | How do I prevent system information from being displayed on a terminal? |
1,406,248,737,000 |
I have a couple of large disks with backup/archive material on them. They're ext4. Regarding the ones of those that will be stored for a couple of years without reading the whole disc again I've been thinking of a way to refresh the disks magnetic state. Shelf life of drives seems to be a matter of debate everywhere I... |
Generally you can't really refresh the whole disk without reading/writing all of it. fsck is unlikely to provide what you need - it works with the file system not the underlying device hence it mostly just scans file system meta data (inodes and other file system structures).
badblocks -n might be an option to dd if=X... | How do I refresh the magnetic state on a disks with backups? |
1,406,248,737,000 |
This is my first question in UNIX:
I started with shell scripts 2 days ago.
But I have a question: is a shell script a special programming language for a specific shell?
|
If you know of any command, say, ls, you type it, and then hit return, the shell will know where that program (ls) is, invoke it, and show you the result. This is the "non-script" shell usage.
But, if you order a couple of such commands in a sequence, say A, B, C, D, and then put it (the sequence) in an executable fil... | Is shell script a programming language? [closed] |
1,406,248,737,000 |
I am bind mounting a single file on top of another one and after making changes with an editor, I don't see the modifications in both files. However, if I make the changes with the shell using redirection, >>, e.g., I do see the changes in both files. Below is an example to demonstrate:
First case:
-bash-3.00# echo fo... |
What is happening is that vi is creating a new file (inode) and, effectively, undoing the bind, even though the mount is still in place. Appending uses the existing file (inode).
Take a look at the inode numbers of the files using ls -li as I step through your test(s).
$ echo foo > foo
$ echo bar > bar
$ ls -li foo ba... | single bind mounted file gets out of sync in linux |
1,406,248,737,000 |
I created a cronjob, it runs for a very long time but now don't know how to stop it.
|
You should stop the process that the crontab started running.
#kill -HUP PID (PID: Process ID is the process running)
To see a relation of the PID with the running processes (and more info) use top command, change the column order with the keys < and >
Also try ps -ax|grep [your_process_file] which lists the running ... | List currently running cron tab and stop it |
1,406,248,737,000 |
So I have this program which I manually run as root :
sudo gammu-smsd -c /etc/gammu-smsdrc -d
What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .
Is it ok to just edit root's crontab and stick this command there?... |
How about /etc/rc.local?
This will be executed last in the startup sequence.
| How to run a program on boot up? |
1,406,248,737,000 |
I have recently upgraded to Fedora 33 (Linux 5.9.16-200) on my machine. I am running vim-enhanced version 8.2. When I type sudo vim (or even sudo vi) in order to edit files with admin privilege, I get the following error.
sudo: __vi_internal_vim_alias: command not found
I am not sure what is causing this. Vim loads f... |
As @scy mentioned unalias-ing the vi and vim is a workaround solution for keeping the sudo="sudo " alias so it can be used with other aliases.
Expanding his/her answer for the different shells:
ZSH Shell: Add to the .zshrc file (of the user you want to be affected by the changes)
located at:
For Fedora 33 Workstatio... | How to resolve __vi_internal_vim_alias: command not found? |
1,406,248,737,000 |
I am tuning my linux machine running Elasticsearch. It says that I should give at least half the memory of the machine running elasticsearch to the filesystem cache. But I don't know how much of it is given currently to filesystem cache. How to find it? And how to change it to half of the RAM?
|
You won't give memory to the file system cache, because it is part of the page cache.
You may need to have enough physical RAM to make that possible (so you might need to buy more RAM).
See also LinuxAteMyRam (which explains that "free" RAM is used in the page cache for file data), and use the free(1) command (also ps... | How to give RAM to the filesystem cache |
1,406,248,737,000 |
I have installed the mlocate package on Asus RT-N56U running Padavan with Entware-ng, which is based on OpenWrt. This embedded Linux distribution has SSH enabled.
My locate results are out of date. When I use the updatedb command this error appears:
updatedb: can not find group mlocate
How can I fix this, preferab... |
The addgroup package is necessary and is included in busybox of padavan firmware.
Do the following steps as root:
grep -s mlocate /etc/group || addgroup mlocate
chgrp mlocate /opt/var/mlocate
chmod g=rx,o= /opt/var/mlocate
chgrp mlocate /opt/bin/locate
chmod g+s,go-w /opt/bin/locate
touch /opt/var/mlocate/mlocate.db
c... | How to fix "updatedb: can not find group ` mlocate'" on entware? |
1,406,248,737,000 |
I have a long running (3 hours) shell script running on a CentOS 7 machine. The script runs a loop with an inner loop and calls curl in each iteration.
I'm starting the script with PM2 because it's already on the system and it's good for managing processes. However it seems that it might not be good for shell scripts.... |
sysdig can monitor for these using the evt.type=kill filter:
# terminal uno
perl -E 'warn "$$\n"; $SIG{INT}= sub { die "aaaaargh" }; sleep 999'
# terminal dos
sysdig -p '%proc.pname[%proc.ppid]: %proc.name -> %evt.type(%evt.args)' evt.type=kill
# terminal tres
kill -INT 11943 # or whatever
A more specific filter m... | Can I track down where a SIGINT came from if it's not from a user? |
1,406,248,737,000 |
when loading a shared library in Linux system, what is the memory layout of the shared library?
For instance, the original memory layout is the following:
+-----------+
|heap(ori) |
+-----------+
|stack(ori) |
+-----------+
|.data(ori) |
+-----------+
|.text(ori) |
+-----------+
When I dlopen foo.so, will the memory... |
The answer is "Other". You can get a glimpse of the memory layout with cat /proc/self/maps. On my 64-bit Arch laptop::
00400000-0040c000 r-xp 00000000 08:02 1186758 /usr/bin/cat
0060b000-0060c000 r--p 0000b000 08:02 1186758 /usr/bin/cat
0060c000-0060d000 rw-p 000... | Memory layout of dynamic loaded/linked library |
1,406,248,737,000 |
I'm running a Oracle Linux VM on a Windows 7 host and I'm trying to ssh into my MacBook.
I've already created the private/pub keys in my Mac. I have copied the id_rsa.pub contents into the authorized_keys file in .ssh folder.
I have changed the authorized_keys permissions to 600 for the current user.
Permissions for ~... |
Your username in the VM is different than your username on the Mac. By default, ssh assumes the usernames are the same if you don't specify it explicitly. It's trying to log in to a user that doesn't exist (or that you haven't set up), which is why it always fails.
To avoid that, you can either specify the username ea... | ssh from linux into mac - permission denied |
1,406,248,737,000 |
I want to move all my 14.5 TB of media drives (not OS) to a combined LVM file system due to constant problems arranging things to fit into multiple smaller file systems.
My question is if after setup any of the 6 drives moves to a different location (/dev/sd*), is that going to be a problem? I have always mounted them... |
Each LVM object (physical volume, volume group, logical volume) has a UUID. LVM doesn't care where physical volumes are located and will assemble them as long as it can find them.
By default, LVM (specifically vgscan, invoked from an init script) scans all likely-looking block devices at boot time. You can define filt... | How does LVM find drives after setup |
1,406,248,737,000 |
I'm debugging a closed-source software installer that seems to have some pre-conceived notions about my distribution. The installation aborts after not finding apt-get. The command it attempts to run is:
apt-get -y -q install linux-headers-3.7.5-1-ARCH
I suppose the "package name" comes from /usr/src, where the sole ... |
You're running Arch linux. According to pacman -Q -i linux-headers, the package "linux-headers" contains "Header files and scripts for building modules for linux kernel". When the linux kernel gets built, various constants, which might be numbers or strings or what have you, get defined. Some loadable modules need to... | What package could "linux-headers-3.7.5-1-ARCH" mean? |
1,406,248,737,000 |
After being a long-time Debian Linux user, I decided to give SUSE a try. One of the major selling points of SUSE is the YaST configuration system. It provides a set of wizards for common configuration tasks. Almost every tutorial I can find uses YaST at some point.
Unfortunately, the text version of the utility seems... |
Living in the town (Nuremberg, Germany) where SuSE has its current roots I have a little background-info from some people, who originally worked for SuSE.
The current graphical yast2 (running on X11) has its predecessors of the time when it was usual to just have non-graphical interfaces. That predecessor was yast - w... | Are SUSE servers intended to be used graphically? |
1,406,248,737,000 |
Can the default permissions and ownership of /sys/class/gpio/ files be set, e.g. by configuring udev? The point would be to have a real gid for processes that can access GPIO pins on a board.
Most "solutions" include suid wrappers, scripts with chown and trusted middleman binaries. Web searches turn up failed attempts... |
The GPIO interface seems to be built for system (uid root) use only and doesn't have the features a /dev interface would for user processes. This includes creation permissions.
In order to allow user processes (including daemons and other system services) access, the permissions need to be granted by a root process at... | Set GPIO permissions cleanly |
1,406,248,737,000 |
Running Gentoo 3.4.0
Having recently heard about the /etc/motd file, i tried to have it display random cowsay fortunes.
I wrote some random bash script to act as a daemon, feeding the /etc/motd as a named pipe, as seen on some forums.
I don't think there's any problem with the script because cat'ing the pipe works jus... |
You're not missing anything obvious. I dug into the source of the pam_motd module to figure this one out.
The trick is that pam_motd does the following with /etc/motd:
Check the size of the file.
Allocate a buffer of that size.
Read the entire file into the buffer.
Output the buffer through whatever output method is... | /etc/motd is not displayed when a named pipe? |
1,406,248,737,000 |
In the version 2.6.15 kernel, I got that I can rewrite the task_struct in the file (include/linux/sched.h),like:
struct task_struct {
unsigned did_exec:1;
pid_t pid;
pid_t tgid;
...
char hide;
}
But, unfortunately, when I upgraded to the version 2.6.30.5, I looked through the same file, ... |
Use grep or any other search tool to look for the definition:
grep -r '^struct task_struct ' include
Or search online at LXR:
http://lxr.linux.no/linux+v2.6.30.5/+search?search=task_struct
The structure is still defined in include/linux/sched.h. There's a forward declaration which is used in mutually recursive type d... | Where is the struct task_struct definition in the 2.6.30.5 Linux Kernel? |
1,406,248,737,000 |
If I want to disable beep sounds from stuff like bash, I add this line to "/etc/inputrc":
set bell-style none
Sadly, this doesn't work for some other events like GDM start-up and shut down. I thought that adding this line to "/etc/modprobe.d/blacklist.conf" would help:
blacklist pcspkr
That makes me wonder and doubt... |
Solution for GNOME 2 (Debian 6):
I tried one more thing... System -> Preferences -> Sound. This brings up the Volume Control application:
From there I click on Preferences which brings up another window. I then click on Beep, and that mutes window thus:
I then proceed to clicking on the speaker icon on PCM column, a... | How to disable the beep sound system-wide |
1,406,248,737,000 |
Is there a way to find out for any given process with which parameters it was started?
|
To find what arguments were passed to pdnsd, I'd do:
[~]> pgrep -l pdnsd
1373 pdnsd
[~]> cat /proc/1373/cmdline
/usr/sbin/pdnsd--daemon-p/var/run/pdnsd.pid[~]>
(cmdline file entries are separated by null characters; use something like tr '\0' '\n' </proc/<pid>/cmdline to see more legible output.)
/proc/<pid>/ cont... | Finding out with which parameters a program was started |
1,406,248,737,000 |
I once had some package that you could run to instantly replace a running Windows instance with a running Linux instance. I'm not talking about virtualization or coLinux. I'm talking about the moral equivalent of hot-swapping out the Windows kernel and replacing it with a Linux kernel. It may have only worked on Win9x... |
You're probably remembering loadlin
| What's the name of the technology that instantly boots to Linux from within Windows? |
1,406,248,737,000 |
I just tried to open new terminal window and this error message displayed:
Failed to open PTY: No space left on device
It seems I can't open terminal window anymore unless closing existing one (or reboot). I don't have any other problem in my system.
My system:
Debian Buster (xfce4)
Linux debian 4.19.0-18-amd64 #1 S... |
You are looking in completely wrong place. Storage devices have nothing to do with PTY.
PTY is a "Pseudo Terminal Interfaces". It is responsible for creating connection from remote terminals. For example, you use xterm or ssh - the new PTY master channel is created on the actual machine.
Max number of PTYs (or remote ... | "No space left on the device", but it's not |
1,406,248,737,000 |
I am trying to build my source using gcc 8.3.0
root@eqx-sjc-engine2-staging:/usr/local/src# gcc --version
gcc (Debian 8.3.0-2) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTI... |
Depending on the makefile, you probably need something like:
make CFLAGS="-Wno-error=format-truncation"
The default Makefile rules, and most well-written Makefiles, should see CFLAGS for option arguments to the C compiler being used. Similarly, you can use CXXFLAGS for providing options to the C++ compiler, and LDFL... | How to suppress all warnings being treated as errors for format-truncation |
1,406,248,737,000 |
I know that you can display interfaces by doing ip a show. That only displays the interfaces that the host can see, but virtual interfaces configured by containers don't appear in this list. I've tried using ip netns as well, and they don't show up either. Should I recompile another version of iproute2? In /proc/net/f... |
An interface, at a given time, belongs to one network namespace and only one. The init (initial) network namespace, except for inheriting physical interfaces of destroyed network namespaces has no special ability over other network namespaces: it can't see directly their interfaces. As long as you are still in init's ... | How do I find all interfaces that have been configured in Linux, including those of containers? |
1,406,248,737,000 |
I am on Arch Linux, Deepin Desktop. I am using Noto Serif as my standard font, but I don't like its Arabic characters. So my goal is to use another font just for arabic characters.
Here is what I have tried. I created a new configuration file in /etc/fonts/conf.d/ with the following contents:
<?xml version="1.0"?>
<!D... |
Many Noto fonts report to the system that they support the Arabic script, which they do—in part. One of these fonts is the Urdu font, and for whatever reason it has the priority over other fonts that support the Arabic Script.
You can prefer a specific font over the others as follows:
<?xml version="1.0"?>
<!DOCTYPE f... | Changing font family for characters of a certain language/script using fontconfig? |
1,406,248,737,000 |
I have a service which is sporadically publishing content in a certain server-side directory via rsync. When this happens I would like to trigger the execution of a server-side procedure.
Thanks to the inotifywait command it is fairly easy to monitor a file or directory for changes. I would like however to be notified... |
Drawing on your own answer, if you want to use the shell read you could take advantage of the -t timeout option, which sets the return code to >128 if there is a timeout. Eg your burst script can become, loosely:
interval=$1; shift
while :
do if read -t $interval
then echo "$REPLY" # not timeout
... | Monitor a burst of events with inotifywait |
1,406,248,737,000 |
Quite interested in the size of the kernel ring buffer, how much information it can hold, and what data types?
|
Regarding the size, it's recorded in your kernel's config file. For example, on Amazon EC2 here, it's 256 KiB.
# grep CONFIG_LOG_BUF_SHIFT /boot/config-`uname -r`
CONFIG_LOG_BUF_SHIFT=18
# perl -e 'printf "%d KiB\n",(1<<18)/1024'
256 KiB
#
Referenced in /kernel/printk/printk.c
#define __LOG_BUF_LEN (1 << CONFIG_LOG_... | How to find out a linux kernel ring buffer size? |
1,406,248,737,000 |
How does systemd handle the death of the children of managed processes?
Suppose that systemd launches the daemon foo, which then launches three other daemons: bar1, bar2, and bar3. Will systemd do anything to foo if bar2 terminates unexpectedly? From my understanding, under Service Management Facility (SMF) on Solaris... |
It doesn't.
The main process handles the death of its children, in the normal way.
This is the POSIX world. If process A has forked B, and process B has forked C, D, and E; then process B is what sees the SIGCHLD and wait() status from the termination of C, D, and E. Process A is unaware of what happens to C, D, and... | How does systemd handle the death of a child of a managed process? |
1,406,248,737,000 |
I'd like to create a small terminal utility requiring a bit of very simple graphics. Therefore I'd like to use ncurses.
Now what I'm wondering is: will a ncurses program or python script that uses ncurses be visible over ssh? I'd also like the colors to be visible as well.
|
It works (no surprise), but if you are running a command via ssh (rather than the default shell), you will have to use the -t option to allocate a terminal.
The ssh manual page says
-t
Force pseudo-terminal allocation. This can be used to execute
arbitrary screen-based programs on a remote machine, which can be... | Ncurses over ssh - will they be displayed? |
1,406,248,737,000 |
I'm trying to upgrade glibc on a system on which I do not have root access. Therefore, I'm installing to a local prefix. I would like some help understanding best practices for setting this up, as well as help resolving a particular issue. (The quick summary of my issue: when I include the newly-installed glibc lib pa... |
Because of a mismatch of ld-linux-x86-64.so.2 (man ld.so) and libc.so.
If you want to run gdb under the LD_LIBRARY_PATH setting, run as follows:
export LD_LIBRARY_PATH=~/local/lib
/lib64/ld-linux-x86-64.so.2 --library-path /lib64 /usr/bin/gdb /bin/ls
This runs /usr/bin/gdb in the old library environment and /bin/ls i... | Locally-installing glibc-2.23 causes all programs to segfault |
1,406,248,737,000 |
I have a file myfile that must be re-generated periodically. Re-generation takes some seconds. On the other hand, I have to periodically read the last (or next to last) file generated. What is the best way to guarantee that I am reading a completely generated file and that, once I begin reading it, I will be able to r... |
If you're moving within the same filesystem, mv is atomic -- it's just a rename, not copying contents. So if the last step of your generation is:
mv myfile.new myfile.last
The reading processes will always see either the old or new version of the file, never anything incomplete.
| What is a good strategy to generate and copy files atomically |
1,406,268,808,000 |
I'm using tmpfs for my /tmp directory. How can I make the computer decide to swap out the files inside the /tmp before swapping out anything that is being used by applications?
Basically the files inside /tmp should have a higher swappiness compared to the memory being used by processes.
It seems this answer https://u... |
If all goes well, your kernel should decide to "do the right thing" all by itself. It uses a lot of fancy heuristics to decide what to swap out and what to keep when there is memory pressure. Those heuristics have been carefully built by really smart people with a lot of experience in memory management and are already... | How to make files inside TMPFS more likely to swap |
1,406,268,808,000 |
How do I check the health of my hard drives? I know that you can do it with system rescue, but is there a way to do it from root without booting onto system rescue?
|
smartmontools is the package you are looking for. Using the smartctl command you could try:
sudo smartctl -a /dev/sda
Of course as mentioned below the drive needs to support SMART for information to be available, but whether it is supported/enabled will be in the output of the above command. If you look at the man pa... | how to check health of hard drives? |
1,406,268,808,000 |
Problem
Run iftop for 5 seconds, capture the screenshot and save it to a file.
iftop is a beautiful program for visualizing network traffic, but it doesn't have a batch mode where I can run it for few seconds and capture the output to a file.
So my idea is
use commands like screen to create a virtual display and run ... |
I don't think you'll be able to do this with screen unless the output is actually rendered in a window, which probably defeats the point of using screen.
However, the window does not have to be in the foreground.
The ImageMagick suite contains a utility called import you can use for this. If import --help gives you "... | Capturing Screenshot of terminal application via shell script? |
1,406,268,808,000 |
I'm working with a fresh install of Ubuntu 12.04 and I've just added a new user:
useradd -m testuser
I thought that the -m flag to create a home directory for users was pretty standard, but now that I've taken a closer look I'm a little confused:
By default the new directory that was just created shows up as:
drwxr-x... |
To make the creation of the home directory behave differently do
useradd -m -K UMASK=0066 testuser
Giving other no access at all should be safe.
| What type of permissions should a user's home directory and files have? |
1,406,268,808,000 |
I am mainly using Linux for programming. I basically started with Archlinux and Manjaro and I kinda like it.
What I really like is the package management. It has a huge collection of new software and the updates are coming out really fast.
For example when GCC 4.8 was released I instantly had it 2 days after the relea... |
I'd recommand you Gentoo for programming. I use it myself and it's very convenient:
latest updates with a powerful system to prevent you break all the dependencies
rolling release, so there is no jumping from a version to another
it's a compiled distribution, so they are particularly concerned with the packaging of t... | Linux distro for a developer |
1,406,268,808,000 |
The other day, I was using a laptop for general desktop use when its keyboard began to act up. Most of the keys on the keyboard's right side stopped working entirely and key combinations such as Ctrlu made characters appear that should not have appeared. The backspace key exhibited the strangest behavior; it was someh... |
Update2:
Forgot you posted the tar ball. Too bad. Anyhow, did a test on your .mod files
by using the below code and:
./grum_lic_test32 evan_teitelman/boot/grub/i386-pc/*.mod
which yielded the following error:
...
bufio.mod License: LICENSE=GPLv3+ OK
cacheinfo.mod License: LICENS... | Grub 'incompatible license' error |
1,406,268,808,000 |
My previous question produced the commands to add an encrypted swap file:
# One-time setup:
fallocate -l 4G /root/swapfile.crypt
chmod 600 /root/swapfile.crypt
# On every boot:
loop=$(losetup -f)
losetup ${loop} /root/swapfile.crypt
cryptsetup open --type plain --key-file /dev/urandom ${loop} swapfile
mkswap /dev/map... |
You may want to have a look at:
crypttab(5)
[email protected](8)
systemd-cryptsetup-generator(8)
Those work for encrypted volumes backed by block devices. They should also work for file backed volumes.
Update:
This does work for me:
# Automatically generated by systemd-cryptsetup-generator
[Unit]
Description=Crypto... | How do I configure systemd to activate an encrypted swap file? |
1,406,268,808,000 |
Possible Duplicate:
Make all new files in a directory accessible to a group
I have a directory in which collaborative files / directories are stored. Say directory abc is owned by root and the group is project-abc. I'd like for this directory to have the following:
Only members of group project-abc are allowed ... |
The best thing you can do is to add the setgid bit (chmod g+s) to your directories. See Directory Setuid and Setgid in the coreutils manual. New directories will then preserve group ownership.
As for permissions, the best you can do is make sure umask 002 is in use every time someone works inside this directory.
(Yes,... | How do I set permissions for a directory so that files and directories created under it maintain group write permissions? [duplicate] |
1,406,268,808,000 |
I want to gather the Edid information of the monitor.
I can get it from the xorg.0.log file when I run X with the -logverbose option.
But the problem is that If I switch the monitor (unplug the current monitor and then plug-in another monitor), then there is no way to get this information.
Is there any way to get the ... |
There is a tool called read-edid doing exactly what its name suggests.
| Edid information |
1,406,268,808,000 |
I'm trying to understand which FAT based filesystems my Real Time 2.6 Linux supports. I have tried 3 things:
/proc/filesystems shows vfat among others non-relevant for the question (like ext2, etc)
/proc/config.gz shows:
# DOS/FAT/NT Filesystems
#
CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_FAT_DEFAULT... |
The FAT drivers include support for FAT32; it’s treated as a variant along with FAT12 and FAT16. If you see vfat in /proc/filesystems, then FAT32 is supported.
exFAT is supported, in recent kernels, by a specific exFAT driver, with its own configuration option (EXFAT_FS). It’s listed separately in /proc/filesystems.
e... | Understanding Linux FAT fs (FAT, VFAT, FAT32, exFAT) support |
1,406,268,808,000 |
The Linux Filesystem Hierarchy Standard says that /var/lib "holds state information pertaining to an application or the system."
FreeBSD doesn't mention /var/lib in hier(7). The closest thing I can find is /var/db ("miscellaneous automatically generated system-specific database files"), which seems like a more descrip... |
The LHFS also says about /var as a whole:
/var is specified here in order to make it possible to mount /usr read-only. Everything that once went into /usr that is written to during system operation (as opposed to installation and software maintenance) must be in /var.
And this is the link to the past for /var/lib: "... | How did /var/lib get its name? |
1,406,268,808,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,406,268,808,000 |
As far as I know in Linux kernel,
the structure task_struct represents threads i.e. light weight processes, but not processes.
processes are not represented by any structure, but by groups of threads sharing the same thread group id.
So is the following from Operating System Concepts correct?
Linux also provides ... |
Linux also provides the ability to create threads using the clone() system call. However, Linux does not distinguish between processes and threads. In fact, Linux uses the term task —rather than process or thread— when referring to a flow of control within a program.
We need to distinguish between the actual implemen... | Does Linux not distinguish between processes and threads? |
1,406,268,808,000 |
How to find files that were created or modified based on a particular timestamp.
Let's say timestamp be date +%d-%m-%y_%H.%M
Could you suggest a command which fetches files based on a particular a timestamp ?
|
You could use the following command:
find /path/to/dir -newermt "yyyy-mm-dd HH:mm:ss" -not -newermt "yyyy-mm-dd HH:mm:ss+1"
This command will list file in the folder /path/to/dir modified between yyyy-mm-dd HH:mm:ss and yyyy-mm-dd HH:mm:ss + 1 second
This should do the trick, You can also adapt this command to fin... | How to find files based on timestamp |
1,406,268,808,000 |
Is there a way to set the pipe capacity of pipes defined in a Bash (or other shell) script? Take e.g.
cmd1 | cmd2
In recent Linuxes the pipe capacity is set to 64KB by default. I know I can control the amount of data "buffered" between the two processes in two ways:
Using buffer(1): e.g. cmd1 | buffer | cmd2
Using fc... |
Based on DepressedDaniel and Stéphane Chazelas suggestions I settled on the closest thing to a oneliner I could find:
function hugepipe {
perl -MFcntl -e 'fcntl(STDOUT, 1031, 1048576) or die $!; exec { $ARGV[0] } @ARGV or die $!' "$@"
}
This allows to do:
hugepipe <command> | <command>
and the pipe between the two... | Set pipe capacity in Linux |
1,406,268,808,000 |
GCC documentation says that the -g option produces debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2).
So, what is Linux native debugging symbols format? What is it called?
Update: I've just found a 15-year old gcc mailing list discussion where it was said that the native f... |
On Linux the default is now Dwarf 2 and/or 4. To see this, run readelf --debug-dump=info on a binary containing debug symbols (or stripped symbols); for example, on Fedora, with glibc-debuginfo installed, running readelf --debug-dump=info /usr/lib/debug/bin/gencat.debug will give you something like
<1><ea>: Abbrev Nu... | What is Linux native debugging symbols format? |
1,406,268,808,000 |
I'm looking for a reliable way to detect renaming of files and get both old and new file names. This is what I have so far:
COUNTER=0;
inotifywait -m --format '%f' -e moved_from,moved_to ./ | while read FILE
do
if [ $COUNTER -eq 0 ]; then
FROM=$FILE;
COUNTER=1;
else
TO=$FILE;
COUNTER=0;
echo "sed -... |
I think your approach is correct, and tracking the cookie is a robust way of doing this.
However, the only place in the source of inotify-tools (3.14) that cookie is referenced is in the header defining the struct to match the kernel API.
If you like living on the edge, this patch (issue #72) applies cleanly to 3.14 ... | inotifywait - get old and new file name when renaming |
1,406,268,808,000 |
I'm just getting into upstart so i wrote a very basic script just to print to log file called: vm-service.conf that I put in /etc/init:
description "Virtual Images"
author "Me"
start on runlevel [2345]
stop on runlevel [016]
respawn
script
echo "DEBUG: `set`" >> /tmp/vm-service.log
end script
pre-stop sc... |
Upstart will consider the job stopped if the main process (what is run if the script or exec stanzas are specified) exits. Upstart will then run the post-start process.
So what is happening is the first script is running and exiting, Upstart is considering the job stopped, then the second script is running and exiting... | Using upstart with stop unknown instance |
1,406,268,808,000 |
If I have a tmpfs set to 50%, and later on I add or remove RAM, does tmpfs automatically adjust its partition size?
Also what if I have multiple tmpfs each set at 50%. Do multiple tmpfs compete against each other for the same 50%? How is this managed by the OS?
|
If you mount a tmpfs instance with a percentage it will take the percent size of the systems physical ram. For instance, if you have 2gb of physical ram and you mount a tmpfs with 50%, your tmpfs will have a size of 1gb. In your scenario, you add physical ram to your system, let's say another 2gb, that your system has... | Does tmpfs automatically resize when the amount RAM changes, and does it compete when there's multiple tmpfs? |
1,406,268,808,000 |
In my system I have eth0 (which may or may not be connected) and a modem on ppp0 (which always may be up or down). The the case where both interfaces are up and ppp0 is the default route, I'd like to find a way to determine the gateway IP actual address of eth0. I tried "netstat -rn" but in this configuration the ou... |
Assume eth0 is DHCP client interface.
One option is to check the DHCP client lease files dhcpd.leases
Place and name depends on the system; on some Fedora systems, the files under /var/lib/dhclient/ are lease files, where the interesting string is like that :
option routers 192.168.1.1;
Another option, which worked... | How to determine eth0 gateway address when it is not the default gateway? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.