What will happen if I change kernel configuration file in /boot? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm trying to understand all role of /boot/config-$kernel_version file.
I know I can see current kernel feature configuration from /boot/config-$kernel_version and I know I can make with my desirable kernel feature config file with use of config tool to create a .config file in /usr/src/linux-* directory.
but what exactly is this /boot/config* file for? I can't find any good explanation any where
is it just an archive file? Or what will happen if I change some configuration in here?
Or can someone share good link that describe this matter properly?

You are correct: the /boot/config-.... file shows the configuration used used to compile the corresponding kernel. Most people run distros, and do not compile their own kernels. Therefore, the presence of this file is generally useless. At best, it can allow some information if the user faces kernel problems, as it gives the exact configuration used during compilation. Modifying it will not have any effect on the system.
On the other hand, for those who do compile their own kernels, for development, testing or experimentation, this provides a good starting point. For example, if I am running Ubuntu, and I have the kernel source (with Ubuntu patches), the config file will allow me to compile my own, identical kernel. Then, I can experiment with what changes to the source or the config have.....

Related

Linux: let a process fail, if it does opens a file for writing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
Improve this question
I would like a command-line-tool to fail if it opens a particular file for writing.
Is there a way I can modify the environment (maybe via cgroups) of the command-line tool, so that the command/process gets (for example) "permission denied"?
chmod a-w file does not work. The process seems to unlink() and then re-create the file.
I know that I can watch the syscalls of a process with strace. But is there a way to alter some calls, so that the process gets a different result?
Background: unittesting
strace has an option called -e inject or simply --inject which can be used to alter system calls of the tracee. (See manpage here)
In particular, in can be combined with the -P option to only trace syscalls accessing a specified path.
Since the calls are honored in the order they are loaded from shared libraries, you can use LD_PRELOAD to load a custom library prior to the system libraries and hijack their execution. This is used by many network card accelerators like OpenOnload from Solarflare/Xilinx.
https://sumit-ghosh.com/articles/hijacking-library-functions-code-injection-ld-preload/

Can I point /etc directory somewhere else when I run a specific program [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
Suppose I have a custom binary on Linux that references /etc/mybinary/my.conf file.
I can not change the binary, nor the config file, is it possible to fool the binary to look into my /home/hari/etc directory instead of /etc/mybinary folder when I run the binary. Maybe mount over the folder somehow prior to running it?
Your custom program might accept some program option (or some environment variable) to override its configuration file. Try to run yourcustomprogram --help to find out (then man yourcustomprogram) and read its documentation.
And you might consider using a bind mount (or a symbolic link) to solve your issue. See also mount(8)
Set environment variable to the main TOP directory from where config file is available
For example
before running set TOPDIR=/home/hari
and in your program read the environment variable TOPDIR and get config file from that path. ($TOPDIR/etc/mybinary/my.conf
If you can not change the code to modify binary, you can use softlink
create a link from /home/hari/etc/my.conf -> /etc/mybinary/my.conf

How do I make Linux run a foreign program (almost) as if native [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I read, some years ago, that you could get linux to invoke the java command to run java programs by adding a bit of linux magic, but I can't remember how to do it or where I read it.
Back then I got it working and, if I recall correctly, it was fairly easy to do; just tell linux to use java to run .jar or similar files. I believe I also got it to run powerpc binaries, through qemu, using the same technique. Naturally, you would still have to mark them as exeutable.
I am not talking running java java_program_to_run or using some shell script that will, essentially, just call the same command. Nor am I asking for a way to convert a java program to an x86 binary for any particular operating system.
It was a technique that would allow Linux to deal with exectuables that wheren't native to the system, almost, as if they where native (some simulation required).
You want to checkout binfmt. More specifically, follow the instructions for java. I realize the usual practice is to copy the details into the answer, but they're quite long and it doesn't feel right to copy-and-paste the whole thing into the answer.

Linux kernel version discrepancy [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
This is maybe a basic question.
I am relatively new to Linux and I use Fedora 20. When I run:
uname -r
command, I get
3.11.10-301.fc20.x86_64
When I run:
rpm -qa kernel
I get:
kernel-3.11.10-301.fc20.x86_64
kernel-3.13.10-200.fc20.x86_64
kernel-3.14.4-200.fc20.x86_64
Regarding this discrepancy, may I please ask some basic questions:
What are the differences between the two commands? Don't they both search for the version information of the kernel?
What causes that discrepancy?
What can I do to correct them?
Any insight would be appreciated. Thank you.
What are the differences between the two commands? Don't they both search for the version information of the kernel?
The first gives the version of the currently running kernel. The second gives the name, version, release, and arch of all kernel packages installed. Two completely different things.
What causes that discrepancy?
You can only run one kernel at a time, chosen either at boot or via kexec.
What can I do to correct them?
There is nothing wrong, and hence nothing to correct.

What would happen if the Linux kernel deleted itself? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
What would happen if the Linux kernel deleted itself? Will there be a moment when it could no longer delete files because rm or the program used for deletion has been deleted too?
Regards.
The question is (apart from being off-topic) somewhat wrong in itself, as rm is not part of the kernel, but either a shell built-in or a separate user-level program. Admittedly, rm uses a syscall provided by the kernel, but that is irrelevant.
The kernel itself is loaded from a compressed image and locked in RAM. It does not matter whether you delete the compressed image until you reboot (which will fail with the boot loader giving you a message like "vmlinuz not found"). You have no way of removing the kernel from RAM (well, other than rebooting...).
Also, for the most part, it does not even matter whether you delete a file, including a running program's executable anyway (if we may be so daunting as to call the kernel a "program" for a moment) under Linux, because deleting a file merely removes the link, not the file. It is a Windows-typical assumption that deleting a file does evil, destructive things.
Under Unix-like systems, it is perfectly possible to delete (or replace) a program while it is running, and it will not cause any problems at all. You will remove the name in the filesystem, that's all. Any open descriptors will remain valid until the last one is closed, the original file will stay intact as-is for any observer who obtained a handle earlier, and it will be "gone" for everyone trying to get at it later.

Resources