home       inleiding       sysadmin       services       links       bash       werk       nothing      

diverse commando's

niet onmiddellijk onder EEn noemer onder te brengen ...

  1. du (directory usage)
     
    man page
    NAME
       du - estimate file space usage
     
    SYNOPSIS
       du [OPTION]... [FILE]...
       du [OPTION]... --files0-from=F
     
    DESCRIPTION
       Summarize disk usage of the set of FILEs, recursively for directories.
       Mandatory  arguments  to  long  options are mandatory for short options
       too.

     
    interessante link(s):
    https://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/
     
    voorbeelden:
     
    du -chs
    grand total (c), human readable (h), summarize (s)
    merk het verschil op in gebruik ...
    zonder asterisk *

    $ du -chs /var 2>/dev/null
    806M    /var
    806M    total

     
    ... met asterisk *

    $ du -chs /var/* 2>/dev/null
    18M /var/backups
    455M    /var/cache
    8,0K    /var/games
    310M    /var/lib
    4,0K    /var/local
    0   /var/lock
    12M /var/log
    4,0K    /var/mail
    4,0K    /var/opt
    0   /var/run
    60K /var/spool
    12M /var/tmp
    4,0K    /var/www
    806M    total

     
    du -cs /etc/* 2>/dev/null | sort -nr
    ordent de meest gevulde files en directories bovenaan ...

    $ du -cs /etc/* 2>/dev/null | sort -nr | head
    28932   total
    11724   /etc/skel
    3672    /etc/brltty
    1036    /etc/apparmor.d
    1024    /etc/gufw
    936 /etc/ssl
    704 /etc/mono
    652 /etc/apache2
    496 /etc/X11
    436 /etc/fonts

     

  2. at
     
    man page
    NAME
       at,  batch,  atq, atrm - queue, examine or delete jobs for later execu‐
       tion
     
    SYNOPSIS
       at [-V] [-q queue] [-f file] [-mMlv] timespec...
       at [-V] [-q queue] [-f file] [-mMkv] [-t time]
       at -c job [job...]
       atq [-V] [-q queue]
       at [-rd] job [job...]
       atrm [-V] job [job...]
       batch
       at -b
     
    DESCRIPTION
       at and batch read commands from standard  input  or  a  specified  file
       which are to be executed at a later time, using /bin/sh.
     
       at      executes commands at a specified time.
     
       atq     lists  the  user's  pending  jobs, unless the user is the supe‐
               ruser; in that case, everybody's jobs are listed.   The  format
               of  the  output  lines (one for each job) is: Job number, date,
               hour, queue, and username.
     
       atrm    deletes jobs, identified by their job number.
     
       batch   executes commands when system  load  levels  permit;  in  other
               words,  when  the  load  average  drops below 1.5, or the value
               specified in the invocation of atd.

     
    interessante link(s):
    https://www.tecmint.com/linux-cron-alternative-at-command-to-schedule-tasks/
     
    voorbeeld
     
    $ echo "wget https://nl.wordpress.org/wordpress-4.9.4-nl_NL.tar.gz"| at -t 201803021155

    warning: commands will be executed using /bin/sh
    job 2 at Fri Mar  2 11:55:00 2018

    $ atq

    1   Fri Mar  2 11:55:00 2018 a user
    2   Fri Mar  2 11:55:00 2018 a user

    $ atrm 2
    $ atq

    1   Fri Mar  2 11:55:00 2018 a user

     
    om de output van het ge-schedule-de commando te zien, moeten we in linux onze lokale mail raadplegen.
     
    In mijn geval draaide er geen lokale maildaemon:
     
    Het volgende commando toont alle draaiende daemons ....
    $ sudo systemctl list-unit-files | grep enabled | sort

    accounts-daemon.service                    enabled 
    acpid.path                                 enabled 
    acpid.socket                               enabled 
    anacron-resume.service                     enabled 
    anacron.service                            enabled 
    apt-daily.timer                            enabled 
    apt-daily-upgrade.timer                    enabled 
    atd.service                                enabled 
    autovt@.service                            enabled 
    avahi-daemon.service                       enabled 
    avahi-daemon.socket                        enabled 
    bind9.service                              enabled 
    binfmt-support.service                     enabled 
    bluetooth.service                          enabled 
    brltty.service                             enabled 
    casper.service                             enabled 
    cgmanager.service                          enabled 
    cgproxy.service                            enabled 
    cron.service                               enabled 
    cups-browsed.service                       enabled 
    cups.path                                  enabled 
    cups.service                               enabled 
    cups.socket                                enabled 
    dbus-org.bluez.service                     enabled 
    dbus-org.freedesktop.Avahi.service         enabled 
    dbus-org.freedesktop.ModemManager1.service enabled 
    dbus-org.freedesktop.nm-dispatcher.service enabled 
    dbus-org.freedesktop.thermald.service      enabled 
    display-manager.service                    enabled 
    dm-event.socket                            enabled 
    dns-clean.service                          enabled 
    friendly-recovery.service                  enabled 
    getty@.service                             enabled 
    gpu-manager.service                        enabled 
    hddtemp.service                            enabled 
    lightdm.service                            enabled 
    lm-sensors.service                         enabled 
    lvm2-lvmetad.socket                        enabled 
    lvm2-lvmpolld.socket                       enabled 
    lvm2-monitor.service                       enabled 
    mintsystem.service                         enabled 
    ModemManager.service                       enabled 
    munin-node.service                         enabled 
    mysql.service                              enabled 
    networking.service                         enabled 
    NetworkManager-dispatcher.service          enabled 
    network-manager.service                    enabled 
    NetworkManager.service                     enabled 
    NetworkManager-wait-online.service         enabled 
    ntp.service                                enabled 
    openvpn.service                            enabled 
    pppd-dns.service                           enabled 
    remote-fs.target                           enabled 
    resolvconf.service                         enabled 
    rsyslog.service                            enabled 
    sshd.service                               enabled 
    ssh.service                                enabled 
    syslog.service                             enabled 
    systemd-timesyncd.service                  enabled 
    thermald.service                           enabled 
    ufw.service                                enabled 
    ureadahead.service                         enabled 
    uuidd.socket                               enabled 
    vboxautostart-service.service              enabled 
    vboxballoonctrl-service.service            enabled 
    vboxdrv.service                            enabled 
    vboxweb-service.service                    enabled 
    vsftpd.service                             enabled 

     
    netstat gaf ook geen open poort 25 ....
    $ netstat -vatn | grep 127

    tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
    tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
    tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN     
    tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN     

     
    En daarom moeten we postfix installeren:
    $ sudo apt install postfix
     
    netstat geeft vervolgens wel poort 25 ...
    $ netstat -vatn | grep :25

    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
    tcp6       0      0 ::1:25                  :::*                    LISTEN    

    en we kunnen dus ons at experiment verder zetten ....
     
    $ echo "ping -c 10 -i 0.2 google.be"| at -m -t 201803020934

    warning: commands will be executed using /bin/sh
    job 7 at Fri Mar  2 09:34:00 2018

    $ mail

    s-nail version v14.8.6.  Type ? for help.
    "/var/mail/user": 1 message 1 new
    >N  1 user               Fri Mar  2 09:34   28/1589  Output from your job        7 

    ? 1

    [-- Message  1 -- 28 lines, 1589 bytes --]:
    From user@lap17.syntraab.mechelen  Fri Mar  2 09:34:03 2018
    Subject: Output from your job        7
    To: bert@lap17.syntraab.mechelen
    Message-Id: <20180302083403.09C461221C8@lap17.syntraab.mechelen>
    Date: Fri,  2 Mar 2018 09:34:02 +0100 (CET)
    From: user@lap17.syntraab.mechelen (bert)
     
    PING google.be (172.217.20.67) 56(84) bytes of data.
    64 bytes from ams15s33-in-f3.1e100.net (172.217.20.67): icmp_seq=1 ttl=55 time=16.6
    ms
    64 bytes from ams15s33-in-f3.1e100.net (172.217.20.67): icmp_seq=2 ttl=55 time=10.9
    ms
    64 bytes from ams15s33-in-f3.1e100.net (172.217.20.67): icmp_seq=3 ttl=55 time=15.5
    ms

    als het commando mail niet werkt moeten we nog mailutils installeren ...
    sudo apt install mailutils