Linux Notes
- 1.
DNF - 2. Install the Latest Updates
- 3. Enable root account
- 4. List IP Addresses
- 5. List Ports
- 6. Create an Archive via Tar
- 7. WEB
- 8. Firewall
- 9. GPU
- 10. IPMI
- 11. Shells
- 12. GIT
- 13. Visual Studio Code
- 14. .Net 6.x.x
- 15. Docker
- 16. Temporarily Mount Windows Share
- 17. Permanently Mount a Windows/Linux File Share
- 18. Log Files
- 19. Misc Commands
- 20. Troubleshooting
1. DNF
| Only for RHEL |
-
Perform the following steps to install the
DNFpackage manager which is the successor to theyumpackage manager:
1.1. Install the DNF Package Manager
-
Install the
DNFpackage manager (not required on RedHat 8/CentOS 8)sudo yum install -y dnf -
Install EPEL repository
sudo dnf install -y epel-releaseIf the previous command failed, try this one:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -
Make the DNF cache
sudo dnf makecache
1.2. Update the DNF Package Manager
-
Add the
EPELRepo:sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -
Add the
RemiRepo:sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -
Install dnf-utils Package:
sudo dnf install dnf-utils -
Update Software packages:
sudo dnf updateThis may take a while to complete…
2. Install the Latest Updates
-
Run the following to view the available updates
apt list --upgradable -
Run the following to update the system
sudo apt -y dist-upgrade
3. Enable root account
-
Execute the following:
sudo passwd rootsudo passwd -u root -
Update this file:
-
Edit this file
sudo vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf -
Append this text at the end:
greeter-show-manual-login = true
-
-
Update this file too:
-
Edit this file
sudo vi /etc/ssh/sshd_config -
Append this test at the end:
PermitRootLogin yes -
Restart the ssh server
sudo systemctl restart sshd
-
-
Reboot!
sudo shutdown -r now
8. Firewall
8.1. Ports
-
Open a Port
Expand for Fedora instructions
-
Check status
sudo firewall-cmd --state -
Open Port
sudo firewall-cmd --add-port=3389/tcp --permanent -
Reload FW Rules
sudo firewall-cmd --reload -
Show rules
sudo firewall-cmd --list-all -
Remove a port
-
Remove
sudo firewall-cmd --remove-port=3389/tcp -
Make persistent
sudo firewall-cmd --runtime-to-permanent
-
Expand for Ubuntu instructions
-
Enable FW
sudo systemctl enable ufw --now -
Open Port 3389
sudo ufw allow 3389/tcp -
Reload FW rules
sudo ufw reload
-
10. IPMI
-
To discover IPMI devices
commandipmiutil discoverresultdiscover ver 1.11 Discovering IPMI Devices: 01| response from | 192.168.0.1 | 02| response from | 192.168.0.2 |
11. Shells
13. Visual Studio Code
13.1. Install
Refer to the VSC doc.
14. .Net 6.x.x
Expand for Ubuntu
| Must have version 22.04+ of Ubuntu |
-
Reference doc is here.
-
Install
sudo apt update && sudo apt install dotnet6
15. Docker
15.1. RHEL
-
Emulate Docker CLI using podman.
-
RedHat uses podman as its command line interface to manage the container ecosystem. So, instead of using the docker cli command you would now use podman in its place.
-
However most container related documentation will reference the docker cli command so in order to simplify things and use docker or podman on RedHat, do the following:
-
Become root
su -
Try to run docker which won’t be found but should offer to install the
podman-dockerpackage:docker bash: docker: command not found... Install package 'podman-docker' to provide command 'docker'? [N/y] y -
Continue with the install…
-
-
-
Emulate
docker-composeviapodman-compose.-
The above installation will only give you the Docker cli but if you need
docker-composeyou’ll have to usepodman-compose, however this is not available at default. -
Install
-
Become root
su -
Try to run podman-compose which won’t be found but should offer to install the
podman-composepackage:podman-compose bash: podman-compose: command not found... Install package 'podman-compose' to provide command 'podman-compose'? [N/y] y -
Continue with the install…
-
-
Now you can use
podman-composeas a direct replacement fordocker-compose.
-
16. Temporarily Mount Windows Share
|
This mount is temporary and will be lost upon system reboot. |
-
First install the
cifs-utilspackage (this only needs to be done once):RHELsudo dnf install cifs-utilsUbuntusudo apt -y install cifs-utils -
Make a mount point
sudo mkdir -p /mnt/Norco/Stuff -
Mount the windows share:
sudo mount -t cifs -o username=<user@domain> //norco/Stuff /mnt/Norco/Stuff (1) Password for mattosd@dhante.local@//norco/Stuff: ********** $1 supply credentials that have access to the share. -
Confirm mount exists
Commanddf -hSample OutputFilesystem Size Used Avail Use% Mounted on devtmpfs 841M 0 841M 0% /dev tmpfs 870M 0 870M 0% /dev/shm tmpfs 870M 9.1M 861M 2% /run tmpfs 870M 0 870M 0% /sys/fs/cgroup /dev/mapper/rhel-root 17G 4.7G 13G 28% / /dev/sda1 1014M 242M 773M 24% /boot tmpfs 174M 12K 174M 1% /run/user/42 tmpfs 174M 4.0K 174M 1% /run/user/1000 //norco/Stuff 700G 520G 181G 75% /mnt/Norco/Stuff (1) [dhante@v-RedHat00 ~]$1 This is our mounted directory
17. Permanently Mount a Windows/Linux File Share
| A shared folder must first exist on the remote Windows/Linux system before trying to mount that existing share locally. |
-
First (this only needs to be done once)
Ubuntusudo add-apt-repository universe -
Next install the
cifs-utilspackage (this only needs to be done once):Ubuntusudo apt install cifs-utilsFedorasudo dnf install cifs-utils -
Make a mount point
Examplesudo mkdir -p /mnt/p-ubuntu-norco/Backups -
Create a
.mnt-credfile in the user’s home directoryThe file name is not important but must be the same as the name entered into the
/etc/fstabfile.-
Edit the file
Examplevi /home/mattosd/.mnt-cred -
Add credential related contents:
These are credentials for the remote system. Exampleusername=mattosd password=s3cret
-
-
Add an entry to the
/etc/fstabfile:-
Edit
sudo vi /etc/fstab -
Add one of the following:
-
Windows file share:
//p-winserv-norco/Backups /mnt/p-ubuntu-norco/Backups cifs credentials=/home/mattosd/.mnt-cred,_netdev 0 0 (1)1 The existing shared folder on the remote Norcoserver is namedBackups.This is a long single line. -
Linux file share:
//p-ubuntu-norco/Backups /mnt/p-ubuntu-norco/Backups cifs guest,iocharset=utf8,file_mode=0777,dir_mode=0777,credentials=/home/mattosd/.mnt-cred (1)1 The existing shared folder on the remote p-ubuntu-norcoserver is namedBackups.This is a long single line.
-
-
-
Now mount:
Ubuntusudo mount -aFedorasudo mount -asudo systemctl daemon-reload
19. Misc Commands
19.1. Reset an Ethernet Interface or Wi-Fi adapter
-
Stop the Interface
sudo ip link set dev <interface> stop -
Start the Interface
sudo ip link set dev <interface> start
19.2. Find DHCP Server
-
Use the nmap command
sudo nmap --script broadcast-dhcp-discover -
Use the dhclient command
sudo dhclient -d -nw eno1 (1)1 replace eno1 with the actual interface. use ifconfigto find
19.3. Check DNS entry
|
If the
|
19.4. Check External Port
-
To confirm able to connect to an external port
-
Use the
netcatcommandExample to check google.comnc -v google.com 443If the
nccommand is not found, install via:sudo apt install -y netcat
-
19.6. Disk Space
-
Use
df -hto display space used by file systems:[root@v-RedHat-MidPoint /]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.4G 0 1.4G 0% /dev tmpfs 1.4G 0 1.4G 0% /dev/shm tmpfs 1.4G 155M 1.2G 12% /run tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup /dev/mapper/rhel_v--redhat--midpoint-root 17G 17G 20K 100% / (1) /dev/sda1 1014M 346M 669M 35% /boot tmpfs 275M 16K 275M 1% /run/user/42 tmpfs 275M 4.0K 275M 1% /run/user/10001 Here we can see the root file system is full with 17GB of data -
Use
du -h -s *to display space used by folders:[root@v-RedHat-MidPoint /]# du -h -s * 0 bin 306M boot 0 dev 33M etc 360M home 0 lib 0 lib64 0 media 0 mnt 12G opt (1) 0 proc 40K root 155M run 0 sbin 0 srv 0 sys 36K tmp 4.4G usr 562M var1 /optis using 12G -
Use
du -cha --max-depth=1 /var | grep -E "M|G"