configuring networking from the command line

nmcli : interface to the network manager daemon

/etc/sysconfig/network-scripts :

nmcli con sho : show connections

watch some videos on DNS/networking, knowledge still feels kind of loose

nmcli con add con-name foo ifname enp1s0 type ethernet : add a network connection with:

  • name: foo
  • ifname: enp1s0
  • type: ethernet

editing network configuration files

ls -l /etc/sysconfig/network-scripts/ifcfg-* : network config config files

configuring hostnames and name resolution

hostname

hostnamectl status

hostnamectl set-hostname somehostname.com

/etc/hosts

user@host ~ > getent hosts localhost ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

archiving and transferring files

tar -cf etc.tar /etc

tar -tf etc.tar

tar -cf userhome.tar /home/user : create a tar with a dir, removing the leading /

tar -tf userhome.tar : investigate tar contents

tar -czf mydir-backup-$(date +%F).tar.gz : add a datestamp to the tar name

tar compression

  • czf : gzip, strong
  • cfj : bzip, stronger
  • cfJ : xzip, strongest
  • cf : no compression

tar -xf : e(x)tract from (f)ile

tar -xf the.tar.xz path/to/dir : extract just target dir

transferring files between systems securely

scp, uses ssh

scp -r user@host:/somedir . : copy remote somedir to this location

sftp : secure FTP-type interface, FTP over ssh; traditional FTP is plaintext, so don’t use that sftp is basically interactive scp

sftp> ls : execute ls in the sftp connection sftp> mkdir adir : make a dir in the sftp connection sftp> lcd alocaldir : change to a local directory sftp> put alocaldir : upload a local directory to remote sftp server

syncronizing files between systems securely

rsync : uses ssh to synchronize files between systems

rysnc -Par otherhost:/adir . : progress, archive, recursively

this means repeated commands will send a file list, and only sync the difference between the two systems

installing and updating software packages

subscription manager tool

subscription-manager status : get status of machine subscription-manager register : tell redhat about your host subscription-manager attach --auto : idk subscription-manager repos --disable='*' --enable myrepo : disable all repos then explicitly enable one

access.redhat.com asset management

rpm

need rpm file, can do queries against database or file

rpm : redhat package management, archive of all the files and directories, metadata, and scripts to handle the lifecycle

  • all installed software is stored in the rpm database
  • resolves packages
  • helps prevent conflicts
  • redhat signs the packages with gpg private key, and makes the public key available to everyone
  • redhat provides a full install of a package, not just updates to existing packages
  • it is possible to have multiple versions of packages installed as long as they have different names
  • ls -l *.rpm

rpm -i my.rpm : install an rpm; will inform about failed dependencies but will not resolve/install them

rpm -qf /etc/ssh/sshd_config : (q)uery target (f)ile, shows which package provides the file

yumdownloader openssh-server : downloads an openssh-server file

rpm -qpl openssh-server-* : conduct a (q)uery against the rpm (p)ackage, (l)isting files

rpm -qpd openssh-server-* : conduct a (q)uery against the rpm (p)ackage, showing (d)ocumentation

rpm2cpio myrpm | cpio -duim : unpacking an archive, extracting all files and dirs

installing and updating software packages with yum

yum can execute against rpm database, or local rpm file, or repositories

yum search nmap : find packages in repos

yum info nmap : get info about package

repoquery -l nmap : list package files

yum provides *bin/authconfig : find packages providing specific file

yum remove nmap : remove nmap

don’t use -y when removing software, because you could remove dependencies

yum group list : show groups

yum group info 'Development Tools' : show details about target group

^info^install : replace the word info in previous command with install

yum history

user@host ~ > yum history Loaded plugins: fastestmirror, langpacks You don’t have access to the history DB.

where does software come from

yum repolist all : list all repos

cat /etc/yum.repos.d/rhel_dvd.repo : read repo details

managing package module streams: testing multiple versions of software in RHEL8

  • modularity: single repo, multiple versions and dependencies of application
    • module is a group of rpms
    • modules have different streams
    • only one can be enabled at a time
    • yum module subcommand
  • app stream: provides software with different life cycles

yum module list perl : shows all streams, and default stream perl: Practical Extraction and Report Language

yum module info perl

yum module install perl yum install @perl : installs a group

  • @ means item acting against is a module

accessing linux file systems

block devices (ls -l will show leading b) are special files which represent real storage devices, /dev, /sda, sdb, etc.

lsblk : show block(s)

partitions etc.

single file system from multiple disks using LVM

df -h : shows file systems

df -h / : shows specific file system

1
2
# blkid /dev/somedev
/dev/somedev: UUID="someuuid" TYPE="xfs"

mounting and unmounting file systems

mount what where : mount the what device to the where location

umount what : unmount a device

locating files in the system

find where how what find / -name sshd_config : search entire filesystem by name for sshd_config

  • use iname for case-insensitive search

find / -user someuser : find all files owned by someuser, can also use userid you can use -delete to delete found files, oh man

find / -type f -user someuser -size -10M : find files owned by someuser less than 10M in size

find /home -size +10M -iname "*.mkv" -exec rm -f {} \; : removes files greater than 10M that have the mkv extension

  • {} : represents what’s going to be found
  • \; : terminates the command
  • can also use -delete instead of -exec...

find /home -perm 111 : find files with exactly permissions 111 (exec) find /home -perm /111 : find files with permissions 111 (exec) in them find /home -type f -perm /111 : find files with permissions 111 (exec) in them that are just files

find /home -type f -perm /111 -exec rm -i {} \; : find files with permissions 111 (exec) in them that are just files, then do an interactive removal

find /home -type f -perm /111 -exec chmod -x {} \; : find files with permissions 111 (exec) in them that are just files, then remove the execution permission

find /home -type f -mmin -60 : find files modified in the last 60 minutes

locate : uses a database of files on file system

  • need to run updatedb to update the source dateabase
  • not too reliable because it’s dependent on updatedb
  • is not as flexible as find

analyzing and managing remote servers

firewall-cmd --add-service cockpit : not persistent, will not survive reboot or restart of the firewall daemon

  • cockpit is the web user interface for managing systems