CyberKeeda In Social Media

AWK equivalent in Windows CMD




Missing AWK on Windows ?  for /f  may help you.
Lets see how can we implement the same.


Example.

C:\Users\Cyberkeeda>netsh interface show interface

Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled        Connected      Dedicated        Wi-Fi
Enabled        Connected      Dedicated        VMware Network Adapter VMnet1
Enabled        Connected      Dedicated        VMware Network Adapter VMnet8
Enabled        Disconnected   Dedicated        Ethernet

Lets assume we have saved the same within a file in linux names as file.txt

Within Linux, to gather the State of interfaces, we use the below command.

cat file.txt| awk '{print $2}'

State
Connected
Connected
Connected
Disconnected

In Windows, it can be accomplished with FOR /F

C:\Users\cyberkeeda>for /f "tokens=2" %a in ('netsh interface show interface') do @echo %a

State
Connected
Connected
Connected
Disconnected

Now, if wish to add two values .

cat file.txt| awk '{print $1 " " $2}'

Admin State
-------------------------------------------------------------------------
Enabled Connected
Enabled Connected
Enabled Connected
Enabled Disconnected

Same can be accomplished within Windows as

C:\Users\cyberkeeda>for /f "tokens=1,2" %a in ('netsh interface show interface') do @echo %a %b
Admin State
-------------------------------------------------------------------------
Enabled Connected
Enabled Connected
Enabled Connected
Enabled Disconnected

In case, if you want to additional string along with the variable.

C:\Users\cyberkeeda>for /f "tokens=1,2" %a in ('netsh interface show interface') do @echo Boot Stats= %a Ethernet stat= %b


Now in case, if you want to use further filter within it, below one liner can help you.

C:\Users\cyberkeeda>netsh interface show interface | for /f "tokens=2" %a in ('findstr Wi-Fi') do @echo %a
Connected




Read more ...

How to Create Windows 10 Bootable USB on Ubuntu or any Linux desktop



Are you looking for any desktop application on Ubuntu to create a bootable pendrive/flash drive with Windows.

WoeUSB is a simple tool that enable you to create your own usb stick windows installer from an iso image or a real DVD.


WoeUSB  package contains two programs:
  • woeusb: A command-line utility that enables you to create your own bootable Windows installation USB storage device from an existing Windows Installation disc or disk image
  • woeusbgui: A GUI wrapper of woeusb based on WxWidgets


So, lets know how install the WoeUSB on Ubuntu 
Official & updated Installation and Github link : Here
#    sudo add-apt-repository ppa:nilarimogard/webupd8
#    sudo apt update
#    sudo apt install woeusb
In case if you wish to remove that woeusb PPA, remove it from the bellow command.
#    sudo add-apt-repository --remove ppa:nilarimogard/webupd8
#    sudo apt-update
Now, WoeUSB has installed on my Ubuntu, though the interface is self explanatory still let's move ahead and know how to use it.

Open WoeUSB application and choose the USB drive and your windows iso kept within your Ubuntu.
Once you are done click install and you are done, you can monitor the progress on screen.


In case you receive a error dialogue like below, follow the below steps

Find your USB drive's mounted file system and block by running lsblk on terminal and find your device their.
To filter, look for size of your USB or name of the USB drive, below screen shot gives the picture of my USB drive ( 8 GB ) size, and named as /dev/sdc
#    lsblk

So we will unmount that partition out of the system.
Notice there  /dev/sdc is the full size of my USB disk, but the data is witten on it's /dev/sdc1 partition.
My USB disk is  /dev/sdc, ensure your USB is unmounted with the following command. Replace /dev/sdc1 with your own partition name.
#    sudo umount /dev/sdc1
Now try again from the   WoeUSB desktop application.
In case if you are willing to do the same through woeusb CLI utility, here is the way.
#    sudo woeusb -v --device /home/kunal/windows-10.iso /dev/sdc
/home/kunal/windows-10.iso  :  Replace it with your iso location.
/dev/sdc : replace it with your USB drive ( check it from lsblk )
Read more ...

PIP SSL eeror while installing : SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)


If you too, have encountered SSL errors while installation/upgrading any python package from pip.
Here below is the workaround for it.


You might be flooded by this errors.
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579) 

Workaround.

Ignore SSL errors by setting pypi.org and files.pythonhosted.org as trusted hosts.
#  pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
Lets assume i want to install pika through pip 
#  pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pika
Read more ...

How to Configure PostgreSQL user and Database

Content.

In this blog post, we will cover the below content.
  • Creating PostgreSQL users
  • Creating PostgreSQL databases
  • Adding an existing user to a database
  • Deleting PostgreSQL User
  • Deleting PostgreSQL Database.

By default PostgresSQL installation always includes the postgres superuser ( Linux Shell User) and postgresql database user too. Initially you have to use the same postgres user to coonnect to PostgreSQL until you create other users.
A PostgreSQL users are also known as role. 


Follow the steps to create a PostgreSQL user.


Use the passwd copmmand ( passwd postgres )to change the postgres linux user's password.
Just after PostgreSQL db instllation, change the password for default postgres  database superuser'spassword.
#    su - postgres
# psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'newpassword';"
Now we are all set to create new database user, switch again to postgres super user
#    su - postgres
#    createuser muser --pwprompt
Above crateuser will prompt you few questions.
  • Enter password for new role: prompt, type a password for the user.
  • Enter it again: prompt, retype the password.
  • Shall the new role be a superuser? prompt, type y if you want to grant superuser access. Otherwise, type n.
  • Shall the new role be allowed to create databases? prompt, type y if you want to allow the user to create new databases. Otherwise, type n.
  • Shall the new role be allowed to create more new roles? prompt, type y if you want to allow the user to create new users. Otherwise, type n.

Follow the steps to create a PostgreSQL Database.

Open a new linux terminal from root and run the commands one by one.
#    su - postgres
One can now run commands as the PostgreSQL superuser. 

To create a database, type the following command. Replace user with the name of the user that you want to own the database, and replace dbname with the name of the database that you want to create.

PostgreSQL users that have permission to create databases can do so from their own accounts by typing the following command, replacing dbname is the name of the database to create.
#    createdb -O myuser dbname
#    createdb dbname

Follow the steps to add a PostgreSQL db user to existing  Database.

Run the psql command program as the database's owner, or as the postgres superuser.
I will be using postgres user here
#    GRANT permissions ON DATABASE dbname TO username;
Replace above dbname and username as per your requirement.

Follow the steps to delete a PostgreSQL user.

Important point to consider before deleting a db user.


If the user owns any databases or other objects, you cannot drop the user. Instead, you receive an error message " dropuser: removal of role "username" failed: ERROR:  role "username" cannot be dropped because some objects depend on it "
DETAIL:  owner of database dbname "

You should change the database's owner (or drop the database entirely), and then you can drop the user, then run the below command
#    dropuser username
Follow the steps to delete a PostgreSQL Database
#    dropdb dbname

    Read more ...

    How to Install PostgreSQL Relational Database on CentOS



    PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
    Official link : Here 

    Let's know how to install PostgreSQL on CentOS 7.
      Note :   Video Tutorial at the bottom of the blog post

    Method 1

    Install from CentOS repository.
    For the time being CentOS 7 repositories ship with PostgreSQL version 9.2.15
    To install from the CentOS repositories, simply run:
     sudo yum install postgresql-server postgresql-contrib
    Now lets Initialize your Postgres database and start PostgreSQL and configure it to start on Boot
    #  sudo postgresql-setup initdb 
    #  sudo systemctl start postgresql
    #  sudo systemctl enable postgresql

    Method 2.

    Install the latest stable version of PostgreSQL from Postgres Repository
    Official repository link :  Here

    Note : Currently official repositiry provides packages based on RPM distribution ( Redhat/CentOS/Fedora...)

    Select the version you wish to install from the Postgres Yum repositories.
    Locate the CentOS 7 link for your chosen version and download it to your Centos 7 host.
    For the time being, I'm selecting Postgresql 9.6.3, choose as per your requirement.

    #  wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
    Install the downloaded postgres rpm package and install centos epel too.
    #  rpm -ivh pgdg-centos96-9.6-3.noarch.rpm
    #  yum install epel-release
    Now we are almost all set to install PostgreSQL.

    Update Yum to apply your changes and install PostgreSQL.
    When installing Postgres manually, you will have to specify the version, we will be installaing postgresql-9.6
    #  sudo yum update
    #  sudo yum install postgresql96-server postgresql96-contrib
    Important Point to notice.
    When Postgres is installed using above method 2, the version number is included in its configuration directories. For example, /var/lib/pgsql becomes /var/lib/pgsql/9.6. 
    This is also the case with systemd units
    systemctl status postgresql becomes systemctl status postgresql-9.6
    Now lets Initialize your Postgres database and start PostgreSQL and configure it to start on Boot.
    #  sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
    #  sudo systemctl start postgresql-9.6
    #  sudo systemctl enable postgresql-9.6
    And we are done..

    In case you are looking for the Installation Video Tutorial, below is the stuff.





    Read more ...

    How to install Sublime text editor on Ubuntu


    Sublime text editor is one of the popular text editor for code, markup and prose that's the line it says on it's official website  and most of the users believe the same.
    So let's know how to install it on your Ubuntu Box.

    I'm using Ubuntu 18.04  while writing this blog during installation.

    Install the GPG key


      #  wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -

    Make apt work using https also


      #  sudo apt-get install apt-transport-https

    Select the channel to use ( Recommended Stable )
    For Stable release use the below command.
      #  echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list 

    For Development release use the below command.
      #  echo "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

    Update apt sources and install Sublime Text


      #  sudo apt-get update #  
      #  sudo apt-get install sublime-text

    To remove/uninstall sublime text editor  use the below command


      #  sudo apt-get remove sublime-text && sudo apt-get autoremove #  


    Meanwhile you can anytime install it from Ubuntu Software Center,  it's also enlisted there.

    Official Installation Link : Here


    Read more ...
    Related Posts Plugin for WordPress, Blogger...
    Designed By Kunal Saha