Linux Programmer | RHCE | RHCSA

Search This Blog

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
 




Friday, 22 June 2018

Set default image viewer in wine.

Set picassa photo viewer as default app for image

You can use the command mimeopen, in a terminal go to the folder where you have some pictures with extensions, you should do it for every extension. Suppose for picture named image.jpg. Run the command:
mimeopen -d image.jpg 
You will get a popup menu, where you can see some options, here is sample of my apps:
If mimeopen package not exists then you can install:
libfile-mimeinfo-perl

$ mimeopen -d e.jpg 
Please choose a default application for files of type image/jpeg

    1) Wine Internet Explorer  (wine-extension-jpe)
    2) Wine Internet Explorer  (wine-extension-jfif)
    3) gThumb  (gthumb)
    4) Pinta  (pinta)
    5) Image Viewer  (gpicview)
    6) Shutter  (shutter)
    7) Firefox Web Browser  (firefox)
    8) Shotwell Viewer  (shotwell-viewer)
    9) GIMP Image Editor  (gimp)
    10) Other...
AS you can notice you could see some wine apps so if you find picasa choose it, else choose other(10) and type the command that runs your picasa. It looks like
WINEPREFIX=~/.purval WINE=/opt/wine-staging/bin/wine /opt/wine-staging/bin/wine ~/.wine/drive_c/myapps/foo.exe
This Configuration files are located at: /usr/share/mime/image 

 

Friday, 27 April 2018

List the google cloud printers from specific configured mail id.

How to list google cloud printers from specific configured mail id in linux.

for e.g.
if you have installed google cloud printers, and want to list printers from one mail id using python script then

1. navigate to cloudprint-cups configuration files location,
cd /usr/share/cloudprint-cups/

2. create one file listsingleprinter.py

paste below content in to the file,

if __name__ == '__main__':  # pragma: no cover

    import sys
    import os
    from auth import Auth
    from printermanager import PrinterManager
    from ccputils import Utils
    Utils.SetupLogging()

    mail_is = sys.argv[1]
    # line below is replaced on commit
    CCPVersion = "20140814.2 000000"
    Utils.ShowVersion(CCPVersion)

    os.system("echo '%s' >/tmp/.c_mail"%mail_is)
    requestors, storage = Auth.SetupAuth(True)
    printer_manager = PrinterManager(requestors)
    printers = printer_manager.getPrinters()
    if printers is None:
        print "No Printers Found"
        os.system("rm -rf /tmp/.c_mail")
        sys.exit(1)

    for printer in printers:
        print printer.getListDescription()
        os.system("rm -rf /tmp/.c_mail")


3. make changes in to auth.py

change in to SetupAuth function

@staticmethod
    def SetupAuth(interactive=False,
                  permissions=None):
        """Sets up requestors with authentication tokens

        Args:
          interactive: boolean, when set to true can prompt user, otherwise
                       returns False if authentication fails

        Returns:
          requestor, storage: Authenticated requestors and an instance
                              of storage
        """
        if permissions is None:
            permissions = ['https://www.googleapis.com/auth/cloudprint']
        modifiedconfig = False

        # parse config file and extract useragents, which we use for account
        # names
        userids = []
        if os.path.exists(Auth.config):
            content_file = open(Auth.config, 'r')
            content = content_file.read()
            data = json.loads(content)
            for user in data['data']:
                userids.append(str(user['credential']['user_agent']))
        else:
            modifiedconfig = True

        if len(userids) == 0:
            userids = [None]

        requestors = []
    if os.path.exists("/tmp/.c_mail"):
        mail = commands.getoutput("cat /tmp/.c_mail")
        userids = [mail]
        for userid in userids:
            storage = multistore_file.get_credential_storage(
                Auth.config,
                Auth.clientid,
                userid,
                permissions)
            credentials = storage.get()

            if not credentials and interactive:
                credentials = Auth.AddAccount(storage, userid, permissions)
                modifiedconfig = True
                if userid is None:
                    userid = credentials.user_agent

            if credentials:
                # renew if expired
                requestor = CloudPrintRequestor()
                if credentials.access_token_expired:
                    Auth.RenewToken(interactive, requestor, credentials, storage, userid)
                requestor = credentials.authorize(requestor)
                requestor.setAccount(userid)
                requestors.append(requestor)

        # fix permissions
        if modifiedconfig:
            Utils.FixFilePermissions(Auth.config)

        if not credentials:
            return False, False
        else:
            return requestors, storage

    @staticmethod
    def GetAccountNames(requestors):
        requestorAccounts = []
        for requestor in requestors:
            requestorAccounts.append(requestor.getAccount())
        return requestorAccounts

 
 

Tuesday, 10 April 2018

​Configuring NFS server & client


​Configuring NFS server & client

1. Configuring NFS server : 
  • apt-get install nfs-kernel-server
  • apt-get install nfs-common
  • vi /etc/exports
                ​/home *(rw,sync,no_root_squash,no_subtree_check)
  • exportfs -a
​2. Configuring NFS Client 

  • apt-get install nfs-common
  • mkdir /mnt/share
  • ​chmod 0777 /mnt/share
  • mount -t nfs 
    ​$server_ip
    :/home/
    ​$path_to_directory
     /mnt/share

  • ​To check share is mounted or not ?
  • mount

  • ​To umount NFS share 
  • umount /mnt/share​





These 15 resources will sharpen you for interviews and real production chaos

  1. Explainshell – paste any bash command, and it breaks it down word by word. No more guessing awk or sed. 2. KubeSim – browser-based Kube...