From 056a3b105426b5acddf45ba803db2c3d538a8999 Mon Sep 17 00:00:00 2001 From: waldek Date: Mon, 21 Feb 2022 14:23:15 +0100 Subject: [PATCH] some more, some more --- essential/readme.md | 605 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 604 insertions(+), 1 deletion(-) diff --git a/essential/readme.md b/essential/readme.md index 3ab5867..7e5a8a3 100644 --- a/essential/readme.md +++ b/essential/readme.md @@ -525,4 +525,607 @@ Compiled programs contain actual [instructions](https://en.wikipedia.org/wiki/In This means that programs that are compiled are always compiled for a specify architecture which in our case is x86-64. On a Raspberry Pi this would be armhf or arm64. -## `root` and `/` and `/root` are not the same thing +Interpreted programs are not compiled to machine code but when we run them each line is passed to an appropriate **interpreter** and executed **line by line**. +The first line of a script is often the path to the interpreter that *understands* the code that will follow. +Popular interpreted languages are `bash`, `sh`, `python`, `php`, ... + +We can take it *one* more step forward and peak into the *content* of the files. +A nice little program to do this is called `head` who's purpose in life is to show the first few lines of a file. +First for `vlc`. + +``` +waldek@hellodebian:~$ head /usr/bin/vlc +ELF>@�1@8 + HHh,h�>�>�>�>�>��> �> +??? ?(?0?8?@?H?P?X?`?�h??x?�?�?�? �?!�?"�?#�?$�?%�?&�?'�?(H�H��/H��t��H���5�.�%�.@�%�.h������%z.h������%r.h������%j.h�����%b.h�����%Z.h�����%R.h�����%J.h�p����%B.�`����%:.h �P����%2.h +�@����%*.h + �0����%".h +�����%.h�����% � ����%�.h +.h������%.h������%�-h������%�-h������%�-h�����%�-h�����%�-h�����%�-h�����%�-h�p����%�-h�`����%�-h�P����%�-h��@����%�-h0����%�-h� ����%�-h�����%�-h�������������L����������1�L��H�������k����S�[Hc�H�G����L���:����L���-����L��� ���� + L�� + H��H�5� + fHn�H�BfHn�H�� H���fl�I�H)�L�t$L��I���H��L���I�~�o���Lc�K���L���������I��H����H��H������H�5��S���H� +H�/ + L��H�5 + �v���H� + H�5 + L�������H�5! + L���!���H�5 + +L���'���H������L���H���L��������L���S����L���F���������H�5��������1�L������������L���5����8�����I���&���H�=�*M��H���@���u + H���1�������n���A�H�E�dH+%(u?H�e�D��[A\A]A^]�I�M�H�=\*H�� +CH�=L�����)�DH�=�)H��)H9�tH��)H��t�f.�1������H�=�)H�5�)H)�H��H��?H��H�H��tH�U)H����fD���=q)u/UH�=6)H��t + H�=:)�����h����I)]�����{���f.��1���$���@H�?�������)��AUI��ATI��UH��SH��H���L�D$@L�L$H��t7)D$P)L$`)T$p)�$�)�$�)�$�)�$�)�$�dH�%(H�D$1�H�={(H�T$ H��$�$ �D$0H�DH�T$������ + ��v1H�=B(�����H�D$dH+%(uH���[]A\A]����H�=(I��1�� +H��H�=7 H�5H�=?'�������e����#������f�ATI���f���H�=�'L��H�I���1����������H�i���1�1��.(�f��=(UH��u#H�5H�����������H��t5H��]��DI��1�H� +�H�H�5�H�=7&��&����X1�Z]A\A]�H�����ff.���='UH��u#H�5�H�����������H��t5H��]��DI��1�H��RH� +!"����H�H��DESKTOP_STARTUP_ID--no-ignore-config--media-library--dbusvlcorg.VideoLAN.VLCVLC/3.0.16VLC media playerglobalhotkeys,noneVLC is not supposed to be run as root. Sorry. +If you need to use real-time priorities and/or privileged TCP ports +you can use %s-wrapper (make sure it is Set-UID root and +``` + +And now of `which`. + +``` +waldek@hellodebian:~$ head /usr/bin/which +#! /bin/sh +set -ef + +if test -n "$KSH_VERSION"; then + puts() { + print -r -- "$*" + } +else + puts() { + printf '%s\n' "$*" +waldek@hellodebian:~$ +``` + +Notice how the `vlc` file is mostly **not human readable** but we can still make out some keywords? +The `which` file however is perfectly readable! +The first line of the `which` file is `#! /bin/sh` which is the path to the interpreter. +The `#!` is called a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). +We can dig into this to learn more about this mysterious `sh`. + +``` +waldek@hellodebian:~$ file /bin/sh +/bin/sh: symbolic link to dash +waldek@hellodebian:~$ which dash +/usr/bin/dash +waldek@hellodebian:~$ file /usr/bin/dash +/usr/bin/dash: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=cb6911fd56559717336c938bef1ce479b0a85b35, for GNU/Linux 3.2.0, stripped +waldek@hellodebian:~$ +``` + +Surprise surprise! +The *interpreter* is a compiled program! +When you think about it it does make sense because at the end of the day the computer *only* understands machine instructions. +So when you execute a script each line of code is converted to machine instructions on the spot. +This makes scripts easier to write but slower at execution. + +## More about paths + +The prompt in our terminal tells us who we are, on which machine, and **where** we are located. +This where is symbolized with the `~` character. +But where is this where? + +``` +waldek@hellodebian:~$ pwd +/home/waldek +waldek@hellodebian:~$ +``` + +The `pwd` program **p**rints our **w**orking **d**irectory, meaning where we are located on our system. +A user's home directory is symbolized with this tilde character. +We can move around our system with the `cd` command which is an abbreviation of **c**hange **d**irectory. +`cd` by itself seems to to *nothing* but this is not the case. +It's a *shortcut* to go to your user's home directory. +Let's try this out. + +``` +waldek@hellodebian:~$ cd +waldek@hellodebian:~$ cd /usr/bin +waldek@hellodebian:/usr/bin$ cd +waldek@hellodebian:~$ cd - +/usr/bin +waldek@hellodebian:/usr/bin$ cd +waldek@hellodebian:~$ +``` + +The first line appears to do nothing because we are already in our home directory. +Next we move to the directory which contains the programs we discovered before and we see our prompt change. +It now shows *where* we are located! +The next line takes us back to our home and from there we can move *back to where we were before* with the `cd -` command. +This last command is also a handy *shortcut*! + +Moving around is nice but once we arrive at our destination it would be practical to be able to list the files in that directory no? +This can be done with the `ls` program. +For example. + +``` +waldek@hellodebian:~$ cd /usr/bin/ +waldek@hellodebian:/usr/bin$ ls +'[' getconf nmtui-hostname systemd-escape + 7z getent nohup systemd-hwdb + 7za getfacl notify-send systemd-id128 + 7zr getkeycodes nproc systemd-inhibit + aa-enabled getopt nroff systemd-machine-id-setup + aa-exec gettext nsenter systemd-mount + aconnect gettext.sh nslookup systemd-notify + add-apt-repository gio nstat systemd-path + addpart gio-querymodules nsupdate systemd-resolve + addr2line gjs ntfs-3g systemd-run + alsabat gjs-console ntfs-3g.probe systemd-socket-activate + alsaloop gkbd-keyboard-display ntfscat systemd-stdio-bridge + alsamixer glib-compile-schemas ntfscluster systemd-sysusers + alsatplg gmake ntfscmp systemd-tmpfiles + alsaucm gnome-calculator ntfsdecrypt systemd-tty-ask-password-agent + amidi gnome-calendar ntfsfallocate systemd-umount + amixer gnome-characters ntfsfix tabs + apg gnome-clocks ntfsinfo tac + apgbfm gnome-contacts ntfsls tail + aplay gnome-control-center ntfsmove tar + aplaymidi gnome-disk-image-mounter ntfsrecover tasksel + appres gnome-disks ntfssecaudit taskset + appstreamcli gnome-documents ntfstruncate tbl + apropos gnome-extensions ntfsusermap tbl-dctrl + apt gnome-extensions-app ntfswipe tee + apt-add-repository gnome-font-viewer numfmt telnet + apt-cache gnome-help numlockx telnet.netkit + apt-cdrom gnome-keyring nvlc tempfile + apt-config gnome-keyring-3 obamenu test + apt-extracttemplates gnome-keyring-daemon obconf thunar + apt-ftparchive gnome-logs obexctl Thunar + apt-get gnome-maps objcopy thunar-settings + apt-key gnome-music objdump thunar-volman + apt-listchanges gnome-screenshot obsession-exit thunar-volman-settings + apt-mark gnome-session obsession-logout tic + apt-sortpkgs gnome-session-classic obxprop time-admin + ar gnome-session-custom-session oclock timedatectl + arch gnome-session-inhibit od timeout + arecord gnome-session-quit odp2pdf tjbench + arecordmidi gnome-shell odp2ppt tkjpeg + as gnome-shell-extension-prefs ods2pdf tload + aseqdump gnome-shell-extension-tool odt2bib toc2cddb + aseqnet gnome-shell-perf-tool odt2doc toc2cue + aspell gnome-software odt2docbook toe + aspell-import gnome-sound-recorder odt2html top + atobm gnome-system-monitor odt2lt totem + atril gnome-terminal odt2pdf totem-video-thumbnailer + atril-previewer gnome-terminal.wrapper odt2rtf touch + atril-thumbnailer gnome-text-editor odt2sdw tput + awk gnome-thumbnail-font odt2sxw tr + axfer gnome-todo odt2txt traceproto + b2sum gnome-tweaks odt2txt.unoconv traceproto.db + baobab gnome-weather odt2xhtml traceroute + base32 gnome-www-browser odt2xml traceroute6 + base64 gold ooxml2doc traceroute6.db + basename gpasswd ooxml2odt traceroute.db + basenc gpg ooxml2pdf traceroute-nanog + bash gpg-agent open tracker + bashbug gpgcompose openbox transmission-gtk + bccmd gpgconf openbox-lxde transset + bdftopcf gpg-connect-agent openbox-session troff + bdftruncate gpgparsemail openssl true + bf_compact gpgsm openvt truncate + bf_compact-bdb gpgsplit operon trust + bf_copy gpgtar orca tryaffix + bf_copy-bdb gpgv orca-dm-wrapper tset + bf_tar gpg-wks-server os-prober tsort + bf_tar-bdb gpg-zip p11-kit tty + bitmap gpic p7zip tzselect + bluemoon gpicview pacat ucf + bluetoothctl gprof pacmd ucfq + bluetooth-sendto grep pactl ucfr + bmtoa grep-aptavail padsp ucs2any + bogofilter grep-available pager udevadm + bogofilter-bdb grep-dctrl pa-info udisksctl + bogolexer grep-debtags pamon ul + bogolexer-bdb grep-status paperconf umax_pp + bogotune gresource paplay umount + bogotune-bdb groff parcellite uname + bogoupgrade grog parec unattended-upgrade + bogoupgrade-bdb grops parecord unattended-upgrades + bogoutil grotty parole uncompress + bogoutil-bdb groups partx unexpand + boltctl grub-editenv passwd unicode_start + bootctl grub-file paste unicode_stop + broadwayd grub-fstest pasuspender uniq + btattach grub-glue-efi patch unity-scope-loader + btmgmt grub-kbdcomp pathchk unlink + btmon grub-menulst2cfg pavucontrol unlzma + buildhash grub-mkfont pax11publish unmkinitramfs + bunzip2 grub-mkimage pcmanfm unoconv + busctl grub-mklayout pdb3 unopkg + busybox grub-mknetdir pdb3.9 unshare + bwrap grub-mkpasswd-pbkdf2 peekfd unxz + bzcat grub-mkrelpath perf unzip + bzcmp grub-mkrescue perl unzipsfx + bzdiff grub-mkstandalone perl5.32.1 update-alternatives + bzegrep grub-mount perl5.32-x86_64-linux-gnu update-desktop-database + bzexe grub-ntldr-img perlbug update-menus + bzfgrep grub-render-label perldoc update-mime-database + bzgrep grub-script-check perli11ndoc upower + bzip2 grub-syslinux2cfg perlivp uptime + bzip2recover gsettings perlthanks usb-devices + bzless gsf pgrep usbhid-dump + bzmore gsf-office-thumbnailer pic usbreset + c++ gsf-vba-dump pico userinfo + c89 gstreamer-codec-install piconv usermount + c89-gcc gtbl pidof userpasswd + c99 gtf pidwait users + c99-gcc gtk-builder-tool pinentry users-admin + cancel gtk-encode-symbolic-svg pinentry-gnome3 utmpdump + captoinfo gtk-launch pinentry-x11 VBoxClient + caribou-preferences gtk-query-settings ping VBoxClient-all + cat gtk-update-icon-cache ping4 VBoxControl + catchsegv gucharmap ping6 VBoxDRMClient + catman gunzip pinky vdir + cc gzexe pipewire vi + cd-create-profile gzip pipewire-media-session view + cd-fix-profile h2ph pipewire-pulse viewres + cd-iccdump h2xs pkaction vim.tiny + cd-it8 hciattach pkcheck vlc + cdrdao hciconfig pkcon vlc-wrapper + c++filt hcitool pkexec vmstat + chacl hd pkg-config vmwarectrl + chage head pkill w + chardet HEAD pkmon w3m + chardetect helpztags pkttyagent w3mman + charmap hex2hcd pl2pm wall + chattr hexdump pldd watch + chcon host plog watchgnupg + cheese hostid plymouth wc + chfn hostname pmap wdctl + chgrp hostnamectl pod2html wget + chmod htop pod2man whatis + choom i386 pod2text whereis + chown ibus pod2usage which + chrome-gnome-shell ibus-daemon podchecker whiptail + chrt ibus-setup poff who + chsh iceauth pon whoami + chvt ico POST widget + ciptool icombine ppt2odp word-list-compress + cjpeg iconv pr wpa_passphrase + ckbcomp id precat write + cksum iecset preconv write.ul + clear ijoin preunzip wrjpgcom + clear_console im-config prezip www-browser + cmp im-launch prezip-bin X + codepage infocmp print X11 + col infotocap printenv x11perf + colcrt install printf x11perfcomp + colormgr install-menu prlimit x86_64 + colrm install-printerdriver prove x86_64-linux-gnu-addr2line + column instmodsh proxy x86_64-linux-gnu-ar + comm intel-virtual-output prtstat x86_64-linux-gnu-as + compose ionice ps x86_64-linux-gnu-c++filt + consolehelper ip psfaddtable x86_64-linux-gnu-cpp + consolehelper-gtk ipcmk psfgettable x86_64-linux-gnu-cpp-10 + corelist ipcrm psfstriptable x86_64-linux-gnu-dwp + cp ipcs psfxtable x86_64-linux-gnu-elfedit + cpan ipod-read-sysinfo-extended pslog x86_64-linux-gnu-g++ + cpan5.32-x86_64-linux-gnu ipod-time-sync pstree x86_64-linux-gnu-g++-10 + cpio iptables-xml pstree.x11 x86_64-linux-gnu-gcc + cpp ischroot ptar x86_64-linux-gnu-gcc-10 + cpp-10 isdv4-serial-debugger ptardiff x86_64-linux-gnu-gcc-ar + c_rehash isdv4-serial-inputattach ptargrep x86_64-linux-gnu-gcc-ar-10 + crontab ispell ptked x86_64-linux-gnu-gcc-nm + csplit ispell-wrapper ptksh x86_64-linux-gnu-gcc-nm-10 + ctstat join ptx x86_64-linux-gnu-gcc-ranlib + cupstestppd join-dctrl pulseaudio x86_64-linux-gnu-gcc-ranlib-10 + cut journalctl pw-cat x86_64-linux-gnu-gcov + cvlc jpegexiforient pw-cli x86_64-linux-gnu-gcov-10 + cvt jpegtran pwd x86_64-linux-gnu-gcov-dump + cvtsudoers json_pp pw-dot x86_64-linux-gnu-gcov-dump-10 + dash kbdinfo pw-dump x86_64-linux-gnu-gcov-tool + date kbd_mode pwdx x86_64-linux-gnu-gcov-tool-10 + dbus-cleanup-sockets kbxutil pw-metadata x86_64-linux-gnu-gold + dbus-daemon kernel-install pw-mididump x86_64-linux-gnu-gprof + dbus-launch kill pw-midiplay x86_64-linux-gnu-ld + dbus-monitor killall pw-midirecord x86_64-linux-gnu-ld.bfd + dbus-run-session kmod pw-mon x86_64-linux-gnu-ld.gold + dbus-send l2ping pw-play x86_64-linux-gnu-lto-dump-10 + dbus-update-activation-environment l2test pw-profiler x86_64-linux-gnu-nm + dbus-uuidgen laptop-detect pw-record x86_64-linux-gnu-objcopy + dbxtool last pw-reserve x86_64-linux-gnu-objdump + dconf lastb pw-top x86_64-linux-gnu-pkg-config + dd lastlog py3clean x86_64-linux-gnu-ranlib + deallocvt lcf py3compile x86_64-linux-gnu-readelf + debconf ld py3versions x86_64-linux-gnu-size + debconf-apt-progress ld.bfd pydoc3 x86_64-linux-gnu-strings + debconf-communicate ldd pydoc3.9 x86_64-linux-gnu-strip + debconf-copydb ld.gold pygettext3 x86_64-pc-linux-gnu-pkg-config + debconf-escape less pygettext3.9 xarchiver + debconf-set-selections lessecho python3 xargs + debconf-show lessfile python3.9 xauth + debianbts lesskey querybts xbiff + deb-systemd-helper lesspipe quodlibet xbrlapi + deb-systemd-invoke lexgrog qvlc xcalc + defmt-c lft ranger xclipboard + defmt-sh lft.db ranlib xclock + delpart libnetcfg rbash xcmsdb + delv libreoffice rcp xconsole + desktop-file-edit libwacom-list-local-devices rctest xcursorgen + desktop-file-install light-locker rdjpgcom xcutsel + desktop-file-validate light-locker-command rdma xdg-autostart + df link readelf xdg-dbus-proxy + dfu-tool linux32 readlink xdg-desktop-icon + dh_bash-completion linux64 realpath xdg-desktop-menu + dh_dkms linux-boot-prober rendercheck xdg-email + dh_installxmlcatalogs linux-check-removal renice xdg-icon-resource + dh_perl_openssl linux-update-symlinks reportbug xdg-mime + diff linux-version report-hw xdg-open + diff3 listres reset xdg-screensaver + dig ln resizecons xdg-settings + dir lnstat resizepart xdg-user-dir + dircolors loadkeys resolvectl xdg-user-dirs-gtk-update + dirmngr loadunimap rev xdg-user-dirs-update + dirmngr-client localc rfcomm xditview + dirname locale rgrep xdpyinfo + discover-config localectl rhythmbox xdriinfo + djpeg localedef rhythmbox-client xedit + dmesg lodraw rifle Xephyr + dm-tool loffice ristretto xev + dnsdomainname lofromtemplate rlogin xeyes + dnstap-read logger rm xfburn + doc2odt login rmdir xfce4-about + doc2pdf loginctl rnano xfce4-accessibility-settings + domainname logname routef xfce4-appearance-settings + dotlockfile loimpress routel xfce4-appfinder + dpkg lomath rpcgen xfce4-clipman + dpkg-architecture look rsh xfce4-clipman-history + dpkg-buildflags loweb rstart xfce4-clipman-settings + dpkg-buildpackage lowntfs-3g rstartd xfce4-color-settings + dpkg-checkbuilddeps lowriter rtstat xfce4-dict + dpkg-deb lp runcon xfce4-display-settings + dpkg-distaddfile lpoptions run-mailcap xfce4-find-cursor + dpkg-divert lp_solve run-parts xfce4-keyboard-settings + dpkg-genbuildinfo lpstat run-with-aspell xfce4-mime-helper + dpkg-genchanges ls rview xfce4-mime-settings + dpkg-gencontrol lsattr rvlc xfce4-mouse-settings + dpkg-gensymbols lsblk rygel xfce4-notifyd-config + dpkg-maintscript-helper lsb_release sane-find-scanner xfce4-panel + dpkg-mergechangelogs lscpu savelog xfce4-popup-applicationsmenu + dpkg-name lsinitramfs scanimage xfce4-popup-clipman + dpkg-parsechangelog lsipc scp xfce4-popup-clipman-actions + dpkg-query lslocks scp-dbus-service xfce4-popup-directorymenu + dpkg-realpath lslogins screendump xfce4-popup-places + dpkg-scanpackages lsmem script xfce4-popup-whiskermenu + dpkg-scansources lsmod scriptlive xfce4-popup-windowmenu + dpkg-shlibdeps lsns scriptreplay xfce4-power-manager + dpkg-source lsof scrot xfce4-power-manager-settings + dpkg-split lspci sdiff xfce4-screenshooter + dpkg-statoverride lspgpot sdptool xfce4-sensors + dpkg-trigger lsusb sdw2odt xfce4-session + dpkg-vendor lto-dump-10 seahorse xfce4-session-logout + du luit sed xfce4-session-settings + dumpkeys lwp-download see xfce4-settings-editor + dwp lwp-dump select-default-iwrap xfce4-settings-manager + echo lwp-mirror select-editor xfce4-taskmanager + edit lwp-request sensible-browser xfce4-terminal + editor lxappearance sensible-editor xfce4-terminal.wrapper + editres lxclipboard sensible-pager xfconf-query + egrep lxde-logout sensors xfd + eject lxhotkey sensors-conf-convert xfdesktop + elfedit lxinput seq xfdesktop-settings + enc2xs lxlauncher sessreg xfhelp4 + encguess lxlock setarch xflock4 + enchant-2 lxmusic setfacl xfontsel + enchant-lsmod-2 lxpanel setfont xfrun4 + env lxpanelctl setkeycodes xfsettingsd + envsubst lxpolkit setleds xfwm4 + eog lxrandr setlogcons xfwm4-settings + eqn lxsession setmetamode xfwm4-tweaks-settings + evince lxsession-db setpci xfwm4-workspace-settings + evince-previewer lxsession-default setpriv xgamma + evince-thumbnailer lxsession-default-apps setsid xgc + evolution lxsession-default-terminal setterm xhost + ex lxsession-edit setupcon xiccd + exfalso lxsession-logout setvtrgb xinit + exifautotran lxsession-xdg-autostart setxkbmap xkbbell + exo-desktop-item-edit lxsettings-daemon sftp xkbcomp + exo-open lxtask sg xkbevd + expand lxterminal sh xkbprint + expiry lynx sha1sum xkbset + expr lzcat sha224sum xkbset-gui + factor lzcmp sha256sum xkbvleds + faillog lzdiff sha384sum xkbwatch + faked-sysv lzegrep sha512sum xkeystone + faked-tcp lzfgrep shares-admin xkill + fakeroot lzgrep shasum xload + fakeroot-sysv lzless shotwell xlogo + fakeroot-tcp lzma showconsolefont xls2ods + fallocate lzmainfo showkey xlsatoms + false lzmore showrgb xlsclients + fc-cache make shred xlsfonts + fc-cat make-first-existing-target shuf xmag + fc-conflist mako-render simple-scan xman + fc-list malcontent-client size xmessage + fc-match malcontent-control skill xmms2d + fc-pattern man slabtop xmms2-launcher + fc-query mandb sleep xmodmap + fc-scan manpath slogin xmore + fc-validate man-recode smproxy Xorg + fgconsole mapscrn snice xprop + fgrep mawk soelim xrandr + file mcookie soffice xrdb + file-roller md5sum software-properties-gtk xrefresh + fincore md5sum.textutils sort xsane + find mdig sort-dctrl xscreensaver + findaffix memusage sotruss xscreensaver-command + findmnt memusagestat spa-acp-tool xscreensaver-demo + firefox mesa-overlay-control.py spa-inspect xscreensaver-getimage + firefox-esr mesg spa-monitor xscreensaver-getimage-file + flock mid3cp spa-resample xscreensaver-getimage-video + fmt mid3iconv spd-conf xscreensaver-systemd + fold mid3v2 spd-say xscreensaver-text + fonttosfnt migrate-pubring-from-classic-gpg spdsend x-session-manager + free mimeopen speaker-test xset + funzip mimetype speech-dispatcher xsetmode + fuser mkdir splain xsetpointer + fusermount mkfifo split xsetroot + fusermount3 mkfontdir splitfont xsetwacom + fwupdagent mkfontscale sprof xsm + fwupdate mk_modmap ss xstdcmap + fwupdmgr mknod ssh xsubpp + fwupdtool mktemp ssh-add x-terminal-emulator + fwupdtpmevlog mmcli ssh-agent xvidtune + g++ moggsplit ssh-argv0 xvinfo + g++-10 monitor-sensor ssh-copy-id Xwayland + gamma4scanimage more ssh-keygen xwd + gapplication mount ssh-keyscan x-window-manager + gatttool mountpoint startlxde xwininfo + gcalccmd mousepad start-pulseaudio-x11 xwud + gcc mpris-proxy startx x-www-browser + gcc-10 mt startxfce4 xxd + gcc-ar mt-gnu stat xz + gcc-ar-10 mtrace stdbuf xzcat + gcc-nm munchlist streamzip xzcmp + gcc-nm-10 mutagen-inspect strings xzdiff + gcc-ranlib mutagen-pony strip xzegrep + gcc-ranlib-10 mv stty xzfgrep + gcm-import namei su xzgrep + gcm-inspect nano sudo xzless + gcm-picker nautilus sudoedit xzmore + gcm-viewer nautilus-autorun-software sudoreplay yelp + gcov nawk sum yes + gcov-10 nc sushi ypdomainname + gcov-dump nc.traditional su-to-root zcat + gcov-dump-10 neqn svlc zcmp + gcov-tool netcat switcherooctl zdiff + gcov-tool-10 networkctl sxw2odt zdump + gcr-viewer newgrp synaptic-pkexec zegrep + gdbus ngettext sync zenity + gdialog nice system-config-printer zfgrep + gdk-pixbuf-csource nisdomainname system-config-printer-applet zforce + gdk-pixbuf-pixdata nl systemctl zgrep + gdk-pixbuf-thumbnailer nm systemd zipdetails + gdm-control nm-applet systemd-analyze zipgrep + gdmflexiserver nmcli systemd-ask-password zipinfo + gdm-screenshot nm-connection-editor systemd-cat zless + gedit nm-online systemd-cgls zmore + gencat nmtui systemd-cgtop znew + geqn nmtui-connect systemd-delta + GET nmtui-edit systemd-detect-virt +waldek@hellodebian:/usr/bin$ +``` + +That's a **lot** of programs! +Can you find `cd` in there? +Spoiler alert, you wont... +Maybe it's located somewhere else? +Let's have a look. + +``` +waldek@hellodebian:/usr/bin$ which cd +waldek@hellodebian:/usr/bin$ +``` + +`cd` is not a program but a builtin command. +From a practical point of view there is no difference but I do like to mention it for completeness. +Later down the line it will help you to contextualize the differences between shells a bit better. +But built into *what*? +Below you can see a snippet of a part of the `bash-builtin` manual. +For now just accept the specific shell we're using is called `bash`. + +``` +BASH-BUILTINS(7) Miscellaneous Information Manual BASH-BUILTINS(7) + +NAME + bash-builtins - bash built-in commands, see bash(1) + +SYNOPSIS + bash defines the following built-in commands: :, ., [, alias, bg, bind, break, builtin, case, cd, command, compgen, complete, continue, de‐ + clare, dirs, disown, echo, enable, eval, exec, exit, export, fc, fg, getopts, hash, help, history, if, jobs, kill, let, local, logout, popd, + printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, unalias, + unset, until, wait, while. +``` + +### Absolute and relative paths + +> All roads lead to Rome. + +There are multiple ways to go to the same location on your system. +You can always go either in an **absolute** way, or in *multiple* **relative** ways. +The root of your system is `/` and to list what we can find there we can use `ls`. + +``` +waldek@hellodebian:~$ cd / +waldek@hellodebian:/$ ls +bin dev home initrd.img.old lib32 libx32 media opt root sbin sys usr vmlinuz +boot etc initrd.img lib lib64 lost+found mnt proc run srv tmp var vmlinuz.old +waldek@hellodebian:/$ +``` + +From here we can go back home in multiple ways. + +``` +waldek@hellodebian:/$ cd +waldek@hellodebian:~$ cd - +/ +waldek@hellodebian:/$ cd home/waldek/ +waldek@hellodebian:~$ cd - +/ +waldek@hellodebian:/$ cd /home/waldek/ +waldek@hellodebian:~$ +``` + +The first one is the handy shortcut we learned, and we go back to the root of our system with the `cd -` shortcut. +The following two manipulations look very similar but there is a subtle difference. +The first one `home/waldek` is a **relative** path, and the second one `/home/waldek` is an **absolute** one. +Relative paths depend on where you are located, absolute ones always point to the same location. +An example. + +``` +waldek@hellodebian:~$ cd /usr/bin/ +waldek@hellodebian:/usr/bin$ cd /home/waldek/ +waldek@hellodebian:~$ cd - +/usr/bin +waldek@hellodebian:/usr/bin$ cd home/waldek +-bash: cd: home/waldek: No such file or directory +waldek@hellodebian:/usr/bin$ +``` + +The second command fails because from where I'm standing, there is no folder called `home/waldek`! +I can however still go to my home in a relative way but I need to *go back* a few directories first. + +``` +waldek@hellodebian:/usr/bin$ cd ../../home/waldek/ +waldek@hellodebian:~$ pwd +/home/waldek +waldek@hellodebian:~$ +``` + +The `..` means go **back** one directory so in our example we go back **two** directories, which brings us to the `/` of our system and from there we go **up** to `home` and then `waldek`. + +### Exercise + +Explore your system a bit using `cd` and `ls`. +You'll probably encounter some weird messages along the way. +Keep note of them so we can discuss it together. + +### `root` and `/` and `/root` are not the same thing + +## A pit stop to review what we've learned so far + +Below is a list of programs and command we've seen so far. + +|command|desciption| +|---|---| +|systemctl|manipulate running services| +|apt|the Debian package manager| +|htop|a command line task manager we installed| +|vlc|a video player we installed| +|date|display the time of day| +|which|show the path to an executable| +|file|print more information about a file's content| +|head|show the first lines of a file| +|pwd|print working directory| +|cd|change directory| +|ls|list content of a directory| +