Linux Knowledge Base
What is Kernel?
Kernel is the core operating system. It control the hardware, the booting sequence, network and the whole process.
Kernel-doc :- It is the documentation of the Kernel.
/usr/share/doc/kernel/documentation (This path contain the documentation of lots of process running in the system)
Kernel Variants or Images
The regular kernel support max 4gb of RAM.
The PAE kernel support more than 16GB of RAM.
The XEN kernel is for Virtualization.
Kernel-modules are basically the drivers for various driver like USB, Firewall, Path of modules are /lib/modules.
Commands
'lsmod' command is use to chk the modules loaded in your box.
'modinfo' command in use to load or unload any module/device.
'demidecode' shows the bios information.
'modprobe' command is use to load ur unload any module/device.
to add 'module -a <module name>'
to remove 'modprobe -r <module name>
/etc/modprobe.conf is used to config usr modules.
THE Chicken/ Egg Problems :-
This problem occurs when we added new filesytem of new device.
Solution : Create new initrd.
makeinitrd --with=raid1 /boot/initrd -raid1-$(unmae -r).img $(unmae -r)
Kernel Proc
/proc used to get or set Kernel configure. It is a virtual filesytem used to display, memory and various other info.
cat /proc/cpuinfo (for CPU information)
cat /proc/meminfo (for memory information)
free -m (used to get current memory information)
sysctl :- Add persistence to /proc/sys settings
How to copy file and folder to remote server via SCP?
scp -r mydata root@172.23.1.74:/home/data/
How to Change the Time Zone and Date in Linux(Centos)?
To change the time zone use the following commands (Here we are setting the timezone to London) -
cp /usr/share/zoneinfo/Europe/London /etc/localtime
or
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
To change the Current Date Time use the following command
date -s "17 OCT 2013 07:46:00"
Then if you put the date command the output will be
Thu Oct 17 07:46:00 BST 2013
Ulimit : - ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
Usually, you have to increase the values of some of the Linux kernel limits before your install or run many applications.
With ulimit you can set two kind of limits:
1. Soft limit: is the value that the kernel enforces for the corresponding resource.
2. Hard limit: acts as a ceiling for the soft limit.
An unprivileged process may only set its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process may make arbitrary changes to either limit value.
Checking the values of the kernel limits
# ulimit -a
core file size (blocks, -c) 1
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 59517
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) 6695364
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 59517
virtual memory (kbytes, -v) 6301520
file locks (-x) unlimited
Changing temporally the value of a limit
With ulimit you can change the value of one limit for the current shell:
# ulimit -n 16384
This command sets the maximum number of opened files to 16384 for the current shell.
Making permanent changes to a limit
Linux servers have a PAM (plugabble authentication) module that handles system limits:
“By default limits are taken from the /etc/security/limits.conf config file. Then individual files from the /etc/security/limits.d/ directory are read. The files are parsed one after another in the order of “C locale. The effect of the individual files is the same as if all the files were concatenated together in the order of parsing. If a config file is explicitely specified with a module option then the files in the above directory are not parsed.
In our example we will set the maximum number of files to 16384 for all users of the system (values can be set for individual users or groups as well):
# vi /etc/security/limits.conf
Add two lines for each limit:
* soft nofile 16384
* hard nofile 16384
Reboot your machine and test the new limits configuration