Linux Programmer | RHCE | RHCSA

Search This Blog

Saturday 22 December 2018

Error while connecting RDP "an authentication error has occurred the token supplied to the function is invalid".

an authentication error has occurred the token supplied to the function is invalid

I have installed xrdp 0.9.8 at server side.

Remote desktop connections are working fine when i am connect it from windows 8/10.

but when i am trying to connect RDP from windows 7 it is showing error which is showing on left side.








in xrdp 0.9.8 TLSv1.2 and TLSv1.3 is added by default.
in older version of windows system TLSv1.3 was not supported. thats why it is not connecting with xrdp server.

To resolve this issue from server side follow the steps below.
1. Login to xrdp server.
2. navigate to xrdp configuration file location,

$cd /etc/xrdp
$vim xrdp.ini

replace
ssl_protocols=TLSv1.2, TLSv1.3
with
ssl_protocols=TLSv1, TLSv1.1

3. Restart xrdp service.
$ service xrdp restart

Friday 30 November 2018

How to make Canon LBP2900B work on Ubuntu 16.04 LTS?

After clean installation of Ubuntu 16.04 my Canon LBP2900 refused to print. I found out a solution.

Standard method to install driver doesn't work.
To install driver manually I downloaded and unpacked them from the official web-site of Canon.
The next step was to choose between the 32- or 64-bit driver. First my decision was to use 64-bit driver, because my OS is also 64-bit. But it was a mistake, 64-bit driver refused to work.
So I choose 32-bit driver, unpacked and installed two packages in the following order:
Check which packages are installed (32bit/64bit)
$ dpkg -l | grep -i cndrvcups

Remove the existing 64 bit installed packages:
$ apt-get remove --purge cndrvcups-*

Install 32 bit packages
$ sudo dpkg -i cndrvcups-common.deb 
$ sudo dpkg -i cndrvcups-capt.deb

If some dependency errors, then,
$ apt-get install -f


Then reboot and start work after reinstalling printer.
 

Wednesday 21 November 2018

blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'.

Getting this kind of error while connecting with the database,

blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
Solution:
Go to shell of the database server(Where sql database is located) and enter below command,

$ mysqladmin -uusername -ppassword flush-hosts;

Tuesday 13 November 2018

Cups printing issue

CUPS: Adding printer fails with “Unable to get list of printer drivers: Success”

When installing a new printer using the CUPS web interface, instead of displaying the list of drivers only the message
Unable to get list of printer drivers:
Success
OR
When i try to list printer drivers with command line,
$ lpinfo -m
lpinfo: success
is displayed. No printers drivers list can be shown.
Workaround:
Cups runs lpinfo -m to get a list of printer drivers, and this runs scripts in /usr/lib/cups/driver, and one of these is causing problems. By removing all scripts and adding them one by one you can determine which script is causing the problems.

Move all the scripts to a subdirectory, so that they are ignored.
cd /usr/lib/cups/driver
mkdir /opt/driver
mv * /opt/driver/
then copy one by one driver to original location.
for ex.
cp /opt/driver/cupsfilter /usr/lib/cups/driver
you can check it by running lpinfo command
lpinfo -m
All drivers are showing. Place files one by one and check.





Tuesday 30 October 2018

Running bash commands in parallel.

Introduction

A modern server is typically multi-core, perhaps even multi-CPU. That is plenty of computing power to unleash on a given job. However, unless you run a job in parallel, you are not maximizing the use of all that power.

Below are some typical everyday operations we can speed up using parallel computing:
  1. Backup files from multiple source directories to a removable disk.
  2. Resize image files in a directory.
  3. Compress files in a directory.

Image result for bash

To execute a job in parallel, you can use any of the following commands:
  • ppss
  • pexec
  • GNU parallel
This post focuses on the GNU parallel command.

Installation of GNU Parallel

To install GNU parallel on a Debian/Ubuntu system, run the following command:
$ sudo apt-get install parallel

General Usage

The GNU parallel program provides many options which you can specify to customize its behavior. Interested readers can read its man page to learn more about their usage. In this post, I will narrow the execution of GNU parallel to the following scenario.
My objective is to run a shell command in parallel, but on the same multi-core machine. The command can take multiple options, but only 1 is variable. Specifically, you run concurrent instances of the command by providing a different value for that one variable option. The different values are fed, one per line, to GNU parallel via the standard input.
The rest of this post shows how GNU parallel can backup multiple source directories by running rsync in parallel.

Parallel backup

The following command backs up 2 directories in parallel: /home/peter and /data.
$ echo -e '/home/peter\n/data' | parallel -j-2 -k --eta rsync -R -av {} /media/myBKUP

Standard input

The echo command assembles the 2 source directory locations, separated by a newline character (\n), and pipes it to GNU parallel.

How many jobs?

By default, GNU parallel deploys 1 job per core. You can override the default usint the -joption.
-j specifies the maximum number of parallel jobs that GNU parallel can deploy. The maximum number can be specified in 1 of several ways:
  • -j followed by a number

    -j2 means that up to 2 jobs can run in parallel.
  • -j+ followed by a number

    -j+2 means that the maximum number of jobs is the number of cores plus 2.
  • -j- followed by a number

    -j-2 means that the maximum number of jobs is the number of cores minus 2.
If you don't know how many cores the machine has, run the command below:
$ parallel --number-of-cores
8

Keeping output order

Each job may output lines to the standard output. When multiple jobs are run in parallel, the default behavior is that a job's output is displayed as soon as the job finishes. You may find this confusing because the output order may be different from the input order. The -k option keeps the output sequence the same as the input sequence.

Showing progress

The --eta option reports progress while GNU parallel executes, including the estimated remaining time (in seconds).

Input place-holder

GNU parallel substitutes the {} parameter with the next line in the standard input.
Each input line is a directory location, e.g., /home/peter. Instead of the full location, you can specify other parameters in order to extract a portion thereof - e.g., the directory name(/home) and the basename (peter). Please refer to the man page for details.

Summary

GNU parallel is a tool that Linux administrators should add to their repertoire. Running a job in parallel can only improve one's efficiency. If you are already familiar with xargs, you will find the syntax familiar. Even if you are new to the command, there is a wealth of on-line help on the GNU parallel website.

How to mount USB drives on VirtualBox


Prerequisites
The VirtualBox extension pack must be installed on the VirtualBox host. 

Configuring USB

Follow the steps below to configure VirtualBox USB.






  1. Add user to vboxusers group.
    VirtualBox access to the host's USB drives is only ranted to users of the vboxusers group. As root on the host, run the following command to add each VirtualBox user (e.g., peter) to the group.
     $ usermod -aG vboxusers peter
    
  2. Power off VM.
    VirtualBox defaults to using USB Controller 1.1 (OHCI). Modern hardware uses USB Controller 2.0(EHCI) and USB Controller 3.0(xHCI). Before you can change the USB controller protocol, the virtual machine must be powered off.
  3. Open VirtualBox Manager, click Settings, and select USB.
  4. Specify USB Controller.
    Select either USB 2.0 (EHCI) Controller or USB 3.0 (xHCI) Controlleraccording to your actual hardware.

    Note that you can add USB Device Filters to define the types of USB drives which will be automatically made visible to the guest OS. Be forewarned that the USB drive, once made visible to the guest OS, will no longer be available to the host. More on the use of device filters in the next section.

Accessing USB drive

Below is the step-by-step procedure to mount and access a flash drive.
  1. Insert the flash drive into your host machine's USB port.
  2. Unmount the flash drive (if it is auto-mounted on your host).
    Making it available to the guest will automatically and instantly unmount it from the host. To avoid any data loss due to pending writes to the drive, it is a good practice to explicitly unmount the drive prior to handing control to the guest.
  3. Power on the system as guest.
  4. Assign USB drive to guest OS.

    Open the virtual system console, and right click the USB drive icon.

    Click to select your USB drive.

    Note that this is a 1-time assignment only. Please see instructions at the end of the section on how to automatically assign this particular USB drive for all subsequent sessions.
  5. Login to system, and mount the drive.
    You can mount a MS-DOS based flash drive by running the following commands as root. Replace /dev/da0s1 with the proper device identifier for your USB drive. (You can find out the exact device ID by first running dmesg to identify the device name, e.g. da0, andfdisk to reveal the disk partition structure, e.g., s1.)
     # mkdir -p  /media/usb
     # mount -t msdosfs  /dev/da0s1  /media/usb
    
    To unmount the drive,
     # umount /media/usb
    
To always automatically assign a particular USB drive to the guest OS, open the VirtualBox Manager, click Settings, and then USB.







Finally, click Add USB device filter (with the + sign) icon, and select the USB drive that is currently inserted in the host.

Reset admin password ubuntu

How to reset administrative password in ubuntu

  1. start machine.
    After the BIOS screen appears, press down the left shift key to enter GRUB. This step can be quite finicky, and you may need to repeat it several times until you get the timing just right.
  2. Select the Advance Option for ubuntu
  3. .
  4. In Grub Version list, scroll down to the top Recovery mode line, and press Enter.
    If the Linux kernel image had been upgraded on the machine before, you would see multiple recover mode lines on the screen. Select the recovery mode line that corresponds to the latest Linux image(that is nearest to the top).
  5. In the Recovery Menu screen click on root 'Drop to root shell prompt'.
  6. Press Enter again.
    If you have set root a password, you would be prompted to enter it at this step. Otherwise, just press Enter to continue.
  7. Remount filesystem.
    After all the hard work, you are now at the root shell prompt. The filesystem at this point is read-only. Remount the file system to add write permission.
    $ mount -o rw,remount /
    
  8. Reset admin user password now.
    Use the passwd command to change the password for the admin user.
    $ passwd <username>
    
    Press Control-D to return to the recovery menu.
  9. Click on resume.
  10. Exit recovery.
    Press OK to exit recovery mode and continue booting.
Here you Go.

Password resetted successfully.

Saturday 11 August 2018

Change the PDF printer Output directory

Since Ubuntu 7.10, a PDF printer has been installed by default. The behavior of this feature has changed from Ubuntu 7.10, instead of asking for a name and location for the PDF, Ubuntu 8.04 will guess a name for the document and place the file in a folder called PDF in your home directory.

  1. Open the file /etc/cups/cups-pdf.conf as the root user:
    gksu gedit /etc/cups/cups-pdf.conf
    
  2. The lines starting with the “#” character are comments. The first un-commented line, which specifies the output directory, should look something like this:
    Out ${HOME}/PDF
    
  3. Change this line to the path you want your PDFs saved to. This will save them to the current users’s desktop:
    Out ${HOME}/Desktop
    
  4. Save and close the text editor. Now you just need to restart CUPS for the change to take effect.
    sudo /etc/init.d/cups restart
    Changing the output directory dosn’t work in some cases because of apparmor
    
    The default (and therefore allowed by apparmor) place for created pdf's is $(HOME)/PDF. If this directory is not used (or is a symlink, just to add this), that means you've changed the default path in cups-pdf.conf, you'll need to apply this changes in the /etc/apparmor.d/usr.sbin.cupsd file too.
    you'll need to change the lines:
     @{HOME}/PDF/ rw,
     @{HOME}/PDF/* rw,
    @{HOME}/PDF/ rw@{HOME}/PDF/*rw,

    into:
    @{HOME}/Desktop/ rw@{HOME}/Desktop/*rw,
    in the mentioned usr.sbin.cupsd file and restart the apparmor-service.

    sudo /etc/init.d/apparmor restartthen restart the cups service,sudo /etc.init.d/cups restart 
     

Tuesday 31 July 2018

How to handle more than 10 parameters in shell

Use curly braces to set them off:
echo "${10}"
You can also iterate over the positional parameters like this:
for arg
or
for arg in "$@"
or
while (( $# > 0 ))    # or [ $# -gt 0 ]
do
    echo "$1"
    shift
done

Thursday 26 July 2018

Windows shared network printer issue in ubuntu 18.04

Windows shared network printing issue in ubuntu 18.04.

- printers are installed in windows 8 machine and shared.
- when try to find the network printer from ubuntu 18.04 using the ip of windows machine then it is showing an error 
"no network printer found"

- even, when we found the shared folders using smbclient command then it will showing an error


smbclient -L 192.168.1.20
output:
syslog option deprecated,
Enter WORKGROUP\root's password:

    Sharename       Type      Comment
    ---------       ----      -------

    ADMIN$          Disk      Remote Admin
    Backup          Disk     
    bk              Disk     
    bkp             Disk     
    C$              Disk      Default share
    Canon UFR II Color Class Driver Printer   Canon UFR II Color Class Driver
    Canon-LBP2900-toc64 Printer   Canon LBP2900
    Canon2900       Printer   \\MUIN-KHAN\Canon-LBP2900
    D$              Disk      Default share
    Data            Disk     
    HP-LaserJet-M1005 Printer   \\KESHA\Hewlett-Packard-HP-LaserJet-M1005
    IPC$            IPC       Remote IPC
    libjack         Disk     
    print$          Disk      Printer Drivers
    raj             Disk     
    Users           Disk     
Reconnecting with SMB1 for workgroup listing.
Connection to 192.168.1.20 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Failed to connect with SMB1 -- no workgroup available


it is showing an error as showing in bold letter.

even if are checking the syslog then it will be like,

Jul 26 10:01:03 localhost dbus-daemon[712]: [system] Successfully activated service 'org.freedesktop.hostname1'
Jul 26 10:01:03 localhost systemd[1]: Started Hostname Service.
Jul 26 10:01:20 localhost python: io/hpmud/jd.c 93: unable to read device-id
Jul 26 10:01:20 localhost python: io/hpmud/jd.c 745: invalid ip 192.168.1.20
Jul 26 10:01:20 localhost hp-makeuri: hp-makeuri[13665]: error: Device not found



Solution:

First: Ubuntu does not install a smb.conf in 18.04 so I suggest you install the samba client package:

Code:
sudo apt install smbclient
Second: Then edit /etc/samba/smb.conf and right unser the workgroup = WORKGROUP line add this line to change the default:
Code:
client max protocol = NT1
Third: Install samba packages.
Code:
apt-get install samba
and reboot.... Yes reboot..
fourth: Install CUPS:
Code:
apt-get install cups; apt-get install cups-bsd 

fifth: Install python3-smbc:
Code:
apt-get install python3-smbc
 Now try to find network printer from system-config-printer 

it works !!!

Wednesday 18 July 2018

X11Forwarding with SSH not working when connect user through Ncomputing device ?

X11Forwarding with SSH not working when connect user through N-computing device ?
Issue Description:

Install N-computing Server in one linux machine.
Trying to connect another user through Ncomputing client using Vspace.

User logged in successfully but when the connected user tried to connect another machine through ssh using X11forwading then it is not working .

For e.g.

$ ssh purval@192.168.1.76 -CX

then it take some time to login and after 1 or 2 minute it will logged in successfully.

but when we try to open some GUI application then it wont open.

Solution:

1. Logout the SSH session
2. run below command with normal user
      $ xhost +
3. Login user using SSH with -CX and try to open application.

it works !!


if you enter $xhost command it will show output like,

access control disabled, clients can connect from any host

$xhost - will remove the xhost access control which you have set.

About Xhost

xhost is a server access control program for X. It is used to add and delete host names or user names to the list allowed to make connections to the X server. In the case of hosts, this provides a rudimentary form of privacy control and security. It is only sufficient for a workstation (single user) environment, although it does limit the worst abuses in other cases. Environments which require more sophisticated measures should implement the user-based mechanism or use the hooks in the protocol for passing other authentication data to the server.


Thank you,



Wednesday 27 June 2018

Display System information on desktop

Do you want to display system information on desktop without disturbing regular work ?

here is the package which is help to do that.

conky

1. install conky
apt-get install conky-all

2. install conky-manager to make changes from GUI.
  • Add the necessary repository with the command sudo add-apt-repository ppa:teejee2008/ppa
  • Update apt with the command sudo apt-get update
  • Install Conky Manager by issuing the command sudo apt-get install conky-manager
3. open conky-manager 
     Open terminal and type
     $ conky-manager

4. Select any option which you want to add on desktop

5. To add information like ipaddress and macid 

The configuration files are located into .conky folder into the users home directory

 

~/.conky/Green Apple Desktop/conky_seamod

# IP information
${if_existing /proc/net/route wlan0}
${addr wlan0}
${else}${if_existing /proc/net/route eth1}IP ADDRESS
${addr eth1}
${else}
Network disconnected
${endif}${endif}

Mac ID
# Mac ID information
${exec ifconfig eth1 | grep -i addr | grep -i HWaddr | awk '{print$5}'}

 
This will responsible to display IP and macid information in theme

You can also remove the existing not used information from screen by removing it from the file.

6. Another configuration files are located at, 
  ~/.config/conky-manager.json

7. To add it on startup
 
~/.config/autostart/conky.desktop

[Desktop Entry]
Type=Application
Exec=sh "/home/purval/.conky/conky-startup.sh"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_IN]=Conky
Name=Conky
Comment[en_IN]=
Comment=


 
You can also do this from conky-manager GUI
 




SSH not working with password after upgrade ubuntu 22.04

Issue: In recent upgrade of ubuntu 22.04 we are not able to login server with SSH password. but when we try to login with key then it allow...