COMP9311 extension
This is an extension knowledge about COMP9311
Auto deploy PostgreSQL
You can find the shell script here. You can execute the following command in grieg server to deploy the SQL server.
1 | chmod +x deploy.sh |
The code in deploy.sh is:
1 | user=$(whoami) |
Backgroud information
griegmeans a server named grieg
Login CSE/GRIEG
You can log in to cse server by using the following command:
1 | ssh ZID@cse.unsw.edu.au |
PS: Please replace ZID with your zid, and the password is same as your zid passowrd (typing the password in terminal is unvisitable).
After log in to the cse server, then you can log in to grieg server by using the following command:
1 | ssh grieg |
Also, you can log in to grieg directly by using the following command:
1 | ssh ZID@grieg.cse.unsw.edu.au |
PS: Please replace ZID with your zid, and the password is same as your zid passowrd (typing the password in terminal is unvisitable).
Log in to cse server without password
You can log in to cse server without password by uploading ssh-key into the server. If you did not have a ssh-key, you can generate a ssh-key by using the following command (please execute these commands in personal computer) :
1 | ssh-keygen |
Then you can use ssh-copy-id to copy your key to server:
1 | ssh-copy-id ZID@cse.unsw.edu.au |
PS: Please replace ZID with your zid.
You can find more details here
.bash_profile settings
When you logging in to cse server, you may can not find these files (.bash_profile, .bashrc or .profile). You can use touch command to create a empty file in home directory.
1 | cd ~ // switch the directory into home directory |
Then you can find the .bash_profile file by using:
1 | ls -al |
Then you can add the following config code into .bash_profile:
1 | if [ `hostname` = "grieg" ] |
PS: Please replace ZID with your zid.
Terminal display
Several students asked how to modify the Linux terminal display. After logging in to grieg server, on the left hand side it looks like:
1 | grieg % |
It only shows the hostname which is very inconvenient when we want to know which folder we are in. The following commands can help you to solve the issue:
- Log in to
griegserver - Add this line
export PS1="\u@\h \w $ "into the.bash_profilefile - Execute
source ~/.bash_profile
Then the terminal display should like:
1 | ZID@grieg ~ $ |
Where ~ means home directory.
You can find more details here
Upload files to cse server
Use scp (srcure copy) command can upload files/directory from local (Linux or Mac system) to remote cse server:
1 | scp [source file] [username]@[destination server]:/path/ |
For example:
1 | scp schema.sql ZID@cse.unsw.edu.au:~ |
Which means upload the schema.sql file into your cse server home directory.
If you want to upload a directory you can use:
1 | scp -r [source directory] [username]@[destination server]:/path/ |
If you are using windows system, you can have a look winscp. And UNSW gives a guideline about that
SSH config
After finished configuration of log in without password. (section 1.3). You can config the ssh config file like:
1 | Host cse |
Where ZID is your zid. Now, you can use ssh cse instead of ssh zid@cse.unsw.edu.au.
Lab 02
The lab 02 slides is available here, if you have any issues, please email me.
Lab03
Step up
Download the weblog.zip by using
wgetcommand in the terminal:wget https://www.cse.unsw.edu.au/~cs9311/21T1/lab/04/weblog.zipUnzip the weblog.zip files:
unzip weblog.zipCreate a database for this lab:
createdb weblogLoad SQL file
switch to the weblog directory:
cd weblogload schema:
psql weblog -f schema.sqlload data sql file:
1
2
3psql weblog -f Hosts.sql
psql weblog -f Sessions.sql
psql weblog -f Accesses.sql
Regex online test regex
K-Core decomposition
Given a graph G, the k-core of G can be computed by recursively deleting every node and its adjacent edges if its degree is less than k.
The python code of k-core as shown in the following part.
1 | import copy |