Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (1) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (30) javascript (3) Linux (164) Mac (19) Machine Learning (1) mySQL (47) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (45) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Saturday 29 December 2018

mySQL and phpMyAdmin

https://docs.slackware.com/howtos:databases:install_mysql_on_slackware


See here for a more up to date account of installing Apache, php, mySQL and phpMyAdmin on Debian.

Thursday 27 December 2018

smb.conf

# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba, 
# read the Samba-HOWTO-Collection. This may be obtained from:
#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the 
# Samba-Guide which is generated daily and can be downloaded from: 
#  http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash) 
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors. 
#
#======================= Global Settings =====================================

SQL DML Data Manipulation Language


SELECT
SELECT *
FROM someTable
ORDER BY pk_id;


VARIABLES 
SELECT id, machine, user
FROM db.tableA varA
JOIN db.tableB varB ON (varA.user = varB.user)
WHERE id=500
ORDER BY id
LIMIT 10;

/*! so db.tableA can be referenced by varA and db.tableB by varB */ 

INSERT INTO
INSERT INTO 〈table name〉( 〈column 1〉, 〈column 2〉,... 〈column n〉 )
VALUES ( 〈value 〉, 〈value 2〉, ..., 〈value n〉);
Note column names do not require quotation marks, however values do.

INSERT INTO 〈table name〉
VALUES
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉)
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉)
      ( 〈value 〉, 〈value 2〉, ..., 〈value n〉); 
Note: We can omit the column names so long as the list of values match the number of columns AND are in the correct order.

UPDATE WHERE
UPDATE 〈table_name〉
SET column1 = value1, column2 = value2, ...
WHERE 〈condition〉;

DELETE FROM
DELETE FROM 〈table_name〉 WHERE 〈condition〉;
DELETE FROM table_name
Note: the latter command removes ALL data from the table. 

If we wish to list all different values in a column and count the number of instances of that value.
SELECT "names", COUNT("names") AS numberOfTimes
FROM mydf
GROUP BY "names"
ORDER BY
numberOfTimes;

   

SQL DDL Data Definition Language


SQL in Jupyter Notebooks specifically PostgreSQL



Linux users and groups

users

1) useradd user
Create a user. 
2) passwd user
Create/Change password for user.

To create a new user, gennerally run 1, then 2 above, alternatively, you can use adduser user
which is a higher level command. 
adduser user group
As above but also adds user to group.
passwd -l user
Lock user, preventing logon using password.
passwd -u user 
Unlock user. 
passwd -S user  
Get Status for user. 

groups


groups username 
Shows a list of groups the current user is a member of.
id shows the numerical id's.

groupadd newgroup
Create a new group 
addgroup newgroup
Create a new group  
usermod -a -G group username
usermod -a -G group1,group2,group3 username 
append group(s) to username. Add username to group(s)

usermod -g groupname username 
Modify user's primary group (g = primary group G = secondary group)

useradd -G group username
Create a new user and assign it to group
getent group
List all groups on system.

groupdel group
Remove group 
groupmod --new-name NEW_GROUP_NAME OLD_GROUP_NAME
rename a group.  


 

 

Thursday 20 December 2018

Linux user log

To view the recent logon activity for a user, use the following;

last username

Monday 10 December 2018

email forwarding

Assuming everything else is set up, users domains and such;

Add the following entry to aliases file;

user: forward@somewhere.com

Then update aliases file and restart sendmail.

You can also add a .forward file to the user's home folder like so;

forward1@somewhere.com
forward2@somewhere.com

The former method is preferred.

Tuesday 27 November 2018

Removing LVM



# df -hP | grep -i data01
/dev/mapper/datavg-testlv  976M  2.6M  907M   1% /data01

# lvs
  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   centos -wi-ao---- 17.47g
  swap   centos -wi-ao----  2.00g
  testlv datavg -wi-ao----  1.00g
1. Delete the entry of the mount point from the /etc/fstab :
# cat /etc/fstab
...
/dev/mapper/datavg-testlv            /data01              ext4    defaults        0 0
...
2. Unmount the mount point :
# umount /data01
3. Disable lvm :
# lvchange -an /dev/datavg/testlv
4. Delete lvm volume :
# lvremove /dev/datavg/testlv
5. Disable volume group :
# vgchange -an datavg
6. Delete volume group :
# vgremove datavg
7. Delete physical Volumes being used for the volume group “datavg” :
# pvremove /dev/sdb  /dev/sdc

Tuesday 20 November 2018

Slackbuilds

A note on Slackbuilds.

I noticed during some issues with fail2ban that as I had run my build script while anaconda2 was installed, this meant that the installation package when run would put binaries in the /opt/anaconds2/bin directory as opposed to /usr/bin

Even after removing anaconda2 directory and also entries from root and user .bashrc files, running the installation package, still put the fail2ban-client file in /opt/anaconds2/bin as opposed to /usr/bin

This I'm guessing was down to the fact that the python location was in my PATH when the build script was run and of course after this was removed, I rebuilt the installation package and installed and all was as expected.

I need to verify this as I thought you could run a build script and then use the installation package on a different machine, obviously with the same version of slackware but this may not be the case. Perhaps I was thinking about regular compiling into binaries?

rc.local_shutdown

#!/bin/sh
#
# /etc/rc.d/rc.local_shutdown:  Local system shutdown script.
#
# Put any local shutdown commands in here.

# by H Nisbet 02 Nov 2018

if [ -x /etc/rc.d/rc.tm351vm ]
then
        /etc/rc.d/rc.tm351vm suspend # attempt suspend first
#       /etc/rc.d/rc.tm351vm stop
fi

# Stop fail2ban:
if [ -x /etc/rc.d/rc.fail2ban ]; then
        echo "Stopping fail2ban: /etc/rc.d/rc.fail2ban stop"
        /etc/rc.d/rc.fail2ban stop
fi


# Stop Webminin:
if [ -x /etc/rc.d/rc.webmin ]; then
        echo "Stopping Webmin:   /etc/rc.d/rc.webmin stop"
        /etc/rc.d/rc.webmin stop

fi

rc.local

#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
if [ -x /etc/rc.d/rc.tm351vm ]
then
        /etc/rc.d/rc.tm351vm start

fi

# Start fail2ban
if [ -x /etc/rc.d/rc.fail2ban ]; then
        echo "Starting fail2ban:   /etc/rc.d/rc.fail2ban"
        /etc/rc.d/rc.fail2ban start
fi

# Log boot time...
/bin/date >> /var/log/boot.log

jail.conf

# Fail2Ban jail specifications file
#
# Comments: use '#' for comment lines and ';' (following a space) for inline comments
#
# Changes:  in most of the cases you should not modify this
#           file, but provide customizations in jail.local file, e.g.:
#
# [DEFAULT]
# bantime = 3600
#
# [ssh-iptables]
# enabled = true
#

fail2ban.conf

# Fail2Ban main configuration file
#
# Comments: use '#' for comment lines and ';' (following a space) for inline comments
#
# Changes:  in most of the cases you should not modify this
#           file, but provide customizations in fail2ban.local file, e.g.:
#
# [Definition]
# loglevel = 4
#

[Definition]

# Option:  loglevel
# Notes.:  Set the log level output.
#          1 = ERROR
#          2 = WARN
#          3 = INFO
#          4 = DEBUG
# Values:  NUM  Default:  3
#
loglevel = 3

# Option:  logtarget
# Notes.:  Set the log target. This could be a file, SYSLOG, STDERR or STDOUT.
#          Only one log target can be specified.
#          If you change logtarget from the default value and you are
#          using logrotate -- also adjust or disable rotation in the
#          corresponding configuration file
#          (e.g. /etc/logrotate.d/fail2ban on Debian systems)
# Values:  STDOUT STDERR SYSLOG file  Default:  /var/log/fail2ban.log
#
logtarget = /var/log/fail2ban.log

# Option: socket
# Notes.: Set the socket file. This is used to communicate with the daemon. Do
#         not remove this file when Fail2ban runs. It will not be possible to
#         communicate with the server afterwards.
# Values: FILE  Default:  /var/run/fail2ban/fail2ban.sock
#
socket = /var/run/fail2ban/fail2ban.sock

# Option: pidfile
# Notes.: Set the PID file. This is used to store the process ID of the
#         fail2ban server.
# Values: FILE  Default:  /var/run/fail2ban/fail2ban.pid
#
pidfile = /var/run/fail2ban/fail2ban.pid

Monday 19 November 2018

Slackware Configuration

Network/Host name
netconfig
/etc/rc.d/rc.inet1.conf
/etc/hosts
/etc/hosts.deny
/etc/hosts.allow
/etc/resolve

Runlevel

rc.d 
/etc/rc.d/rc.local
/etc/rc.d/rc.local_shutdown

SSHD
/etc/ssh

Samba
/etc/rc.d/rc.samba
/etc/samba/smb.conf

SendMail
/etc/rc.d/rc.sendmail

Spamassassin

Apache
/etc/rc.d/rc.httpd
/etc/httpd/httpd.conf
/etc/httpd/extras/

ProFTPd
/etc/inetd.conf
users allow file?
/etc/proftpd.conf

awstats
/etc/awstats/
/var/run/awstats/
/var/lib/swstats/
Cron job: TBA
Update data: perl awstats.pl -config=mysite -update

Fail2ban
/etc/fail2ban/
/etc/rc.d/rc.fail2ban

awstats

Location of files for awstats in Slackware.

Site configuration files:
/etc/awstats/

Binaries or such:
/var/run/awstats/

Data:
/var/lib/swstats/

Cron job:
TBA

Update data:
perl awstats.pl -config=mysite -update

Saturday 27 October 2018

Compile C C++ in Linux

gcc source.c -o executable.o

Samba

Users must be added to system in normal way and then also added to samba as follows:

smbpasswd -a user

Wednesday 13 June 2018

Change Form component from other class

To change a component on a form from another class, for example if we have a GUI which is the startup component and we have a slave class that does a lot of work, calculations, searching and such and we wish to update a coomponent on our form from within this slave class.



In the form class, which we’ll call GUI


slave s = new slave(this);// slave is the other class and “this” is a reference to itself, the GUI


In the other class, which we’ll call slave

GUI form; // where GUI is the name of the form class


    public slave(GUI formObject)//formObject is a reference to the GUI form passed by “this”.


    {
        form = formObject;
        //form.setVisible(true); // not needed as it’s already visible
    }

void changeButton()
    {
        form.setButtonText("hello"); // The setButtonText method is an accessible method in the GUI form
    }

Friday 9 March 2018

GitHub - Pushing to remote is rejected as a result of email address being exposed

Problem with PyCharm & Clion and gitHub on Mac specifically…

Also found on Debian, probably affects all applications pushing to GitHub


Pushing to remote is rejected as a result of email address being exposed.

Check;

git config --global user.email

If this shows email address, change is as per below;

git config --global user.email “plisken1@users.noreply.github.com”

Tuesday 30 January 2018

ECC Memory

WINDOWS 7 
wmic MEMORYCHIP get DataWidth,TotalWidth

LINUX
dmidecode -t 17