notes update

This commit is contained in:
Hugh Ratsch
2025-03-06 18:51:21 -06:00
parent 1c0abd53fe
commit 5830b72de9
+179 -1
View File
@@ -1028,4 +1028,182 @@ systemctl --user enable container-mynginx.service # enable the mynginx service
systemctl --user status container-mynginx.service # check the status of the mynginx service systemctl --user status container-mynginx.service # check the status of the mynginx service
### after rebooting the system, the service will start automatically ### after rebooting the system, the service will start automatically
``` ```
## Create Archives and Compress Files
### Using gzip and bzip2
```bash
### gzip
gzip file.txt # Compress the file.txt file
gunzip file.txt.gz # Decompress the file.txt.gz file
zcat file.txt.gz # Display the contents of the file.txt.gz file
### bzip2
bzip2 file.txt # Compress the file.txt file
bunzip2 file.txt.bz2 # Decompress the file.txt.bz2 file
bzcat file.txt.bz2 # Display the contents of the file.txt.bz2 file
```
### Using xz and zip
```bash
### xz
xz file.txt # Compress the file.txt file
unxz file.txt.xz # Decompress the file.txt.xz file
xzcat file.txt.xz # Display the contents of the file.txt.xz file
### zip
zip file.zip file.txt # Compress the file.txt file
zip file.zip file1.txt file2.txt # Compress multiple files
unzip file.zip # Decompress the file.zip file
zipinfo file.zip # Display the contents of the file.zip file
```
### Tar and Star
```bash
### tar
tar -cvf archive.tar file.txt # Create an archive of the file.txt file
tar -xvf archive.tar # Decompress the archive.tar file
tar -tvf archive.tar # Display the contents of the archive.tar file
### tar with compression
tar -czvf archive.tar.gz file.txt # Create an archive of the file.txt file with compression
tar -cjvf archive.tar.bz2 file.txt # Create an archive of the file.txt file with compression
tar -cJvf archive.tar.xz file.txt # Create an archive of the file.txt file with compression
### star basic commands
star -cf archive.tar file.txt # Create an archive of the file.txt file
star -xf archive.tar # Decompress the archive.tar file
star -tvf archive.tar # Display the contents of the archive.tar file
```
### Finding Files to Archive
```bash
### find
sudo find / -type f -name "*.txt" # Find all files with a .txt extension
### cpio
sudo find / -type f -name "*.txt" | cpio -ocvB > archive.cpio # Create an archive of the files
### cpio extract
cpio -idv < archive.cpio # Extract the archive.cpio file
### cpio with compression
sudo find / -type f -name "*.txt" | cpio -ocvB | gzip > archive.cpio.gz # Create an archive of the files with compression
### cpio with compression extract
gunzip -c archive.cpio.gz | cpio -idv # Extract the archive.cpio.gz file
```
## Manage Users, Groups and Shells
### Creating New Users
```bash
sudo useradd user1 # Create a new user
sudo useradd -m user1 # Create a new user and home directory
sudo useradd -s /bin/bash user1 # Create a new user and set the shell to bash
sudo useradd -c "User One" user1 # Create a new user and set the comment to User One
```
### Controlling Default Values
```bash
### default useradd configuration file
sudo vim /etc/default/useradd
### skeleton directory
cd /etc/skel
### create a file in the skeleton directory
echo "This is a test file" > test.txt
### when a new user is created, the files in the skeleton directory are copied to the user's home directory
sudo useradd user1
### check the home directory
ls -a /home/user1
### login.defs configuration file
sudo vim /etc/login.defs
### change the default shell to bash
DEFAULT_SHELL=/bin/bash
### change the default group to users
DEFAULT_GROUP=users
```
### Deleting Users
```bash
sudo userdel user1 # Delete the user
sudo userdel -r user1 # Delete the user and home directory
```
### User Modification
```bash
sudo usermod -c "User One" user1 # Change the comment to User One
sudo usermod -s /sbin/nologin user1 # Change the shell to nologin
sudo usermod -aG users user1 # Add the user to the users group
sudo usermod -L user1 # Lock the user
sudo usermod -U user1 # Unlock the user
sudo usermod -d /home/user2 user1 # Change the home directory to /home/user2
sudo usermod -m -d /home/user2 user1 # Change the home directory to /home/user2 and move the user's files to the new directory
```
### Understanding Groups
```bash
sudo groupadd admins # Create a new group
sudo groupadd -g 1000 admins # Create a new group with a specific group ID
sudo groupdel admins # Delete the group
sudo groupmod -n admins admin # Change the group name to admin
sudo groupmod -g 1000 admins # Change the group ID to 1000
sudo groupmod -aG admins user1 # Add the user to the admins group
### lid
lid -g admins # Display the members of the admins group
```
### Assigning Privileges to Groups
```bash
### visudo
sudo visudo # Edit the sudoers file
### add the following line to the sudoers file
%admins ALL=(ALL) ALL
### dnf update for tier-4 admin group
%tier4admin ALL=(ALL) NOPASSWD: /usr/bin/dnf update
```
### The Passwd and Shadow Files
```bash
### passwd file
sudo vim /etc/passwd
### shadow file
sudo vim /etc/shadow
### chage
chage -l user1 # Display the user's password expiration information
chage -m 0 user1 # Set the minimum password age to 0
chage -M 90 user1 # Set the maximum password age to 90 days
chage -E -1 user1 # Set the password to never expire
chage -E 2025-03-07 user1 # Set the password to expire on a specific date
```
## Process Text & Create Links
### Redirection Basics
```bash
### redirect the output of the ls command to a file
ls -l > output.txt
### redirect the output of the ls command to a file and append to the file
ls -l >> output.txt
```