Anything that doesn’t warrant a War & Peace explanation goes in here…
The command and a brief what it does and why would you want to.
First up querying what a package brings to the party – excess baggage that may require further exploration…
repoquery
repoquery --requires --resolve
Good for rpmfusion or other repo’s that may add in things that change base packages. It does require that the repo is in the yum configuration for it to query. The yum settings can be switched on and off so that future yum updates wont check that particular repo and install things without your knowledge. This requires that yum-utils is installed.
yum-config-manager
The –enablerepo option overides the permanent option set in the .repo file for only the current command. –disablerepo does the opposite for enabled repos.
If you install (or have installed) the yum-utils package then you can use yum-config-manager to permanently enable/disable repos without editing the file:
yum-config-manager --enable remi
will permanently enable the remi repo.
yum repolist all
will list all the repo id which you use with the –enable or –disable option.
one-off install from disabled repositories
By default yum installs only from the enabled repositories. For some reason if you like to install a package from a disabled repositories, use –enablerepo option in the ‘yum install’ as shown below.
yum --enablerepo=fedora-source install vim-X11.x86_64
RedHat Centos 7 firewall quickies
firewall-cmd --get-active-zones - Shows which zones you have and which interfaces firewall-cmd --zone=public --add-port=2049/tcp --permanent - Adds nfs4 port 2049 to the firewall permanently firewall-cmd --reload - Reload the firewall for the changes to take effect
firewall-cmd --zone=public --list-all - shows all the current rules, interfaces, ports etc
firewall-cmd --permanent --zone=public --add-port=80/tcp - add a port permanently web and tcp in this instance
firewall-cmd --zone=public --remove-port=80/tcp - remove a port 'The firewall giveth and the firewall taketh away!'
firewall-cmd --panic-on - exactly as advertised, shuts up shop
firewall-cmd --query-panic - what state is panic in? on or off
firewall-cmd --panic-off - open for business again
RedHat Centos 7 services quickies
systemctl start name.service - Starts a service systemctl stop name.service - Stops a service systemctl restart name.service - Restarts a service systemctl reload name.service - Reloads configuration systemctl status name.service - Checks if a service is running systemctl is-active name.service - Checks if a service is running systemctl list-units --type service --all - Displays the status of all services systemctl enable name.service - Enables a service. systemctl disable name.service - Disables a service. systemctl status name.service - Checks if a service is enabled. systemctl is-enabled name.service - Checks if a service is enabled. systemctl list-unit-files --type service - Lists all services and checks if they are enabled. systemctl list-dependencies --after - Lists services that are ordered to start before the specified unit. chkconfig --list systemctl list-dependencies --before - Lists services that are ordered to start after
RedHat Centos 7 xrdp
yum install epel-release yum install xrdp systemctl enable xrdp.service systemctl start xrdp.service firewall-cmd --zone=public --add-port=3389/tcp --permanent firewall-cmd --reload restorecon -v /usr/sbin/xrdp restorecon -v /usr/sbin/xrdp-sesman reboot
Screen command
Delete a rogue screen session screen -ls screen -S <pid> -p 0 -X quit
rpm install by date query
rpm -qa --queryformat '%{installtime} (%{installtime:date}) %{name}\n' | sort -n | tail -5
miss off the tail to get a complete list
samba firewall
firewall-cmd –permanent –add-port=137/tcp
firewall-cmd –permanent –add-port=138/tcp
firewall-cmd –permanent –add-port=139/tcp
firewall-cmd –permanent –add-port=445/tcp
firewall-cmd –permanent –add-port=901/tcp
firewall-cmd –reload
Man page to nicely formatted PDF
For when you absolutely have to have a nicely printed Man page to scribble all over at the machine in question..
man -t <man page you want in here> | ps2pdf - man-page-name.pdf
List disk usage/folder sizes in order
du -xh * | sort -rn | head -20
fsck check
The dreaded ‘non shall pass’ when a system hasn’t been shutdown correctly or a drive is failing.
Run fsck without -a or -P
Look at the file system it is complaining about – probably one that is in device-mapper and write down the path. Then: –
fsck /dev/mapper/device/in/the/warning/message
and follow the prompts as they come up on the screen to repair the affected system.
run process as other user to see ‘their’ issues
as root: –
su <uid>
ls and see different date format
ls -l –time-style=full-iso
Find your external I.P address
curl ifconfig.me