Balu Wiki Documentation Release 0.42
Total Page:16
File Type:pdf, Size:1020Kb
BaLu Wiki Documentation Release 0.42 Balle & Lilu Mar 05, 2021 Contents 1 Arch Linux 1 2 Cgroups 3 3 Debian 7 4 Debugging 9 5 Fedora 11 6 Filesystem 13 7 Gnome3 15 8 Grub2 19 9 Inotify 23 10 IPMI 25 11 Kernel 29 12 LVM 33 13 Memory Management 35 14 OpenPandora 37 15 Redhat 41 16 Systemd 47 17 Xorg 55 18 OpenBSD 57 19 MacOS 71 20 Tools 77 i 21 Network 113 22 Security 141 23 Hacking 163 24 Cluster 173 25 Databases 241 26 Virtualization 263 27 Programming 279 28 Misc 349 29 Indices and tables 357 ii CHAPTER 1 Arch Linux 1.1 Install yaourt • Edit /etc/pacman.conf [archlinuxfr] Server= http://repo.archlinux.fr/$arch • Install yaourt pacman -Sy yaourt • Now you can install packages from aur.archlinux.org with yaourt -S <pkg> 1 BaLu Wiki Documentation, Release 0.42 2 Chapter 1. Arch Linux CHAPTER 2 Cgroups 2.1 Overview • Cgroups group processes so that you can define ressource limits and get stats for it • Processes are called tasks • Every process can only be in one cgroup • A cgroup can inherit the properties of another cgroup mkdir /cgroup/ mount -t cgroup -o memory nodev /cgroup/ 2.2 Installation yum install libcgroup 2.3 Create a new cgroup • Temporarily mkdir /cgroup/<groupname> • Or cgcreate -a <user> -g memory,cpu:<groupname> • Permanent by editing /etc/cgconfig.conf 3 BaLu Wiki Documentation, Release 0.42 group <name>{ [<permissions>] <controller>{ <param name>= <param value>; } } • e.g. mount{ cpuset= /cgroup/cpuset; cpu= /cgroup/cpu; cpuacct= /cgroup/cpuacct; memory= /cgroup/memory; devices= /cgroup/devices; freezer= /cgroup/freezer; net_cls= /cgroup/net_cls; blkio= /cgroup/blkio; } group students{ blkio{ blkio.throttle.read_bps_device= "1000"; blkio.throttle.write_bps_device= "1000"; } } • Dont forget to restart the cgconfig service in order to load the changes! service cgconfig restart 2.4 Map user and processes to a cgroup • Edit /etc/cgrules.conf <user> <subsystems> <cgroup> <user>:<command> <subsystems> <cgroup> • names with a prepending @ are groups 2.5 Manually starting a process in a cgroup cgexec -g <subsystems>:<cgroup> <command> <arguments> 2.6 Define limits • For memory memory.limit_in_bytes= 1000000 4 Chapter 2. Cgroups BaLu Wiki Documentation, Release 0.42 • Cpu time (default 1024 is 100% so 100 is ~10%) cpu.shares= 100 • CPU pinning cpuset.cpus=0-5,14,15 • Storage time (100% is value of 1024) blkio.weight= 512 2.6. Define limits 5 BaLu Wiki Documentation, Release 0.42 6 Chapter 2. Cgroups CHAPTER 3 Debian 3.1 Install with sysvinit as init system • On boot screen of install medium type tab and append preseed/late_command="in-target apt-get install -y sysvinit-core" 3.2 How to build a deb package • Unzip archive • cd source • dh_make -e [email protected] -f ../tar-file • choose single binary • Edit debian/control file • define dependency e.g. • libssl0.9.8 (>= 0.9.8~) • Enter description • Edit debian/rules override_dh_auto_configure: dh_auto_configure -- --prefix=/opt/myprogram • Move debian/init.d.ex to debian/myprogram.init and maybe edit it • dpkg-buildpackage -rfakeroot -b 7 BaLu Wiki Documentation, Release 0.42 3.3 Setting up a chroot environment debootstrap unstable /data/debian-tree 8 Chapter 3. Debian CHAPTER 4 Debugging 4.1 Create a core dump file ulimit -c unlimited 4.2 Read core dump file gdb /path/to/application /path/to/corefile 9 BaLu Wiki Documentation, Release 0.42 10 Chapter 4. Debugging CHAPTER 5 Fedora 5.1 Restart network systemctl restart NetworkManager.service 5.2 Allow SELinux exception • Click on selinux alert in bottom right corner • Click on Troubleshoot • Paste solution as root 5.3 Disable boot logo plymouth-set-default-theme details -R 5.4 Gnome3 settings • Install gnome-tweak-tool • Install gconf-editor 5.5 Change login background • Edit /usr/share/backgrounds/beefy-miracle/default/beefy-miracle.xml 11 BaLu Wiki Documentation, Release 0.42 5.6 Install flash plugin rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch. ,!rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux yum check-update yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl 5.7 Upgrade system • http://fedoraproject.org/wiki/Upgrading_Fedora_using_yum 12 Chapter 5. Fedora CHAPTER 6 Filesystem 6.1 Show used inodes df -i 6.2 Dont reserve 5% space for system mke2fs -m0 6.3 Find out filesystem of unmounted device parted -l /dev/sda 6.4 SSD • Add the following options to fstab noatime,discard 13 BaLu Wiki Documentation, Release 0.42 14 Chapter 6. Filesystem CHAPTER 7 Gnome3 7.1 Configure startup applications • You can eithe use gnome-session-properties • or gnome-tweak-tool 7.2 Install a new theme • Goto www.gnome-look.org • Download a theme • Unzip it to ~/.themes • Install it with gnome-tweak-tool 7.3 Cool themes • http://gnome-look.org/content/show.php/Ambiance+Dark+Blue?content=169553 • http://gnome-look.org/content/show.php/E17gtk?content=163472 • http://gnome-look.org/content/show.php/Cenodark-red?content=165815 • http://gnome-look.org/content/show.php/Just-Dark?content=168025q 15 BaLu Wiki Documentation, Release 0.42 7.4 Automatically place windows • Enable Auto move windows extension • Add new placement rule 7.5 Non blank screensaver • killall gnome-screensaver • yum install xscreensaver • xscreensaver-demo 7.6 Changing keyboard shortcuts • Applications -> System Tools -> System Settings -> Keyboard 7.7 Default shortcuts • Alt+F1 - Switch between overview and desktop view • Alt+F2 - Launch command • Windows key - Goto activity view (enter first keys of what to execute / search) 7.8 Reload Gnome config • Alt+F2 r 7.9 Disable automount gsettings set org.gnome.desktop.media-handling automount false gsettings set org.gnome.desktop.media-handling automount-open false systemctl restart gdm.service 7.10 Install extensions • Goto extensions.gnome.org • Click on an extensions • Use the on/off button to install/deinstall extension 16 Chapter 7. Gnome3 BaLu Wiki Documentation, Release 0.42 7.11 Pidgin integration • Install https://extensions.gnome.org/extension/170/pidgin-peristent-notification/ • Or install https://extensions.gnome.org/extension/258/notifications-alert-on-user-menu/ 7.12 System monitor in top panel • Install https://extensions.gnome.org/extension/120/system-monitor/ 7.13 Declaring the primary monitor • Goto settings -> monitor • Use drag and drop to move the monitors around, the first is the primary 7.14 Configure desktop to be on all monitors • gnome-tweak-tool -> desktops 7.15 Remove window decorations • Assuming you use Adwaita as theme • Edit /usr/share/themes/Adwaita/metacity-1/metacity-theme-1.xml • Search for frame_geometry name=”normal” • Add has_title=”false” • Reload Gnome config 7.16 Alternative menu • To access the alternative menu hold the Alt key • This will for example allow you to hibernate instead of shutdown in the user menu 7.17 Switching back to old GNOME look and feel • Either set “Use Fallback Mode” in System Settings -> Details -> Graphics • Or install Mate http://mate-desktop.org/ 7.11. Pidgin integration 17 BaLu Wiki Documentation, Release 0.42 18 Chapter 7. Gnome3 CHAPTER 8 Grub2 8.1 Overview • Setting can be found in /etc/default/grub • Menu entries are located in /etc/grub.d/ as shell scripts (ordered by their number) • Do not directly edit /boot/grub/grub.cfg that the main config but its created from the above • To generate a basic config run grub-mkconfig -o /boot/grub/grub.cfg • To install grub into MBR grub-install /dev/sda 8.2 Global Kernel parameter • Edit /etc/default/grub parameter GRUB_CMDLINE_LINUX 8.3 Create a new Linux entry • Create a new script in /etc/grub.d e.g. 11_mylinux or edit 40_custom #!/bin/sh set -e menuentry "My Linux"{ set root=(hd0,1) (continues on next page) 19 BaLu Wiki Documentation, Release 0.42 (continued from previous page) linux /vmlinuz(add other options here as required) initrd /initrd.img( if the other kernel uses/needs one) } • Dont forget to make it executable! 8.4 Boot encrypted root with ramdisk menuentry "My Linux"{ set root=(hd0,1) linux /vmlinuz root=/dev/mapper/root cryptdevice=/dev/sda4:root initrd /initrd.img } 8.5 Boot encrypted root without ramdisk (untested) menuentry "My Linux"{ insmod gzio insmod part_gpt insmod cryptodisk insmod luks insmod gcry_twofish insmod gcry_sha256 cryptomount -u <uuid> insmod lvm insmod ext2 set root='lvm/vg-root' linux /vmlinuz root=/dev/mapper/vg-root } 8.6 Boot Windows • Create a new script in /etc/grub.d e.g. 99_windows #!/bin/sh menuentry "Windows XP"{ set root="(hd0,3)" chainloader +1 } 8.7 Boot only signed kernel and ramdisk • Generate gpg keypair 20 Chapter 8. Grub2 BaLu Wiki Documentation, Release 0.42 • Sign kernel gpg --detach-sign vmlinuz • Edit Grub config trust boot.key set check_signatures=enforce 8.8 Booting a rescue cd image menuentry "SYSRESCUECD"{ set iso=/systemrescuecd-x86-3.8.1.iso loopback loop ${iso} linux(loop)/isolinux/rescue64 nomodeset vga=791 docache setkmap=fr isoloop= ${iso} initrd(loop)/isolinux/initram.igz } 8.9 Convert grub1 menu.lst to grub2 config grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg 8.8. Booting a rescue cd image 21 BaLu Wiki Documentation, Release 0.42 22 Chapter 8. Grub2 CHAPTER 9 Inotify • React on file change events • Install incron • incrontab -e <directory> <file change mask> <command or action> options /var/www/html IN_CREATE /root/scripts/backup.sh /sales IN_DELETE /root/scripts/sync.sh /var/named/chroot/var/master IN_CREATE,IN_ATTRIB,IN_MODIFY /sbin/rndc reload /tmp IN_ALL_EVENTS logger"file $@ changed" 9.1 Recursive inotify • https://github.com/splitbrain/Watcher • http://www.splitbrain.org/blog/2011-01/07-watcher_a_recursive_incron_alternative [DEFAULT] logfile=/var/log/watcher.log pidfile=/var/run/watcher.pid [data] watch=/data events=create,delete,modify recursive=true autoadd=true command=rsync -a --delete $filename /media/backup 23 BaLu Wiki Documentation, Release 0.42 24 Chapter 9.