Linux Sysadmin
- alternatives command (e.g. to set to a specific default Java version)
sudo alternatives --config java
- Introduction to the alternatives command in Linux
- To remove an alternatives entry:
asroot alternatives --remove java /home1/hub/java11_64.ansible/jdk-11.0.20.1+1/bin/java
- User accounts:
- Add user to sudoers
One method is to add the user to wheel group:# usermod -aG wheel username
. Now log in again asusername
and rungroups
command. - Create group:
sudo groupadd ansible
- Create user (also add user to sudoers via
wheel
group membership):
sudo useradd -g ansible -G wheel ansible
- Set password:
passwd ansible
- Remove prompt for password when using sudo (not most secure, but very handy for using ansible etc):
Runvisudo
Comment-out and comment these lines, to leave them like this:## Allows people in group wheel to run all commands #%wheel ALL=(ALL) ALL ## Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL
To test, running
sudo id
should returnroot
- Add user to sudoers
- Cron
- ps
- Seeing all of the command-line:
ps auxww | grep java
- Seeing all of the command-line:
- System-wide LD_LIBRARY_PATH update:
- LD_LIBRARY_PATH - how to update for a system service: Add the directory to /etc/ld.so.conf or a new file in /etc/ld.so.conf.d/, depending on distro. After that, you must run (at least on Redhat) ldconfig as root.
- See also https://developer.ibm.com/technologies/linux/tutorials/l-lpic1-102-3/.
- System-wide PATH update:
- See files in
/etc/profile.d
- See files in
- rpm:
- List installed packages:
rpm -qa
- List files in an uninstalled rpm:
rpm -qpl ./BaseOS/Packages/yum-utils-4.0.8-3.el8.noarch.rpm
- List files in an installed rpm:
rpm -ql postgresql12-server.x86_64 | grep conf
- Idenitfy the package a file came from:
rpm -qf /usr/bin/svn
- Install an rpm, and automatically install any dependencies (via yum):
yum --nogpgcheck localinstall VirtualBox-6.1-6.1.12_139181_el8-1.x86_64.rpm
- List installed packages:
- systemd:
- Debug service startup faiure:
journalctl -xe -u redis
- List all services:
systemctl list-unit-files | grep -i postgres
orsudo systemctl list-units --type=service
- Example config file path:
/usr/lib/systemd/system/MFSafeNet.service
- Debug service startup faiure:
- top:
- yum:
- Yum cheatsheet
- List files in an uninstalled package:
yum repoquery --list postgresql12-contrib.x86_64
- List all available versions of each package, rather than the most recent version:
yum --showduplicates --disablerepo="*" --enablerepo="pgdg10" list available
- Install a package version that is not the most recent:
yum --showduplicates --disablerepo="*" --enablerepo="pgdg10" install postgresql10-server-10.12
Another example:
yum --showduplicates --disablerepo="*" --enablerepo="pgdg10" install postgresql10-odbc-10.03.0000-1PGDG.rhel7
Note: Take the package base name (e.g. “postgresql10-server”) and then add the version (e.g. “10.12”). See also here.
Written on October 13, 2020