postgressudo -i -u postgres psql enters the promptin the prompt, \l lists the databasesout of the prompt, psql -l does the samepsql "name" enters the prompt for that database\dt (or \dt+ ) lists the tablesin psql you can: CREATE DATABASE "name"; CREATE USER "name" WITH PASSWORD "password"; GRANT ALL PRIVILEGES ON DATABASE "name" TO "user"; \q to quit |
tmuxpane splitting:ctrl-b " (top/bottom)ctrl-b % (side/side)move between panes: ctrl-b [ARROW_KEY] windows: ctrl-b c (create)ctrl-b & (delete)ctrl-b p (previous)ctrl-b n (next)ctrl-b [NUMBER] (skip to num)sessions: tmux new -s [NAME] tmux ls tmux attach -t [NAME] tmux rename-session -t [OLD_NAME] [NEW_NAME] ctrl-b d |
gitSet up server to be able to push local project to it:on server: mkdir [REPO_NAME].git cd [REPO_NAME].git git init --bare git branch -m [BRANCH_NAME] branch name is usually master or main cd hooks/ touch post-receive chmod +x post-receive #!/bin/sh GIT_WORK_TREE=[/DESIRED/PATH] git checkout -f [BRANCH_NAME] on local: git remote add [CHOSEN_NAME] [USER]@[REMOTE]:[PATH/TO/REPO_NAME].git name is of remote (e.g. origin) git push [CHOSEN_NAME] Revert working directory changes to file: git checkout HEAD [FILENAME] Unstage file changes: git reset HEAD [FILENAME] Revert working directory to previous commit in commit log: git reset [COMMIT_SHA] |
Misc:ln -s [EXISTING] [LINK] get key hash: ssh-keygen -E sha256 -l -f [PATH_TO_PUBKEY] (or -E md5 )test github connection: ssh -T git@github.com |
chmod/chgrp/chownWhen you runls -al :drwxr-xr-x 2 root root 4096 Dec 3 16:09 . permissions #hardlinks owner group size(bytes) LastModified Filename The permissions are formatted like this: *######### "*" is the special permissions flag. Marks things like if it is a symlink or directory. "#########" is actually broken into three sets of three: - The first set is for the user who owns it, "owner" (u) - The second set is the permissions for "group" (g) - The third set is the permission for "others" (o) - Also: All three sets together are called "all" (a) The letters refer to: r : "read", 4 w : "write", 2 x : "execute", 1 chmod command: Change the permissions of a file or directory: chmod [permissions] [file] [permissions] can be formatted two ways: chmod 766 . (sum of numbers corresponding to r/w/x)chmod u+rw,g=rw,a-x . (add, set, subtract permissions for specific user sets)chown/chgrp command: Change the owner or group of a file or directory: Options include: recursive operation and only certain sources chown [-r] [--from=CURRENT_OWNER:CURRENT_GROUP] NEW_OWNER chgrp [-r] NEW_OWNER |
netstatA useful command for seeing if your servers really are listening on the ports:mac : netstat -vanp tcp linux: netstat -vlnt -v : verbose -n : numbers (e.g. 127.0.0.1 instead of localhost) -p tcp : only tcp connections (mac) -t : only tcp connections (linux) -a : "all" sockets, normally servers are not shown (mac or linux) -l : only listening sockets, normally not shown (linux) |
Regex:
|