http://enos.itcollege.ee/~edmund/osadmin/eng/labs/ codeshare.io/c11 OSadmin labs ------------ ISOs can be downloaded: http://upload.itcollege.ee/edmund/iso/Ubuntu/ OVA files (preinstalled VMs): http://upload.itcollege.ee/edmund/ova/ when importing, please reinitialize MAC-address server install: http://enos.itcollege.ee/~edmund/osadmin/est/praktikumid/OSadmin-ubuntu-server-install.pdf desktop install: http://enos.itcollege.ee/~edmund/osadmin/est/praktikumid/OSadmin-ubuntu-server-install.pdf download at CLI: wget (or curl) wget http://upload.itcollege.ee/edmund/iso/Ubuntu/ubuntu-16.04.1-server-amd64.iso please check also checksums! http://upload.itcollege.ee/edmund/iso/ISO-checking.html ubuntu-16.04.1-server-amd64.iso ubuntu-mate-16.04.1-desktop-amd64.iso + appropriate checksums /home/edmund/VirtualBox VMs /shared/linux/edmund/VirtualBox VMs bind mount http://unix.stackexchange.com/questions/198590/what-is-a-bind-mount https://en.wikipedia.org/wiki/Binary_prefix https://www.virtualbox.org/wiki/Documentation -> End-user documentation https://www.virtualbox.org/manual/UserManual.html virtual networking https://www.virtualbox.org/manual/ch06.html Ubuntu https://help.ubuntu.com/community/BootOptions http://www.memtest.org/ hostname: server user/psw: student partition table type: MBR (dos) - 4 primary partitions /dev/sda1..4 - primary partitions OR 3 primary + 1 extended with 1...128 logical volumes /dev/sda1..3 primary /dev/sda4 - extended /dev/sda5... logical volume GPT - up to 128 partitions (all primary) https://en.wikipedia.org/wiki/GUID_Partition_Table https://en.wikipedia.org/wiki/Names_of_large_numbers https://en.wikipedia.org/wiki/Kernel_(operating_system) https://www.kernel.org/ # # # CTRL+L to clean quickly the CLI scroll the CLI: SHIFT+PgUp/PgDn Software updates sudo -i (become root) CRON - like scheduled tasks in Windows switching GUI-CLI: CTRL+ALT+F1...F6 back: ALT+F7 in VM: ALT+arrow keys update packages database: sudo apt-get update https://wiki.ubuntu.com/DevelopmentCodeNames full upgrade all packages apt-get dist-upgrade clean the APT cache (/var/cache/apt/archives/) sudo apt-get clean check running kernel: uname -r apt is a wrapper of apt-get but some parameters may be different - check the man-pages for more details after upgrade we have a new version of kernel we need to update GRUB to announce of new kernel sudo update-grub then reboot and ensure that new kernel is in use uname -r then remove old kernel(s) options: * apt-get autoremove * apt list --installed | grep linux-image * apt list --installed | grep linux-header http://askubuntu.com/questions/17823/how-to-list-all-installed-packages http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/ some searchers: list installed package ubuntu # # # query DHCP address: sudo dhclient enp0s8 release: sudo dhclient -r enp0s8 using key file to log into SSH server: http://enos.itcollege.ee/~edmund/materials/ssh.txt we need OpenSSH server to be installed on server at first: http://www.ewhathow.com/2013/09/how-to-check-if-ssh-is-running-on-linux/ find out whether you have ssh server installed service --status-all | grep ssh ps aux | grep ssh netstat -plant | grep :22 sudo apt update #update database sudo apt install ssh openssh-blacklist* #install the packages sudo apt clean #clean the APT cache search packages online: http://packages.ubuntu.com/ check codename CLI: lsb_release -c # # # Please log in at (virtual lab system) https://i-tee.itcollege.ee/ labs are avaliable at http://upload.itcollege.ee/edmund/ova/ as .ova files as well (please see ubuntu folder) for rdesktop you can define keyboard: rdesktop -u -p -N -k et -a16 i-tee.itcollege.ee: update system: sudo apt update sudo apt full-upgrade sudo apt clean in case of new kernel: sudo update-grub sudo reboot https://guacamole.incubator.apache.org/doc/gug/using-guacamole.html challenge: find out a way to copy-paste text directly into VM (virtual machine) if needed, SSH server configuration file is here: /etc/ssh/sshd_config after changing SSH server configuration, restart its service: sudo service ssh restart Setting up SSH key-based authentication - http://enos.itcollege.ee/~edmund/materials/ssh.txt # # # name resolving 1st step - hosts file https://en.wikipedia.org/wiki/Hosts_(file) /etc/hosts #server IP-alias 172.16.10.1 s1 ~/.bash_aliases # server shell alias alias s1='ssh student@s1' run session scripts: . ~/.bash_aliases source ~/.bash_aliases firewall https://help.ubuntu.com/community/UFW SSH port: cat /etc/services | grep ssh change owner: chown user:group file changing interface names http://enos.itcollege.ee/~edmund/osadmin/materials/net/70-persistent-net.rules # # # Quick Access to labs -------------------- desktop rdesktop -u -p -N -k et -a16 i-tee.itcollege.ee:9008 server rdesktop -u -p -N -k et -a16 i-tee.itcollege.ee:9009 user apps ~/.local/share/applications/ (has highest priority) system-wide /usr/share/applications/ system-wide icons: /usr/share/icons/ /usr/share/pixmaps/ create a text file ~/.local/share/applications/labs.desktop: [Desktop Entry] Name=OSadmin virtual lab GenericName=OSadmin virtual lab Comment=OSadmin virtual lab Exec=sh /full/path/connect-vlab.sh Terminal=false Type=Application Icon=mathomatic Categories=Network; StartupNotify=false make ~/.local/share/applications/labs.desktop executable: chmod +x ~/.local/share/applications/labs.desktop more information: man chmod http://permissions-calculator.org/ Making shortcut to desktop: start dragging the icon (*.desktop file) then hold down ALT-key choose "create shortcut" release the mouse left key # # # https://wiki.ubuntu.com/Releases search: new in kernel 4.10.11 http://www.phoronix.com/scan.php?page=news_item&px=Linux-4.10-Features-So-Far https://kernelnewbies.org/Linux_4.10 check architecture, CPU: arch lscpu lowlatency ~real time kernel e.g. jack audio server (http://www.jackaudio.org/), CNC milling machine (http://linuxcnc.org/) etc more about audio servers https://en.wikipedia.org/wiki/Sound_server some aliases: http://enos.itcollege.ee/~edmund/materials/bash/bash_aliases_root.txt install new kernel - download and update http://enos.itcollege.ee/~edmund/osadmin/eng/labs/kernel.sh - copy it to server: CLI: scp -i ~/.ssh/keyfile kernel.sh user@host:/home/student/ GUI: use Ubuntu file manager to connect over SSH and copy the file - create bash alias to run kernel.sh periodically in future weather in CLI - see the file http://enos.itcollege.ee/~edmund/osadmin/eng/labs/weather-in-terminal.txt - when needed, install curl - weather in: -- Tallinn Airport: curl wttr.in/tll -- Tallinn: curl wttr.in/tallinn - help: curl wttr.in/:help - create an alias: -- alias wtr='curl wttr.in/tallinn' screensaver CLI Matrix - install package cmatrix - run in different modes -- cmatrix -b -- cmatrix -s -b Some more Termsaver sudo apt-get install termsave termsaver matrix man termsaver Pipes - seems to not work (can you fix it?) https://github.com/pipeseroni/pipes.sh Aquarium requires modified version of Perl https://www.ghacks.net/2011/03/02/have-some-linux-ascii-fun-with-asciiquarium/ Some more fun programs: sl, fortune, lolcat, cowsay, boxes, figlet see http://enos.itcollege.ee/~edmund/osadmin/eng/labs/fun.sh see http://enos.itcollege.ee/~edmund/osadmin/eng/labs/environment-variables.txt create new env variable for user using existing variables # # # Disk management DOS (MBR) 4 pri OR 3 pri + 1 ext with up to 128 logical volumes GPT /dev/sdb /dev/sdc /dev/sdd /dev/sde pwd /root mkdir -p /var/research/"research department" mkdir -p /var/research/windows /var/research/linux /var/research/mac chmod 070 /var/research/windows /var/research/linux /var/research/mac addgroup clippy && addgroup tux && addgroup apple chown :clippy /var/research/windows && chown :apple /var/research/mac && chown :tux /var/research/linux chgrp clippy /var/research/windows adduser --ingroup clippy win adduser --ingroup tux lin adduser --ingroup apple mac modify later: usermod -g clippy win partitions: /dev/sdb1 -> win /dev/sdc1 -> lin /dev/sdd1 -> mac /dev/sde1 -> swap fdisk, cfdisk, parted cfdisk /dev/sdb mkfs https://help.ubuntu.com/community/hfsplus apt update && apt install hfsprogs make filesystems mkfs.ntfs /dev/sdb1 mkfs -t ntfs mounting ntfs-3g /dev/sdb1 /var/research/windows mount -t ext4 /dev/sdc1 /var/research/linux mount -t hfsplus /dev/sdd1 /var/research/mac /etc/fstab fsck getent group clippy: 1001 getent group tux: 1002 getent group apple: 1003 # Change groups, permissions also AFTER mounting file systems chgrp clippy /var/research/windows chgrp tux /var/research/linux chgrp apple /var/research/mac chmod 070 /var/research/windows /var/research/linux /var/research/mac nano /etc/fstab ...... UUID=hash /var/research/windows ntfs-3g gid=1001,umask=0707 0 0 UUID=hash /var/research/linux ext4 defaults 0 0 UUID=hash /var/research/mac hfsplus gid=1003,umask=0707 0 0 UUID=hash none swap sw 0 0 replace hash with proper value shown using blkid mount and check the fstab syntax mount -a SWAP ---- make swap: mkswap /dev/sde1 mount swap: swapon /dev/sde1 add proper line to /etc/fstab turn on all swap spaces: swapon -a Change umask per user ~/.profile umask=007 Swappiness https://askubuntu.com/questions/103915/how-do-i-configure-swappiness https://en.wikipedia.org/wiki/Swappiness current value cat /proc/sys/vm/swappiness sysctl vm.swappiness change sysctl vm.swappiness=10 check: sysctl vm.swappiness # # # monitor certain log file, e.g. sudo -i tail -f /var/log/auth.log ### combine multiple commands: command1 `command2` command1 $(command2) # # # For SSD disks please use fstrim by default it is located at /etc/cron.weekly/ folder you can move it to the /etc/cron.daily/ or even /etc/cron.hourly/ folder depending on your activities TBW - terabytes to write some shopping: https://hakshop.com/ https://www.defcon.org/ https://www.yubico.com/products/yubikey-hardware/