Hot answers tagged

154

This is binfmt_misc in action: it allows the kernel to be told how to run binaries it doesn't know about. Look at the contents of /proc/sys/fs/binfmt_misc; among the files you see there, one should explain how to run Mono binaries: enabled interpreter /usr/lib/binfmt-support/run-detectors flags: offset 0 magic 4d5a (on a Debian system). This tells the ...


18

/dev/vcs[a]<n> will only get you the last screen-full even if you've scrolled up, but the selection ioctl()s as used by gpm will allow you to dump the currently displayed screen even when you've scrolled up. So you can can do: sleep 3; perl -e ' require "sys/ioctl.ph"; # copy: ioctl(STDIN, &TIOCLINUX, $arg = pack("CS5", 2, 1, 1, 80, 25, ...


17

There are three independent "directories" at play here: your current shell's current working directory, the shell script's current working directory, and the directory containing the shell script. To demonstrate that they are independent, you can write a shell script, saved to /tmp/pwd.sh, containing: #!/bin/sh pwd cd /var pwd You can then change ...


15

The entire kernel is loaded into memory at boot, typically along with an initramfs nowadays. (It is still possible to set up a system to boot without an initramfs but that's unusual on desktops and servers.) The initramfs's role is to provide the functionality needed to mount the "real" filesystems and continue booting the system. That involves kernel ...


9

I'm not working for a distribution, but I can think of at least two reasons: Some distributions apply their custom patches to the Kernel which are not merged into mainline yet. This means for every update of the Kernel they need to ensure that their patches don't break anything and still function properly. Even the latest stable Kernel release can contain ...


8

The problem is caused by the TasksMax systemd attribute. It was introduced in systemd 228 and makes use of the cgroups pid subsystem, which was introduced in the linux kernel 4.3. A task limit of 512 is thus enabled in systemd if kernel 4.3 or newer is running. The feature is announced here and was introduced in this pull request and the default values were ...


8

The terminal description is named for Linux, which provides its own console emulator (as do several other kernels). Except for FreeBSD, all of the Linux- and modern BSD-platforms get "termcap" by deriving it from the terminfo database in ncurses. Console entries are specific to the systems in which they are implemented (unlike many terminal emulators, ...


6

A zombie process is basically already dead. The only thing is that nobody has acknowledged its death yet so it continues occupying an entry in the process table as well as a control block (the structure the Linux kernel maintains for every thread in activity). Other resources like mandatory locks on files, shared memory segments, semaphores, etc. are ...


6

start cmd:> awk 'lines[$0]++ == 0' input Hi how are you hello today is monday I am fine


6

From the man page -y, --yes, --assume-yes Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package or removing an essential package, occurs then apt-get will abort. Configuration Item: APT::Get::Assume-Yes.


6

The commands that read stdin are almost all of the filter family, i.e. programs that transform a flow of text data to a transformed one. cat , sed, awk, gzip and even sh are good examples of such "filters". The cited commands, cp, mv and rm are definitely not filters but commands that do things with the arguments passed, here files or directories. The cd ...


5

You can test this using ab, a software that resides inside apache2-utils package. Example: ab -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://mysite.mydomain.com/ -r: Avoid exiting on socket errors. -n: Number of requests to perform. -c: Number of multiple requests running in concurrency. -k: Enable HTTP KeepAlive. Means it will perform ...


5

The manual page, e.g, as you might find on OSX or Unix commands is incomplete: Among other things, less initializes itself using the termcap strings for the cursor keys, home/page keys, pageup/pagedown keys. In most configurations, it is also possible to override the termcap settings with environment variables beginning LESS_TERMCAP_, e.g., LESS_TERMCAP_ku ...


5

How are you using cron -m? Are you passing it a script that sends mail to a group of people? If so, why not just put MAILTO=cron-people in your crontab, and define cron-people as a mail alias? Then you can just update that alias as necessary.


5

This is an easy job for sort, use the unique (-u) option of sort: % sort -u file1.txt hello Hi how are you I am fine today is monday To save it in file2.txt: sort -u file1.txt >file2.txt If you want to preserve the initial order: % nl file1.txt | sort -uk2,2 | sort -k1,1n | cut -f2 Hi how are you hello today is monday I am fine


5

The entire kernel (but not its modules) will be loaded into memory. If there are modules which the kernel will need before any filesystems are available (this usually means the drivers for the filesystems and their devices), then those modules will be in the initramfs (in memory), and the kernel will load them from there. Other modules can be loaded later ...


5

The Linux kernel's system call interfaces are very stable. But the kernel has other interfaces that aren't always compatible. /proc is mostly stable, but there have been a few changes in the past (e.g. some interfaces moving to /sys some time after /sys was created). A number of device-related interfaces have been removed in the past. /sys contains some ...


5

The "marking that memory as unused" is a function of how much work the unlinkat(2) system call has to do, which in turn scales linearly with the size of the file. For a default tmpfs on a RHEL 6 system with ~4G of memory, this can be demonstrated as follows. $ sudo mkdir /tmpfs; sudo mount -t tmpfs -o size=75% tmpfs /tmpfs; cd /tmpfs $ dd if=/dev/zero bs=1M ...


4

You can use rsync linux utility. You need to specify source and destination,it works locally as well as remotely. Please check man rsync for more details. For solaris, you'll need to install it.


4

Yes, it is provided by GRUB. The GRUB command shell is just as powerful as the shell. You can use it to discover boot images, kernels, and root filesystems. When you're at the grub> prompt, you have a lot of functionality similar to any command shell such as history and tab-completion. The grub rescue> mode is more limited, with no history and no ...


4

MemAvailable is included in /proc/meminfo since version 3.14 of the kernel; it was added by commit 34e431b0a. That's the determining factor in the output variations you show. The commit message indicates how to estimate available memory without MemAvailable: Currently, the amount of memory that is available for a new workload, without pushing the system ...


4

You could add word boundaries, and change . to \. (so as to match literal periods, instead of any characters) sed 's/\b72\.16\.90\.12\b/#&/g' Also note the use of & to save having to duplicate the replacement. You probably don't need the g modifier either in this context, since your host addresses are one per line.


4

Present (or Current) Working Directory Does the command pwd in a shell script return the directory the shell script is in? No. Firstly, by definition, no shell script or shell command returns anything other than a numeric exit status between 0 - 255. That's axiomatic, but not generally not what people mean when they ask these types of questions. ...


3

This is the expected output to Arm based processors. All Serialized cores are shown in list with line breaks instead of separated processors. Features are evaluated by cpuinfo code, and only show if all cores support them /* * Mismatched CPU features are a recipe for disaster. Don't even * pretend to support them. */ ...


3

Well after a lot of debugging (and head banging against the wall) in the init script that I was using to switch_root to the directory where debian is, I did not mount /dev, /proc and /sys... The correct tty was actually 1:2345:respawn:/sbin/getty ttyHSL0 115200


3

Global vs. local variables is a difference within a shell only (with respect to shell functions). Exported vs. non-exported variables is a difference to subprocesses (not only subshells) of the shell only (only exported variables become environment variables for subprocesses).


3

If you have fuser installed and have the permission to use sudo: for i in $(sudo fuser /dev/pts/0); do ps -o pid= -o command= -p $i done eg: 24622 /usr/bin/python /usr/bin/terminator 24633 ksh93 -o vi


3

Your filesystem is mounted with relatime by default. Access times will not be updated, if they're already newer than or equal to the modified time of the file. This is an (POSIX-violating) optimization, to avoid every single file read causing a write to the disk. Apparent atime updates are not affected by buffering. (lazyatime will buffer atime for up to ...


3

You could use grep with -A. Something like: $ grep -A 13 '^\[2\]' inputfile.txt The -A specifies the number of lines you want to include after the match. But I think it would be better to use sed in this case: $ sed -n '/^\[2\]/,/^$/p' inputfile.txt This will print everything between [2] and an empty line. The same using awk: $ awk -v RS='' -v ...



Only top voted, non community-wiki answers of a minimum length are eligible