wtorek, 31 maja 2016

getSystem data - Java

public class GetOSDetails {
    public static void main(String[] args)
    {
        String osName = System.getProperty("os.name");
        String osVersion = System.getProperty("os.version");
        String osArch = System.getProperty("os.arch");

        System.out.printf("OS Name: %s, \nOS Version: %s, \nOS Arch %s\n",osName, osVersion, osArch);
    }
}

Play With StringBuilder Java

import java.io.File;
import java.io.IOException;

public class StringBuilderTest1
{
    public static void main(String[] args) throws IOException {
        int ver = 10;
        StringBuilder sb = null;
        for(int i=1;i<10;i++)
        {
            sb = new StringBuilder().append("e:\\file").append(i).append(".txt");

            String x = new String(sb);
            System.out.print(x);
            File file = new File(x);

            if(file.createNewFile()) {
                System.out.println(" file created");
            }
            else
            {
                System.out.print("file already exists");
            }
        }
    }
}

poniedziałek, 30 maja 2016

get system info via python

import platform
import sys

def linux():
        try:
                return platform.linux()
        except:
                return "N/A"

print("""
Python version: %s
dist: %s
system: %s
machine: %s
uname: %s """ % (sys.version.split('\n'), str(platform.dist()), platform.system(), platform.machine(), platform.uname(),))

niedziela, 29 maja 2016

what is __doc__ - python

def print_max(x, y):
    '''
    Writing the bigest int
    '''
    x = int(x)
    y = int(y)

    if x > y:
        print('%d is max %d is min' % (x, y))
    else:
        print('%d is max %d is min' % (y, x))

print_max(10, 511)
print(print_max.__doc__)

Learning to Code with Python: Lesson 2.2 Simple Animation









from tkinter import *
import random
import time

tk = Tk()
canvas = Canvas(tk, width=500, heigh=400)
tk.title("drawing")
canvas.pack()

ball = canvas.create_oval(10, 10, 60, 60, fill="orange")
xspeed = 1yspeed = 1
while True:
    canvas.move(ball, xspeed, yspeed)
    pos = canvas.coords(ball)
    if pos[3] >= 400 or pos[1] <=0:
        yspeed = -yspeed
    if pos[2] >= 500 or pos[0] <= 0:
        xspeed = -xspeed
    tk.update()
    time.sleep(0.01)
tk.mainloop()

sobota, 28 maja 2016

get int's from array - simple loop

for(j=0;j<size;j++)
{
                printf("element[%d] = %d\n",j,n[j]);
 }
for each element in array get array "index" and value

array lenght in C

#include <stdio.h>
#include <stdlib.h>

int main()
{
        int i;
        int arr[4] = {1,2,3,4};
        int l = sizeof(arr)/sizeof(arr[0]);

        for(int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
        {
                printf(" %d \n",arr[i]);
        }

        return 0;
}

run if python version

import sys
if sys.version_info[0] < 3:
    print ("must be using python 3")
else:
    print(sys.version_info[0])

środa, 25 maja 2016

git your files to github

1. First Time

echo "# nauka_java" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/bormarek/nauka_java.git
git push -u origin master

2. to push changed files
git add RandomTest.java

C:\Users\Marek\IdeaProjects\java\src>git commit -m "random method collection"
[master f72ffe9] random method collection
 Committer: Marek Borkowski <Marek Borkowski>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 10 insertions(+)
 create mode 100644 RandomTest1.java

C:\Users\Marek\IdeaProjects\java\src>git push -u origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 391 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/bormarek/java.git
   044547c..f72ffe9  master -> master
Branch master set up to track remote branch master from origin.

poniedziałek, 23 maja 2016

javap - The Java Class File Disassembler

┌─[marek@virt]─[~/dev/java]
└──╼ cat HelloWorld.java
public class HelloWorld
{
    public static void main(String[] args)
    {
        System.out.println("Hello world");
    }
}
 


┌─[marek@virt]─[~/dev/java]
└──╼ javap -c HelloWorld
Compiled from "HelloWorld.java"
public class HelloWorld {
  public HelloWorld();
    Code:
       0: aload_0      
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: return       

  public static void main(java.lang.String[]);
    Code:
       0: getstatic     #2                  // Field java/lang/System.out:Ljava/io/PrintStream;
       3: ldc           #3                  // String Hello world
       5: invokevirtual #4                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       8: return       
}

enumerate output python

import sys

total = len(sys.argv)

if len(sys.argv) <= 1:
        print "to few args"
else:
        for count, elem in enumerate(sys.argv):
                print count, elem

czwartek, 19 maja 2016

array size c++ java lenght substitute.

#include <iostream>

using namespace std;

int main()
{
        cout << "Array of integers" << endl;
        int numbers[10] = {1,2,3,4,5,6,7,8,9,0};
        int size = sizeof numbers/sizeof(int);
        cout << size << endl;

        for(int i=0;i<=size;i++)
        {
                cout << "elements at index " << i << endl;
        }
        return 0;
}

wtorek, 17 maja 2016

where is lxc conetainer FS - ubuntu

┌─[ubuntu]─[/var/cache/lxc/xenial/rootfs-amd64]
└──╼ pwd
/var/cache/lxc/xenial/rootfs-amd64


┌─[ubuntu]─[/var/cache/lxc/xenial/rootfs-amd64]
└──╼ ll
razem 76
drwxr-xr-x  2 root root 4096 lut  5 10:48 sys
drwxr-xr-x  2 root root 4096 kwi 12 22:14 proc
drwxr-xr-x  2 root root 4096 kwi 12 22:14 home
drwxr-xr-x  2 root root 4096 kwi 12 22:14 boot
drwx------  2 root root 4096 maj 17 21:01 root
drwxr-xr-x  2 root root 4096 maj 17 21:01 mnt
drwxr-xr-x  2 root root 4096 maj 17 21:01 srv
drwxr-xr-x  2 root root 4096 maj 17 21:01 opt
drwxr-xr-x  2 root root 4096 maj 17 21:01 media
drwxr-xr-x 11 root root 4096 maj 17 21:01 var
drwxr-xr-x 10 root root 4096 maj 17 21:01 usr
drwxr-xr-x  2 root root 4096 maj 17 21:01 lib64
drwxr-xr-x  4 root root 4096 maj 17 21:02 dev
drwxr-xr-x 11 root root 4096 maj 17 21:02 lib
drwxrwxrwt  2 root root 4096 maj 17 21:03 tmp
drwxr-xr-x  7 root root 4096 maj 17 21:03 run
drwxr-xr-x  2 root root 4096 maj 17 21:03 bin
drwxr-xr-x  2 root root 4096 maj 17 21:03 sbin
drwxr-xr-x 66 root root 4096 maj 17 21:03 etc

Interesting apt function

1. Installation Simulation

┌─[ubuntu]─[/tmp]
└──╼ apt-get install -s htop
Czytanie list pakietów... Gotowe
Budowanie drzewa zależności     
Odczyt informacji o stanie... Gotowe
Zostaną zainstalowane następujące NOWE pakiety:
  htop
0 aktualizowanych, 1 nowo instalowanych, 0 usuwanych i 0 nieaktualizowanych.
Inst htop (2.0.1-1 Ubuntu:16.04/xenial [amd64])
Conf htop (2.0.1-1 Ubuntu:16.04/xenial [amd64])


2. How Do I Check Package Information
┌─[ubuntu]─[/tmp]
└──╼ apt-cache show netcat
Package: netcat
Priority: optional
Section: universe/net
Installed-Size: 30
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Ruben Molina <rmolina@udea.edu.co>
Architecture: all
Version: 1.10-41
Depends: netcat-traditional (>= 1.10-39)
Filename: pool/universe/n/netcat/netcat_1.10-41_all.deb
Size: 3438
MD5sum: ef404dcc16fdf7b7fc049e8499b5d6dd
SHA1: 6445cd6789821840978146ef1d33a2475e092c42
SHA256: 1865119bdf88c21df3c039f987492defac68668bf7293ba279e76943c0fd1785
Description-pl: Uniwersalne narzędzie dla TCP/IP  -- pakiet przejściowy
 To jest pakiet "atrapa", który zależy od domyślnej wersji netcata w
 lennym, aby ułatwić wprowadzanie nowej wersji. Można go bezpiecznie
 usunąć.
Description-md5: 1353f8c1d079348417c2180319bdde09
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu


3. How Do I Check Dependencies for Specific Packages?
┌─[ubuntu]─[/tmp]
└──╼ apt-cache showpkg apache2
Package: apache2
Versions:
2.4.18-2ubuntu3 (/var/lib/apt/lists/pl.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/pl.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-amd64_Packages
                  MD5: d02426bc360345e5acd45367716dc35c
 Description Language:
                 File: /var/lib/apt/lists/pl.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-i386_Packages
                  MD5: d02426bc360345e5acd45367716dc35c
 Description Language: en
                 File: /var/lib/apt/lists/pl.archive.ubuntu.com_ubuntu_dists_xenial_main_i18n_Translation-en
                  MD5: d02426bc360345e5acd45367716dc35c


Reverse Depends:
  phabricator,apache2 2.2.7
  tinyows,apache2
  python-pycsw-wsgi,apache2 2.4.12~
  mythweb,apache2
  mythbuntu-desktop,apache2
  libapache2-mpm-itk:i386,apache2 2.4.6-4~
  libapache2-mpm-itk:i386,apache2 2.4.9-2~
  dwww:i386,apache2 2.4.4-6~
  bandwidthd-pgsql:i386,apache2 2.4
  bandwidthd:i386,apache2 2.4
  zoneminder,apache2 2.4.18~
  zabbix-frontend-php,apache2 2.4.18~
  yubikey-val,apache2
  yubikey-ksm,apache2
  yocto-reader,apache2 2.4.10~
  xymon,apache2
  xapian-omega,apache2
  x2goplugin-provider,apache2
  wwwconfig-common,apache2
  wulf2html,apache2
  wordpress,apache2
  wims,apache2 2.4.12~
  wiliki,apache2
  whiteboard,apache2
  websimba,apache2
  webgui,apache2
  web2ldap,apache2
  w3c-markup-validator,apache2
  w3c-linkchecker,apache2
  viewvc,apache2
  usemod-wiki,apache2 2.4.10~
  usemod-wiki,apache2
  umegaya,apache2 2.4.9~
  ukolovnik,apache2
  uec-provisioning-webui,apache2
  ubumirror,apache2
  tt-rss,apache2
  trac,apache2
  sympa,apache2
  sugarplum,apache2 2.4.10~
  stacks-web,apache2
  sslh,apache2
  srg,apache2
  sqwebmail,apache2
  squirrelmail,apache2
  squid-cgi,apache2
  sql-ledger,apache2
  spip,apache2
  smokeping,apache2
  smokeping,apache2 2.4.17~
  smokeping,apache2
  smb2www,apache2 2.4.6~
  smb2www,apache2
  slbackup-php,apache2
  sitesummary,apache2
  sipwitch-cgi,apache2
  sipml5-web-phone,apache2
  simplesamlphp,apache2
  simpleid-ldap,apache2
  simpleid,apache2 2.4.18~
  shaarli,apache2 2.4.18~
  serverstats,apache2
  semanticscuttle,apache2
  scuttle,apache2
  sbox-dtc,apache2
  sarg,apache2
  rtpg-www,apache2
  rtpg-www,apache2
  rtgui,apache2 2.4.18~
  rtgui,apache2
  rt4-apache2,apache2
  routino-www,apache2
  roundcube-core,apache2
  rancid-cgi,apache2
  queuegraph,apache2
  python-letsencrypt-apache,apache2
  pyca,apache2
  pyblosxom,apache2
  puppetmaster-passenger,apache2
  puppetmaster-common,apache2
  postfixadmin,apache2
  postfix-cluebringer-webui,apache2
  pnopaste,apache2
  piuparts-master,apache2
  pictor,apache2
  phpsysinfo,apache2
  phppgadmin,apache2 2.4.18~
  phpmyadmin,apache2
  phpldapadmin,apache2
  phpbb3,apache2
  php-horde,apache2
  photofloat,apache2
  phamm,apache2 2.4.18~
  openjpip-server,apache2 2.4.10~
  otrs2,apache2
  libapache2-mpm-itk,apache2 2.4.6-4~
  openguides,apache2
  onak,apache2
  ogamesim-www,apache2
  octopussy,apache2
  ocsinventory-server,apache2 2.4.18~
  ocsinventory-reports,apache2 2.4.18~
  oar-web-status,apache2
  oar-restful-api,apache2
  oar-restful-api,apache2
  netmrg,apache2
  mythexport,apache2
  musica,apache2
  moodle,apache2
  mobyle,apache2 2.4.17~
  mobyle,apache2 2.4
  mirrorkit,apache2
  man2html,apache2
  mailgraph,apache2
  lurker,apache2
  ltsp-cluster-control,apache2
  loganalyzer,apache2
  live-build-cgi,apache2
  linkchecker-web,apache2
  lightsquid,apache2
  libopenjpip-server,apache2 2.4.12~
  libapache2-mpm-itk,apache2 2.4.9-2~
  libapache2-mod-webauth,apache2 2.4.4
  libapache2-mod-webauthldap,apache2 2.4.4
  jsmath,apache2 2.4.9~
  libapache2-mod-auth-radius,apache2
  letodms,apache2
  ledgersmb,apache2
  ldap-account-manager,apache2
  jwchat,apache2
  dwww,apache2 2.4.4-6~
  jscommunicator-web-phone,apache2
  jffnms,apache2
  iptotal,apache2
  info2www,apache2
  ikiwiki-hosting-web,apache2
  icingaweb2,apache2
  icinga2-classicui,apache2
  icinga-cgi-bin,apache2
  icinga-cgi,apache2
  htcheck-php,apache2
  hoteldruid,apache2
  hoogle,apache2
  hiki,apache2
  haci,apache2
  gridsite,apache2 2.4.18~
  gosa,apache2
  glpi,apache2
  gitweb,apache2
  gbrowse,apache2 2.4.17~
  gbrowse,apache2 2.4
  ganglia-webfrontend,apache2
  galette,apache2
  fusiondirectory,apache2
  freeipa-server,apache2
  freedombox-setup,apache2
  flatnuke,apache2
  flashproxy-proxy,apache2
  flashproxy-facilitator,apache2
  emboss-explorer,apache2 2.4.6~
  dwww,apache2 2.4.18~
  dpkg-www,apache2 2.4.12~
  dwww,apache2
  dsc-statistics-presenter,apache2
  drupal7,apache2
  drraw,apache2
  bcfg2-web,apache2 2.4.17~
  dotclear,apache2 2.4.18~
  dotclear,apache2
  dolibarr,apache2
  doc-central,apache2
  djagios,apache2
  darcsweb,apache2
  d-push,apache2
  cvsweb,apache2
  cricket,apache2
  couriergraph,apache2
  courier-webadmin,apache2
  cortado,apache2
  coquelicot,apache2
  colplot,apache2
  colplot,apache2
  collectd-core,apache2
  collabtive,apache2 2.4.18~
  collabtive,apache2 2.4
  cobbler,apache2
  citadel-webcit,apache2
  cipux-cat-web,apache2
  chemical-structures,apache2
  ch5m3d,apache2
  cgit,apache2 2.4.18~
  cacti,apache2
  ampache,apache2 2.4.18~
  barbican-api,apache2 2.4.18~
  bandwidthd-pgsql,apache2
  bandwidthd-pgsql,apache2 2.4
  bandwidthd,apache2
  bandwidthd,apache2 2.4
  auth2db-frontend,apache2
  apcupsd-cgi,apache2
  analog,apache2
  javascript-common,apache2 2.4.6~
  ajaxterm,apache2
  aegis-web,apache2
  adzapper,apache2
  adzapper,apache2
  adzapper,apache2
  389-admin,apache2
  apache2:i386,apache2
  openstack-dashboard,apache2
  nut-cgi,apache2
  nagios3-cgi,apache2
  mailman,apache2
  maas-region-api,apache2
  apache2-dbg,apache2 2.4.18-2ubuntu3
  backuppc,apache2
  awstats,apache2
  apache2-doc,apache2
Dependencies:
2.4.18-2ubuntu3 - dpkg (2 1.17.14) lsb-base (0 (null)) procps (0 (null)) perl (0 (null)) mime-support (0 (null)) apache2-bin (5 2.4.18-2ubuntu3) apache2-utils (2 2.4) apache2-data (5 2.4.18-2ubuntu3) apache2.2-bin (0 (null)) apache2.2-common (0 (null)) ssl-cert (0 (null)) www-browser (0 (null)) apache2-doc (0 (null)) apache2-suexec-pristine (16 (null)) apache2-suexec-custom (0 (null)) ufw (0 (null)) apache2.2-bin (0 (null)) apache2.2-common (0 (null)) apache2:i386 (32 (null))
Provides:
2.4.18-2ubuntu3 - httpd-cgi (= ) httpd (= )
Reverse Provides:


4. How Do I Check statistics of Cache
┌─[ubuntu]─[/tmp]
└──╼ apt-cache stats
Liczba nazw pakietów: 70310 (1406 k)
Liczba wszystkich typów pakietów: 108566 (4777 k)
  Zwykłych pakietów: 80567
  Czysto wirtualnych pakietów: 979
  Pojedynczych pakietów wirtualnych: 9945
  Mieszanych pakietów wirtualnych: 2234
  Brakujących: 14841
W sumie różnych wersji: 83959 (6717 k)
W sumie różnych opisów: 146271 (3511 k)
W sumie zależności: 606939/209772 (15,5 M)
W sumie zależności wersja/plik: 44648 (1072 k)
W sumie zależności opis/plik: 15199 (365 k)
W sumie mapowań zapewnień: 17442 (419 k)
W sumie dopasowanych napisów: 154509 (3409 k)
Sumaryczny rozmiar niewykorzystanego miejsca: 11,0 k
Całkowity rozmiar: 37,6 M
Total buckets in PkgHashTable: 50503
  Unused: 12500
  Used: 38003
  Utilization: 75.249%
  Average entries: 2.85677
  Longest: 15
  Shortest: 1
Total buckets in GrpHashTable: 50503
  Unused: 12500
  Used: 38003
  Utilization: 75.249%
  Average entries: 1.85012
  Longest: 8
  Shortest: 1


5. Find dependencies of a package

┌─[ubuntu]─[/tmp]
└──╼ apt-cache depends apache2
apache2
  Wymaga wstępnie: dpkg
    dpkg:i386
  Wymaga: lsb-base
  Wymaga: procps
    procps:i386
  Wymaga: perl
  Wymaga: mime-support
  Wymaga: apache2-bin
  Wymaga: apache2-utils
    apache2-utils:i386
  Wymaga: apache2-data
  W konflikcie z: <apache2.2-bin>
  W konflikcie z: <apache2.2-common>
  Poleca: ssl-cert
  Sugeruje: <www-browser>
    dillo
    edbrowse
    hv3
    lynx:i386
    lynx
    netsurf
    netsurf-fb
    netsurf-gtk
    qupzilla
    uzbl
    chimera2
    chromium-browser
    elinks
    epiphany-browser
    firefox
    konqueror
    links
    links2
    midori
    netrik
    rekonq
    surf
    w3m
    w3m:i386
    xemacs21-mule
    xemacs21-mule-canna-wnn
    xemacs21-nomule
  Sugeruje: apache2-doc
 |Sugeruje: apache2-suexec-pristine
  Sugeruje: apache2-suexec-custom
  Sugeruje: ufw
  Zastępuje: <apache2.2-bin>
  Zastępuje: <apache2.2-common>
 

poniedziałek, 16 maja 2016

how to install rust language on centos7 vps

1. sudo yum install curl
2. curl -sSf https://static.rust-lang.org/rustup.sh | sh

└──╼ curl -sSf https://static.rust-lang.org/rustup.sh | sh
rustup: gpg available. signatures will be verified
rustup: downloading manifest for 'stable'
rustup: downloading toolchain for 'stable'
######################################################################## 100.0%
gpg: Signature made Tue 12 Apr 2016 04:51:11 AM EDT using RSA key ID 7B3B09DC
gpg: Good signature from "Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 108F 6620 5EAE B0AA A8DD  5E1C 85AB 96E6 FA1B E5FE
     Subkey fingerprint: C134 66B7 E169 A085 1886  3216 5CB4 A934 7B3B 09DC
rustup: installing toolchain for 'stable'
rustup: extracting installer
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'rust-std-x86_64-unknown-linux-gnu'
install: installing component 'rust-docs'
install: installing component 'cargo'

    Rust is ready to roll.


czwartek, 12 maja 2016

add forwarded-port via firewall-cmd

┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=80:toaddr=10.0.3.223 --permanent

┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --list-all
public (default, active)
  interfaces: enp0s8 enp0s9
  sources:
  services: dhcpv6-client http https ssh
  ports: 5000/tcp
  protocols:
  masquerade: no
  forward-ports: port=80:proto=tcp:toport=80:toaddr=10.0.3.223
  icmp-blocks:
  rich rules:

remove forwarded-port firewall-cmd

┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --list-all
public (default, active)
  interfaces: enp0s8 enp0s9
  sources:
  services: dhcpv6-client http https ssh
  ports: 5000/tcp
  protocols:
  masquerade: no
  forward-ports: port=80:proto=tcp:toport=:toaddr=10.0.3.223
    port=80:proto=tcp:toport=80:toaddr=10.0.3.223
  icmp-blocks:
  rich rules:
   
┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --remove-forward-port==80:proto=tcp:toport=:toaddr=10.0.3.223
missing port
┌─[✗]─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --remove-forward-port=port=80:proto=tcp:toport=:toaddr=10.0.3.223
success
┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --remove-forward-port=port=80:proto=tcp:toport=80:toaddr=10.0.3.223
success
┌─[ubuntu]─[~]
└──╼ firewall-cmd --zone=public --list-all

public (default, active)
  interfaces: enp0s8 enp0s9
  sources:
  services: dhcpv6-client http https ssh
  ports: 5000/tcp
  protocols:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

ip addr - get ip and mac address only

ip addr show enp0s3 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

192.168.1.148
fe80::a00:27ff:fe4c:49a9

something goes wrong - how to remove untaged container

┌─[ubuntu]─[~/testDocker]
└──╼ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
<none>                  <none>              faf44dedba3b        17 seconds ago      120.8 MB
nickistre/ubuntu-lamp   latest              b6f2fc2138c1        5 days ago          633.7 MB
ubuntu                  latest              c5f1cf30c96b        8 days ago          120.8 MB
fedora                  latest              ddd5c9c1d0f2        9 weeks ago         204.7 MB



┌─[ubuntu]─[ubuntu]─[~/testDocker]
└──╼ sudo docker rmi $(docker images -q -f dangling=true)
Deleted: sha256:faf44dedba3be5530978da6a1ca1e03458c17c81c356e16bec6486d08576f926


┌─[ubuntu]─[~/testDocker]
└──╼ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
nickistre/ubuntu-lamp   latest              b6f2fc2138c1        5 days ago          633.7 MB
ubuntu                  latest              c5f1cf30c96b        8 days ago          120.8 MB
fedora                  latest              ddd5c9c1d0f2        9 weeks ago         204.7 MB




sudo docker images|grep \<none\>|awk -F " " '{print "sudo docker rmi " $3}'|sh


command usefull to list untagged images
 
docker images --filter "dangling=true"
 

delete all docker images

┌─[virt]─[~]
└──╼ docker rmi $(docker images -q)


Untagged: docker.io/ubuntu:latest
Deleted: 17b6a9e179d7cb99d2f27978ca3ac6cf23eefb23201472ed54f5d9fb94894922
Deleted: b0c2dfa2701fba584d203de7ffef490cb9a1826a4b22b33dd21a5638cbe76832
Deleted: 202e40f8bb3abf835124666aa607f8787c5016bcf339cb65607ad718b609496e
Deleted: acb8e44f43faf158c097976f7d4d21be7846ae6cec2244bbb5bc98e62595e4b9
Deleted: 487bffc61de6f950082a5cc90fc4d3169a2a1373af9704210c1c5820a882daad
Untagged: docker.io/nfnty/arch-mini:latest
Deleted: 4fc09f59d00fc78b12f62da4840224346ba87814e009c312147da0f5a87996d8
Deleted: 497eebcf61fb3fc3c1344437fb5b6f77f06cded8877882183ba25bd360c92b81
Deleted: e1c96069070c051afe4b67ddeb3efc47fd256c9da26fabead9e3a06d7f254096
Deleted: d57e0bba13b0909e53b0acf4065edb75f0619ae3a8638e921e9d95eb191278d1
Deleted: 871d4e3bf97c7a74f5d2e99025307c285a7ad5494631907a7b41b5aeca0ec631
Deleted: d1ada8114789f5dba3411c91d7f8ee4433b8aefb05185ff112d9d02d7a9e6853
Deleted: 9ea6961a052d7152c2ab0a35d0df50b9ae0f76eb04081aa29024a8174a758dc7
Deleted: 13b6f8c5702863d14eaced3653ebbe011a2324ebf65ee0435df690bd148bdcfe
Untagged: docker.io/nickistre/centos-lamp:latest
Deleted: d1e78ef4e5c79a27a341c2a79da8265d7764f20d375255ec359f95673a80662e
Deleted: 40dad44fb07864bd71a017c554670dc91ae3f7796a68feb6e7a7b60e0f27d538
Deleted: da63317043a4b74e1b0c6aa764730387999974c99315f463cf0a655bf42b3fa1
Deleted: 3700dfbc10b1c33735e1d48545b9db9c1e234a05aa663a2bc2a837d79f92f91d
Deleted: 275d1ee6afe01585df3e248f72661efa94d7fa16c569c84a57992c8f8fa7823b
Deleted: 65d81aba8749f6eb66bac29395ab0ea50002b390700795f3781bd3d9a26eb5ee
Deleted: 96ce836f2e9bad8c2e036ab468ba7077f8dd96f990c2941e0752ed1f90f51a01
Deleted: d537094abe4a011c2d5f272ed03bfdb70162617e4552ef40bdd5512bd195d2ae
Deleted: b95c167982586014abef2c3476884ec49b7fcf818c54429c8eb4426611069cff
Deleted: 18cb52c9a58bba797dcbc8685bd40560b5f92ebc4a7f67bc7382f80526cddd05
Deleted: 731f0c50edaf18709cfb96729d3178529b9eb9bfc71bd6a414bf8960941dedbb
Deleted: b65443d5d38eddeed126471ae2c82d45262bd4069f45fe07e4ad2235be7154cd
Deleted: 760d6b3be40b200fe3388ccf55862f098a91135dc783087f8d0878d791cb18fe
Deleted: fef4e4dda0a92ad6b8ced415de19fafcbd2ef6a9e2af224d3f11bd436612af26
Deleted: 4c5c941670df196261cf77f7588d23fc0dbe504ecc2835b5daec0feb18fd3ee4
Deleted: 630367902b0b8fa39f1504a89093380e09b84088f6cb491c9a7b11018a642838
Deleted: cef52ac257311bd24e6c8ce6c35747ef46434d2c39afb540e5ee2d078f0a68e0
Deleted: fb416c18da79c7bc9b177bc1c3eca7c9dfe60ed48e2531583c87265215b84fb0
Deleted: 39843ad887c76fb25068deab1322d86f752aeae0cd074f30ff993c0dfc153304
Untagged: docker.io/centos:latest
Deleted: 28e524afdd052cfa82227c67344c098aabcd51021dd1f3b0c71485abcdd78a86
Deleted: 044c0f15c4d9a7499734b75b73ea5754ceb2c1c22e86d7eaa5ab8098b60c5267
Deleted: 2ebc6e0c744d13008fac31bfffae2ebdbb04acd1a90bf63466496cd856e19365
Deleted: fa5be2806d4c9aa0f75001687087876e47bb45dc8afb61f0c0e46315500ee144


┌─[virt]─[~]
└──╼ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

delete all stopped docker containers

┌─[virt]─[~]
└──╼ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                  PORTS               NAMES
fbc0f5880f07        28e524afdd05        "/bin/bash"         7 days ago          Exited (0) 7 days ago                       mad_carson
693d26008209        28e524afdd05        "/bin/bash"         7 days ago          Exited (0) 7 days ago                       distracted_spence
d37940ef94ea        17b6a9e179d7        "/bin/bash"         7 days ago          Exited (0) 7 days ago                       suspicious_chandrasekhar
81f809e2f7d5        17b6a9e179d7        "/bin/bash"         7 days ago          Exited (0) 7 days ago                       goofy_gates


┌─[virt]─[~]
└──╼ docker rm $(docker ps -q -a)


fbc0f5880f07
693d26008209
d37940ef94ea
81f809e2f7d5


┌─[virt]─[~]
└──╼ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

środa, 4 maja 2016

Very simple echo server based on nc

on server: nc -l 4444 -k -c 'xargs -n1 echo hello'

on client:  [marek@oc3050801487 ~]$ nc -v 192.168.1.197 4444
Connection to 192.168.1.197 4444 port [tcp/krb524] succeeded!
asd
hello asd