Bash: Search recursively in files for a string

Lets say we are searching for the word ‘date’ in a folder and subfolders for files that have the following naming : *-log.txt

grep --include=\*-log.txt -rnw 'date'

Lets say the files have more than one extension

grep --include=\*-log.{txt,log} -rnw 'date'

Error 0x0000011b Windows 10 USB printing

To fix the recent 0x0000011b printing errors without removing the current Windows Updates (KB5005565), you can instead disable the CVE-2021-1678 mitigation enabled by default this month.

To do that, open the Windows Registry Editor and navigate to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print key, create a new DWORD-32 bit value named RpcAuthnLevelPrivacyEnabled, and set it to 0 and restart the PC.

Auto-logout users in linux systems (from: https://ostechnix.com)

Auto logout inactive users in Linux

There are three methods to do this…. I post form https://ostechnix.com one. To get the rest methods please visit https://ostechnix.com/auto-logout-inactive-users-period-time-linux/

We can auto logout inactive user sessions after certain time in three ways. Let us see the first method.

Method 1:

Edit ~/.bashrc or ~/.bash_profile file:

$ nano ~/.bashrc

Or,

$ nano ~/.bash_profile

Add the following line at the end:

TMOUT=100

Configure user time out value in Linux

This makes the user to logout automatically after an inactivity of 100 seconds. You can define this value as per your convenient. Press ESC and type :wq to save the file and close it.

Apply the changes by running the following command:

$ source ~/.bashrc

Or,

$ source ~/.bash_profile

Now, leave the session idle for 100 seconds. After an inactivity of 100 seconds, you will see the following message and the user will be automatically logged out from the session.

timed out waiting for input: auto-logout
Connection to 192.168.122.181 closed.

Auto logout inactive users in Linux

This setting can be easily modified by the user. Because, ~/.bashrc file is owned by the user himself.

To modify or delete the timeout settings, simply delete the lines added above and apply the changes by running the following command:

$ source ~/.bashrc

Alternatively, the user can disable this by running the following commands:

$ export TMOUT=0

Or,

$ unset TMOUT

Since the timeout setting is stored in the user-owned ~/.bashrc file, s/he can easily bypass it by simply deleting the line. If you want to prevent the user from changing the settings, follow second method.

Linux terminal commands for background runs

Using nohup allows you to run a command in the background and keep it running. How? nohup bypasses the HUP signal (signal hang up), making it possible to run commands in the background even when the terminal is off. Combine this command with redirection to “/dev/null” (to prevent nohup from making a nohup.out file), and everything goes to the background with one command.

nohup COMMAND &>/dev/null &

If instead of closing the terminal you type disown the terminal windows will not include in its jobs the command you wrote above and therefore even when you close it, the command will still run.

Powershell’s equivelant .bashrc

To find the equivelant of .bashrc file that exists in Linux, type in powershell v7 the following command:

$PROFILE | Get-Member -Type NoteProperty | Format-List *

and it will show you all the locations for the various profile files depending on functions such as Remote Hosts, CurrentHosts etc.

A sample file will look like this:

##Go to Path
Function myFolder {Set-Location -Path "C:\Myfolder\"}
Function dev {Set-Location -Path "C:\DevFolder\"}

#Get version
Function Get-Version {$PSVersionTable.PSVersion}

#Alias Command
Function Pro {notepad $PROFILE.AllUsersCurrentHost}

#Alias to EXE
Set-Alias -Name mp -Value D:\Software\MyProgram.exe
Set-Alias -Name c -Value cls


#Customize prompt
Function Prompt
{
$env:COMPUTERNAME + "\" + (Get-Location) + "> "
}

Install Virtuoso 7 on Ubuntu 20.04 LTS

In order to install Virtuoso on Ubuntu 20.04 LTS the follwoing steps need to be followed:

# sudo apt-get install libtool
# sudo apt-get install dpkg-dev build-essential
# sudo apt update
# sudo apt-get install autoconf automake bison checkinstall flex gawk gperf libiodbc2  libiodbc2-dev libssl-dev libtool python-dev

Edit the source list sudo nano /etc/apt/sources.list to add the following line: deb http://security.ubuntu.com/ubuntu xenial-security main Then 
# sudo apt update
# sudo apt install libssl1.0.0

# git clone https://github.com/openlink/virtuoso-opensource.git
# cd virtuoso-opensource
# sudo git checkout stable/7 # Needed - flex/bison error in stable
# sudo ./autogen.sh
# sudo ./configure --with-layout=debian
# sudo make
# sudo make install



# Test that virt starts OK — ctrl-c to close after verifying
in /usr/bin/

sudo ./virtuoso-t -fd -c /var/lib/virtuoso-opensource-7/db/virtuoso.ini

How to Install CouchDB on Ubuntu 20.04 from LINUXIZE.com

Apache CouchDB is a free and open-source NoSQL database developed by the Apache Software Foundation. It can be used as a single-node or clustered database.

CouchDB server stores its data in named databases, which contains documents with JSON structure. Each document consists of a number of fields and attachments. Fields can include text, numbers, lists, booleans, more. CouchDB includes a RESTful HTTP API that allows you to read, create, edit, and delete database documents.

This article covers the steps of installing the latest version of CouchDB on Ubuntu 20.04.

Installing CouchDB on Ubuntu is relatively straightforward. We’ll enable the CouchDB APT repository, import the repository GPG key, and install the CouchDB package.

Enabling CouchDB repository

Run the following commands as root or user with sudo privileges to enable the CouchDB repository and import GPG key:

curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc | sudo apt-key add -echo "deb https://apache.bintray.com/couchdb-deb focal main" | sudo tee -a /etc/apt/sources.list

Installing CouchDB on Ubuntu

Once the repository is enabled, update the packages list and install CouchDB:

sudo apt updatesudo apt install couchdb

The installer will ask you whether you want to install CouchDB in a clustered or standalone mode. A cluster means multiple servers connected together, working as a single, distributed data store.

We will install CouchDB in a single-server standalone mode.

CouchDB Select Mode

Next, you’ll be given an option to set the IP address of the network interface on which the CouchDB will bind to. For a single-server setup, leave the default 127.0.0.1. If you are configuring a cluster, enter the interface IP address or type 0.0.0.0, which tells CouchDB to binds to all network interfaces.

CouchDB Select Interface

On the next prompt, set the admin password. It is highly recommended to set the password, which will take CouchDB out of the insecure “admin party” mode. If you leave this field blank, an admin user will not be created.

CouchDB Create Admin

Finally, confirm the password, and the CouchDB installation will continue.

CouchDB Confirm Password

Verifying CouchDB Installation

The CouchDB server is running at localhost:5984. To verify whether the installation was successful and the service is running, run the following curl command that will print information about the CouchDB database in JSON format:

curl http://127.0.0.1:5984/

The output will look like this:

{
  "couchdb":"Welcome",
  "version":"3.1.0",
  "git_sha":"ff0feea20",
  "uuid":"4589130c33b0dae4c166330463542ad4",
  "features":[
    "access-ready",
    "partitioned",
    "pluggable-storage-engines",
    "reshard",
    "scheduler"
  ],
  "vendor":{
    "name":"The Apache Software Foundation"
  }
}

For clarity the output above is formatted.

If you prefer GUI, you can access the CouchDB web-based interface, Fauxton at:

http://127.0.0.1:5984/_utils/

Conclusion

We’ve shown you how to install CouchDB on Ubuntu 20.04. You can find more information on this topic in the Apache CouchDB Documentation .

Entire Article was taken from http://www.linuxize.com . Original Link here: https://linuxize.com/post/how-to-install-couchdb-on-ubuntu-20-04/

AWS: Provide to a specific folder on S3, RW rights

Create an IAM role and add the following policy, to provide access to a specific older in a bucket on S3.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowUserToSeeBucketListInTheConsole",
            "Action": [
                "s3:ListAllMyBuckets",
                "s3:GetBucketLocation"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "AllowRootAndHomeListingOfCompanyBucket",
            "Action": [
                "s3:ListBucket"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::my-test-bucket"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "",
                        "my-test-folder/",
                        "my-test-folder/test/",
                        "my-test-folder/test/folder/"
                    ],
                    "s3:delimiter": [
                        "/"
                    ]
                }
            }
        },
        {
            "Sid": "AllowListingOfUserFolder",
            "Action": [
                "s3:ListBucket"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::my-test-bucket"
            ],
            "Condition": {
                "StringLike": {
                    "s3:prefix": [
                        "my-test-folder/test/folder/*"
                    ]
                }
            }
        },
        {
            "Sid": "AllowAllS3ActionsInUserFolder",
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::my-test-bucket/my-test-folder/test/folder/*"
            ]
        }
    ]
}

Add sudo user centos/ubuntu (www.linuxize.com)

Centos AND Ubuntu

sudo adduser iordanis

in Centos do also the following to setup the password for the above user:

passwd iordanis

Now, to add him to the sudo users group :

Ubuntu

usermod -aG sudo

In Centos :

usermod –aG wheel iordanis

If you want to add a user in the sudoers group then: (The below text is taken from www.linuxize.com

The users’ and groups’ sudo privileges are defined in the /etc/sudoers file. Adding the user to this file allows you to grant customized access to the commands and configure custom security policies.

You can configure the user sudo access by modifying the sudoers file or by creating a new configuration file in the /etc/sudoers.d directory. The files inside this directory are included in the sudoers file.

Always use visudo to edit the /etc/sudoers file. This command checks the file for syntax errors when you save it. If there are any errors, the file is not saved. If you open the file with a text editor, a syntax error may result in losing the sudo access.

Typically, visudo uses vim to open the /etc/sudoers. If you don’t have experience with vim and you want to edit the file with nano , change the default editor by running:

EDITOR=nano visudo

Let’s say you want to allow the user to run sudo commands without being asked for a password. To do that, open the /etc/sudoers file:

visudo

Scroll down to the end of the file and add the following line:
/etc/sudoers

username ALL=(ALL) NOPASSWD:ALL

Save a file and quit the editor . Do not forget to change “username” with the username you want to grant access to.

Another typical example is to allow the user to run only specific commands via sudo . For example, to allow only the mkdir and rmdir commands, you would use:
/etc/sudoers

username ALL=(ALL) NOPASSWD:/bin/mkdir,/bin/rmdir

Instead of editing the sudoers file, you can accomplish the same by creating a new file with the authorization rules in the /etc/sudoers.d directory. Add the same rule as you would add to the sudoers file:

echo "username ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/username

This approach makes the management of the sudo privileges more maintainable. The name of the file not important. It is a common practice the name of the file to be the same as the username.

Allow Or Deny SSH Access To A Particular User Or Group In Linux (from OSTechNix.com)

To allow SSH access for a particular user, for example sk, edit sshd_config file:

$ sudo vi /etc/ssh/sshd_config

Press “i” to enter into insert mode and add or modify the following line:

AllowUsers sk

Edit ssh configuration file to allow ssh access to particular user

Replace “sk” with your username. Please mind the space indentation between “AllowUsers” and “sk”. You should use Tab instead of Space-bar. Meaning – add the word “AllowUsers” and hit the Tab key and then specify the username.

You can also specify more than one user as shown below.

AllowUsers user1 user2

To allow an entire group, say for example root, add/edit the following line:

AllowGroups root

This setting will allow all the members of the “root” group to ssh to the Linux server.

Press ESC key to exit insert mode and type :wq to save and quit the SSH config file. Restart SSH service to take effect the changes.

$ sudo systemctl restart sshd

for the detailed articles with pictures please visit https://ostechnix.com/allow-deny-ssh-access-particular-user-group-linux/