Create a common_readonly role and configure it to access shared data for all users:
CREATE ROLE common_readonly NOLOGIN;
GRANT CONNECT ON DATABASE user1dbshare TO common_readonly;
GRANT CONNECT ON DATABASE user2dbshare TO common_readonly;
GRANT USAGE ON SCHEMA public TO common_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO common_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO common_readonly;
GRANT common_readonly TO user1;
GRANT common_readonly TO user2;
Log in to each database and create a table:
For user1dbshare:
\c user1dbshare user1
CREATE TABLE memo (
id SERIAL PRIMARY KEY,
key_words VARCHAR(255),
content TEXT,
english_content TEXT
);
For user1dbprivate:
\c user1dbprivate user1
CREATE TABLE memo (
id SERIAL PRIMARY KEY,
key_words VARCHAR(255),
content TEXT,
english_content TEXT
);
For user2dbshare:
\c user2dbshare user2
CREATE TABLE memo (
id SERIAL PRIMARY KEY,
key_words VARCHAR(255),
content TEXT,
english_content TEXT
);
For user2dbprivate:
\c user2dbprivate user2
CREATE TABLE memo (
id SERIAL PRIMARY KEY,
key_words VARCHAR(255),
content TEXT,
english_content TEXT
);
This command sets ACL (Access Control List) for the file yourFileName.csv. -m option indicates modifying the ACL. u:yourUserName:r assigns read (r) permission to the user yourUserName.
sudo setfacl -m u:yourUserName:r yourFileName.csv
Revoking Permissions
This command removes the ACL entry for the user yourUserName from the file yourFileName.csv. -x option indicates removing a specified ACL entry.
sudo setfacl -x u:yourUserName yourFileName.csv
Setting Default Permissions (Mask)
This command sets the mask permission for the file yourFileName.csv to read, write, and execute (rwx). The mask defines the maximum permissions allowed for users other than the owner and the group. Here, setting the mask to rwx allows users to have up to read, write, and execute permissions.
sudo setfacl -m m::rwx yourFileName.csv
Removing All ACL Entries
This command removes all ACL entries from the file yourFileName.csv, resetting it to its default permission state. -b option indicates deleting all ACL entries.
sudo setfacl -b yourFileName.csv
Viewing ACL Settings
This command displays the current ACL settings for the file yourFileName.csv.
# Enable Remote Desktop by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
# Check if there is any existing firewall rule for port 3389 (RDP)
$ExistingRule = Get-NetFirewallRule -Direction Inbound | Where-Object { $_.LocalPort -eq 3389 }
# Enable the rule if it exists
if ($ExistingRule) {
$ExistingRule | Enable-NetFirewallRule
"Existing Remote Desktop firewall rules have been enabled."
} else {
# Create a new firewall rule if no existing rule is found
New-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow
"No existing rule found, a new Remote Desktop firewall rule has been created and enabled."
}
# Enable Network Level Authentication (NLA) by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -value 1
# Check if Remote Desktop service has been enabled
$RDPStatus = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server').fDenyTSConnections
if ($RDPStatus -eq 0) {
"Remote Desktop is enabled"
} else {
"Remote Desktop is not enabled"
}
Edit SSH Configuration: Navigate to C:\ProgramData\ssh\sshd_config on your Windows machine. Locate the line # override default of no subsystems. Directly below this line, add: Subsystem powershell "C:\Progra~1\PowerShell\7\pwsh.exe" -sshs -NoLogo -NoProfile
Restart SSH Service: Use the command line to execute: Restart-Service sshd
Establish SSH Session: From your Ubuntu machine, execute the following command in PowerShell: Enter-PSSession -HostName 192.168.1.5 -UserName yourUserName -SSHTransport
With these adjustments, you should be able to successfully log in to your Windows machine from Ubuntu using PowerShell over SSH.
to run as Administrator: eg:
Start-Process -FilePath "powershell" -ArgumentList "-Command dir > D:\output.txt" -Verb RunAs
If it uses NetworkManager: cat /etc/netplan/01-network-manager-all.yaml : # Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager
Determine the Default Gateway: Use the ip route command to find out the default gateway of your network, which is essential for configuring your static IP. ip route | grep default | awk '{print $3}'
Setting a Static IP Address: Replace "WifiName" with your actual connection name. Here’s how you can set a static IP address, gateway, DNS, and switch the method to manual: nmcli con mod "WifiName" ipv4.addresses 192.168.1.10/24 nmcli con mod "WifiName" ipv4.gateway 192.168.1.1 nmcli con mod "WifiName" ipv4.dns "8.8.8.8" nmcli con mod "WifiName" ipv4.method manual
Applying the Changes: After setting the static IP, you need to restart the network connection to apply these changes: nmcli con down "WifiName" nmcli con up "WifiName"
Reverting to DHCP (Dynamic IP): If you encounter any issues or decide to return to using DHCP, you can reset the configuration as follows: nmcli con mod "WifiName" ipv4.method auto nmcli con down "WifiName" nmcli con up "WifiName"