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.