Linux
1) Linux useful commands
#redo last command but as root
sudo !!
#open an editor to run a command
crtlx+e
#create . a super fast ram disk
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M
#don't add comand to history (note the laeading space
ls -l .
#fix a really long command that you messed up
fc
#tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379
ssh-L 3337:127.0.0.1:6379 root@emkc.org -N?
#quickly create folders
mkdir -p folder/{sub1, sub2}/{sub1, sub2, sub3}
#intercept stdout and log to file
cat file | tee -a log | cat > /dev/null
#exit terminal but leave all processes running
disown -a && exit
2) Linux boot process
a) BIOS
- Basic Input/Output System
- Special firmware
- It's operating system independent
* this is not unique to the Linux OS
- Primary purpose is to find and execute the boot loader
-Performs the POST
* Power-On Self Test
-Knows about bootable devices:
*Hard drives
*USB drivers
*DVD drivers
*etc.
- The boot device search order can be changed.
b) Boot loaders
- LILO (Linux Loader)
- GRUB (Grand Unified Bootloader)
* Replaced LILO
- Boot loaders start the operating system
- Boot loaders can start the operating system with different options
c) Initial RAM Disk
- initrd (initial RAM disk)
- Temporary filesystem that is loaded from disk and stored in memory.
- Contains helpers and modules requires to load the permanent OS file system.
d) The /boot Directory
/boot
- contains the files required to boot Linux
- initrd
- kernel
- boot loader configuration
Example for ubuntu OS:
abi-3.13.0-46-generic
config-3.13.0-46-generic
grub/
initrd.img-3.13.0-46-generic
System.map-3.13.0-46-generic
vmlinuz-3.13.0-46-generic
e) Kernel Ring Buffer
- contains messages from the Linux kernel
- dmesg
- /var/log/dmesg
f) Runlevels
0 - Shuts down the systems
1, S, s - Single user mode. Used for maintenance.
2 - Multi-user mode with graphical interface (Debian/Ubuntu)
3 - Multi-user text mode (RedHat/CentOS)
4 - Undefined
5 - Multi-user mode with graphical interface. (RedHat/CentOS)
6 - Reboot
Runlevel is control by init program
g) Init
- /etc/inittab:
- id:3:initdefault: // example seting runlevel 3 as a default run level
- being phased out by systemd
h) Systemd
- uses targets insted of runlevels
# cd
/lib/systemd/system
# ls -l runlevel5.target
lrwxrwxrwx. 1 root root 16 Jul 17 2014
runlevel5.target -> graphical.target
#systemctl set-default graphical.target
- list of avaible targets is in /lib/systemd/system
- runlevel targets are simlinks to the real target being used for exampe runlevel5.target is a simlink to graphical.target
i) to change the default runlevel , or target
*with systemd, use the "systemctl: command follow by "set-default" and desired target.
* Optional , you can manually create a simlink to the desired target from the /etc/systemd/system/default.target file. This example sets the default target to be graphical, which is equivalent to runlevel 5.
* With the init system, you can change runlevels using "telinit" command.
telinit RUNLEVEL (telinit 5)
* With "systemctl"
systemctl isolate TARGET (systemctl isolate graphical.target)
j) Rebooting commands
- telinit 6
- systemctl isolate reboot.target
- reboot
- shutdown [options] time [message]
# shutdown -r 15:30 "rebooting!"
# shutdown -r +5 "rebooting soon!" # rebooting in 5 minutes
# shutdown -r now
k) Poweroff
- telinit 0
- systemctl isolate poweroff.target
- poweroff
l) Linux kernel
- named vmlinux
- compressed vmlinuz
3) System messages and logging
4) Disk and filesystem managment
5) managing users and groups
6) Linux networking concepts and applications
7)
Namespacing
-Isolating resources per process/or group of processes)
-ex. Processes, Hard drive, Network, Users, Hostnames, Inter Process Communication
Control Groups (cgroups)
-Limit amount of resources used per process
-Memory, Cpu Usage , HD I/O, Network Bandwith
#redo last command but as root
sudo !!
#open an editor to run a command
crtlx+e
#create . a super fast ram disk
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M
#don't add comand to history (note the laeading space
ls -l .
#fix a really long command that you messed up
fc
#tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379
ssh-L 3337:127.0.0.1:6379 root@emkc.org -N?
#quickly create folders
mkdir -p folder/{sub1, sub2}/{sub1, sub2, sub3}
#intercept stdout and log to file
cat file | tee -a log | cat > /dev/null
#exit terminal but leave all processes running
disown -a && exit
2) Linux boot process
a) BIOS
- Basic Input/Output System
- Special firmware
- It's operating system independent
* this is not unique to the Linux OS
- Primary purpose is to find and execute the boot loader
-Performs the POST
* Power-On Self Test
-Knows about bootable devices:
*Hard drives
*USB drivers
*DVD drivers
*etc.
- The boot device search order can be changed.
b) Boot loaders
- LILO (Linux Loader)
- GRUB (Grand Unified Bootloader)
* Replaced LILO
- Boot loaders start the operating system
- Boot loaders can start the operating system with different options
c) Initial RAM Disk
- initrd (initial RAM disk)
- Temporary filesystem that is loaded from disk and stored in memory.
- Contains helpers and modules requires to load the permanent OS file system.
d) The /boot Directory
/boot
- contains the files required to boot Linux
- initrd
- kernel
- boot loader configuration
Example for ubuntu OS:
abi-3.13.0-46-generic
config-3.13.0-46-generic
grub/
initrd.img-3.13.0-46-generic
System.map-3.13.0-46-generic
vmlinuz-3.13.0-46-generic
e) Kernel Ring Buffer
- contains messages from the Linux kernel
- dmesg
- /var/log/dmesg
f) Runlevels
0 - Shuts down the systems
1, S, s - Single user mode. Used for maintenance.
2 - Multi-user mode with graphical interface (Debian/Ubuntu)
3 - Multi-user text mode (RedHat/CentOS)
4 - Undefined
5 - Multi-user mode with graphical interface. (RedHat/CentOS)
6 - Reboot
Runlevel is control by init program
g) Init
- /etc/inittab:
- id:3:initdefault: // example seting runlevel 3 as a default run level
- being phased out by systemd
h) Systemd
- uses targets insted of runlevels
# cd
/lib/systemd/system
# ls -l runlevel5.target
lrwxrwxrwx. 1 root root 16 Jul 17 2014
runlevel5.target -> graphical.target
#systemctl set-default graphical.target
- list of avaible targets is in /lib/systemd/system
- runlevel targets are simlinks to the real target being used for exampe runlevel5.target is a simlink to graphical.target
i) to change the default runlevel , or target
*with systemd, use the "systemctl: command follow by "set-default" and desired target.
* Optional , you can manually create a simlink to the desired target from the /etc/systemd/system/default.target file. This example sets the default target to be graphical, which is equivalent to runlevel 5.
* With the init system, you can change runlevels using "telinit" command.
telinit RUNLEVEL (telinit 5)
* With "systemctl"
systemctl isolate TARGET (systemctl isolate graphical.target)
j) Rebooting commands
- telinit 6
- systemctl isolate reboot.target
- reboot
- shutdown [options] time [message]
# shutdown -r 15:30 "rebooting!"
# shutdown -r +5 "rebooting soon!" # rebooting in 5 minutes
# shutdown -r now
k) Poweroff
- telinit 0
- systemctl isolate poweroff.target
- poweroff
l) Linux kernel
- named vmlinux
- compressed vmlinuz
3) System messages and logging
4) Disk and filesystem managment
5) managing users and groups
6) Linux networking concepts and applications
7)
Namespacing
-Isolating resources per process/or group of processes)
-ex. Processes, Hard drive, Network, Users, Hostnames, Inter Process Communication
Control Groups (cgroups)
-Limit amount of resources used per process
-Memory, Cpu Usage , HD I/O, Network Bandwith
Komentarze
Prześlij komentarz