Second Edition
Essential Skills for Linux Users and System and Network Administrators
Constant widthConstant width boldConstant width italic
$ echo "fa95fb748b34d470a7cfa5e3c1c8fa1163e2dc340cd5a60f7ece9dc963ecdf88 \ *ubuntu-21.04-desktop-amd64.iso" | shasum -a 256 --check ubuntu-21.04-desktop-amd64.iso: OK
$ ls -C1 /media/duchess/'Ubuntu 21.04.1 amd64'/ boot casper dists EFI install isolinux md5sum.txt pics pool preseed README.diskdefines ubuntu
$ ls -C1 /media/duchess/Fedora-WS-Live-34-1-6/ EFI images isolinux LiveOS
$ ls -l /dev | grep cdr lrwxrwxrwx 1 root root 3 Mar 7 12:38 cdrom -> sr0 lrwxrwxrwx 1 root root 3 Mar 7 12:38 cdrw -> sr0 crw-rw----+ 1 root cdrom 21, 2 Mar 7 08:34 sg2 brw-rw----+ 1 root cdrom 11, 0 Mar 7 12:57 sr0
$ wodim dev=/dev/cdrom -v ubuntu-21.04-desktop-amd64.iso
$ lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT NAME FSTYPE LABEL MOUNTPOINT sda ├─sda1 vfat /boot/efi ├─sda2 xfs osuse15-2 /boot ├─sda3 xfs / ├─sda4 xfs /home └─sda5 swap [SWAP] sdb └─sdb1 xfs 32gbusb sr0
$ sudo dd status=progress if=ubuntu-20.04.1-LTS-desktop-amd64.iso of=/dev/sdb 211509760 bytes (212 MB, 202 MiB) copied, 63 s, 3.4 MB/s
2782257664 bytes (2.8 GB, 2.6 GiB) copied, 484 s, 5.7 MB/s 5439488+0 records in 5439488+0 records out 2785017856 bytes (2.8 GB, 2.6 GiB) copied, 484.144 s, 5.8 MB/s
| Partition name | Filesystem type | Mountpoint |
|---|---|---|
$ sudo cat /sys/firmware/acpi/tables/MSDM MSDMU DELL CBX3 AMI FAKEP-RODUC-TKEY1-22222-33333
C:\Users\Duchess> wmic path softwarelicensingservice get OA3xOriginalProductKey OA3xOriginalProductKey FAKEP-RODUC-TKEY1-22222-33333
$ mkdir loopiso
$ sudo mount -o loop Fedora-Workstation-Live-x86_64-34-1.2.iso loopiso mount: /home/duchess/loopiso: WARNING: device write-protected, mounted read-only
$ sudo umount loopiso
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
$ sudo update-grub
GRUB_TIMEOUT="10" GRUB_TIMEOUT_STYLE=menu
$ sudo ls -C1 /etc/grub.d/ 00_header 01_users 08_fallback_counting 10_linux 10_reset_boot_success 12_menu_auto_hide 20_linux_xen 20_ppc_terminfo 30_os-prober 30_uefi-firmware 40_custom 41_custom backup README
$ sudo chmod -x 20_linux_xen
$ sudo chmod +x 20_linux_xen
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' # afterwards to update /boot/grub2/grub.cfg. GRUB_DEFAULT=0 GRUB_TIMEOUT=10 GRUB_TIMEOUT_STYLE=menu
GRUB_DEFAULT=menuentry 'openSUSE Leap 15.2' --class opensuse --class gnu-linux
--class gnu --class os
menuentry_id_option 'gnulinux-simple-102a6fce-8985-4896-a5f9-e5980cb21fdb' {
load_video
set gfxpayload=keep
insmod gzio
[...]
$ sudo awk -F\' '/menuentry / {print i++,$2}' /boot/grub/grub.cfg
0 Ubuntu
1 Ubuntu, with Linux 5.8.0-53-generic
2 Ubuntu, with Linux 5.8.0-53-generic (recovery mode)
3 Ubuntu, with Linux 5.8.0-50-generic
4 Ubuntu, with Linux 5.8.0-50-generic (recovery mode)
5 UEFI Firmware Settings
GRUB_TIMEOUT=10GRUB_DEFAULT=savedGRUB_CMDLINE_LINUX=GRUB_CMDLINE_LINUX_DEFAULT=GRUB_TERMINAL=gfxtermGRUB_GFXMODE=
GRUB_BACKGROUND=GRUB_THEME=GRUB_BACKGROUND="/boot/grub/duchess-books.jpg"
grub> menu_color_highlight=cyan/blue grub> menu_color_normal=yellow/black
#!/bin/sh
if [ "x${GRUB_BACKGROUND}" != "x" ] ; then
if [ "x${GRUB_COLOR_NORMAL}" != "x" ] ; then
echo "set color_normal=${GRUB_COLOR_NORMAL}"
fi
if [ "x${GRUB_COLOR_HIGHLIGHT}" != "x" ] ; then
echo "set color_highlight=${GRUB_COLOR_HIGHLIGHT}"
fi
fi
$ sudo chown +x 07_font_colors
export GRUB_COLOR_NORMAL="yellow/black" export GRUB_COLOR_HIGHLIGHT="cyan/blue"
| Color options | |||
|---|---|---|---|
| black | dark-gray | light-green | magenta |
| blue | green | light-gray | red |
| brown | light-cyan | light-magenta | white |
| cyan | light-blue | light-red | yellow |
$ apt search theme | grep grub
GRUB_THEME=/boot/grub/themes/ubuntu-mate/theme.txt
grub> set pager=1
grub> ls (hd,0) (hd0,gpt5) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,msdos1)
grub> ls (hd0,3) Partition hd0,3: filesystem type ext* - Last modification time 2021-12-29 01:17:58 Tuesday, UUID 5c44d8b2-e34a-4464-8fa8-222363cd1aff - Partition start at 526336KiB - Total size 20444160KiB
grub> ls (hd0,2)/ bin dev home lib64 media opt root sbin sys usr boot etc lib lost+found mnt proc run srv tmp var
grub> ls (hd0,2)/boot efi/ grub/ System.map-5.3.18-lp152.57-default config-5.3.18-lp152.57-default initrd-5.3.18-lp152.57-default vmlinuz vmlinuz-5.3.18-lp152.57-default sysctl.conf-5.3.18-lp152.57-default vmlinux-5.3.18-lp152.57-default.gz
grub> set root=(hd0,2) grub> linux /boot/vmlinuz-5.3.18-lp152.57-default root=/dev/sda2 grub> initrd /boot/initrd-5.3.18-lp152.57-default grub> boot
grub rescue> ls (hd0) (hd0,gpt5) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1, msdos1)
grub rescue> ls (hd0,3)
Partition hd0,3: filesystem type ext* - Last modification time 2021-12-29
01:17:58
Tuesday, UUID 5c44d8b2-e34a-4464-8fa8-222363cd1aff - Partition start at
526336KiB -
Total size 20444160KiB
grub rescue> ls (hd0,2)/ bin dev home lib64 media opt root sbin sys usr boot etc lib lost+found mnt proc run srv tmp var
grub rescue> ls (hd0,2)/boot efi/ grub/ System.map-5.3.18-lp152.57-default config-5.3.18-lp152.57-default initrd-5.3.18-lp152.57-default vmlinuz vmlinuz-5.3.18-lp152.57-default sysctl.conf-5.3.18-lp152.57-default vmlinux-5.3.18-lp152.57-default.gz
grub rescue> set prefix=(hd0,2)/boot/grub grub rescue> set root=(hd0,2) grub rescue> insmod normal grub rescue> insmod linux
grub> linux /boot/vmlinuz-5.3.18-lp152.57-default root=/dev/sda2 grub> initrd /boot/initrd-5.3.18-lp152.57-default grub> boot
$ sudo grub-mkconfig -o /boot/grub/grub.cfg $ sudo grub-install /dev/sda
$ stat /sbin/shutdown File: /sbin/shutdown -> /bin/systemctl Size: 14 Blocks: 0 IO Block: 4096 symbolic link Device: 802h/2050d Inode: 1177556 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
$ systemctl poweroff
$ systemctl shutdown
$ systemctl reboot
$ systemctl halt
$ shutdown -h now
$ shutdown -h +10 Shutdown scheduled for Sun 2021-05-23 11:04:43 PDT, use 'shutdown -c' to cancel.
Broadcast message from duchess@client4 on pts/4 (Sun 2021-05-24 10:54:43 PDT): The system is going down for poweroff at Sun 2021-05-24 11:04:43 PDT!
$ shutdown -c
Broadcast message from duchess@client4 on pts/4 (Sun 2021-05-24 10:56:00 PDT): The system shutdown has been cancelled
$ shutdown -h +6 "Time to stop working and go outside to play!"
$ shutdown -h 22:15
$ shutdown -r
$ shutdown -H
$ halt $ reboot $ poweroff
$ halt --reboot $ poweroff --reboot
$ systemctl suspend
$ systemctl hibernate
$ systemctl hybrid-sleep
$ systemctl suspend-then-hibernate
# What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
$ sudo systemctl disable ctrl-alt-del.target Removed /etc/systemd/system/ctrl-alt-del.target. $ sudo systemctl mask ctrl-alt-del.target Created symlink /etc/systemd/system/ctrl-alt-del.target → /dev/null.
$ sudo systemctl unmask ctrl-alt-del.target Removed /etc/systemd/system/ctrl-alt-del.target. $ sudo systemctl enable ctrl-alt-del.target Created symlink /etc/systemd/system/ctrl-alt-del.target → /lib/systemd/system/reboot.target.
$ sudo systemctl disable ctrl-alt-del.target Removed /etc/systemd/system/ctrl-alt-del.target. $ sudo ln -s /lib/systemd/system/poweroff.target \ /etc/systemd/system/ctrl-alt-del.target
$ stat /lib/systemd/system/ctrl-alt-del.target File: /lib/systemd/system/ctrl-alt-del.target -> reboot.target Size: 13 Blocks: 0 IO Block: 4096 symbolic link Device: 802h/2050d Inode: 136890 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
$ sudo nano /etc/crontab # m h dom mon dow user command 10 22 * * * root /sbin/shutdown -h +20
# m h dom mon dow user command 00 23 * * 1-5 root /sbin/shutdown -h now
$ sudo crontab -e # m h dom mon dow command 00 23 * * 1-5 /sbin/shutdown -h now
| Field | Allowed values |
|---|---|
# shutdown at 1:05 am Saturdays and Sundays 00 01 * * 7,0 root /sbin/shutdown -h +5
00 01 * * 6,7 root /sbin/shutdown -h +5
@reboot @yearly @annually @monthly @weekly @daily @midnight @hourly
$ cat /sys/power/state freeze mem disk
$ sudo rtcwake -m freeze -s 60
$ sudo rtcwake -n -m disk no -u -t $(date +%s -d "tomorrow 08:00") rtcwake: wakeup from "disk" using /dev/rtc0 at Mon Nov 23 08:00:00 2021
# m h dom mon dow user command 00 23 * * 1-5 root /usr/sbin/rtcwake -m disk -s 28800
$ ip addr show
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> state UP 0
link/ether 9c:ef:d5:fe:8f:20 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.97/24 brd 192.168.1.255 scope global dynamic
[...]
$ sudo ethtool enp0s25 | grep -i wake-on
Supports Wake-on: pumbg
Wake-on: g
$ sudo ethtool -s enp0s25 wol g
$ @reboot root /usr/bin/ethtool -s enp0s25 wol g
$ /usr/bin/wakeonlan 9c:ef:d5:fe:8f:20
$ /usr/bin/wakeonlan -i 192.168.44.255 9c:ef:d5:fe:8f:20
$ iw dev
phy#0
Interface wlxcc3fd5fe014c
ifindex 3
wdev 0x1
addr 9c:bf:25:fe:0e:7c
ssid accesspointe
type managed
channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz
txpower 20.00 dBm
$ iw phy0 wowlan show command failed: Operation not supported (-95)
$ iw phy0 wowlan show WoWLAN is disabled
$ sudo iw phy0 wowlan enable magic-packet WoWLAN is enabled: * wake up on magic packet
$ /usr/bin/wakeonlan 9c:bf:25:fe:0e:7c
$ /usr/bin/wakeonlan -i 192.168.44.255 9c:bf:25:fe:0e:7c
#! /bin/sh ### BEGIN INIT INFO # Provides: sshd # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: OpenBSD Secure Shell server ### END INIT INFO set -e # /etc/init.d/ssh: start and stop the OpenBSD "secure shell(tm)" daemon test -x /usr/sbin/sshd || exit 0 umask 022 if test -f /etc/default/ssh; then [...]
[Unit] Description=OpenBSD Secure Shell server Documentation=man:sshd(8) man:sshd_config(5) After=network.target auditd.service ConditionPathExists=!/etc/ssh/sshd_not_to_be_run [Service] EnvironmentFile=-/etc/default/ssh ExecStartPre=/usr/sbin/sshd -t ExecStart=/usr/sbin/sshd -D $SSHD_OPTS ExecReload=/usr/sbin/sshd -t ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartPreventExitStatus=255 Type=notify RuntimeDirectory=sshd RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target Alias=sshd.service
$ stat /sbin/init File: /sbin/init -> /lib/systemd/systemd [...]
$ stat /sbin/init File: /sbin/init [...]
$ sudo stat /proc/1/exe File: /proc/1/exe -> /lib/systemd/systemd [...]
$ sudo stat /proc/1/exe File: /proc/1/exe -> /sbin/init [...]
$ cat /proc/1/comm systemd
$ cat /proc/1/comm init
$ ps -p 1
PID TTY TIME CMD
1 ? 00:00:00 systemd
$ ps -p 1
PID TTY TIME CMD
1 ? 00:00:00 init
$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 10:06 ? 00:00:01 /sbin/init splash root 2 0 0 10:06 ? 00:00:00 [kthreadd] root 3 2 0 10:06 ? 00:00:00 [rcu_gp] root 4 2 0 10:06 ? 00:00:00 [rcu_par_gp] [...]
$ pstree -p
systemd(1)─┬─ModemManager(925)─┬─{ModemManager}(944)
│ └─{ModemManager}(949)
├─NetworkManager(950)─┬─dhclient(1981)
│ ├─{NetworkManager}(989)
│ └─{NetworkManager}(991)
├─accounts-daemon(927)─┬─{accounts-daemon}(938)
│ └─{accounts-daemon}(948)
├─acpid(934)
├─agetty(1103)
├─avahi-daemon(953)───avahi-daemon(970)
[...]
$ pstree -sp 5193
systemd(1)───kate(5193)─┬─bash(5218)
├─{kate}(5195)
├─{kate}(5196)
├─{kate}(5197)
├─{kate}(5198)
├─{kate}(5199)
[...]
$ ps -eo pid,user,stat,comm
PID USER STAT COMMAND
1 root Ss systemd
2 root S kthreadd
32 root I< kworker/3:0H-kb
68 root SN khugepaged
11222 duchess Rl konsole
$ systemctl
$ systemctl > /tmp/systemctl-units.txt
$ systemctl --all
$ systemctl list-unit-files UNIT FILE STATE proc-sys-fs-binfmt_misc.automount static -.mount generated mount generated dev-hugepages.mount static home.mount generated [...] 322 unit files listed.
$ systemctl list-unit-files --type=service UNIT FILE STATE accounts-daemon.service enabled acpid.service disabled alsa-state.service static alsa-utils.service masked anacron.service enabled [...] 212 unit files listed.
$ systemctl list-unit-files --type=service --state=enabled UNIT FILE STATE accounts-daemon.service enabled anacron.service enabled apparmor.service enabled autovt@.service enabled avahi-daemon.service enabled [...] 62 unit files listed.
$ systemctl list-unit-files --type=service --state=disabled UNIT FILE STATE acpid.service disabled brltty.service disabled console-getty.service disabled mariadb@.service disabled [...] 12 unit files listed.
$ systemctl list-unit-files --type=service --state=static UNIT FILE STATE alsa-restore.service static alsa-state.service static apt-daily-upgrade.service static apt-daily.service static [...] 106 unit files listed.
$ systemctl list-unit-files --type=service --state=masked UNIT FILE STATE alsa-utils.service masked bootlogd.service masked bootlogs.service masked checkfs.service masked [...] 36 unit files listed.
$ systemctl status cups.service
● cups.service - CUPS Scheduler
Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset:
enabled)
Active: active (running) since Sun 2021-11-22 11:01:48 PST; 4h 17min ago
TriggeredBy: ● cups.path
● cups.socket
Docs: man:cupsd(8)
Main PID: 1403 (cupsd)
Tasks: 2 (limit: 18760)
Memory: 3.8M
CGroup: /system.slice/cups.service
├─1403 /usr/sbin/cupsd -l
└─1421 /usr/lib/cups/notifier/dbus dbus://
Nov 22 11:01:48 host1 systemd[1]: Started CUPS Scheduler.
$ systemctl status mariadb.service bluetooth.service lm-sensors.service
$ sudo systemctl start sshd.service
$ sudo systemctl stop sshd.service
$ sudo systemctl restart sshd.service
$ sudo systemctl reload sshd.service
$ sudo systemctl start sshd.service mariadb.service firewalld.service
ExecStart=/usr/sbin/httpd/ $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
$ sudo systemctl enable sshd.service Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service → /usr/lib/systemd/system/sshd.service
$ sudo systemctl enable --now sshd.service
$ sudo systemctl disable sshd.service Removed /etc/systemd/system/multi-user.target.wants/sshd.service $ sudo systemctl stop sshd.service
$ sudo systemctl disable --now sshd.service
$ sudo systemctl reenable mariadb.service Removed /etc/systemd/system/multi-user.target.wants/mariadb.service. Removed /etc/systemd/system/mysqld.service. Removed /etc/systemd/system/mysql.service. Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
$ sudo systemctl mask bluetooth.service Created symlink /etc/systemd/system/bluetooth.service → /dev/null.
$ sudo systemctl unmask bluetooth.service Removed /etc/systemd/system/bluetooth.service. $ sudo systemctl start bluetooth.service
$ sudo systemctl kill mariadb $ systemctl status mariadb ● mariadb.service - MariaDB 10.1.44 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: inactive (dead) since Sun 2020-06-28 19:57:49 PDT; 6s ago [...]
$ sudo systemctl kill -9 mariadb
$ sudo kill 1234
$ sudo kill -9 1234
$ top top - 20:30:13 up 4:24, 6 users, load average: 0.00, 0.03, 0.06 Tasks: 246 total, 1 running, 170 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.4 us, 0.2 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 16071016 total, 7295284 free, 1911276 used, 6864456 buff/cache KiB Swap: 8928604 total, 8928604 free, 0 used. 13505600 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3504 madmax 20 0 99.844g 177588 88712 S 2.6 1.1 0:08.68 evolution 2081 madmax 20 0 3818636 517756 177744 S 0.7 3.2 5:07.56 firefox 1064 root 20 0 567244 148432 125572 S 0.3 0.9 12:54.75 Xorg 2362 stash 20 0 2997732 230508 145444 S 0.3 1.4 0:40.72 Web Content [...]
$ sudo kill -1 1234
$ systemctl is-system-running running
$ systemctl get-default graphical.target
$ runlevel N 5
$ sudo systemctl rescue
$ sudo systemctl emergency
$ sudo systemctl reboot
$ sudo systemctl isolate multi-user.target
$ sudo systemctl set-default multi-user.target
$ ls -l /lib/systemd/system/runlevel*
$ systemctl list-dependencies graphical.target
$ systemd-analyze blame
34.590s apt-daily.service
6.782s NetworkManager-wait-online.service
6.181s dev-sda2.device
4.444s systemd-journal-flush.service
3.609s udisks2.service
2.450s snapd.service
[...]
$ systemd-analyze blame --user
3.991s pulseaudio.service
553ms at-spi-dbus-bus.service
380ms evolution-calendar-factory.service
331ms evolution-addressbook-factory.service
280ms xfce4-notifyd.service
[...]
duchess@pc:~$ id uid=1000(duchess) gid=1000(duchess) groups=1000(duchess),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin), 126(sambashare),131(libvirt)
duchess@pc:~$ id madmax uid=1001(madmax) gid=1001(madmax) groups=1001(madmax),1010(composers)
duchess@client4:~$ sudo id -un root duchess@client4:~$ sudo -u madmax id -gn madmax
$ ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 68208 May 27 2020 /usr/bin/passwd
$ ps -a|grep passwd 12916 pts/1 00:00:00 passwd $ ps -eo pid,euser,ruser,rgroup | grep 12916 12916 root root root
$ sudo useradd test1
$ id test1 uid=1011(test1) gid=1011(test1) groups=1011(test1) $ sudo ls -a /home/test1/ . .. .bash_logout .bash_profile .bashrc
$ sudo passwd test1 Changing password for user test1. New password: password Retype new password: password passwd: all authentication tokens updated successfully.
$ sudo passwd -e test1 Expiring password for user test1. passwd: Success
test1:x:1011:1011::/home/test1:/bin/bash
$ sudo useradd -mU test2
$ sudo useradd -G group1,group2,group3 test1
$ useradd -G group1,group2,group3 -c 'Test 1,,,,' test1
$ sudo useradd -rs /bin/false service1
$ useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel CREATE_MAIL_SPOOL=yes
$ less /etc/xdg/user-dirs.defaults # Default settings for user directories # # The values are relative pathnames from the home directory and # will be translated on a per-path-element basis into the users locale DESKTOP=Desktop DOWNLOAD=Downloads TEMPLATES=Templates PUBLICSHARE=Public DOCUMENTS=Documents MUSIC=Music PICTURES=Pictures VIDEOS=Videos # Another alternative is: #MUSIC=Documents/Music #PICTURES=Documents/Pictures #VIDEOS=Documents/Videos
XDG_DESKTOP_DIR="$HOME/table" XDG_DOWNLOAD_DIR="$HOME/landing-zone" XDG_DOCUMENTS_DIR="$HOME/omg-paperwork" XDG_MUSIC_DIR="$HOME/singendance" XDG_PICTURES_DIR="$HOME/piccies"
duchess@pc:~$ xdg-user-dirs-update --set DOWNLOAD $HOME/landing-zone duchess@pc:~$ xdg-user-dirs-update --set DESKTOP $HOME/table duchess@pc:~$ xdg-user-dirs-update --set DOCUMENTS $HOME/omg-paperwork duchess@pc:~$ xdg-user-dirs-update --set MUSIC $HOME/singendance duchess@pc:~$ xdg-user-dirs-update --set PICTURES $HOME/piccies
$ xdg-user-dirs-update --force
DESKTOP DOWNLOAD TEMPLATES PUBLICSHARE DOCUMENTS MUSIC PICTURES VIDEOS
duchess@pc:~$ ln -s /users/stuff/duchess /home/duchess/singendance
$ sudo groupadd musicians
$ sudo groupadd -r service1
# Min/max values for automatic uid selection in useradd(8) # UID_MIN 1000 UID_MAX 60000 # System accounts SYS_UID_MIN 201 SYS_UID_MAX 999 # Extra per user uids SUB_UID_MIN 100000 SUB_UID_MAX 600100000 SUB_UID_COUNT 65536 # # Min/max values for automatic gid selection in groupadd(8) # GID_MIN 1000 GID_MAX 60000 # System accounts SYS_GID_MIN 201 SYS_GID_MAX 999 # Extra per user group ids SUB_GID_MIN 100000 SUB_GID_MAX 600100000 SUB_GID_COUNT 65536
$ sudo usermod -aG musicians duchess
$ sudo usermod -aG musicians,composers,stagehands duchess
musicians:x:900:stash,madmax,duchess
$ sudo adduser stash
Adding user 'stash' ...
Adding new group 'stash' (1009) ...
Adding new user 'stash' (1009) with group 'stash' ...
Creating home directory '/home/stash' ...
Copying files from '/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for stash
Enter the new value, or press ENTER for the default
Full Name []: Stash Cat
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
stash:x:1009:1009:Stash Cat,,,:/home/stash:/bin/bash
FIRST_SYSTEM_UID=100 LAST_SYSTEM_UID=999 FIRST_SYSTEM_GID=100 LAST_SYSTEM_GID=999 FIRST_UID=1000 LAST_UID=59999 FIRST_GID=1000 LAST_GID=59999--
$ stat /usr/sbin/adduser File: /usr/sbin/adduser -> useradd Size: 7 Blocks: 0 IO Block: 4096 symbolic link [...]
$ sudo adduser --system --no-create-home --group service Adding system user 'service1' (UID 124) ... Adding new group 'service1' (GID 135) ... Adding new user 'service1' (UID 124) with group 'service1' ... Not creating home directory '/home/service1'.
service1:x:124:135::/home/service1:/usr/sbin/nologin
$ sudo addgroup composers Adding group 'composers' (GID 1010) ... Done.
composers:x:1010:
$ sudo addgroup --system service1 Adding group 'service1' (GID 136) ... Done.
$ sudo pwck user 'news': directory '/var/spool/news' does not exist user 'uucp': directory '/var/spool/uucp' does not exist user 'www-data': directory '/var/www' does not exist user 'list': directory '/var/list' does not exist $ sudo grpck group mail has an entry in /etc/gshadow, but its password field in /etc/group is not set to 'x' grpck: no changes
$ sudo pwck -q $ sudo grpck -q group mail has an entry in /etc/gshadow, but its password field in /etc/group is not set to 'x'
$ sudo pwck -q invalid password file entry delete line 'fakeservice:x:996:996::/home/fakeservice'? n delete line 'fakeservice:!:18469::::::'? n pwck: no changes
user 'www-data': directory '/var/www' does not exist
$ sudo passwd -l stash passwd: password expiry information changed.
$ sudo passwd -u stash passwd: password expiry information changed.
$ sudo usermod --expiredate 1 stash
$ sudo usermod --expiredate -1 stash
stash:*:1009:1009:Stash Cat,,,:/home/stash:/bin/bash
$ sudo userdel stash
$ sudo userdel -r stash
$ sudo deluser stash Removing user 'stash' ... Warning: group 'stash' has no more members. Done.
$ sudo deluser --remove-all-files --backup stash
$ sudo deluser --remove-all-files --backup-to /user-backups stash
$ sudo delgroup musicians
$ sudo delgroup --only-if-empty musicians
$ sudo find / -uid 1007
$ sudo find /etc -uid 1007 $ sudo find /home -uid 1007 $ sudo find /var -uid 1007
$ sudo find / -gid 1007 $ sudo find / -name duchess $ sudo find / -group duchess
$ sudo find /backups -uid 1007 -exec chown -v 1010 {} \;
changed ownership of '/backups/duchess/' from 1007 to 1010
changed ownership of '/backups/duchess/bin' from 1007 to 1010
changed ownership of '/backups/duchess/logs' from 1007 to 1010
$ sudo find / -uid 1007 -exec cp -v {} /orphans \;
$ sudo find / -uid 1007 -exec cp -rv {} /orphans \;
$ sudo find / -uid 1007 -exec rm -v {} \;
$ sudo find / -uid 1007 -exec rm -rv {} \;
$ sudo find / -uid 1007 -exec mv {} /orphans \;
$ find / -nouser $ find / -nogroup
duchess@pc:~$ su -l Password: root@pc:~#
root@pc:~# exit logout duchess@pc:~$
duchess@pc:~$ su Password: root@pc:/home/duchess~#
duchess@pc:~$ sudo visudo [sudo] password for duchess: [...] ##Allow root to run any commands root ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL) ALL [...]
stash server1 = /bin/rpm, /usr/bin/yum, /usr/bin/dnf
Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/yum, /usr/bin/dnf Cmnd_Alias SYSTEMD = /usr/bin/systemctl start, /usr/bin/systemctl stop, /usr/bin/systemctl reload, /usr/bin/systemctl restart, /usr/bin/systemctl status, /usr/bin/systemctl enable, /usr/bin/systemctl disable, /usr/bin/systemctl mask, /usr/bin/systemctl unmask
stash server1 = SOFTWARE, SYSTEMD
User_Alias JRADMIN = stash, madmax JRADMIN server1 = SOFTWARE, SYSTEMD
Host_Alias SERVERS = server1, server2, server3
JRADMIN SERVERS = SOFTWARE, SYSTEMD
$ sudo awk 'BEGIN {system("/bin/bash")}'
root@client4:/home/duchess#
$ sudo less /etc/systctl.conf # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. /etc/sysctl.conf
duchess@client4:~$ sudo less /etc/systctl.conf # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. !'sh' duchess@client4:~$ sudo less /etc/sysctl.conf # whoami root
$ sudo visudo
$ Defaults timestamp_timeout=60
$ cd /etc/sudoers.d/ $ sudo visudo -f stash
$ sudo ls /etc/sudoers.d/ README stash
duchess@pc:~$ sudo su -l [sudo] password for duchess: root@pc:~#
$ sudo visudo [sudo] password for root:
duchess@pc:~$ sudo visudo # Defaults targetpw # ALL ALL=(ALL) ALL
$ stat --format=%a:%A:%U:%G /etc 755:drwxr-xr-x:root:root
$ mkdir -v presentations mkdir: created directory 'presentations'
$ mkdir -p presentations/2020/august mkdir: created directory 'presentations/2020' mkdir: created directory 'presentations/2020/august'
$ sudo mkdir -v /charts mkdir: created directory '/charts'
$ mkdir -m 0700 /home/duchess/dog-memes
$ touch newfile.txt
$ tree -L 1 / / ├── backups ├── bin ├── boot [...]
$ touch newfile.txt
$ touch file{00..99}
$ touch test{00..99}.doc
$ ls
test00.doc
test01.doc
test02.doc
[...]
$ touch {00..99}test.doc
$ ls
00test.doc
01test.doc
02test.doc
[...]
$ yes This is a test file | head -c 500 MB > testfile.txt
$ for x in {01..100};
> do yes This is a test file | head -c 1MB > $x-testfile.txt;
> done
001-testfile.txt 002-testfile.txt 003-testfile.txt [...]
$ touch {0..150}test.doc
$ ls -C1
0test.doc
100test.doc
101test.doc
102test.doc
103test.doc
104test.doc
105test.doc
106test.doc
107test.doc
108test.doc
109test.doc
10test.doc
110test.doc
111test.doc
112test.doc
113test.doc
114test.doc
115test.doc
116test.doc
117test.doc
118test.doc
119test.doc
11test.doc
120test.doc
121test.doc
[...]
madmax@client2:~$ ls --group-directories-first Audiobooks bin Desktop Documents Downloads games Music Pictures Public Templates Videos
$ cd /home/madmax/Audiobooks
$ cd Audiobooks
$ pwd /home/madmax
$ rm -v aria.ogg removed 'aria.ogg'
$ rm -iv intermezzo.wav rm: remove regular file 'intermezzo.wav'? y removed 'intermezzo.wav'
$ rm -rvi rehearsals rm: descend into directory 'rehearsals'? y rm: remove regular file 'rehearsals/brass-section'? y [...]
$ rm -rv rehearsals/2020/jan
$ rm -rv rehearsals
$ rm -v *.txt
$ rm -v aria*
$ cp -v aria.ogg solo.flac ~/songs2/ 'aria.ogg' -> '/home/duchess/songs2/aria.ogg' 'solo.flac' -> '/home/duchess/songs2/solo.flac'
$ cp -rv ~/music/songs2 /shared/archives
$ cp -rv --parents duchess/music/songs2/ shows/ duchess -> shows/duchess duchess/music -> shows/duchess/music 'duchess/music/songs2' -> 'shows/duchess/music/songs2' 'duchess/music/songs2/intro.flac' -> 'shows/duchess/music/songs2/intro.flac' 'duchess/music/songs2/reprise.flac' -> 'shows/duchess/music/songs2/reprise.flac' 'duchess/music/songs2/solo.flac' -> 'shows/duchess/music/songs2/solo.flac'
$ mv -v aria.ogg solo.flac ~/songs2/ renamed 'aria.ogg' -> '/home/duchess/songs2/aria.ogg' renamed 'solo.flac' -> '/home/duchess/songs2/solo.flac'
$ mv -v ~/songs2/ ~/music/
$ chmod -v 0600 file.txt mode of 'file.txt' changed from 0644 (rw-r--r--) to 0600 (rw-------)
$ chmod 0666 file.txt
$ chmod -v 0644 file.txt mode of 'file.txt' changed from 0666 (rw-rw-rw-) to 0644 (rw-r--r--)
$ chmod 0660 file.txt
$ chmod 0750 backup.sh
| Mode | Owner | Group | Other |
|---|---|---|---|
| Permission | Description |
|---|---|
$ sudo mkdir /shared
$ chmod 0755 /shared
$ chmod -R 0755 /shared
$ chmod 0700 /shared
$ chmod 0770 /shared
$ chmod -v 1770 /home/duchess/shared mode of '/home/duchess/shared changed from 0770 (rwxrwx---) to 1770 (rwxrwx--T)
$ chmod 4750 backup-script mode of 'backup-script' changed from 0750 (rwxrw----) to 4770 (rwsrwx---)
$ chmod 2770 /home/duchess/shared mode of '/home/duchess/shared' changed from 0770 (rwxrwx---) to 2770 (rwxrws---)
| Mode | Special modes | Owner | Group | World |
|---|---|---|---|---|
| Option name | Octal value |
|---|---|
$ stat --format=%a:%A:%U:%G /tmp 1777:drwxrwxrwt:root:root
$ stat --format=%a:%A:%U:%G /usr/bin/passwd 4755:-rwsr-xr-x:root:root
$ chmod -v 00770 backup.sh mode of 'backup.sh' changed from 1770 (rwxrwx--T) to 0770 (rwxrwx---)
$ chmod -v =770 backup.sh mode of 'backup.sh' changed from 1770 (rwxrwx--T) to 0770 (rwxrwx---)
$ stat --format=%a:%A:%U:%G file.txt 664:-rw-r--r--:stash:stash
$ chmod -v g+w,o+w file.txt mode of 'file.txt' changed from 0644 (rw-r--r--) to 0666 (rw-rw-rw-)
$ chmod -v g-w,o-w file.txt mode of 'file.txt' changed from 0666 (rw-rw-rw-) to 0644 (rw-r--r--)
$ chmod -v u=rw,g=rw,o-r file.txt mode of 'file.txt' changed from 0644 (rw-r-r--) to 0660 (rw-rw----)
$ chmod -v u+x file.txt mode of 'file.sh' changed from 0660 (rw-rw----) to 0760 (rwxrw----)
$ chmod -v u=rw,g=rw,o=r file.txt mode of 'file.sh' changed from 0760 (rwxrw----) to 0664 (rw-rw-r--)
| Mode | Value |
|---|---|
| Owner | Notation |
|---|---|
$ stat --format=%a:%A:%U:%G /home/duchess 755:drwxr-xr-x:duchess:duchess
$ chmod o+t /shared/stickydir mode of '/shared/stickydir' changed from 0775 (rwxrwxr-x) to 1775 (rwxrwxr-t)
$ chmod -v g+s /shared mode of '/shared' changed from 0770 (rwxrwx---) to 2770 (rwxrws---)
$ chmod -v u+s backup-script mode of 'backup-script' changed from 0755 (rwxr-xr-x) to 4755 (rwsr-xr-x)
| Mode | User | Group | Other |
|---|---|---|---|
$ stat --format=%a:%A:%U:%G /tmp 1777:drwxrwxrwt/:root:root
$ stat --format=%a:%A:%U:%G /usr/bin/passwd 4755:-rwsr-xr-x:root:root
$ chmod -v 444 file1 file2 file3
$ chmod -vR 755 /shared
$ chmod -v 644 *.txt
$ chmod -v 644 abcd*
$ find . -type f -exec chmod -v 660 {} \;
$ sudo find / -user madmax -exec chmod -v 660 {} \;
$ sudo find / -user 1007 -exec chmod -v 660 {} \;
duchess@client1:~$ sudo chown -v madmax: song.wav changed ownership of 'song.wav' from duchess:duchess to madmax:duchess
$ sudo chown -v :composers song.wav changed ownership of 'song.wav' from madmax:duchess to :composers
$ sudo chown stash:stash song.wav
$ sudo chown -v madmax:share file1 file2 file3
$ sudo chown -v :share *.txt
$ chown -Rv --from duchess stash /shared/compositions $ chown -Rv --from 1001 1005 /shared/compositions
$ sudo find / -user duchess -exec chown -v stash {} \;
$ sudo find / -user 1001 -exec chown -v 1005 {} \;
$ umask 0002
$ umask -S u=rwx,g=rwx,o=rx
$ umask 0022
UMASK 022
| umask | Directories | Files |
|---|---|---|
$ ln -s /files/userstuff stuff
$ ln /files/config1.txt myconf.txt
$ stat stuff File: stuff -> /files/userstuff Size: 4 Blocks: 0 IO Block: 4096 symbolic link Device: 804h/2052d Inode: 877581 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 1000/ madmax) Gid: ( 1000/ madmax)
$ ls -l [...] lrwxrwxrwx 1 madmax madmax 4 Apr 26 12:42 stuff -> /files/userstuff
$ ls -li 1353 -rw-rw-r-- 3 madmax madmax 11208 Apr 26 13:06 config.txt 1353 -rw-rw-r-- 3 madmax madmax 11208 Apr 26 13:06 config2.txt 1353 -rw-rw-r-- 3 madmax madmax 11208 Apr 26 13:06 config3.txt
$ stat config3.txt File: config3.txt Size: 11208 Blocks: 24 IO Block: 4096 regular file Device: 804h/2052d Inode: 1353 Links: 3
$ find /etc -xdev -samefile config3.txt ./config ./config2 ./config3
$ df -i /dev/sda4 Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda4 384061120 389965 383671155 1% /home
$ ls -a . .. Audiobooks .bash_history .bash_logout .bashrc bin .bogofilter .cache Calibre-Library cat-memes .cddb .cert
stash@client4:~$ cd . stash@client4:~$ stash@client4:~$ cd .. stash@client4:/home$
duchess@pc:~$ cp -auv Pictures/cat-desk.jpg Pictures/cat-chair.png \ ~/cat-pics /media/duchess/2tbdisk/backups/
duchess@pc:~$ cp -auv ~ /media/duchess/2tbdisk/backups/
duchess@pc:~$ cp -auv /home/duchess/* /media/duchess/2tbdisk/backups/
duchess@pc:~$ crontab -e # m h dom mon dow command 30 22 * * * /bin/cp -au /home/duchess /media/duchess/2tbdisk/backups/
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [...] sdb 8:16 0 1.8T 0 disk └─sdb1 8:17 0 1.5T 0 part /media/duchess/backups
duchess@pc:~$ rsync -av ~ /media/duchess/2tbdisk/ sending incremental file list duchess/ duchess/Documents/ duchess/Downloads/ duchess/Music/ [...] sent 27,708,209 bytes received 20,948 bytes 11,091,662.80 bytes/sec total size is 785,103,770,793 speedup is 28,313.29
duchess@pc:~$ rsync -av ~/arias ~/overtures /media/duchess/2tbdisk/duchess/
duchess@pc:~$ rsync -av /media/duchess/2tbdisk/duchess/arias /home/duchess/
duchess@pc:~$ rsync -av --dry-run \ ~/Music/scores ~/Music/woodwinds /media/duchess/2tbdisk/duchess/
duchess@pc:~$ rsync -av --delete /home/duchess /media/duchess/2tbdisk/
duchess@pc:~$ rsync -av ~/Music/arias empress@laptop:songs/ duchess@laptop's password: building file list ... done arias/ arias/o-mio-babbino-caro.ogg arias/deh-vieni-non-tardar.ogg arias/mi-chiamano-mimi.ogg wrote 25984 bytes read 68 bytes 7443.43 bytes/sec total size is 25666 speedup is 0.99
duchess@pc:~$ rsync -av ~/Music/woodwinds \ empress@remote.example.com:/backups/
duchess@pc:~$ rsync -av empress@remote.example.com:/backups/woodwinds \ /home/duchess/Music/
duchess@pc:~$ rsync --partial --progress \ --log-file=/home/duchess/rsynclog.txt \ -hav ~/Music/arias empress@remote.example.com:/backups/
# m h dom mon dow user command 00 22 * * * root /usr/bin/rsync -a /etc server1:/system-backups
duchess@pc:~$ rsync -av --exclude=lho-perduta.wav \ ~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av --exclude=arias/lho-perduta.wav \ ~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av \
--exclude={'arias/lho-perduta.wav','non-mi-dir.wav','un-bel-di-vedremo.flac'} \
~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av \
--exclude={'soprano/','tenor/','non-mi-dir.wav'} \
~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av --include=*/ --include=lho-perduta.wav \ --exclude='*' ~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av --include=*/ \
--include={'lho-perduta.wav','non-mi-dir.wav','un-bel-di-vedremo.flac'} \
--exclude='*' ~/Music/arias /media/duchess/2tbdisk/duchess/Music/
duchess@pc:~$ rsync -av --include=*/ --include=soprano/lho-perduta.wav --exclude='*' ~/Music/arias /media/duchess/2tbdisk/duchess/Music/ Music/ Music/arias/ Music/arias/baritone/ Music/arias/soprano/ Music/arias/soprano/lho-perduta.wav Music/arias/tenor/ [...]
duchess@pc:~$ rsync -avm --include=*/ --include=soprano/lho-perduta.wav --exclude='*' ~/Music/arias /media/duchess/2tbdisk/duchess/Music/ Music/ Music/arias/soprano/ Music/arias/soprano/lho-perduta.wav
# include file list # /Documents/compositions/jazz/ /Documents/schedule.odt /Videos/concerts/ .config .local /Music/courses/bassoon.avi</strong> [...]
duchess@pc:~$ rsync -av ~ --files-from ~/include-list.txt \ duchess@remote.example.com:/backups/
# exclude file list # # include home directory + /duchess/ # # include .config and .local, exclude all other dotfiles + /duchess/.config + /duchess/.local - /duchess/.* # # include jazz/, exclude all other files in Documents + /duchess/Documents/ + /duchess/Documents/compositions/ + /duchess/Documents/compositions/jazz/ - /duchess/Documents/compositions/* - /duchess/Documents/* # # include schedule.odt, include all .ogg files in # arias/, exclude all other files in Music + /duchess/Music/ + /duchess/Music/schedule.odt + /duchess/Music/arias/*.ogg - /duchess/Music/arias/* - /duchess/Music/* # # includes courses/, exclude all other files in Videos + /duchess/Videos/ + /duchess/Videos/courses/ - /duchess/Videos/* # # exclude everything else - /duchess/*
duchess@pc:~$ rsync -av ~ \ --exclude-from=/home/duchess/exclude-list.txt \ /media/duchess/2tbdisk/
+ /duchess/Documents/compositions/ - /duchess/*
+ /duchess/Documents/ + /duchess/Documents/compositions/ - /duchess/*
+ /duchess/Documents/ + /duchess/Documents/compositions/ - /duchess/Documents/* - /duchess/*
# include home directory + /duchess/ # # include all ogg and flac files + *.ogg + *.flac # # exclude wav files, all cache and temp dirs - *.wav - cache* - temp*
$ rsync --bwlimit=512 -ave ssh ~/Music/arias empress@laptop:songs/
# modules [backup_dir1] path = /backups comment = "server1 public archive" list = yes read only = no use chroot = no uid = 0 gid = 0
$ sudo mkdir /backups/ $ sudo chmod 0700 /backups/
$ sudo systemctl start rsyncd.service
admin@server1:~$ sudo rsync --daemon
admin@server1:~$ rsync server1:: backup_dir1 "server1 public archive"
duchess@pc:~$ rsync server1:: backup_dir1 "server1 public archive" duchess@pc:~$ rsync 192.168.10.15:: backup_dir1 "server1 public archive"
duchess@pc:~$ rsync -av ~/drawings server1::backup_dir1 building file list.....done drawings/ drawings/aug_03 drawings/sept_03 wrote 1126399 bytes read 104 bytes 1522.0 bytes/sec total size is 1130228 speedup is 0.94
duchess@pc:~$ rsync server1::backup_dir1/drawings/ drwx------ 4,096 2021/01/04 06:06:55 . -rw-r--r-- 21,560 2021/09/17 08:53:18 aug_03 -rw-r--r-- 21,560 2021/10/14 16:42:16 sept_03
madmax@buntu:~$ rsync -av server1::backup_dir1/drawings ~/downloads receiving incremental file list created directory /home/madmax/downloads drawings/ drawings/aug_03 drawings/sept_03 sent 123 bytes received 11562479 bytes 1755.00 bytes/sec total size is 1141776 speedup is 1.00
# rsync-users for server1 duchess:12345 madmax:23456 stash:34567
$ sudo chmod 0600 /etc/rsyncd-users
[duchess_backup] path = /backups/duchess comment = Duchess's private archive list = yes read only = no auth users = duchess secrets file =/etc/rsyncd-users use chroot = no strict modes = yes uid = root gid = root
$ sudo mkdir /backups/duchess/ $ sudo chmod -R 0700 /backups/duchess/
$ rsync duchess@server1::duchess_backup Password: 12345 drwxr-xr-x 4,096 2020/06/29 18:24:43 .
$ rsync -av ~/logs duchess@server1::duchess_backup Password: sending incremental file list logs/ logs/irc.log logs/irc_#core-standup.log logs/irc_#core.log logs/irc_#desktop.log logs/irc_#engineering.log logs/irc_#mobile.log sent 130,507 bytes received 305 bytes 37,374.86 bytes/sec total size is 129,383 speedup is 0.99
$ systemctl status rsyncd.service
hosts allow = *.local.net hosts allow = 192.168.1.
Welcome to your local backup server! Please remember to actually back up your files!
[global] motd file = /etc/rsync-motd
$ rsync server1::backup_dir1/ Welcome to your local backup server! Please remember to actually backup your files! drwx------ 4,096 2020/06/29 18:24:43 . -rwxr-xr-x 6,400 2015/03/13 08:21:21 keytool drwx------ 4,096 2020/06/17 06:07:41 WIP drwx------ 4,096 2020/06/17 06:06:55 bin drwxr-xr-x 4,096 2020/06/30 09:47:42 duchess [...]
| Value | Decimal | Value | Binary |
|---|---|---|---|
$ sudo umount /dev/sdc2
$ sudo parted GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)
$ sudo parted /dev/sdb print devices /dev/sdb (2000GB) /dev/sda (4001GB) /dev/sdc (4010MB) /dev/sdd (15.7GB) /dev/sr0 (425MB)
$ sudo parted GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)
(parted) print devices /dev/sda (256GB) /dev/sdb (1000GB) /dev/sdc (4010MB)
(parted) select /dev/sdb Using /dev/sdb (parted) print Model: ATA ST1000DM003-1SB1 (scsi) Disk /dev/sdb: 1000GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 525MB 524MB fat16 boot, esp 2 525MB 344GB 343GB btrfs 3 344GB 998GB 654GB xfs 4 998GB 1000GB 2148MB linux-swap(v1) swap (parted)
$ sudo parted /dev/sda GNU Parted 3.2 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print Model: ATA SAMSUNG SSD SM87 (scsi) Disk /dev/sda: 256GB Sector size (logical/physical): 512B/512B Partition Table: gpt [...]
(parted) print all
Model: ATA SAMSUNG SSD SM87 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 524MB 523MB fat16 EFI system legacy_boot,
partition msftdata
2 524MB 659MB 134MB Microsoft reserved msftres
partition
3 659MB 253GB 253GB ntfs Basic data partition msftdata
4 253GB 256GB 2561MB ntfs diag
Model: ATA ST1000DM003-1SB1 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 525MB 524MB fat16 boot, esp
2 525MB 344GB 343GB btrfs
3 344GB 998GB 654GB xfs
4 998GB 1000GB 2148MB linux-swap(v1) swap
Model: General USB Flash Disk (scsi)
Disk /dev/sdc: 4010MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 4010MB 4009MB primary fat32
(parted) print free
Model: ATA ST4000DM000-1F21 (scsi)
Disk /dev/sda: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 500MB 499MB ext4
2 500MB 60.5GB 60.0GB ext4
3 60.5GB 2061GB 2000GB xfs
4 2061GB 2069GB 8000MB linux-swap(v1)
2069GB 4001GB 1932GB Free Space
$ sudo umount /dev/sdc $ sudo parted /dev/sdc GNU Parted 3.2 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Yes (parted) p Model: General USB Flash Disk (scsi) Disk /dev/sdc: 4010MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags
(parted) mkpart "images" ext4 1MB 2004MB (parted) mkpart "audio files" xfs 2005MB 100%
(parted) print Model: General USB Flash Disk (scsi) Disk /dev/sdc: 4010MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 2005MB 2004MB ext4 images 2 2006MB 4009MB 2003MB xfs audio files (parted) q Information: You may need to update /etc/fstab.
(parted) mkpart "images" ext4 2004MB 100% Warning: You requested a partition from 2004MB to 4010MB (sectors 3914062..7831551). The closest location we can manage is 2005MB to 4010MB (sectors 3915776..7831518). Is this still acceptable to you? Yes/No? Yes
$ sudo parted /dev/sdc GNU Parted 3.2 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: General USB Flash Disk (scsi) Disk /dev/sdc: 4010MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 2005MB 2004MB primary 2 2005MB 4010MB 2005MB primary
(parted) rm 2 (parted) p Model: General USB Flash Disk (scsi) Disk /dev/sdc: 4010MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 2005MB 2004MB primary
(parted) rescue 2000MB 4010MB searching for file systems... 40% (time left 00:01)Information: A ext4 primary partition was found at 2005MB -> 4010MB. Do you want to add it to the partition table? Yes/No/Cancel? Yes
(parted) p Model: General USB Flash Disk (scsi) Disk /dev/sdc: 4010MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 2005MB 2004MB xfs images 2 2005MB 4010MB 2005MB ext4
$ sudo parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: General USB Flash Disk (scsi)
Disk /dev/sdc: 4010MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
[...]
1024MB 2005MB 981MB Free Space
2 2005MB 3500MB 1495MB ext4 audio
3500MB 4010MB 510MB Free Space
(parted) resizepart 2 4010MB
| Filesystem | Resize command |
|---|---|
$ du -sh /media/duchess/shrinkme 922.6M /media/duchess/shrinkme
$ sudo e2fsck -f /dev/sdc2
$ sudo btrfs check /dev/sdc2
$ sudo fsck.vfat -v /dev/sdc2
| Filesystem | Resize command |
|---|---|
(parted) resizepart 1 2000MB Warning: Shrinking a partition can cause data loss, are you sure you want to continue? Yes/No? y
$ sudo lshw | tee hardware.txt
duchess
description: Laptop
product: Latitude E7240 (05CA)
vendor: Dell Inc.
version: 00
serial: 456ABC1
width: 64 bits
[...]
$ sudo lshw -short
H/W path Device Class Description
============================================================
system To Be Filled By O.E.M.
/0 bus H97M Pro4
/0/0 memory 64KiB BIOS
/0/b memory 16GiB System Memory
/0/b/0 memory DIMM [empty]
/0/b/1 memory 8GiB DIMM DDR3 Synchronous
1333
MHz (0.8 ns)
[...]
/0/100/14/0/5 bus USB3.0 Hub
/0/100/14/0/5/1 generic SAMSUNG_Android
/0/100/14/0/5/2 printer MFC-J5945DW
/0/100/14/0/5/4 wlx9cefd5fe8f20 network 802.11 n WLAN
/0/100/14/0/b input USB Optical Mouse
/0/100/14/0/c input QuickFire Rapid keyboard
[...]
$ sudo lshw -businfo Bus info Device Class Description ============================================================= [...] cpu@0 processor Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz usb@3:5.4 wlx9cefd5fe8f20 network 802.11 n WLAN usb@3:b input USB Optical Mouse usb@3:c input QuickFire Rapid keyboard pci@0000:00:19.0 enp0s25 network Ethernet Connection (2) I218-V pci@0000:00:1a.0 bus 9 Series Chipset Family USB scsi@0:0.0.0 /dev/sda disk 4TB ST4000DM000-1F21 scsi@0:0.0.0,1 /dev/sda1 volume 476MiB EXT4 volume [...]
$ sudo lshw -short -class bus -class cpu
$ sudo lshw -html -class bus -class cpu | tee lshw.html $ sudo lshw -xml -class printer -class display -class input | tee lshw.xml $ sudo lshw -json -class storage | tee lshw.json
$ sudo lshw -json -sanitize -class bus -class cpu | tee lshw.json
$ hwinfo --monitor [...] Hardware Class: monitor Model: "VIEWSONIC VX2450 SERIES" Vendor: VSC "VIEWSONIC" Device: eisa 0xe226 "VX2450 SERIES" [...]
$ hwinfo --listmd
$ hwinfo --short
keyboard:
/dev/input/event4 CM Storm QuickFire Rapid keyboard
mouse:
/dev/input/event5 CM Storm QuickFire Rapid keyboard
/dev/input/mice Logitech Optical Wheel Mouse
printer:
Brother Industries MFC-J5945DW
monitor:
VIEWSONIC VX2450 SERIES
graphics card:
Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated
[...]
$ hwinfo --mouse --network --cdrom
$ hwinfo --help
Usage: hwinfo [OPTIONS]
Probe for hardware.
Options:
--<HARDWARE_ITEM>
This option can be given more than once. Probe for a particular
HARDWARE_ITEM. Available hardware items are:
all, arch, bios, block, bluetooth, braille, bridge, camera,
cdrom, chipcard, cpu, disk, dsl, dvb, fingerprint, floppy,
framebuffer, gfxcard, hub, ide, isapnp, isdn, joystick, keyboard,
memory, mmc-ctrl, modem, monitor, mouse, netcard, network, partition,
pci, pcmcia, pcmcia-ctrl, pppoe, printer, redasd,
reallyall, scanner, scsi, smp, sound, storage-ctrl, sys, tape,
tv, uml, usb, usb-ctrl, vbe, wlan, xen, zip
[...]
$ lspci 00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06) 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06) 00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06) [...]
$ lspci -v $ lspci -vv $ lspci -vvv
$ lspci [...] 00:1f.2 SATA controller: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode] [...]
$ lspci -tvv
-[0000:00]-+-00.0 Intel Corporation 4th Gen Core Processor DRAM Controller
+-02.0 Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor
Integrated Graphics Controller
+-03.0 Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD
Audio Controller
+-14.0 Intel Corporation 9 Series Chipset Family USB xHCI Controller
+-16.0 Intel Corporation 9 Series Chipset Family ME Interface #1
+-19.0 Intel Corporation Ethernet Connection (2) I218-V
+-1a.0 Intel Corporation 9 Series Chipset Family USB EHCI
Controller #2
+-1b.0 Intel Corporation 9 Series Chipset Family HD Audio Controller
+-1c.0-[01]--
+-1c.3-[02-03]----00.0-[03]--
+-1d.0 Intel Corporation 9 Series Chipset Family USB EHCI
Controller #1
+-1f.0 Intel Corporation H97 Chipset LPC Controller
+-1f.2 Intel Corporation 9 Series Chipset Family SATA Controller
[AHCI Mode]
\-1f.3 Intel Corporation 9 Series Chipset Family SMBus Controller
$ lspci -D 0000:00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06) 0000:00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06) 0000:00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller [...]
$ lspci -v | awk '/USB/,/^$/'
00:14.0 USB controller: Intel Corporation 9 Series Chipset Family USB xHCI
Controller (prog-if 30 [XHCI])
Subsystem: ASRock Incorporation 9 Series Chipset Family USB xHCI
Controller
Flags: bus master, medium devsel, latency 0, IRQ 26
Memory at efc20000 (64-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: xhci_hcd
00:1a.0 USB controller: Intel Corporation 9 Series Chipset Family USB EHCI
Controller #2 (prog-if 20 [EHCI])
Subsystem: ASRock Incorporation 9 Series Chipset Family USB EHCI
Controller
Flags: bus master, medium devsel, latency 0, IRQ 16
Memory at efc3b000 (32-bit, non-prefetchable) [size=1K]
Capabilities: <access denied>
Kernel driver in use: ehci-pci
$ lspci -v | awk '/Audio/,/^$/'
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor
HD Audio Controller (rev 06)
Subsystem: ASRock Incorporation Xeon E3-1200 v3/4th Gen Core Processor
HD Audio Controller
Flags: bus master, fast devsel, latency 0, IRQ 31
Memory at efc34000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
00:1b.0 Audio device: Intel Corporation 9 Series Chipset Family HD Audio
Controller
Subsystem: ASRock Incorporation 9 Series Chipset Family HD Audio
Controller
Flags: bus master, fast devsel, latency 0, IRQ 32
Memory at efc30000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
$ lspci -nn [....] 00:02.0 VGA compatible controller [0300]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06) [...]
$ lspci -d ::0604 00:1c.0 PCI bridge: Intel Corporation 9 Series Chipset Family PCI Express Root Port 1 (rev d0) 00:1c.3 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d0) 02:00.0 PCI bridge: ASMedia Technology Inc. ASM1083/1085 PCIe to PCI Bridge (rev 03) $ lspci -d 8086:: 00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06) 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06) 00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06) [...] $ lspci -d :0412: 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06)
$ lspci -kd ::0200
00:19.0 Ethernet controller: Intel Corporation Ethernet Connection (2) I218-V
Subsystem: ASRock Incorporation Ethernet Connection (2) I218-V
Kernel driver in use: e1000e
Kernel modules: e1000e
$ lspci -vmmk| awk '/VGA/,/^$/' Class: VGA compatible controller Vendor: Intel Corporation Device: Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller SVendor: ASRock Incorporation SDevice: Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller Rev: 06 Driver: i915 Module: i915
$ lsusb [...] Bus 003 Device 011: ID 148f:5372 Ralink Technology, Corp. RT5372 Wireless Adapter Bus 003 Device 002: ID 0bda:5401 Realtek Semiconductor Corp. RTL 8153 USB 3.0 hub with gigabit ethernet Bus 003 Device 006: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse Bus 003 Device 005: ID 2516:0004 Cooler Master Co., Ltd. Storm QuickFire Rapid Mechanical Keyboard [...]
$ lsusb -tv
[...]
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 3: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
ID 0bda:5401 Realtek Semiconductor Corp. RTL 8153 USB 3.0 hub with
gigabit ethernet
|__ Port 7: Dev 11, If 0, Class=Vendor Specific Class, Driver=rt2800usb, 480M
ID 148f:5372 Ralink Technology, Corp. RT5372 Wireless Adapter
|__ Port 11: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 2516:0004 Cooler Master Co., Ltd. Storm QuickFire Rapid Mechanical
Keyboard
|__ Port 12: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 046d:c018 Logitech, Inc. Optical Wheel Mouse
[...]
$ lsusb
[...]
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 012: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy series,
misc. (MTP mode)
Bus 003 Device 013: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle
(HCI mode)
Bus 003 Device 002: ID 0bda:5401 Realtek Semiconductor Corp. RTL 8153 USB 3.0
hub with gigabit ethernet
[...]
$ lsusb -tv
[...]
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 3: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
ID 0bda:5401 Realtek Semiconductor Corp. RTL 8153 USB 3.0 hub with
gigabit ethernet
|__ Port 4: Dev 12, If 0, Class=Imaging, Driver=, 480M
ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy series, misc. (MTP
mode)
|__ Port 2: Dev 13, If 0, Class=Wireless, Driver=btusb, 12M
ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
|__ Port 2: Dev 13, If 1, Class=Wireless, Driver=btusb, 12M
ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
[...]
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 3.7T 0 disk ├─sda1 8:1 0 476M 0 part /boot ├─sda2 8:2 0 55.9G 0 part / ├─sda3 8:3 0 1.8T 0 part /home └─sda4 8:4 0 7.5G 0 part [SWAP] sdb 8:16 0 1.8T 0 disk ├─sdb1 8:17 0 102M 0 part ├─sdb2 8:18 0 6.5G 0 part ├─sdb3 8:19 0 1.1G 0 part [SWAP] └─sdb4 8:20 0 1.8T 0 part sdc 8:32 0 3.7T 0 disk ├─sdc1 8:33 0 128M 0 part ├─sdc2 8:34 0 439.7G 0 part └─sdc3 8:35 0 3.2T 0 part sdd 8:48 1 3.8G 0 disk └─sdd1 8:49 1 3.8G 0 part sr0 11:0 1 159.3M 0 rom
$ lsblk -f /dev/sdc NAME FSTYPE LABEL UUID MOUNTPOINT sdc ├─sdc1 ├─sdc2 ntfs Seagate Backup Plus 2E203F82203F5057 └─sdc3 ext4 backup 0451d428-9716-4cdd /media/max/backup
$ lsblk -S NAME HCTL TYPE VENDOR MODEL REV TRAN sda 0:0:0:0 disk ATA ST4000DM000-1F21 CC54 sata sdb 2:0:0:0 disk ATA SAMSUNG HD204UI 0001 sata sdc 6:0:0:0 disk Seagate BUP SL 0304 usb sr0 4:0:0:0 rom ATAPI iHAS424 B GL1B sata
$ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 60 Model name: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz [...] L1d cache: 128 KiB L1i cache: 128 KiB L2 cache: 1 MiB L3 cache: 8 MiB [...]
$ lscpu -C NAME ONE-SIZE ALL-SIZE WAYS TYPE LEVEL L1d 32K 128K 8 Data 1 L1i 32K 128K 8 Instruction 1 L2 256K 1M 8 Unified 2 L3 8M 8M 16 Unified 3
Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1
$ uname -m x86_64
$ cat /proc/filesystems
nodev sysfs
nodev tmpfs
nodev bdev
nodev proc
nodev cgroup
nodev cgroup2
nodev cpuset
nodev devtmpfs
nodev debugfs
nodev tracefs
nodev securityfs
nodev sockfs
nodev bpf
nodev pipefs
nodev ramfs
nodev hugetlbfs
nodev devpts
ext3
ext2
ext4
nodev autofs
nodev mqueue
nodev pstore
btrfs
vfat
xfs
fuseblk
nodev fuse
nodev fusectl
jfs
nilfs2
$ lsblk -o NAME,FSTYPE NAME FSTYPE sda ├─sda1 vfat ├─sda2 btrfs ├─sda3 xfs └─sda4 swap sdb ├─sdb1 ext2 ├─sdb2 ext4 ├─sdb3 swap └─sdb4 LVM2_member sdc └─sdc1 vfat sr0
$ lsblk -o NAME,FSTYPE /dev/sdb ├─sdb1 ext2 ├─sdb2 ext4 ├─sdb3 swap └─sdb4 LVM2_member
$ lsblk -o NAME,FSTYPE /dev/sda1 NAME FSTYPE sda1 vfat
$ lsblk -o NAME,FSTYPE,LABEL,FSSIZE,FSUSE%,MOUNTPOINT NAME FSTYPE LABEL FSSIZE FSUSE% MOUNTPOINT loop0 squashfs 646.5M 100% /run/archiso/sfs/airootfs sda ├─sda1 └─sda2 ntfs sdb ├─sdb1 vfat BOOT ├─sdb2 btrfs root ├─sdb3 xfs home └─sdb4 swap sdc iso9660 RESCUE800 └─sdc1 iso9660 RESCUE800 708M 100% /run/archiso/bootmnt sr0
$ lsblk -f sda ├─sdb1 ext4 /media/duchess/stuff [...] $ umount /media/duchess/stuff
$ sudo parted /dev/sdb GNU Parted 3.2 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: ATA SAMSUNG HD204UI (scsi) Disk /dev/sdb: 2000GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 1656GB 1656GB ext4 stor-1 1 1656GB 2656GB 1000GB ext4 stor-2 (parted) rm 1
$ sudo mkdir -p /mnt/madmax/newfs $ sudo mount /dev/sdb1 /mnt/madmax/newfs
$ sudo chown -R madmax:madmax /mnt/madmax/newfs $ sudo chmod -R 0755 /mnt/madmax/newfs
$ tree /shared /shared ├── duchess ├── madmax └── stash
$ tree -L 2 /mnt /mnt ├── duchess ├── madmax │ ├── madmax1 │ └── madmax2 └── stash
$ stat /shared/madmax/madmax1 [...] Access: (0755/drwxr-xr-x) Uid: ( 0/ madmax) Gid: ( 0/ madmax)
$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs [...]
$ mountpoint madmax1/ madmax1/ is a mountpoint
#<file system> <mount point> <type> <options> <dump> <pass> LABEL=xfs-ehd /mnt/madmax/newfs xfs defaults,user 0 2
$ sudo findmnt --verbose --verify / [ ] target exists [ ] UUID=102a6fce-8985-4896-a5f9-e5980cb21fdb translated to /dev/sda2 [ ] source /dev/sda2 exists [ ] FS type is btrfs [W] recommended root FS passno is 1 (current is 0) /mnt/madmax/newfs [ ] target exists [ ] LABEL=xfs-ehd translated to /dev/sdb1 [ ] source /dev/sdb1 exists [ ] FS type is xfs [...] 0 parse errors, 0 errors, 1 warning
$ sudo mount -a
$ df -Th /media/duchess/stuff/ Filesystem Type Size Used Avail Use% Mounted on /dev/sdb1 xfs 952M 7.9M 944M 1% /media/duchess/stuff
$ sudo umount /media/duchess/stuff
$ sudo mkfs.ext4 -L 'mylabel' /dev/sdb1
mke2fs 1.44.1 (24-Mar-2018)
/dev/sdb1 contains a XFS file system labelled 'stuff'
created on Sun Sep 20 19:37:43 2020
Proceed anyway? (y,N) y
Creating filesystem with 466432 4k blocks and 116640 inodes
Filesystem UUID: 99da2e5d-f96a-4fb6-990d-599cf56247a2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
$ dmesg | grep sdb1 [25023.525279] EXT4-fs (sdb1): mounted filesystem with ordered data mode.
$ sudo tune2fs -o journal_data /dev/sdb1 tune2fs 1.44.1 (24-Mar-2018)
$ dmesg | grep sdb1 [25023.525279] EXT4-fs (sdb1): mounted filesystem with ordered data mode.
[ 206.076123] EXT4-fs (sdb1): mounted filesystem with journalled data mode. [ 206.076433] EXT4-fs (sdb1): mounted filesystem with ordered data mode.
$ sudo dumpe2fs -h /dev/sda1 | grep -i uuid dumpe2fs 1.43.8 (1-Jan-2018) Filesystem UUID: 8593f3b7-4b7b-4da7-bf4a-cc6b0551cff8 Journal UUID: f8e42703-94eb-49af-a94c-966e5b40e756
$ lsblk -f | grep f8e42703-94eb-49af-a94c-966e5b40e756 └─sdb5 ext4 journal1 f8e42703-94eb-49af-a94c-966e5b40e756
$ sudo dumpe2fs -h /dev/sda2 | grep UUID dumpe2fs 1.44.1 (24-Mar-2018) Filesystem UUID: 64bfb5a8-0ef6-418a-bb44-6c389514ecfc
$ sudo parted (parted) select /dev/sdb Using /dev/sdb (parted) mkpart "journal1" ext4 1600GB 1800GB (parted) select /dev/sda Using /dev/sda (parted) mkpart "ext4fs" ext4 1MB 500GB
$ sudo tune2fs -l /dev/sda1 | grep -i 'block size' Block size: 4096
$ sudo mke2fs -b 4096 -O journal_dev /dev/sdb5
mke2fs 1.43.8 (1-Jan-2018)
/dev/sdb2 contains a ext4 file system labelled 'ext4'
created on Mon Jan 4 18:25:30 2021
Proceed anyway? (y,N) y
Creating filesystem with 48747520 4k blocks and 0 inodes
Filesystem UUID: f8e42703-94eb-49af-a94c-966e5b40e756
Superblock backups stored on blocks:
Zeroing journal device:
$ sudo mkfs.ext4 -b 4096 -J device=/dev/sdb5 /dev/sda1
mke2fs 1.43.8 (1-Jan-2018)
Creating filesystem with 35253504 4k blocks and 8814592 inodes
Filesystem UUID: 8593f3b7-4b7b-4da7-bf4a-cc6b0551cff8
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Adding journal to device /dev/sdb2: done
Writing superblocks and filesystem accounting information: done
$ sudo tune2fs -O ^has_journal /dev/sda1 $ sudo tune2fs -b 4096 -J device=/dev/sdb5 /dev/sda1
$ sudo tune2fs -m 1 /dev/sda1 tune2fs 1.44.1 (24-Mar-2018) Setting reserved blocks percentage to 1% (820474 blocks)
$ sudo tune2fs -l /dev/sda1 | grep -i 'block size' Block size: 4096
$ sudo tune2fs -m .25 /dev/sda1 tune2fs 1.44.1 (24-Mar-2018) Setting reserved blocks percentage to 0.25% (205118 blocks)
$ sudo tune2fs -r 250000 /dev/sda1 tune2fs 1.44.1 (24-Mar-2018) Setting reserved blocks count to 250000
$ sudo tune2fs -l /dev/sda1 | grep -i 'reserved block' Reserved block count: 250000
$ sudo dumpe2fs -h /dev/sda1 [...] Block count: 82047488 Reserved block count: 250000 [...]
$ sudo apt install xfsprogs
$ sudo parted /dev/sda mkpart testxfs xfs 1MB 500GB
$ sudo mkfs.xfs -L xfstest /dev/sda1
meta-data=/dev/sdb5 isize=512 agcount=4, agsize=640000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0,
reflink=0
data = bsize=4096 blocks=2560000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
$ lsblk -f | grep -w sda1 ├─sda1 xfs xfstest bb5dddb3-af74-4bed-9d2a-e79589278e84
$ sudo mkdir /mnt/xfstest $ sudo mount /dev/sda1 /mnt/xfstest $ sudo chown -R duchess:duchess /mnt/xfstest $ sudo chmod -R -755 /mnt/xfstest
$ sudo parted /dev/sdb
GNU Parted 3.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p free
Model: ATA SAMSUNG HD204UI (scsi)
Disk /dev/sdb: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 1656GB 1656GB xfs files
2 1656GB 1759GB 103GB xfs files2
1759GB 4000GB 242GB Free Space
(parted) resizepart 2
(parted) Warning: Partition /dev/sdb2 is being used. Are you sure you want to
continue?
Yes/No? Yes
End? [1759GB]? 1900GB
(parted) q
$ sudo xfs_growfs /media/duchess/xfs
$ sudo mkfs.exfat /dev/sdc1 mkexfatfs 1.2.8 Creating... done. Flushing... done. File system created successfully.
$ sudo exfatlabel /dev/sdc2 exfatfs
$ lsblk -f NAME FSTYPE LABEL UUID sdc ├─sdc1 ├─sdc2 exfat exfatfs 8178-51D4 └─sdc3
$ sudo parted /dev/sdb GNU Parted 3.2 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: ATA SAMSUNG HD204UI (scsi) Disk /dev/sdb: 2000399MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 0.00GB 1656GB 1656GB xfs files (parted) unit mb mkpart Partition name? []? File system type? [ext2]? fat32 Start? 1656331MB End? 1656831MB (parted) print Model: ATA SAMSUNG HD204UI (scsi) Disk /dev/sdb: 2000399MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1.05MB 1656331MB 1656330MB xfs bup 2 1656331MB 1656831MB 500MB fat32 (parted) q
$ sudo mkfs.fat -F 32 -n fat32test /dev/sdb2 mkfs.fat 4.1 (2017-01-24) mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
$ lsblk -f /dev/sdb NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT sdb ├─sdb1 xfs xfstest 1d742b2d-a621-4454-b4d3-469216a6f01e └─sdb2 vfat fat32test AB39-1808
$ systemctl status sshd ● sshd.service - OpenSSH Daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset Active: inactive (dead) [...]
$ sudo rm /etc/ssh/ssh_host*
$ sudo ssh-keygen -A ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
$ ls -l /etc/ssh/ -r-------- 1 root root 227 Jun 4 11:30 ssh_host_ecdsa_key -r-------- 1 root root 399 Jun 4 11:30 ssh_host_ed25519_key -r-------- 1 root root 1679 Jun 4 11:30 ssh_host_rsa_key
$ ls -l /etc/ssh/ -rw-r--r-- 1 root root 174 Jun 4 11:30 ssh_host_ecdsa_key.pub -rw-r--r-- 1 root root 94 Jun 4 11:30 ssh_host_ed25519_key.pub -rw-r--r-- 1 root root 394 Jun 4 11:30 ssh_host_rsa_key.pub
$ sudo systemctl reload sshd.server
StrictModes yes
ListenAddress 192.168.10.15 ListenAddress 192.168.10.16
sshd 2022 sshd 2023
Port 2022 Port 2023
AllowGroups webadmins backupadmins
PermitRootLogin no
PermitRootLogin prohibit-password
PasswordAuthentication no
DenyUsers duchess madmax stash@example.com cagney@192.168.10.25
LoginGraceTime 90
MaxAuthTries 4
$ sudo sshd -t
$ sudo sshd -t /etc/ssh/sshd_config: line 9: Bad configuration option: Porotocol /etc/ssh/sshd_config: terminating, 1 bad configuration options
duchess@pc:~$ ssh duchess@server1 The authenticity of host 'server1 (192.168.43.74)' can't be established. ECDSA key fingerprint is SHA256:8iIg9wwFIzLgwiiQ62WNLF5oOS3SL/aTw6gFrtVJTx8. Are you sure you want to continue connecting (yes/no)? *yes* Warning: Permanently added 'server1,192.168.43.74' (ECDSA) to the list of known hosts. Password: password Last login: Wed Jul 8 19:22:39 2021 from 192.168.43.183 Have a lot of fun...
duchess@pc:~$ ssh madmax@server1
duchess@pc:~$ ssh server1
duchess@server1:~$ ssh-keygen -lf /etc/ssh/ssh_host_rsa_key 4096 SHA256:32Pja4+F2+MTdla9cs4ucecThswRQp6a4xZ+5sC+Bf0 backup server1 (RSA)
duchess@pc:~/.ssh $ ssh-keygen -C "backup server2" -f id-server2 -t rsa -b 4096 Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id-server2. Your public key has been saved in id-server2.pub. The key fingerprint is: SHA256:32Pja4+F2+MTdla9cs4ucecThswRQp6a4xZ+5sC+Bf0 backup server2 The key's randomart image is: +---[RSA 4096]----+ | .. | | .... | | o. . .| | + . o| | S* .o o o| | +.+..Bo*+| | *.+*EX=o| | o *o.Oo+.| | o.o=+*+.| +----[SHA256]-----+
duchess@pc:~/.ssh $ ssh-copy-id -i id-server1 duchess@server1 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id-server1" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'duchess@server1'" and check to make sure that only the key(s) you wanted were added.
duchess@pc:~/.ssh $ ssh -i id-server1 duchess@server1 Enter passphrase for key 'id-server1': Last login: Sat Jul 11 11:09:53 2021 from 192.168.43.234 Have a lot of fun... duchess@server1:~$
duchess@pc:~/.ssh $ ssh-keygen -t rsa -f id-server2
duchess@pc:~/.ssh $ ssh -i id-server2 duchess@server2
Host server2
HostName server2
User duchess
IdentityFile ~/.ssh/id-server2
IdentitiesOnly yes
$ ssh server2
Host server3
HostName server3
User duchess
IdentityFile ~/.ssh/id-server3
IdentitiesOnly yes
Host server3
HostName server3
User madmax
IdentityFile ~/.ssh/id-server3
IdentitiesOnly yes
Port 2022
$ ssh-keygen -p -f ~/.ssh/id-server2 Enter old passphrase: Key has comment 'backup server2' Enter new passphrase (empty for no passphrase): Enter same passphrase again: passphrase Your identification has been saved with the new passphrase.
keychain ~/.ssh/id-server1 ~/.ssh/id-server2 \ ~/.ssh/id-server3 . ~/.keychain/$HOSTNAME-sh
* keychain 2.8.5 ~ http://www.funtoo.org * Found existing ssh-agent: 2016 * Adding 3 ssh key(s): /home/duchess/.ssh/id-server1 /home/duchess/.ssh/id-server2 /home/duchess/.ssh/id-server3 Enter passphrase for /home/duchess/.ssh/id-server1: Enter passphrase for /home/duchess/.ssh/id-server2: Enter passphrase for /home/duchess/.ssh/id-server3: * ssh-add: Identities added: /home/duchess/.ssh/id-server1 /home/duchess/.ssh/id-server2 /home/duchess/.ssh/id-server3
$ echo $HOSTNAME pc
#!/bin/bash
source $HOME/.keychain/${HOSTNAME}-sh
/usr/bin/rsync -ae "ssh -i /home/duchess/.ssh/id-server3" /home/duchess/ \
duchess@server1:/backups/
$ chmod +x duchess-backup-server1
15 22 * * * /home/duchess/duchess-backup-server1
$ echo $XDG_SESSION_TYPE x11 $ echo $XDG_SESSION_TYPE wayland $ loginctl show-session "$XDG_SESSION_ID" -p Type Type=x11 $ loginctl show-session "$XDG_SESSION_ID" -p Type Type=wayland
X11Forwarding yes
duchess@pc:~$ ssh -Yi id-server1 duchess@server1 Last login: Thu Jul 9 09:26:09 2021 from 192.168.43.80 Have a lot of fun.. duchess@server1:~$
duchess@server1:~$ kmahjongg
duchess@pc:~$ echo $DISPLAY :0.0
duchess@server1:~ssh $ echo $DISPLAY localhost:10.0
$ ssh mailadmin@server2.example.com sudo systemctl restart postfix
$ ssh -Y duchess@laptop /usr/games/gnome-sudoku
duchess@pc:~$ mkdir sshfs
duchess@pc:~$ sshfs duchess@server2: sshfs/
duchess@pc:~$ ls sshfs Desktop Documents Downloads [...]
duchess@pc:~$ fusermount -u sshfs/
duchess@pc:~$ sshfs duchess@server2:/home/duchess/arias sshfs/
duchess@pc:~$ sshfs duchess@server2:/home/duchess/arias sshfs/ -o reconnect
if [ -n "$SSH_CLIENT" ]; then text=" ssh"
fi
export PS1='\[\e[0;36m\]\u@\h:\w${text}$\[\e[0m\] '
$ echo $SSH_CLIENT 192.168.43.234 51414 22
$ ssh -Q help cipher cipher-auth compression kex kex-gss key key-cert key-plain key-sig mac protocol-version sig
$ ssh -Q sig ssh-ed25519 sk-ssh-ed25519@openssh.com ssh-rsa rsa-sha2-256 rsa-sha2-512 ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 sk-ecdsa-sha2-nistp256@openssh.com
$ systemctl status openvpn@.openvpn1.service
● openvpn.service - OpenVPN service
Loaded: loaded (/lib/systemd/system/openvpn.service; enabled; vendor prese>
Active: active (exited) since Sun 2021-01-10 13:43:18 PST; 33min ago
[...]
$ sudo systemctl stop openvpn@.openvpn1.service
[madmax@host1 ~]$ sudo openvpn --remote host2 --dev tun0 --ifconfig 10.0.0.1 \ 10.0.0.2 Sat Jan 9 14:40:34 2021 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode Sat Jan 9 14:40:34 2021 OpenVPN 2.4.8 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jan 29 2020 Sat Jan 9 14:40:34 2021 library versions: OpenSSL 1.1.1d FIPS 10 Sep 2019, LZO 2.10 Sat Jan 9 14:40:34 2021 ******* WARNING *******: All encryption and authentication features disabled -- All data will be tunnelled as clear text and will not be protected against man-in-the-middle changes. PLEASE DO RECONSIDER THIS CONFIGURATION! Sat Jan 9 14:40:34 2021 TUN/TAP device tun0 opened Sat Jan 9 14:40:34 2021 /sbin/ip link set dev tun0 up mtu 1500 Sat Jan 9 14:40:34 2021 /sbin/ip addr add dev tun0 local 10.0.0.1 peer 10.0.0.2 Sat Jan 9 14:40:34 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.122.239:1194 Sat Jan 9 14:40:34 2021 UDP link local (bound): [AF_INET][undef]:1194 Sat Jan 9 14:40:34 2021 UDP link remote: [AF_INET]192.168.122.239:1194
[stash@host2 ~]$ sudo openvpn --remote host1 --dev tun0 --ifconfig 10.0.0.2 \ 10.0.0.1 Sat Jan 9 14:50:53 2021 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode Sat Jan 9 14:50:53 2021 OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Sep 5 2019 Sat Jan 9 14:50:53 2021 library versions: OpenSSL 1.1.1f 31 Mar 2020, LZO 2.10 Sat Jan 9 14:50:53 2021 ******* WARNING *******: All encryption and authentication features disabled -- All data will be tunnelled as clear text and will not be protected against man-in-the-middle changes. PLEASE DO RECONSIDER THIS CONFIGURATION! Sat Jan 9 14:50:53 2021 TUN/TAP device tun0 opened Sat Jan 9 14:50:53 2021 /sbin/ip link set dev tun0 up mtu 1500 Sat Jan 9 14:50:53 2021 /sbin/ip addr add dev tun0 local 10.0.0.2 peer 10.0.0.1 Sat Jan 9 14:50:53 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.122.52:1194 Sat Jan 9 14:50:53 2021 UDP link local (bound): [AF_INET][undef]:1194 Sat Jan 9 14:50:53 2021 UDP link remote: [AF_INET]192.168.122.52:1194 Sat Jan 9 14:51:03 2021 Peer Connection Initiated with [AF_INET]192.168.122.52:1194 Sat Jan 9 14:51:04 2021 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Sat Jan 9 14:51:04 2021 Initialization Sequence Completed
[madmax@host1 ~]$ ping -I tun0 10.0.0.2 PING 10.0.0.2 (10.0.0.2) from 10.0.0.1 tun0: 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.515 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.436 ms [stash@host2 ~]$ ping -I tun0 10.0.0.1 PING 10.0.0.1 (10.0.0.1) from 10.0.0.2 tun0: 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.592 ms 64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.534 ms
$ sudo mkdir /etc/openvpn/keys $ sudo openvpn --genkey --secret myvpn.key
$ scp myvpn.key client1:/etc/openvpn/keys/ Password: myvpn.key 100% 636 142.7KB/s 00:00
# server1.conf dev tun ifconfig 10.0.0.1 10.0.0.2 secret /etc/openvpn/keys/myvpn.key local 192.168.43.184
# client1.conf dev tun ifconfig 10.0.0.2 10.0.0.1 secret /etc/openvpn/keys/myvpn.key remote 192.168.43.184
$ sudo systemctl stop openvpn
[server1 ~] $ sudo openvpn /etc/openvpn/server1.conf
[client1 ~] $ sudo openvpn /etc/openvpn/client1.conf
[server1 ~] $ ping -I tun0 10.0.0.1 [client1 ~] $ ping -I tun0 10.0.0.2
cipher AES-256-CBC
~$ mkdir mypki
~$ sudo cp -r /usr/share/easy-rsa mypki
~$ cd mypki ~/mypki $ easyrsa init-pki init-pki complete; you may now create a CA or requests. Your newly created PKI dir is: /home/duchess/mypki/pki
~/mypki $ easyrsa build-ca [...] Enter New CA Key Passphrase:passphrase Re-Enter New CA Key Passphrase:passphrase [...] Common Name (eg: your user, host, or server name) [Easy-RSA CA]: vpnserver1 [...] CA creation complete and you may now import and sign cert requests. Your new CA certificate file for publishing is at: /home/duchess/mypki/pki/ca.crt
~/mypki $ easyrsa gen-req vpnserver1 nopass Using SSL: openssl OpenSSL 1.1.1d 10 Sep 2019 Generating a RSA private key .............................+++++ ................................................................++++++ writing new private key to '/home/duchess/mypki/pki/private/vpnserver1.key.NYjr5y c9kj' [...] Common Name (eg: your user, host, or server name) [vpnserver1]: Keypair and certificate request completed. Your files are: req: /home/duchess/mypki/pki/reqs/vpnserver1.req key: /home/duchess/mypki/pki/private/vpnserver1.key
~/mypki $ easyrsa gen-req vpnclient1 Using SSL: openssl OpenSSL 1.1.1d 10 Sep 2019 Generating a RSA private key ................+++++ ....................................................................+++++ writing new private key to '/home/duchess/mypki/pki/private/vpnclient1.key.bicpOc EC5S' Enter PEM pass phrase:passphrase Verifying - Enter PEM pass phrase:passphrase [...] Common Name (eg: your user, host, or server name) [vpnclient1]: Keypair and certificate request completed. Your files are: req: /home/duchess/mypki/pki/reqs/vpnclient1.req key: /home/duchess/mypki/pki/private/vpnclient1.key
~/mypki $ easyrsa sign-req server vpnserver1
Using SSL: openssl OpenSSL 1.1.1d 10 Sep 2019
You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.
Request subject, to be signed as a server certificate for 1080 days:
subject=
commonName = vpnserver1
Type the word 'yes' to continue, or any other input to abort.
Confirm request details: yes
Using configuration from /home/duchess/mypki/pki/safessl-easyrsa.cnf
Enter pass phrase for /home/duchess/mypki/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'vpnserver1'
Certificate is to be certified until Jan 27 20:09:12 2024 GMT (1080 days)
Write out database with 1 new entries
Data Base Updated
Certificate created at: /home/duchess/mypki/pki/issued/vpnserver1.crt
mypki $ easyrsa sign-req client vpnclient1
[...]
Certificate created at: /home/duchess/mypki/pki/issued/vpnclient1.crt
$ easyrsa gen-dh Using SSL: openssl OpenSSL 1.1.1d 10 Sep 2019 Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ...........................................+........... ..........+............................................ [...] DH parameters of size 2048 created at /home/duchess/mypki/pki/dh.pem
$ openvpn --genkey --secret ta.key
| Name | Location | Public | Private |
|---|---|---|---|
~/mypki $ ls */* pki/ca.crt pki/index.txt pki/index.txt.old pki/serial pki/dh.pem pki/index.txt.attr pki/openssl-easyrsa.cnf pki/serial.old pki/extensions.temp pki/index.txt.attr.old pki/safessl-easyrsa.cnf pki/ta.key pki/certs_by_serial: 4954C26DB44106B20F1B9DA17CE515E5.pem DA68CBE53E30923C9BCC3B9F1C5C9011.pem pki/issued: vpnclient1.crt vpnserver1.crt pki/private: ca.key vpnclient1.key vpnserver1.key pki/renewed: certs_by_serial private_by_serial reqs_by_serial pki/reqs: vpnclient1.req vpnserver1.req pki/revoked: certs_by_serial private_by_serial reqs_by_serial
$ openssl x509 -noout -text -in vpnserver1.crt
set_var EASYRSA_DN "org" set_var EASYRSA_REQ_COUNTRY "US" set_var EASYRSA_REQ_PROVINCE "Oregon" set_var EASYRSA_REQ_CITY "Walla Walla" set_var EASYRSA_REQ_ORG "MyCo" set_var EASYRSA_REQ_EMAIL "me@example.com" set_var EASYRSA_REQ_OU "MyOU"
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:myCN
# vpnserver1.conf port 1194 proto udp dev tun user nobody group nobody ca /etc/openvpn/keys/ca.crt cert /etc/openvpn/keys/vpnserver1.crt key /etc/openvpn/keys/vpnserver1.key dh /etc/openvpn/keys/dh.pem tls-auth /etc/openvpn/keys/ta.key 0 server 10.10.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt keepalive 10 120 persist-key persist-tun tls-server remote-cert-tls client status openvpn-status.log verb 4 mute 20 explicit-exit-notify 1
# vpnclient1.conf client dev tun proto udp remote server1 1194 persist-key persist-tun resolv-retry infinite nobind user nobody group nobody tls-client remote-cert-tls server verb 4 ca /etc/openvpn/keys/ca.crt cert /etc/openvpn/keys/vpnclient1.crt key /etc/openvpn/keys/vpnclient1.key tls-auth /etc/openvpn/keys/ta.key 1
$ sudo systemctl stop openvpn@.openvpn1.service
$ sudo openvpn /etc/openvpn/vpnserver1.conf Tue Feb 16 16:50:49 2021 us=265445 Current Parameter Settings: Tue Feb 16 16:50:49 2021 us=265481 config = '/etc/openvpn/vpnserver1.conf' [...] Tue Feb 16 16:50:49 2021 us=270212 Initialization Sequence Completed
$ sudo openvpn /etc/openvpn/vpnclient1.conf Tue Feb 16 16:56:22 2021 OpenVPN 2.4.3 x86_64-suse-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jun 20 2017 Tue Feb 16 16:56:22 2021 library versions: OpenSSL 1.1.1d 10 Sep 2019, LZO 2.10 Enter Private Key Password: ******* [...] Tue Feb 16 16:56:26 2021 Initialization Sequence Completed
$ sudo systemctl enable openvpn@austin Created symlink /etc/systemd/system/multi-user.target.wants/openvpn@austin.service → /usr/lib/systemd/system/openvpn@.service. Created symlink /etc/systemd/system/openvpn.target.wants/openvpn@austin.service → /usr/lib/systemd/system/openvpn@.service.
#vpnclient1.ovpn client dev tun proto udp remote server2 1194 persist-key persist-tun resolv-retry infinite nobind user nobody group nobody tls-client remote-cert-tls server verb 4 # ca.crt <ca> -----BEGIN CERTIFICATE----- MIIDSDCCAjCgAwIBAgIUD2UxdEwgvhhr0zq5fAxIDIueB2EwDQYJKoZIhvcNAQEL BQAwFTETMBEGA1UEAwwKdnBuc2VydmVyMTAeFw0yMTAyMjExODU1MjNaFw0zMTAy MTkxODU1MjNaMBUxEzARBgNVBAMMCnZwbnNlcnZlcjEwggEiMA0GCSqGSIb3DQEB AQUAA4IBDwAwggEKAoIBAQDpQJo+Izt8v0zriSWwrChc1tnVj3E3h3XuyEHub7hj y4bMu2PqKByFNr+iikEF3u0d6HrCRSDKt1BcLzL3TsTJ/hJBHAlTyqEgVce1knjL 2g9NnDbekRtJSJCxS9j+RWtP43Xdg5edb5hTCZqdNFHD8oNuSMGFBbHN4oi9eDXl rvyVHJe+UkI1Ow6mW0+ln/IoKNFPovz+l+ds3fJ5+UHe2TaQPQc7tGZ33j7wfJQd es8baFdK+lnmGdUOrW9BQE6ReMSezkz6dKdIZdy7jEs6xoflOzyWlgydmnkAvLnx MBQDgDUbc5MuooVMAWa4yhtz0B9ZmdJDb8jzHDpTPqdRAgMBAAGjgY8wgYwwHQYD VR0OBBYEFF8KPhl1xxV0110JiBs5iUEPoJ1IMFAGA1UdIwRJMEeAFF8KPhl1xxV0 110JiBs5iUEPoJ1IoRmkFzAVMRMwEQYDVQQDDAp2cG5zZXJ2ZXIxghQPZTF0TCC+ GGvTOrl8DEgMi54HYTAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjANBgkqhkiG 9w0BAQsFAAOCAQEAMnRLz3CBApSrjfUKsWYioNGQGvh77Smh/1hPGIu4eEldQSmZ Aj7qclEaORdBxmqrVtA3Z9cX1L0xFrg14nLyddmuWHG3ZChc5ZMpYtD2YpOH265B FFjDp96vK13dpixWKrVpvakLCCA4EvnC8CEjbm0oNFiCgSwKAoJFCcUzwC33swsU B2w5/iT6CZKuKhSmET1IDpG8krGC/Ib2GNAS0szMI94P0ajZgVznMcXOJ7gUg4rM sEB8OzM6GBEZTqbAa9uVMZnOZvZA5jGIbBuelUo0bqGdAyx2B68zzuL//qvsHsvw kZCyKIaXH0NBV7vexMKWcwFLLBzWizFQbbFpFA== -----END CERTIFICATE----- </ca> # vpnclient1.cert <cert> -----BEGIN CERTIFICATE----- MIIDVjCCAj6gAwIBAgIQLhO4FTrqN5WZiQETULAwnzANBgkqhkiG9w0BAQsFADAV MRMwEQYDVQQDDAp2cG5zZXJ2ZXIxMB4XDTIxMDIyMTE4NTYzM1oXDTI0MDIwNjE4 NTYzM1owFTETMBEGA1UEAwwKdnBuY2xpZW50MTCCASIwDQYJKoZIhvcNAQEBBQAD ggEPADCCAQoCggEBALUFYXwk6JW/hRtoMs0Ug5jMcWXsjMUsCz8L8CeXNOs3wQrf YBWF1TYCLPd2/vwXsvbqCE85IZwjsJ5mEx9YgQ5M1teDkLZqBn8y7VIyDAAU8RsN NcrnpeMDV0LgZIBeUrHi4ZTooaw4FdJ5BBYRHR1APVaaHDWx59ohJuBDpriWhvWk lWX0rpSJltXriIOCzky/yEwfw6ah5jWaTgfe41fXq8j3lx2IbgIL7I4//jhC6JYz N7huTdT2uB2MUbYX0XWBffMG8wcBZtMI2XryZmPvFYWP7N5nZZsBXkLz/UngAu3k jkYJOnJy/hdOFLN/yXj7VFydmivUSeekdjjxyAECAwEAAaOBoTCBnjAJBgNVHRME AjAAMB0GA1UdDgQWBBSnLIQoTPLyECbJHfgYBHvQpcmfgzBQBgNVHSMESTBHgBRf Cj4ZdccVdNddCYgbOYlBD6CdSKEZpBcwFTETMBEGA1UEAwwKdnBuc2VydmVyMYIU D2UxdEwgvhhr0zq5fAxIDIueB2EwEwYDVR0lBAwwCgYIKwYBBQUHAwIwCwYDVR0P BAQDAgeAMA0GCSqGSIb3DQEBCwUAA4IBAQBaBpYZXVYUzOcXOVSaijmOZAIVBTeJ meQz9xBQjqDXaRvypWlQ1gQtO8WnK9ruafc1g/h7LtvqtiALnGiJ0NbshkH8C1KE yen46UCau5B/Xi0gA7FoPildvYdKSn/jI6KySCsplubjnJK9H/6DjAcEuqFLcsaY 5vpKQGP9Vl7H7hEVs4f1aory1T4Ma/bdXEOqgzHmIARLmxYeJm90sUT/n7e7VXfy fILZ+8D1fMxCbeQRBkg1e8wJfgEbMRY9aGGt1qAs9gkm9RPelGB18v4iCbyebv3X 4hVHmfjcixdbWiABC7yq/gisooQ0robW/92dgemcwO0awHZX+opNBgwr -----END CERTIFICATE----- </cert> # vpnclient1.key <key> -----BEGIN ENCRYPTED PRIVATE KEY----- MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQInjFvz5a4mY8CAggA MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECNsxQXxvMpN0BIIEyEZdgFwPnGup vyhywXR6l6ihvHK2GRczIgH0mFIiwQDgDjZj2YsEnvSA/P3MHplkU/bgv9DJ5j2T C5wPDmGN4yG1boHx9BQKbXqxGwdz/UcHwmNKur9qnSFrSVEvMDwvum+rmzWuKykf gkKKBCT1JZ2DWKtjjDNYG9qhBn3S2zYVq311dDuLbBcruvo1UL031sDDYWTpVuuf zZc0ozng0Nzb35bNkG6Ib+LYLzJi4stxzw0DTFl52lKv++R6xhmqb81IJE3vBs4H DOutkYfifO1eGqEKksPQRl8n03UVkOtB5pH8VdQeLqEBBaq3qeIfU6FkH9XrPR/E 8VOg9BNpbyuUW7bQu0MzuJ8Ofkjy9K+HHdwFtGPyOatkeaXT/qcKVMvzWcbr8bPc VncavzXdzo0Sb8FigsKYU1lNjgo00Phd3m0AOfptrweK6ucBds5SmqNrUFXiQ2JA Ms3LUw4CXBBgvdu5TsA2xLGysip0RPKLyTnUPGnXxbBaaHMv8Jz3XRCrWgZbtAE3 XhE9fKw+ZMEP+2jpC/1mjN/N9VuJfYZEhgA84wzYMu6pt3zPkWZqR6yGTDFEDhvh OAZYEpqrhe++nxDpuQlpCCl4IndSg9L9oX1ydrvPNHGbRVztd3+r9wr4Ub3fJ1g/ 9ckCdanohEymKbjw34HEMmdx+fn5k2T9bLnl8fsYtcESkg04ChON3yOnZFKl6chT BQ9X2Qmeg7FoawWiUY5o+7OHNKL7QpRt4jXPbXNuXFK9EYvuRzUqubLhL5DdmjuO Se1vvZg7fT4C8qjYsoCa18idA00EN3ePFFf9AssHCoVW92GiUTTKG+qURCjtNtG6 dnPvxiSf98OBkkjeX3ni0cKdfMGoQTSdEy5GexvfRMF5HJrGO+CWXmqSBsuIlPUe quqCsPmpaT2Ws/0UU9cKe4qaKjTL7CghtFmUEhH7t6Cd41Ki9gKi33j3541l9w7l J1bgca4rRUCecp2BPF3IjJc/RnTvHkbUK4mDX9s8xJhYf9WE6JYsk3NBSNNIj/9G FMJlo71x8H3OAdFzRN5bjV797HByZ+YidZIgGAx2dSko3PQPy7RSxdmzFbxfUvzj 9jcYEu+V9unbtDK2qZ9I+LqXGE+EXjPBui40IWp8XIYNlSLn2qgroH079lXhXKBY +DzcBzyT7GTX2QeYE+yqqPRIFWHnbnsnD6dMnAa46h+Si+f5sq33rfRsF7UpK4gV IhzFkncCM47/Taqi0OY04Q40LuSCDjmjFL+VzZOsAtWGRNYNzIgniThEehElJwfI ErzClcVptjhtCer8BPuO7YaMIHk1hKecHFqw3RrimWzroL1iu9Q29m2oM+bVc6mD we6r+t8JbaAFxoHBK4i6M0rcdJPICxDTIOjPC3Fg/MeqiCi7F0DFZvXwPGRD+0Of MBnsDplEUjK06jbE5BjGQ7n7P+dwDxyp/aVO4CfX7ZOco6h9r3b6nqlzPVNE9erw kS7WwT/TWraw/sfIO9sNSgle7PoRh2s/w/oGVhC6ymlMdXe+mhMzHFnGEbBRh2Rd kd/EdYNubHg0k9+RLTwbgwZ+176cIJyOpqaoJGv0bsKM8X26Pk/fkyF6xgdQYQOx 8i9Whea8OjUOQAcgc7gUyA== -----END ENCRYPTED PRIVATE KEY----- </key> # ta.key <tls-auth> -----BEGIN OpenVPN Static key V1----- 4eb35b44d1d8a82cfa51af394d4f58f3 69bf8fe8c0a0a032f38b0ee104889628 8a5dc89486736b39d64ad3c6831bf9ba 9f3f96c3307d322a5bf055b9bc3bfa74 929faf361c14de97445f5927794264bb e3f71c925f2236cfb0109ecfd6406cef 857dfb39783a09ecd56d3cf09ebbc853 0f43b1c787f0db99dbecabcd2090cfbb 54c86d8102a5430fd6a7f37ab5ce8ed9 f6bec8984bde4267f78913ff702dd396 a205b6be9e7ab41cf1ebad3953c27c7c f3b435345e02aede049ef7c9f1c2704f 2ed91110ccb19d0d3bd46a00f54c73e2 07b31160cdc54c3f5a7989bb999ac5f3 89c6de7e79fc93399924a8d298eab462 231234e690c319d5cbd832788f0dbcfb -----END OpenVPN Static key V1----- </tls-auth>
tls-version-min 1.2 tls-version-max 1.3 or-highest
AES-128-GCM ncp-disable
# TLS 1.3 tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 # TLS 1.2 tls-cipher TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256:TLS-ECDHE-RSA- WITH-CHACHA20-POLY1305-SHA256:TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256: TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256
dh none ecdh-curve secp384r1 # use tls-server on the server, tls-client on the client tls-server
# vpnserver1.conf port 1194 proto udp dev tun user nobody group nobody ca /etc/openvpn/keys/ca.crt cert /etc/openvpn/keys/vpnserver1.crt key /etc/openvpn/keys/vpnserver1.key server 10.10.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt keepalive 10 120 persist-key persist-tun tls-server remote-cert-tls client verify-client-cert require tls-cert-profile preferred tls-version-min 1.2 tls-version-max 1.3 or-highest float opt-verify AES-128-GCM ncp-disable dh none ecdh-curve secp384r1 # TLS 1.3 tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 # TLS 1.2 tls-cipher TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256:TLS-ECDHE-RSA- WITH-CHACHA20-POLY1305-SHA256:TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256: TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 status openvpn-status.log verb 4 mute 20 explicit-exit-notify 1
# vpnclient1.conf client dev tun proto udp remote server1 1194 persist-key persist-tun resolv-retry infinite nobind user nobody group nobody tls-client remote-cert-tls server verb 4 # Using inline keys # ca.crt <ca> [...] </ca> # client.crt <cert> [...] </cert> # client.key <key> [...] </key> tls-version-min 1.2 tls-version-max 1.3 or-highest AES-128-GCM ncp-disable dh none ecdh-curve secp384r1 # TLS 1.3 encryption settings tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 # TLS 1.2 encryption settings tls-cipher TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256:TLS-ECDHE-RSA-WITH- CHACHA20-POLY1305-SHA256:TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256:TLS-ECDHE-RSA- WITH-AES-128-GCM-SHA256 status openvpn-status.log verb 4 mute 20 explicit-exit-notify 1
$ sudo netstat -untap | sed '2p;/ssh/!d' Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1296/sshd: /usr/sbi tcp6 0 0 :::22 :::* LISTEN 1296/sshd: /usr/sbi
$ sudo netstat -untap | sed '2p;/ssh/!d' Proto Local Address Foreign Address State PID/Program name tcp 0.0.0.0:22 0.0.0.0:* LISTEN 1296/sshd: /usr/sbi tcp 192.168.1.97:22 192.168.1.91:56142 ESTABLISHED 13784/sshd: duchess tcp6 :::22 :::* LISTEN 1296/sshd: /usr/sbi
$ sudo netstat -untap Proto Local Address Foreign Address State PID/Program name [...] tcp 192.168.43.234:50586 72.21.91.66:443 ESTABLISHED 2798/firefox tcp 192.168.43.234:38262 52.36.174.147:443 ESTABLISHED 6481/chrome tcp 192.168.43.234:53232 99.86.33.45:443 ESTABLISHED 2798/firefox [...]
$ systemctl status nftables.service
● nftables.service - Netfilter Tables
Loaded: loaded (/usr/lib/systemd/system/nftables.service; disabled; vendor>
Active: active (exited) since Sat 2020-10-17 13:15:05 PDT; 4s ago
Docs: man:nft(8)
Process: 3276 ExecStart=/sbin/nft -f /etc/sysconfig/nftables.conf (code=exi>
Main PID: 3276 (code=exited, status=0/SUCCESS)
[...]
$ systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor>
Active: active (running) since Sat 2020-10-17 12:36:20 PDT; 37min ago
Docs: man:firewalld(1)
Main PID: 775 (firewalld)
Tasks: 2 (limit: 4665)
Memory: 40.9M
[...]
$ systemctl status ufw.service
● ufw.service - Uncomplicated firewall
Loaded: loaded (/lib/systemd/system/ufw.service; disabled; vendor preset:
enabled)
Active: inactive (dead)
Docs: man:ufw(8)
$ sudo systemctl stop ufw.service $ sudo systemctl mask ufw.service
$ sudo systemctl stop nftables.service $ sudo systemctl mask nftables.service
$ nmcli device status DEVICE TYPE STATE CONNECTION wlan0 wifi connected ACCESS_POINTE $ nmcli connection down ACCESS_POINTE Connection 'ACCESS_POINTE' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
$ nmcli connection up ACCESS_POINTE Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
$ sudo firewall-cmd --version 0.9.3
FirewallBackend=nftables
FirewallBackend=iptables
$ firewall-cmd --get-default-zone public
$ firewall-cmd --get-zones block dmz drop external home internal public trusted work
$ firewall-cmd --get-active-zones internal interfaces: eth1 work interfaces: wlan0
$ sudo firewall-cmd --zone=public --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ipp ipp-client mdns ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
$ sudo firewall-cmd --list-all-zones [...]
$ sudo firewall-cmd --get-services RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bb bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc bittorrent-lsd ceph ceph-mon cfengine cockpit condor-collector ctdb dhcp dhcpv6 [...]
$ sudo firewall-cmd --get-services| xargs -n1 RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd [...]
$ sudo firewall-cmd --info-service bittorrent-lsd bittorrent-lsd ports: 6771/udp protocols: source-ports: modules: destination: ipv4:239.192.152.143 ipv6:ff15::efc0:988f includes: helpers:
$ sudo firewall-cmd --info-service ceph-mon ceph-mon ports: 3300/tcp 6789/tcp [...]
$ sudo firewall-cmd --zone=work --list-all work target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
$ sudo firewall-cmd --zone=work --permanent --change-interface=eth0 success $ sudo firewall-cmd --zone=work --list-interfaces eth0
$ sudo firewall-cmd --runtime-to-permanent
$ firewall-cmd --get-default-zone internal
$ sudo firewall-cmd --set-default-zone drop success
$ firewall-cmd --zone=internal --list-all internal target: default icmp-block-inversion: no interfaces: sources: services: ssh mdns samba-client dhcpv6-client [...]
$ sudo firewall-cmd --remove-service=samba-client --zone=internal success
$ sudo firewall-cmd --zone=internal --add-service=ldaps success
$ sudo firewall-cmd --runtime-to-permanent success
$ sudo firewall-cmd --reload success
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Name Services</short>
<description>
DNS and DHCP servers for the local network, IPv4 only.
</description>
<service name="dns"/>
<service name="dhcp"/>
<service name="ssh"/>
</zone>
$ sudo firewall-cmd --permanent --get-zones block dmz drop external home internal names public trusted work
$ sudo firewall-cmd --reload success
$ sudo firewall-cmd --get-zones block dmz drop external home internal names public trusted work
$ sudo firewall-cmd --zone=names --list-all names target: default icmp-block-inversion: no interfaces: sources: services: dhcp dns ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
$ sudo firewall-cmd --zone=work --remove-port=22/tcp success $ sudo firewall-cmd --zone=work --add-port=2022/tcp success
$ sudo firewall-cmd --list-all --zone=work work target: default icmp-block-inversion: no interfaces: sources: services: ssh ports:2022/tcp [...]
$ sudo firewall-cmd --runtime-to-permanent
$ ssh -p 2022 server1
$ sudo firewall-cmd --zone=internal \ --add-rich-rule='rule family="ipv4" source address=192.168.1.91 reject' success
$ sudo firewall-cmd --runtime-to-permanent
$ sudo firewall-cmd --zone=internal --list-rich-rules rule family='ipv4' source address='192.168.1.91' reject
$ sudo firewall-cmd --zone=internal \
--remove-rich-rule="rule family='ipv4' \
source address='192.168.1.91' reject"
success
$ sudo firewall-cmd --zone=internal --add-rich-rule='rule family="ipv4" \ source address=192.168.1.91 service name="ssh" protocol=tcp reject' success
$ sudo firewall-cmd --zone=internal --list-all internal target: ACCEPT [...]
$ sudo firewall-cmd --permanent --zone=internal --set-target=REJECT success $ sudo firewall-cmd --reload $ firewall-cmd --zone=names --list-all names target: %%REJECT%% [...]
$ avahi-browse -rt _ipp._tcp [...] txt = ["mopria-certified=1.3" [...]
# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules... # This cannot contain the Group value for security reasons... SystemGroup root
SystemGroup root duchess
$ sudo systemctl restart cups.service
$ sudo groupadd -r cupsadmin $ sudo usermod -aG cupsadmin madmax
SystemGroup root duchess cupsadmin
# Default user and group for filters/backends/helper programs; this cannot be # any user or group that resolves to ID 0 for security reasons... #User lp #Group lp
$ sudo /etc/init.d/cups restart
$ sudo systemctl restart cups.service
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback 192.168.43.81 host1 192.168.43.82 host2 192.168.43.83 host3
host3:~$ ping -c2 host2 PING host2 (192.168.43.82) 56(84) bytes of data. 64 bytes from host2 (192.168.43.82): icmp_seq=1 ttl=64 time=3.00 ms 64 bytes from host2 (192.168.43.82): icmp_seq=2 ttl=64 time=3.81 ms --- host2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 3.001/3.403/3.806/0.402 ms
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback 192.168.43.81 host1.sqr3l.nut host1 192.168.43.82 host2.sqr3l.nut host2 192.168.43.83 host3.sqr3l.nut host3
$ ip addr show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
$ hostname host1
$ hostname -f host1.sqr3l.nut
$ hostname -d sqr3l.nut
192.168.10.15 dev.stashcat.com
12.34.56.78 badsite.com 12.34.56.78 www.badsite.com
hosts: files mdns4_minimal [NOTFOUND=return] dns mymachines
$ sudo nmap --open 192.168.1.0/24 Starting Nmap 7.70 ( https://nmap.org ) at 2021-05-23 13:25 PDT [...] Nmap scan report for dns-server.sqr3l.nut (192.168.1.10) Host is up (0.12s latency). Not shown: 998 filtered ports Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE 22/tcp open ssh 53/tcp open domain [...] Nmap done: 256 IP addresses (3 hosts up) scanned in 81.38 seconds
$ sudo nmap -sU -p 53,67 192.168.1.0/24 Starting Nmap 7.80 ( https://nmap.org ) at 2021-05-27 18:05 PDT Nmap scan report for dns-server.sqr3l.nut (192.168.1.10) Host is up (0.085s latency). PORT STATE SERVICE 53/udp open domain 67/udp open|filtered dhcps Nmap done: 256 IP addresses (3 hosts up) scanned in 13.85 seconds
$ sudo nmap -sU -sT 192.168.1.0/24
$ systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor
preset: enabled)
Active: active (running) since Mon 2021-05-24 05:49:36 PDT; 6h ago
[...]
$ sudo systemctl stop dnsmasq.service
$ nmcli connection show --active NAME UUID TYPE DEVICE 1local 3e348c97-4c5f-4bbf-967e wifi wlan1 1wired 0460d735-e14d-3c3f-92c0 ethernet eth1
$ nmcli con mod "1wired" \ ipv4.addresses "192.168.1.30/24" \ ipv4.gateway "192.168.1.1" \ ipv4.method "manual"
$ sudo systemctl restart NetworkManager.service
$ systemctl status systemd-resolved.service
$ systemctl status systemd-resolved.service
● systemd-resolved.service - Network Name Resolution
Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled;
vendor preset: enabled)
Active: active (running) since Sat 2021-05-22 12:57:34 PDT; 1min 21s ago
[...]
$ sudo systemctl stop systemd-resolved.service $ sudo systemctl disable systemd-resolved.service
$ ls -l /etc/resolv.conf lrwxrwxrwx 1 root root 39 May 21 20:38 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
$ sudo rm /etc/resolv.conf $ sudo touch /etc/resolv.conf
$ sudo nano /etc/NetworkManager/NetworkManager.conf [main] dns=none
search sqr3l.nut nameserver 127.0.0.1 nameserver ::1
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback 192.168.43.81 dns-server 192.168.43.82 backups 192.168.43.83 https
$ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf-old $ sudo nano /etc/dnsmasq.conf
# global options resolv-file=/etc/resolv.conf domain-needed bogus-priv expand-hosts domain=sqr3l.nut local=/sqr3l.nut/ listen-address=127.0.0.1 listen-address=192.168.43.81 # upstream name servers server=208.67.222.222 server=208.67.220.220
$ dnsmasq --test dnsmasq: syntax check OK.
$ sudo systemctl start dnsmasq.service
$ systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset:
enabled)
Active: active (running) since Mon 2021-05-24 17:13:48 PDT; 1min 0s ago
Process: 11023 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited,
status=0/SUCCESS)
Process: 11024 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited,
status=0/SUCCESS)
Process: 11033 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
(code=exited, status=0/SUCCESS)
Main PID: 11032 (dnsmasq)
Tasks: 1 (limit: 18759)
Memory: 2.5M
CGroup: /system.slice/dnsmasq.service
└─11032 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7
/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local->
May 24 17:13:48 dns-server systemd[1]: Starting dnsmasq - A lightweight DHCP and
caching DNS server...
May 24 17:13:48 dns-server dnsmasq[11023]: dnsmasq: syntax check OK.
May 24 17:13:48 dns-server systemd[1]: Started dnsmasq - A lightweight DHCP and
caching DNS server.
$ nslookup dns-server Server: 127.0.0.1 Address: 127.0.0.1#53 Name: dns-server Address: 192.168.43.81 $ nslookup dns-server.sqr3l.nut Server: 127.0.0.1 Address: 127.0.0.1#53 Name: dns-server.sqr3l.nut Address: 192.168.43.81 $ nslookup 192.168.43.81 18.43.168.192.in-addr.arpa name = host1.sqr3l.nut.
$ sudo ss -lp "sport = :domain"
Netid State Local Address:Port Process
udp UNCONN 127.0.0.1:domain users:(("dnsmasq",pid=1531,fd=8))
udp UNCONN 192.168.1.10:domain users:(("dnsmasq",pid=1531,fd=6))
tcp LISTEN 127.0.0.1:domain users:(("dnsmasq",pid=1531,fd=9))
tcp LISTEN 192.168.1.10:domain users:(("dnsmasq",pid=1531,fd=7))
$ sudo firewall-cmd --permanent --add-service=\{dns,dhcp\}
$ dig @192.168.1.10 oreilly.com ; <<>> DiG 9.16.6 <<>> @192.168.1.10 oreilly.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29387 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;oreilly.com. IN A ;; ANSWER SECTION: oreilly.com. 240 IN A 199.27.145.65 oreilly.com. 240 IN A 199.27.145.64 ;; Query time: 108 msec ;; SERVER: 192.168.1.10#53(192.168.1.10) ;; WHEN: Mon May 24 17:49:32 PDT 2021 ;; MSG SIZE rcvd: 72
$ dig @dns-server oreilly.com $ dig @dns-server.sqr3l.nut oreilly.com
# DHCP range dhcp-range=192.168.1.25,192.168.1.75,12h dhcp-lease-max=25
$ sudo systemctl restart dnsmasq.service
$ nmcli con show --active NAME UUID TYPE DEVICE 1net de7c00e7-8e4d-45e6-acaf ethernet eth0 $ nmcli con show 1net | grep ipv..method ipv4.method: auto ipv6.method: auto
$ sudo nmcli con down 1net Connection '1net' successfully deactivated (D-Bus active path: /org/freedesktop/ NetworkManager/ActiveConnection/11 $ sudo nmcli con up 1net Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMan ager/ActiveConnection/15)
$ journalctl -ru dnsmasq -- Logs begin at Sun 2021-02-28 14:35:01 PST, end at Mon 2021-05-31 17:36:04 PDT. -- May 31 17:34:56 dns-server dnsmasq-dhcp[8080]: DHCPACK(eth0) 192.168.1.45 9c:ef:d5:fe:01:7c client2 May 31 17:34:56 dns-server dnsmasq-dhcp[8080]: DHCPREQUEST(eth0) 192.168.1.45 9c:ef:d5:fe:01:7c
$ sudo dhclient -v Internet Systems Consortium DHCP Client 4.3.6-P1 Copyright 2004-2018 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/eth0/9c:ef:d5:fe:01:7c Sending on LPF/eth0/9c:ef:d5:fe:01:7c Sending on Socket/fallback DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0xec8923) DHCPACK from 192.168.1.10 (xid=0xec8923) bound to 192.168.1.27 -- renewal in 1415 seconds.
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.10
dhcp-option=42,192.168.1.11
$ dnsmasq --help dhcp Known DHCP options: 1 netmask 2 time-offset 3 router 6 dns-server 7 log-server 9 lpr-server [...]
dhcp-range=zone1,192.168.50.20,192.168.50.120 dhcp-range=zone2,192.168.60.20,192.168.60.50,24h
dhcp-option=zone1,3,192.168.50.1 dhcp-option=zone2,3,192.168.60.2
dhcp-option=zone1,6,192.168.1.10 dhcp-option=zone2,6,192.168.1.10
dhcp-option=zone2,42,192.168.60.15
option default-url string;
The format and meaning of this option is not described in any standards document, but is claimed to be in use by Apple Computer. It is not known what clients may reasonably do if supplied with this option. Use at your own risk.
man 5 DHCP options
dhcp-host=server2,192.168.3.45
send host-name = gethostname();
send host-name = myhostname
$ nmcli connection show --active NAME UUID TYPE DEVICE wifi1 3e348c97-4c5f-4bbf-967e-7624f3e1e4f0 wifi wlan1
$ nmcli connection show wifi1 | grep send-hostname ipv4.dhcp-send-hostname: yes ipv6.dhcp-send-hostname: yes
$ sudo nmcli con mod wifi1 ipv4.dhcp-send-hostname yes $ sudo nmcli con mod wifi1 ipv6.dhcp-send-hostname yes $ sudo nmcli con reload
/var/log/dnsmasq/dnsmasq.log {
missingok
compress
notifempty
rotate 4
weekly
create
}
$ sudo /etc/logrotate.conf --debug [...] rotating pattern: /var/log/dnsmasq/dnssmasq.log weekly (4 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 considering log /var/log/dnsmasq/dnssmasq.log Creating new state Now: 2021-06-01 13:08 Last rotated at 2021-06-01 13:00 log does not need rotating (log has been already rotated) switching euid to 0 and egid to 0 [...]
address=/wildcard.net/192.168.1.35
$ sudo systemctl restart dnsmasq.service $ nslookup foo.wildcard.net Server: 127.0.0.1 Address: 127.0.0.1#53 Name: foo.wildcard.net Address: 192.168.1.35
$ ps ax|grep -w ntp $ ps ax|grep -w chrony $ ps ax|grep -w timesyncd
$ timedatectl status
Local time: Sun 2020-10-04 10:59:48 PDT
Universal time: Sun 2020-10-04 17:59:48 UTC
RTC time: Sun 2020-10-04 17:59:48
Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: no
systemd-timesyncd.service active: no
RTC in local TZ: no
$ systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled;
vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-timesyncd.service(8)
$ systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service;
disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-timesyncd.service(8)
$ timedatectl set-ntp true
$ systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled;
vendor preset: enabled)
Active: active (running) since Sun 2020-10-04 18:17:51 PDT; 16min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 3990 (systemd-timesyn)
Status: "Synchronized to time server 91.189.89.198:123 (ntp.ubuntu.com)."
Tasks: 2 (limit: 4915)
CGroup: /system.slice/systemd-timesyncd.service
└─3990 /lib/systemd/systemd-timesyncd
Oct 04 18:17:51 pc systemd[1]: Starting Network Time Synchronization...
Oct 04 18:17:51 pc systemd[1]: Started Network Time Synchronization.
Oct 04 18:33:01 pc systemd-timesyncd[3990]: Synchronized to time server
91.189.89.198:123 (ntp.ubuntu.com).
$ sudo systemctl start systemd-timesyncd
$ timedatectl status
Local time: Sun 2020-10-04 18:35:56 PDT
Universal time: Mon 2020-10-05 01:35:56 UTC
RTC time: Mon 2020-10-05 01:35:56
Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
[Time] NTP=0.north-america.pool.ntp.org 1.north-america.pool.ntp.org 2.north-america.pool.ntp.org #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048
0.opensuse.pool.ntp.org 1.opensuse.pool.ntp.org 2.opensuse.pool.ntp.org
$ timedatectl set-time "2020-10-04 19:30:00" Failed to set time: Automatic time synchronization is enabled
$ sudo systemctl stop systemd-timesyncd
$ timedatectl set-ntp false
$ timedatectl set-time "2020-10-04 19:30:00"
$ timedatectl status
Local time: Sun 2020-10-04 19:30:06 PDT
Universal time: Mon 2020-10-05 02:30:06 UTC
RTC time: Mon 2020-10-05 02:30:06
Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: no
systemd-timesyncd.service active: no
RTC in local TZ: no
$ sudo systemctl disable systemd-timesyncd $ sudo systemctl stop systemd-timesyncd
$ chronyc activity 200 OK 8 sources online 0 sources offline 0 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address
pool 0.ubuntu.pool.ntp.org iburst pool 1.ubuntu.pool.ntp.org iburst pool 1.ubuntu.pool.ntp.org iburst server ntp.domain.lan iburst prefer
pool 0.ubuntu.pool.ntp.org iburst pool 1.ubuntu.pool.ntp.org iburst pool 0.north-america.pool.ntp.org iburst pool 1.north-america.pool.ntp.org iburst server ntp.domain.lan iburst prefer
pool 0.north-america.pool.ntp.org iburst pool 1.north-america.pool.ntp.org iburst pool 2.north-america.pool.ntp.org iburst local stratum 10 allow 192.168.0.0/16 allow 2001:db8::/56 driftfile /var/lib/chrony/chrony.drift maxupdateskew 100.0 rtcsync logdir /var/log/chrony log measurements statistics tracking leapsectz right/UTC makestep 1 3
server ntp.domain.lan iburst prefer
server ntp.domain.lan iburst prefer pool 1.north-america.pool.ntp.org iburst pool 2.north-america.pool.ntp.org iburst
$ chronyc tracking Reference ID : A29FC87B (time.cloudflare.com) Stratum : 4 Ref time (UTC) : Tue Oct 06 02:20:23 2020 System time : 0.002051390 seconds fast of NTP time Last offset : +0.002320110 seconds RMS offset : 0.017948814 seconds Frequency : 28.890 ppm fast Residual freq : +0.252 ppm Skew : 1.250 ppm Root delay : 0.069674924 seconds Root dispersion : 0.003726898 seconds Update interval : 838.2 seconds Leap status : Normal
$ chronyc sources chronyc sources 210 Number of sources = 19 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^- golem.canonical.com 2 9 0 37m +55ms[ +58ms] +/- 209ms ^- alphyn.canonical.com 2 9 0 34m +23ms[ +25ms] +/- 158ms ^- pugot.canonical.com 2 9 0 44m +92ms[ +80ms] +/- 229ms ^- chilipepper.canonical.com 2 9 11 31 +48ms[ +48ms] +/- 181ms [...]
$ chronyc sources -v 210 Number of sources = 19 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^- golem.canonical.com 2 9 0 46m +67ms[ +58ms] +/- 209ms ^- alphyn.canonical.com 2 9 0 44m +35ms[ +25ms] +/- 158ms ^* pugot.canonical.com 2 9 1 54m +104ms[ +80ms] +/- 229ms ^- chilipepper.canonical.com 2 9 11 587 +60ms[ +48ms] +/- 181ms ^- ntp.wdc1.us.leaseweb.net 2 7 4 327 +26ms[ +15ms] +/- 198ms ^- 216.126.233.109 2 9 1 459 +106ms[ +95ms] +/- 171ms ^- 157.245.170.163 3 9 1 476 +1191us[ -10ms] +/- 145ms
$ ps ax | grep -w ntpd 3754 ? Ssl 0:00 /usr/sbin/ntpd -u ntp:ntp -g
$ systemctl start ntpd
server ntp.domain.lan iburst prefer pool 2.fedora.pool.ntp.org iburst
$ systemctl restart ntpd
$ sudo /etc/init.d/ntp restart
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
2.fedora.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.000
*ntp.domain.lan. 172.16.16.3 2 u 34 256 203 80.324 -49.772 54.508
+138.68.46.177 ( 80.153.195.191 2 u 92 256 123 90.932 -15.534 39.947
+vps6.ctyme.com 216.218.254.202 2 u 453 256 46 69.927 -29.296 84.811
+ec2-3-217-79-24 132.163.97.6 2 u 426 256 202 165.888 -51.442 93.224
driftfile /var/lib/ntp/drift restrict default nomodify notrap nopeer noquery restrict -6 default nomodify notrap nopeer noquery restrict 127.0.0.1 restrict ::1 pool 0.north-america.pool.ntp.org pool 1.north-america.pool.ntp.org pool 2.north-america.pool.ntp.org leapfile /usr/share/zoneinfo/leap-seconds.list statistics clockstats loopstats peerstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable statsdir /var/log/ntpstats/
$ timedatectl | grep -i "time zone"
Time zone: America/Los_Angeles (PDT, -0700)
$ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers [...]
$ timedatectl list-timezones | grep -i berlin Europe/Berlin
$ sudo timedatectl set-timezone Europe/Berlin
$ date Wed Oct 7 08:32:40 PDT 2020
$ ls -l /etc/localtime lrwxrwxrwx 1 root root 41 Oct 7 08:06 /etc/localtime -> ../usr/share/zoneinfo/America/Los_Angeles
$ ls /usr/share/zoneinfo total 324 drwxr-xr-x 2 root root 4096 May 21 23:02 Africa drwxr-xr-x 6 root root 20480 May 21 23:02 America drwxr-xr-x 2 root root 4096 May 21 23:02 Antarctica drwxr-xr-x 2 root root 4096 May 21 23:02 Arctic [...]
$ ls /usr/share/zoneinfo/Europe [...] -rw-r--r-- 1 root root 2637 May 7 17:01 Madrid -rw-r--r-- 1 root root 2629 May 7 17:01 Malta lrwxrwxrwx 1 root root 8 May 7 17:01 Mariehamn -rw-r--r-- 1 root root 1370 May 7 17:01 Minsk [...]
$ sudo ln -sf /usr/share/zoneinfo/Europe/Madrid/etc/localtime
$ php -r 'print_r(timezone_identifiers_list());'
Array
(
[0] => Africa/Abidjan
[1] => Africa/Accra
[2] => Africa/Addis_Ababa
[3] => Africa/Algiers
[4] => Africa/Asmara
[...]
$ vcgencmd measure_temp temp=48.3'C $ vcgencmd measure_temp temp=61.9'C
$ vcgencmd measure_temp temp=52.1'C
$ sudo dpkg -i imager_1.5_amd64.deb
$ sudo apt install rpi-imager
$ sudo unzip -p 2021-03-24-raspios-buster-armhf.zip | \ sudo dd of=/dev/foo bs=4M conv=fsync status=progress
$ unzip NOOBS_lite_v3_5.zip
$ sudo raspi-config
Tip Ring 1 Ring 2 Sleeve Left audio Right audio Ground Video
| value | mode |
|---|---|
| value | ratio |
|---|---|
dtparam=spi=on dtoverlay=enc28j60
RPi ENC28J60 ---------------------------- +3V3 VCC GPIO10 SI GPIO9 SO GPIO11 SCK GND GND GPIO25 INT CE0#/GPIO8 CS
$ ip link show dev eth1
2: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel
state DOWN mode DEFAULT group default qlen 1000
link/ether d0:50:99:82:e7:2b brd ff:ff:ff:ff:ff:ff
$ sudo apt install firewalld firewall-config firewall-applet
$ ip r show default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.43 metric 303 mtu 1500 192.168.1.0/24 dev eth0 proto dhcp scope link src 192.168.1.43 metric 303 mtu 1500cat
# external interface interface eth1 static ip_address=192.168.1.2/24 static routers=192.168.1.1 # internal interface interface eth0 static ip_address=192.168.2.1/24 static routers=192.168.1.1
$ sudo firewall-cmd --zone=external --change-interface=eth1 success pi@raspberrypi:~ $ sudo firewall-cmd --zone=internal --change-interface=eth0 success pi@raspberrypi:~ $ sudo firewall-cmd --get-active-zones external interfaces: eth1 internal interfaces: eth0
$ sudo firewall-cmd --zone=external --list-all external (active) target: default icmp-block-inversion: no interfaces: eth1 sources: services: ssh ports: protocols: masquerade: yes forward-ports: source-ports: icmp-blocks: rich rules: $ sudo firewall-cmd --zone=internal --list-all internal (active) target: default icmp-block-inversion: no interfaces: eth0 wlan0 sources: services: dhcpv6-client mdns samba-client ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
$ sudo firewall-cmd --runtime-to-permanent success
$ cat /proc/sys/net/ipv4/ip_forward 1
# lsblk -f NAME FSTYPE FSVER LABEL UUID SAVAIL FSUSE% MOUNTPOINT loop0 squashfs 4.0 0 100% /run/archiso/sf s/airootfs sda ├─sda1 └─sda2 ntfs 5E363 sdb ├─sdb1 vfat FAT16 BOOT 5E2F-1E75 ├─sdb2 btrfs root 02bfdc9a-b8bb-45ac-95a8 ├─sdb3 xfs home cc8acf0b-529e-473c-b484 └─sdb4 swap 1 7a5519ae-efe6-45e6-b147 sdc iso9660 RESCUE800 2021-03-06-08-53-50-00 └─sdc1 iso9660 RESCUE800 2021-03-06-08-53-50-00 0 100% /run/archiso/ bootmnt
# mkdir /mnt/sdb2 # mount /dev/sdb2 /mnt/sdb2
# chroot /mnt/sdb2/ /bin/bash :/ #
:/ # passwd root New password: Retype new password: passwd: password updated successfully :/ #
[root@systemrescue ~]# systemctl stop iptables.service
[root@systemrescue ~]# passwd root New password: Retype new password: passwd: password updated successfully
$ ssh root@192.168.10.101 ssh root@192.168.1.91 The authenticity of host '192.168.1.91 (192.168.1.91)' can't be established. ECDSA key fingerprint is SHA256:LlUCEngz5NHg98xv. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.1.91' (ECDSA) to the list of known hosts. root@192.168.1.91's password: [root@sysrescue ~]#
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Offending ECDSA key in /home/duchess/.ssh/known_hosts:12 remove with: ssh-keygen -f "/home/duchess/.ssh/known_hosts" -R "192.168.10.101"
# lsblk -f NAME FSTYPE FSVER LABEL UUID SAVAIL FSUSE% MOUNTPOINT loop0 squashfs 4.0 0 100% /run/archiso/sf s/airootfs sda ├─sda1 └─sda2 ntfs 5E363E30363E0993 sdb ├─sdb1 vfat FAT16 BOOT 5E2F-1E75 ├─sdb2 btrfs root 02bfdc9a-b8bb-45ac-95a8 ├─sdb3 xfs home cc8acf0b-529e-473c-b484 └─sdb4 swap 1 7a5519ae-efe6-45e6-b147 sdc iso9660 RESCUE800 2021-03-06-08-53-50-00 └─sdc1 iso9660 RESCUE800 2021-03-06-08-53-50-00 0 100% /run/archiso/b ootmnt sr0
# mkdir /mnt/sdb3 # mount /dev/sdb3 /mnt/sda3 # ls /mnt/sdb3 bin dev home lib64 media opt root sbin sys usr boot etc lib lost+found mnt proc run srv tmp var # scp -r /mnt/sdb3/home/ duchess@pc:
# cd /mnt/sdb3/home/ # scp -r file1.txt directory1 file2.txt duchess@pc:rescue/
# mkdir /mnt/remote # sshfs duchess@pc:rescue/ /mnt/remote/ # ls /mnt/remote rescue
# ssh duchess@pc duchess@pc's password: duchess@pc:~$ mkdir remote
# mkdir /mnt/linux # mount /dev/sda2 /mnt/linux # mount -o bind /proc /mnt/linux/proc # mount -o bind /dev /mnt/linux/dev # mount -o bind /sys /mnt/linux/dev
# chroot /mnt/linux /bin/bash :/ #
:/ # mount /dev/sda1 /boot/
:/ # grub-install /dev/sda
# mkdir /mnt/windows # mount /dev/sda2
# cd /mnt/windows/Windows/System32/config # chntpw -l SAM chntpw version 1.00 140201, (c) Petter N Hagen Hive <SAM> name (from header): <\SystemRoot\System32\Config\SAM> ROOT KEY at offset: 0x001020 * Subkey indexing type is: 686c <lh> File size 65536 [10000] bytes, containing 7 pages (+ 1 headerpage) Used for data: 318/31864 blocks/bytes, unused: 29/12968 blocks/bytes. | RID -|---------- Username ------------| Admin? |- Lock? --| | 01f4 | Administrator | ADMIN | | | 03e9 | duchess | ADMIN | | | 01f7 | DefaultAccount | | dis/lock | | 01f5 | Guest | | dis/lock | | 01f8 | WDAGUtilityAccount | | dis/lock |
# chntpw -u Administrator SAM chntpw version 1.00 140201, (c) Petter N Hagen Hive <SAM> name (from header): <\SystemRoot\System32\Config\SAM> ROOT KEY at offset: 0x001020 * Subkey indexing type is: 686c <lh> File size 65536 [10000] bytes, containing 9 pages (+ 1 headerpage) Used for data: 321/33816 blocks/bytes, unused: 34/27336 blocks/bytes. ================= USER EDIT ==================== RID : 0500 [01f4] Username: Administrator fullname: comment : Built-in account for administering the computer/domain homedir : 00000220 = Administrators (which has 2 members) Account bits: 0x0210 = [ ] Disabled | [ ] Homedir req. | [ ] Passwd not req. | [ ] Temp. duplicate | [X] Normal account | [ ] NMS account | [ ] Domain trust ac | [ ] Wks trust act. | [ ] Srv trust act | [X] Pwd don't expir | [ ] Auto lockout | [ ] (unknown 0x08) | [ ] (unknown 0x10) | [ ] (unknown 0x20) | [ ] (unknown 0x40) | Failed login count: 0, while max tries is: 0 Total login count: 5 - - - - User Edit Menu: 1 - Clear (blank) user password 2 - Unlock and enable user account [probably locked now] 3 - Promote user (make user an administrator) 4 - Add user to a group 5 - Remove user from a group q - Quit editing user, back to user select Select: [q] ^
Select: [q] ^ 1 Password cleared! [...]
# ddrescue -f -n /dev/sdb1 /dev/sdc1 ddlogfile
GNU ddrescue 1.25
Press Ctrl-C to interrupt
ipos: 100177 MB, non-trimmed: 0 B current rate: 207 MB/s
opos: 100177 MB, non-scraped: 0 B average rate: 83686 kB/s
non-tried: 47868 MB, bad-sector: 0 B, error rate: 0 B/s
rescued: 100177 MB, bad areas: 0, run time: 23m 56s
pct rescued: 66.77%, read errors: 0, remaining time: 6m 4s
time since last successful read: 0s
Copying non-tried blocks... Pass 1 (forwards)
# ddrescue -d -f -r3 /dev/sdb1 /dev/sdc1 ddlogfile
# e2fsck -vfp /dev/sdc1
# mkdir /mnt/sdc1-copy # mount -o ro /dev/sdc1 /mnt/sdc1-copy
[root@systemrescue ~]# lsblk -p -o NAME,FSTYPE,LABEL NAME FSTYPE LABEL /dev/loop/0 squashfs /dev/sr0 /dev/sr1 iso9660 RESCUE800 /dev/sda ├─/dev/sda1 vfat ├─/dev/sda2 xfs osuse15-2 ├─/dev/sda3 xfs home ├─/dev/sda4 xfs └─/dev/sda5 swap /dev/sdb └─/dev/sdb1 xfs backups /dev/sr0
$ isohybrid --partok systemrescuecd-8.01-amd64.iso
$ sudo parted /dev/sdc (parted) mklabel msdos
(parted) mkpart "sysrec" fat32 1MB 2000MB (parted) set 1 boot
(parted) mkpart "data" xfs 2001MB 4000MB (parted) q
$ sudo mkfs.fat -F 32 -n SYSRESCUE /dev/sdc1 $ sudo mkfs.xfs -L data /dev/sdc2
$ sudo dd status=progress if=systemrescuecd-8.01-amd64.iso of=/dev/sdc1
$ sudo install-mbr /dev/sdc
$ sudo if=/usr/share/syslinux/mbr.bin of=/dev/sdc
# lsblk -p lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [...] sdc 8:32 1 3.7G 0 disk ├─sdc1 8:33 1 2G 0 part /run/archiso/bootmnt └─sdc2 8:34 1 152G 0 part /run/archiso/cowspace
$ digikam Object::connect: No such signal org::freedesktop::UPower::DeviceAdded(QString) Object::connect: No such signal org::freedesktop::UPower::DeviceRemoved(QString) digikam: symbol lookup error: digikam: undefined symbol: _ZNK11KExiv2Iface14AltLangStrEdit8textEditEv
$ dmesg | less [ 0.000000] microcode: microcode updated early to revision 0x28, date = 2019-11-12 [ 0.000000] Linux version 5.8.0-45-generic (buildd@lcy01-amd64-024) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #51~20.04.1-Ubuntu SMP Tue Feb 23 13:46:31 UTC 2021 (Ubuntu 5.8.0-45.51~20.04.1-generic 5.8.18) [...]
$ dmesg | grep -w sd [11236.888910] sd 7:0:0:0: [sdd] Attached SCSI removable disk [11245.095341] FAT-fs (sdd1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
$ dmesg -T | less [Tue Mar 23 15:25:17 2021] PCI: CLS 64 bytes, default 64 [Tue Mar 23 15:25:17 2021] Trying to unpack rootfs image as initramfs... [Tue Mar 23 15:25:17 2021] Freeing initrd memory: 56008K [...]
$ dmesg -l err,warn
$ sudo grep -ir graphicsmagick /var/log apt/history.log:Install: libgraphicsmagick-q16-3:amd64 (1.4+really1.3.35-1, automatic), graphicsmagick:amd64 (1.4+really1.3.35-1) [...] /var/log/dpkg.log:2021-03-11 17:00:57 install libgraphicsmagick-q16-3:amd64 1.4+really1.3.35-1 [...]
$ journalctl
$ journalctl -r
$ journalctl -r | less
$ journalctl -ex | less -- The unit grub-initrd-fallback.service has successfully entered the 'dead' state. Mar 27 10:14:29 client4 systemd[1]: Finished GRUB failed boot detection. -- Subject: A start job for unit grub-initrd-fallback.service has finished successfully -- Defined-By: systemd
$ sudo journalctl -u mariadb.service Mar 19 16:07:27 client4 /etc/mysql/debian-start[7927]: Looking for 'mysql' as: /usr/bin/mysql Mar 19 16:07:27 client4 /etc/mysql/debian-start[7927]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck [...]
$ journalctl -u mariadb.service -S today $ journalctl -u ssh.service -S '1 week ago' $ journalctl -u libvirtd.service -S '2021-03-05' $ journalctl -u httpd.service -S '2021-03-05' -u '2021-03-09' $ journalctl -u nginx.service -S '2 hours ago'
$ journalctl -u httpd.service -S '2021-03-05 13:15:00' -U now
$ journalctl -S '1h ago' -U '5 min ago' -o with-unit
$ journalctl -b -n 50 -u httpd.service
$ journalctl -b -2 -u httpd.service
$ journalctl --list-boots
$ journalctl -b -1 -p "crit" -u nginx.service
$ journalctl -b -3 -p "crit".."warning"
$ journalctl -n 10 -u mariadb.service -f
$ journalctl -b -1 | grep madmax
emerg (0) alert (1) crit (2) err (3) warning (4) notice (5) info (6) debug (7)
$ systemctl status systemd-journald.services ● systemd-journald.service - Journal Service Loaded: loaded (/usr/lib/systemd/system/systemd-journald.service; static; vendor preset: disabled) Active: active (running) [...] Mar 27 15:04:40 server2 systemd-journald[508]: Runtime journal (/run/log/journal/ 1181e27c52294e97a8ca5c5af5c92e20) is 8.0M, max 2.3G, 2.3G free. Mar 27 15:04:55 server2 systemd-journald[508]: Time spent on flushing to /var is 381.408ms for 1176 entries. Mar 27 15:04:55 server2 systemd-journald[508]: System journal (/var/log/journal/ 1181e27c52294e97a8ca5c5af5c92e20) is 16.0M, max 4.0G, 3.9G free.
$ sudo mkdir /var/log/journal $ sudo chgrp /var/log/journal/ systemd-journal
[Remote] Seal=false SplitMode=host ServerKeyFile=/etc/pki/journald/log-server.key ServerCertificateFile=/etc/pki/journald/log-server.crt TrustedCertificateFile=/etc/pki/journald/ca.crt
$ sudo chmod -R 0755 /etc/pki/journald $ sudo chmod 0440 /etc/pki/journald/log-server.key
$ sudo chgrp systemd-journal-remote /etc/pki/journald/log- server.key
$ sudo systemctl enable --now systemd-journal-remote.socket $ sudo systemctl enable --now systemd-journal-remote.service
$ sudo firewall-cmd --zone=internal --add-port=19532/tcp $ sudo firewall-cmd --zone=internal --add-port=80/tcp $ sudo firewall-cmd --runtime-to-permanent $ sudo firewall-cmd --reload
$ sudo useradd -r -d /run/systemd -M -s /usr/sbin/nologin -U \ systemd-journal-upload
$ sudo chmod -R 0755 /etc/pki/journald $ sudo chmod 0440 /etc/pki/journald/client.key
[Upload] URL=https://logserver.example.com:19532 ServerKeyFile=/etc/pki/journald/client1.key ServerCertificateFile=/etc/pki/journald/client1.crt TrustedCertificateFile=/etc/pki/journald/ca.crt
$ sudo systemctl restart systemd-journal-upload.service
$ sudo ls -la /var/log/journal/remote/ total 7204 drwxr-xr-x 2 systemd-journal-remote systemd-journal-remote 6 Mar 26 16:41 . drwxr-sr-x+ 4 root systemd-journal 60 Mar 26 16:41 .. rw-r----- 1 systemd-journal-remote systemd-journal-remote 8388608 Mar 26 1 10:46 'remote-CN=client1.example.com'
$ sudo logger -p syslog.debug "Hello, I am client1! Do you hear me?"
Mar 27 18:30:11 client1 madmax[15228]: Hello, I am client1! Do you hear me?
$ sudo sensors-detect # sensors-detect version 3.6.0 # Board: ASRock H97M Pro4 # Kernel: 5.8.0-45-generic x86_64 # Processor: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (6/60/3) This program will help you determine which kernel modules you need to load to use lm_sensors most effectively. It is generally safe and recommended to accept the default answers to all questions, unless you know what you're doing. Some south bridges, CPUs or memory controllers contain embedded sensors. Do you want to scan for them? This is totally safe. (YES/no): [...]
To load everything that is needed, add this to /etc/modules: #----cut here---- # Chip drivers coretemp nct6775 #----cut here---- If you have some drivers built into your kernel, the list above will contain too many modules. Skip the appropriate ones! Do you want to add these lines automatically to /etc/modules? (yes/NO) yes Successful!
$ sudo systemctl restart systemd-modules-load.service
$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +42.0°C (high = +86.0°C, crit = +96.0°C)
Core 0: +34.0°C (high = +86.0°C, crit = +96.0°C)
Core 1: +35.0°C (high = +86.0°C, crit = +96.0°C)
Core 2: +32.0°C (high = +86.0°C, crit = +96.0°C)
Core 3: +31.0°C (high = +86.0°C, crit = +96.0°C)
nouveau-pci-0300
Adapter: PCI adapter
GPU core: +1.01 V (min = +0.70 V, max = +1.20 V)
fan1: 2850 RPM
temp1: +51.0°C (high = +95.0°C, hyst = +3.0°C)
(crit = +105.0°C, hyst = +5.0°C)
(emerg = +135.0°C, hyst = +5.0°C)
dell_smm-virtual-0
Adapter: Virtual device
Processor Fan: 1070 RPM
Other Fan: 0 RPM
Other Fan: 603 RPM
CPU: +41.0°C
SODIMM: +25.0°C
SODIMM: +35.0°C
SODIMM: +34.0°C
$ watch -d sensors
$ watch -d -n 10 sensors Every 10.0s: sensors [...]
$ grep -i nct6775 config-5.8.0-45-generic CONFIG_SENSORS_NCT6775=m
$ lsmod | grep nct6775
CONFIG_SENSORS_NCT6775=y
#!/bin/bash # toohot.sh, plays a mad klavichord riff when a sensor monitor # exceeds its upper limit play /home/madmax/Music/klavichord-4.wav
$ chmod +x toohot.sh
$ play toohot.sh
#!/bin/bash echo "Help, too hot, I am shutting down right now!" && shutdown -h now
$ systemctl status smartd.service
$ sudo smartctl -i /dev/sda smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.8.0-45-generic] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Seagate Desktop HDD.15 Device Model: ST4000DM000-1F2168 [...] SMART support is: Available - device has SMART capability. SMART support is: Enabled
$ sudo smartctl -s on /dev/sda $ sudo smartctl -s off /dev/sda
$ sudo smartctl -x /dev/sda
$ sudo smartctl -H /dev/sda smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.8.0-45-generic] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED
$ sudo smartctl -l error /dev/sda smartctl 7.0 2019-05-21 r4917 [x86_64-linux-5.3.18-lp152.66-preempt] (SUSE RPM) Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART Error Log Version: 1 No Errors Logged
$ sudo smartctl -t long /dev/sda [...] === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Extended self-test routine immediately in off-line mode". Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 109 minutes for test to complete. Test will complete after Thu Mar 25 17:06:33 2021 Use smartctl -X to abort test.
$ sudo smartctl -l selftest /dev/sda [sudo] password for carla: [...] === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) # 1 Extended offline Self-test routine in progress 70% 7961 # 2 Short offline Completed without error 00% 7960 # 3 Short offline Completed without error 00% 7952 [...]
$ sudo update-smart-drivedb /usr/share/smartmontools/drivedb.h updated from branches/RELEASE_7_0_DRIVEDB
SMART Attributes Data Structure revision number: 10 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED 1 Raw_Read_Error_Rate 0x000f 119 099 006 Pre-fail Always 3 Spin_Up_Time 0x0003 092 091 000 Pre-fail Always 4 Start_Stop_Count 0x0032 099 099 020 Old_age Always 5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always 7 Seek_Error_Rate 0x000f 059 057 030 Pre-fail Always 9 Power_On_Hours 0x0032 089 089 000 Old_age Always 10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always 12 Power_Cycle_Count 0x0032 099 099 020 Old_age Always 183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always 184 End-to-End_Error 0x0032 100 100 099 Old_age Always 187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always 188 Command_Timeout 0x0032 100 099 000 Old_age Always 189 High_Fly_Writes 0x003a 100 100 000 Old_age Always 190 Airflow_Temperature_Cel 0x0022 072 059 045 Old_age Always 191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always 192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always 193 Load_Cycle_Count 0x0032 096 096 000 Old_age Always 194 Temperature_Celsius 0x0022 028 041 000 Old_age Always 197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always 198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline 199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always 240 Head_Flying_Hours 0x0000 100 253 000 Old_age Offline 241 Total_LBAs_Written 0x0000 100 253 000 Old_age Offline 242 Total_LBAs_Read 0x0000 100 253 000 Old_age Offline
$ echo "Hello, this is my message" | mail -s "Message subject" root@localhost
[root@localhost ~]# mail "/var/mail/root": 1 message 1 unread >U "/var/mail/root": 1 message 1 new >N 1 stash Mon Mar 29 15:26 13/429 Message subject ?
$ systemctl status smartd.service $ systemctl status postfix.service
$ sudo systemctl enable --now smartd.service $ sudo systemctl enable --now postfix.service
DEFAULT -a -o on -S on -s (S/../.././02|L/../../5/01): /dev/sda /dev/sdb /dev/sdc DEFAULT -H -m root -M test
$ sudo systemctl reload smartd.service
$ top
Tasks: 284 total, 1 running, 283 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.4 us, 4.8 sy, 0.0 ni, 88.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 15691.4 total, 6758.9 free, 4913.0 used, 4019.6 buff/cache
MiB Swap: 15258.0 total, 15258.0 free, 0.0 used. 10016.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1299 duchess 9 0 2803912 22296 17904 S 80.5 0.1 172:25 Web Content
1685 duchess 20 0 3756840 543124 241296 S 7.6 3.4 27:53 firefox
15926 libvirt+ 20 0 5151504 2.3g 25024 S 1.7 15.3 1:39 qemu
[...]
PID to signal/kill [default pid = 1299] Send pid 1299 signal [15/sigterm]
PID to signal/kill [default pid = 1299] Send pid 1299 signal [15/sigterm] 9
Tasks: 249 total, 1 running, 248 sleeping, 0 stopped, 2 zombie
$ sudo kill -s SIGCHLD 1299
$ top -p 4548, 8685, 9348
top - 10:57:39 up 44 min, 2 users, load average: 0.10, 0.11, 0.21
Tasks: 3 total, 0 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.2 us, 0.2 sy, 0.0 ni, 99.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 15691.4 total, 12989.5 free, 1467.4 used, 1234.4 buff/cache
MiB Swap: 15258.0 total, 15258.0 free, 0.0 used. 13601.1 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2907 mysql 20 0 1775688 78584 18396 S 0.0 0.5 0:00.22 mysqld
927 root 20 0 1569764 39072 29320 S 0.0 0.2 0:00.16 libvirtd
822 root 20 0 11040 6384 4732 S 0.0 0.0 0:00.02 smartd
$ ping localhost PING localhost (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.065 ms 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.035 ms
$ ping -c 3 client4 PING client4 (192.168.1.97) 56(84) bytes of data. 64 bytes from client4 (192.168.1.97): icmp_seq=1 ttl=64 time=0.087 ms 64 bytes from client4 (192.168.1.97): icmp_seq=2 ttl=64 time=0.059 ms 64 bytes from client4 (192.168.1.97): icmp_seq=3 ttl=64 time=0.061 ms --- client4 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2046ms rtt min/avg/max/mdev = 0.059/0.069/0.087/0.012 ms
$ ping -c 500 -i 2 server2 >> server2-ping.txt
$ ping -c 500 -i 2 server2 | tee server2-ping.txt
$ sudo modprobe pcspkr $ lsmod|grep pcspkr pcspkr 16384 0
$ echo -e "\a" $ tput bel $ echo -e '\007'
$ fping -c1 -gAds 192.168.1.0/24 2>1 | egrep -v "ICMP|xmt" >> fping.txt
client1.net (192.168.1.15) : [0], 84 bytes, 3.12 ms (3.12 avg, 0% loss)
server2.net (192.168.1.91) : [0], 84 bytes, 5.34 ms (5.34 avg, 0% loss)
client4.net (192.168.1.97) : [0], 84 bytes, 0.03 ms (0.03 avg, 0% loss)
254 targets
3 alive
251 unreachable
0 unknown addresses
251 timeouts (waiting for response)
0.03 ms (min round trip time)
2.83 ms (avg round trip time)
5.34 ms (max round trip time)
3.575 sec (elapsed real time)
$ sudo nmap -sn 192.168.1.0/24 > nmap.txt Starting Nmap 7.70 ( https://nmap.org ) at 2021-03-31 18:30 PDT Nmap scan report for client1.net (192.168.1.15) Host is up (0.0052s latency). MAC Address: 44:A5:6E:D7:8F:B9 (Unknown) Nmap scan report for BRW7440BBC7CA75.net (192.168.1.39) Host is up (1.0s latency). MAC Address: 74:40:BB:C7:CA:75 (Unknown) Nmap scan report for client4.net (192.168.1.97) Host is up (0.47s latency). MAC Address: 9C:EF:D5:FE:8F:20 (Panda Wireless) Nmap scan report for server2.net (192.168.1.91) Host is up. Nmap done: 256 IP addresses (6 hosts up) scanned in 15.19 seconds
$ awk '/Nmap/{print ""}1' nmap.txt > nmap2.txt
Nmap scan report for client1.net (192.168.1.15) Host is up (0.0052s latency). MAC Address: 44:A5:6E:D7:8F:B9 (Unknown) Nmap scan report for BRW7440BBC7CA75.net (192.168.1.39) Host is up (1.0s latency). MAC Address: 74:40:BB:C7:CA:75 (Unknown) Nmap scan report for client4.net (192.168.1.97) Host is up (0.47s latency). MAC Address: 9C:EF:D5:FE:8F:20 (Panda Wireless) Nmap scan report for server2.net (192.168.1.91) Host is up. Nmap done: 256 IP addresses (6 hosts up) scanned in 15.19 seconds
$ sudo nmap -sS 192.168.1.* Starting Nmap 7.70 ( https://nmap.org ) at 2021-03-31 19:36 PDT Nmap scan report for client2.net (192.168.1.15) Host is up (0.027s latency). Not shown: 997 closed ports PORT STATE SERVICE 53/tcp open domain 80/tcp open http MAC Address: 44:A5:6E:D7:8F:B9 (Unknown) Nmap scan report for 192.168.1.39 Host is up (0.074s latency). Not shown: 994 closed ports PORT STATE SERVICE 25/tcp open smtp 80/tcp open http 443/tcp open https 515/tcp open printer 631/tcp open ipp 9100/tcp open jetdirect MAC Address: 74:40:BB:C7:CA:75 (Unknown) [...]
$ nmap -sn 192.168.43.0/24 | grep 'Nmap scan report for' |cut -d' ' -f5,6 server2 (192.168.43.15) dns-server (192.168.43.74) client4 (192.168.43.14)
$ sudo arping -I wlan2 -c 4 192.168.1.91 ARPING 192.168.1.91 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=0 time=49.463 msec 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=1 time=458.306 msec 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=2 time=73.938 msec 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=3 time=504.482 msec --- 192.168.1.91 statistics --- 4 packets transmitted, 4 packets received, 0% unanswered (0 extra) rtt min/avg/max/std-dev = 49.463/271.547/504.482/210.659 ms
$ sudo arping -I wlan2 -c 4 192.168.1.91 ARPING 192.168.1.91 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=0 time=49.463 msec 42 bytes from 2F:EF:D5:FE:8F:20 (192.168.1.91): index=1 time=458.306 msec 42 bytes from 9c:ef:d5:fe:01:7c (192.168.1.91): index=2 time=73.938 msec 42 bytes from 2F:EF:D5:FE:8F:20 (192.168.1.91): index=3 time=504.482 msec [...] --- 192.168.1.91 statistics --- 4 packets transmitted, 4 packets received, 0% unanswered (0 extra) rtt min/avg/max/std-dev = 49.463/271.547/504.482/210.659 ms
$ nmap -sn 192.168.43.0/24 | grep 'Nmap scan report for' |cut -d' ' -f5,6
$ sudo tcpdump -pi eth1 arp listening on eth1, link-type EN1000MB (Ethernet), capture size 262144 bytes 21:19:36.921293 ARP, Request who-has client4.net tell m1login.net, length 28 21:19:36.921309 ARP, Reply client4.net is-at 9c:ef:d5:fe:8f:20
$ httping -c4 -l -g www.oreilly.com PING www.oreilly.com:443 (/): connected to 184.86.29.153:443 (453 bytes), seq=0 time=292.25 ms connected to 184.86.29.153:443 (453 bytes), seq=1 time=726.35 ms connected to 184.86.29.153:443 (452 bytes), seq=2 time=629.11 ms connected to 184.86.29.153:443 (453 bytes), seq=3 time=529.95 ms --- https://www.oreilly.com/ ping statistics --- 4 connects, 4 ok, 0.00% failed, time 6179ms round-trip min/avg/max = 292.2/544.4/726.3 ms
$ httping -c4 -l -Gg www.oreilly.com PING www.oreilly.com:443 (/): connected to 104.112.183.230:443 (453 bytes), seq=0 time=2125.72 ms connected to 104.112.183.230:443 (453 bytes), seq=1 time=701.94 ms connected to 104.112.183.230:443 (453 bytes), seq=2 time=470.66 ms connected to 104.112.183.230:443 (453 bytes), seq=3 time=433.11 ms --- https://www.oreilly.com/ ping statistics --- 4 connects, 4 ok, 0.00% failed, time 7733ms round-trip min/avg/max = 433.1/932.9/2125.7 ms
$ httping -c4 -l -rGg www.oreilly.com PING www.oreilly.com:443 (/): connected to 23.10.2.218:443 (452 bytes), seq=0 time=961.29 ms connected to 23.10.2.218:443 (452 bytes), seq=1 time=1091.16 ms connected to 23.10.2.218:443 (452 bytes), seq=2 time=925.46 ms connected to 23.10.2.218:443 (452 bytes), seq=3 time=913.26 ms --- https://www.oreilly.com/ ping statistics --- 4 connects, 4 ok, 0.00% failed, time 7894ms round-trip min/avg/max = 913.3/972.8/1091.2 ms
$ httping -c4 -l -rGg www.oreilly.com:8080
$ httping -c4 -l -srGg www.oreilly.com PING www.oreilly.com:443 (/): connected to 23.10.2.218:443 (452 bytes), seq=0 time=920.88 ms 200 OK connected to 23.10.2.218:443 (452 bytes), seq=1 time=857.60 ms 200 OK connected to 23.10.2.218:443 (452 bytes), seq=2 time=1246.69 ms 200 OK connected to 23.10.2.218:443 (452 bytes), seq=3 time=1134.91 ms 200 OK --- https://www.oreilly.com/ ping statistics --- 4 connects, 4 ok, 0.00% failed, time 8249ms round-trip min/avg/max = 857.6/1040.0/1246.7 ms
$ mtr -wo LSRABW carlaschroder.com Start: 2021-03-31T09:54:17-0700 HOST: client4 Loss% Snt Rcv Avg Best Wrst 1.|-- m1login.net 0.0% 10 10 55.5 1.2 199.6 2.|-- 172.26.96.169 0.0% 10 10 92.3 29.0 243.6 3.|-- 172.18.84.60 0.0% 10 10 84.5 29.3 220.3 4.|-- 12.249.2.25 0.0% 10 10 80.7 36.4 215.5 5.|-- 12.122.146.97 0.0% 10 10 65.6 34.8 156.6 6.|-- 12.122.111.33 0.0% 10 10 49.3 35.5 97.6 7.|-- cr2.st6wa.ip.att.net 0.0% 10 10 46.7 35.9 64.0 8.|-- 12.122.111.109 0.0% 10 10 57.9 31.4 215.4 9.|-- 12.122.111.81 0.0% 10 10 72.3 27.6 231.4 10.|-- 12.249.133.242 0.0% 10 10 101.2 31.7 263.1 11.|-- ae6.cbs01.wb01.sea02.networklayer.com 0.0% 10 10 93.7 31.6 202.7 12.|-- fc.11.6132.ip4.static.sl-reverse.com 0.0% 10 10 106.0 86.1 171.2 13.|-- ae1.cbs02.eq01.dal03.networklayer.com 60.0% 10 4 102.0 86.5 115.8 14.|-- ae0.dar01.dal13.networklayer.com 0.0% 10 10 103.7 80.3 230.8 15.|-- 85.76.30a9.ip4.static.sl-reverse.com 0.0% 10 10 114.8 82.8 305.7 16.|-- a1.76.30a9.ip4.static.sl-reverse.com 0.0% 10 10 122.7 83.7 278.4 17.|-- hs17.name.tools 0.0% 10 10 145.9 74.9 277.2
$ ping -c 3 hs17.name.tools PING hs17.name.tools (169.61.1.230) 56(84) bytes of data. 64 bytes from hs17.name.tools (169.61.1.230): icmp_seq=1 ttl=46 time=319 ms 64 bytes from hs17.name.tools (169.61.1.230): icmp_seq=2 ttl=46 time=168 ms 64 bytes from hs17.name.tools (169.61.1.230): icmp_seq=3 ttl=46 time=166 ms [...]
$ whois -H networklayer.com
$ mtr -r -c25 oreilly.com >> mtr.txt && date >> mtr.txt
$ apt depends gedit gedit Depends: gedit-common (<< 3.37) Depends: gedit-common (>= 3.36) Depends: gir1.2-glib-2.0 Depends: gir1.2-gtk-3.0 (>= 3.21.3) Depends: gir1.2-gtksource-4 Depends: gir1.2-pango-1.0 Depends: gir1.2-peas-1.0 Depends: gsettings-desktop-schemas Depends: iso-codes [...]
$ zypper search --type pattern S | Name | Summary | Type ---+----------------------+--------------------------------+-- [...] | mail_server | Mail and News Server | pattern | mate | MATE Desktop Environment | pattern i+ | multimedia | Multimedia | pattern | network_admin | Network Administration | pattern | non_oss | Misc. Proprietary Packages | pattern | office | Office Software | pattern | print_server | Print Server | pattern [...]
$ lsb_release -sc focal
$ sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ focal \ universe multiverse"
$ sudo add-apt-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ focal \ universe multiverse"
$ sudo apt update
$ sudo apt upgrade
$ sudo dpkg -i packagename
$ sudo dpkg -r packagename
$ sudo dpkg --purge packagename
$ dpkg -L packagename
$ dpkg-query --listdpkg
$ apt search packagename
$ apt search packagename --names-only
$ apt show packagename
$ sudo apt install packagename
$ sudo apt remove packagename
$ sudo apt remove purge packagename
$ tasksel --list-tasks
$ sudo tasksel install task
$ sudo tasksel remove task
$ dnf repolist --all
$ dnf repolist --enabled
$ dnf repolist --enabled
$ sudo dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo
$ sudo dnf config-manager --set-enabled fedora-extras
$ sudo dnf config-manager --set-disabled fedora-extras
$ dnf search packagename
$ sudo dnf install packagename
$ sudo dnf remove packagename
$ dnf info packagename
$ sudo dnf upgrade
$ dnf grouplist
$ sudo dnf groupinstall "package-group"
$ sudo dnf groupremove "package-group"
$ sudo rpm -i package
$ sudo rpm -U package
$ sudo rpm -e package
$ rpm -ql package
$ rpm -qi package
$ rpm -q --changes package
$ zypper repos
$ zypper repos -d
$ sudo zypper modifyrepo -e repo
$ sudo zypper modifyrepo -d repo
$ sudo zypper adderepo -name "MyNewRepoName" \ http://download.opensuse.org/distribution/leap/15.3/repo/oss/
$ sudo zypper removerepo MyNewRepoName
$ sudo zypper refresh
$ sudo zypper update
$ zypper search packagename
$ zypper search -x packagename
$ sudo zypper install packagename
$ sudo zypper remove packagename
$ sudo zypper -t patterns
$ sudo zypper -t pattern pattern-name