initial commit
This commit is contained in:
68
system/X.md
Normal file
68
system/X.md
Normal file
@@ -0,0 +1,68 @@
|
||||
X is a server which listens to requests for display.
|
||||
|
||||
Basic configurations are under /etc/X11, but xorg.conf is generally no longer used.
|
||||
|
||||
Examples can be found under /usr/share/X11/xorg.conf.d/
|
||||
|
||||
The xorg displays a section, then identifiers, then some options, then ends the section.
|
||||
|
||||
> Section "InputDevice"
|
||||
|
||||
> # generated from default
|
||||
|
||||
> Identifier
|
||||
|
||||
> "Mouse0"
|
||||
|
||||
> Driver
|
||||
|
||||
> "mouse"
|
||||
|
||||
> Option
|
||||
|
||||
> "Protocol" "auto"
|
||||
|
||||
> Option
|
||||
|
||||
> "Device" "/dev/psaux"
|
||||
|
||||
> Option
|
||||
|
||||
> "Emulate3Buttons" "no"
|
||||
|
||||
> Option
|
||||
|
||||
> "ZAxisMapping" "4 5"
|
||||
|
||||
> EndSection
|
||||
|
||||
# Research
|
||||
See current settings with:
|
||||
|
||||
xdpyinfo | less
|
||||
|
||||
Basic info can often be gained with:
|
||||
|
||||
> man ati
|
||||
|
||||
> man Radeon
|
||||
|
||||
Internet resources are available at www.x.org/wiki/Projects/Drivers/
|
||||
|
||||
# Display Manager
|
||||
This presents login options, then starts the desktop. One is LightDM manager.
|
||||
|
||||
The program reads the configuration files in the order of: /usr/share/lightdm/lightdm.conf.d/, /etc/lightdm/lightdm.conf.d/, then /etc/lightdm/lightdm.conf.
|
||||
|
||||
The file /usr/share/lightdm/lightdm.conf.d/50-gues-wrapper.conf
|
||||
|
||||
# X defaults
|
||||
|
||||
~/.Xresources and ~/.Xdefaults load basic X settings.
|
||||
|
||||
Xdefaults is loaded each time if no Xresources is present.
|
||||
|
||||
If Xresources is present, Xdefaults it ignored. Xresources is loaded with:
|
||||
|
||||
> xrdb ~/.Xresources
|
||||
|
10
system/android.md
Normal file
10
system/android.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# mtpfs
|
||||
|
||||
Install:
|
||||
|
||||
> yay -S simple-mtpfs
|
||||
|
||||
List available phones:
|
||||
|
||||
> simple-mtpfs -l
|
||||
|
69
system/awk.md
Normal file
69
system/awk.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Basics
|
||||
|
||||
See a file's contents:
|
||||
|
||||
Return full contents of a string:
|
||||
|
||||
> awk '{ print }' file
|
||||
|
||||
Print the first and second column:
|
||||
|
||||
> awk '{print$1$2}'
|
||||
|
||||
Return every line with the word 'the' (like grep):
|
||||
|
||||
> awk '/the/{print}' file
|
||||
|
||||
Print everything containing a lowercase letter:
|
||||
|
||||
> awk '/[a-z]/{print}' file
|
||||
|
||||
Same with numbers [0-9], or using a caret we can show lines starting with a number - ^[0-9], or ending with an uppercase letter - $[A-Z].
|
||||
|
||||
# Conditionals
|
||||
|
||||
> awk '{ if($1 ~ /123/) print }' file
|
||||
|
||||
Check if the first column is equal to 1 or 2 or 3, and if so then print that line.
|
||||
|
||||
Grep for 'hawk' in a story:
|
||||
|
||||
> awk '/hawk/' story.txt
|
||||
|
||||
Return any line with one or more "&" sequences:
|
||||
|
||||
> awk '/&+/' script.sh
|
||||
|
||||
The pipe is used for 'or', so 'Orcs or drums' would be:
|
||||
|
||||
> awk '/Orcs|Drums/' story.txt
|
||||
|
||||
Basic variables are:
|
||||
|
||||
- FS = Input field separator
|
||||
|
||||
- OFS = Output field separator
|
||||
|
||||
- NF = Number of fields on the current line
|
||||
|
||||
- NR = Number of records in the current file
|
||||
|
||||
- RS = Record separator
|
||||
|
||||
- ORS = Output record separator
|
||||
|
||||
- FILENAME = the file you're looking at.
|
||||
|
||||
So you can count the number of lines in a file, by referencing the number of 'end line' statements:
|
||||
|
||||
> awk 'END{print NR}' story.txt
|
||||
|
||||
Print line 2 from story.txt
|
||||
|
||||
> awk '{if(NR~/^2$/)print}' story.txt
|
||||
|
||||
Same, but any line starting with "2":
|
||||
|
||||
> awk '{if(NR~/^2/)print}' story.txt
|
||||
|
||||
|
91
system/bash_tricks.md
Normal file
91
system/bash_tricks.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Automatic mp3 Tagging
|
||||
|
||||
/u/OneTurnMore on Reddit:
|
||||
|
||||
> !/usr/bin/env bash
|
||||
> IFS=$'\n'
|
||||
> for f in $(find . -type f); do
|
||||
> id3tool $f -t $(basename $f | cut -d- -f3 | sed 's/\.[^\,]*$//')
|
||||
> done
|
||||
|
||||
One can also use
|
||||
|
||||
> sed s/\,[^\.]*$//
|
||||
|
||||
... in order to avoid multiple full stops messing up syntax.
|
||||
|
||||
We can use `\.` as a literal full stop.
|
||||
|
||||
`[^ ]` means anything other than the containing character, so `[^\.]` would mean `anything other than a full stop'.
|
||||
|
||||
`*` in sed means this character is repeated any number of times, including 0, so files with no `.` character would still be processed fine.
|
||||
|
||||
`$` means `end of the line'.
|
||||
|
||||
Apparently sed uses `regex, not globing'.
|
||||
|
||||
Regular expressions (``regex'') looks for patterns and is used with find and grep. It interprets `*' as a wildcard, `?' as a single-character wildcard, and [12,1,2] as characters matching one of a set (in this case, `12 or 1 or 2 but not 21'].
|
||||
|
||||
If the shell is set to find file ``a*b.txt'' then it will pass this first to regex, and hit items like `aab.txt' and `abb.txt'. If it finds nothing, it'll then use globbing, and interpret `a*b.txt' literally.
|
||||
|
||||
# Automatic Renaming
|
||||
|
||||
There are a bunch of files:
|
||||
|
||||
* Column CV.aux
|
||||
* Column CV.log
|
||||
* Column CV.out
|
||||
* Column CV.pdf
|
||||
* Column CV.tex
|
||||
* tccv.cls
|
||||
|
||||
Goal: swap the word ``Column'' for ``Malin'' in all files.
|
||||
|
||||
> IFS=$'\n'
|
||||
|
||||
> for f in $(find . -name "Col*"); do
|
||||
|
||||
> mv "$f" $(echo "$f" | sed s/Column/Malin/)
|
||||
|
||||
> done
|
||||
|
||||
IFS is the field separator. This is required to denote the different files as marked by a new line, and not the spaces.
|
||||
|
||||
# Arguments and Input
|
||||
|
||||
The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm.
|
||||
|
||||
That said, we can sometimes pipe into rm with `xargs rm' to turn the stdin into an argument. For example, if we have a list of files called `list.txt' then we could use cat as so:
|
||||
|
||||
> cat list.txt | xargs rm
|
||||
|
||||
... *However*, this wouldn't work if spaces were included, as rm would take everything literally.
|
||||
|
||||
# Numbers
|
||||
|
||||
Add number to variables with:
|
||||
|
||||
* > let "var=var+1"
|
||||
* > let "var+=1"
|
||||
* > let "var++"
|
||||
* > ((++var))
|
||||
* > ((var=var+1))
|
||||
* > ((var+=1))
|
||||
* > var=$(expr $var + 1)
|
||||
|
||||
((n--)) works identically.
|
||||
|
||||
# Finding Duplicate Files
|
||||
|
||||
|
||||
> find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
|
||||
|
||||
... add blank line to top of first file.
|
||||
|
||||
> awk '/^$/{getline;print;}' all-files.txt > uniq.txt
|
||||
|
||||
> diff all-files.txt uniq.txt | grep '/' | cut -d '.' -f 2,3,4,5 | sed 's#/##' | sed 's/ /\\ /g' | xargs rm
|
||||
|
||||
Output random characters.
|
||||
|
||||
> cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo
|
45
system/compression.md
Normal file
45
system/compression.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Tar
|
||||
|
||||
## Basics
|
||||
|
||||
* --create -c
|
||||
|
||||
* --list -t
|
||||
|
||||
* --extract --get -x
|
||||
|
||||
* --file=file -f file
|
||||
|
||||
|
||||
|
||||
|
||||
Look in tar file:
|
||||
|
||||
> tar -tf filename.tar.gz
|
||||
|
||||
Look in detail:
|
||||
|
||||
> tar -tvf filename.tar.gz
|
||||
|
||||
# Zip
|
||||
|
||||
Zip file:
|
||||
|
||||
> zip name.zip file
|
||||
|
||||
Zip directory:
|
||||
|
||||
> zip -r name.zip dir
|
||||
|
||||
Update existing entries.
|
||||
|
||||
> zip -ru name.zip dir file1 file2
|
||||
|
||||
Delete file from the zipfile.
|
||||
|
||||
> zip -d name.zip dfile
|
||||
|
||||
# 7z for .img.xz
|
||||
|
||||
> 7z x file.img.xz
|
||||
|
29
system/cronie.md
Normal file
29
system/cronie.md
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
Various services from cron exist, e.g.
|
||||
|
||||
> sudo apt -y install cronie
|
||||
|
||||
start the cronie with
|
||||
|
||||
> sudo systemctl start cronie
|
||||
|
||||
start a cron with
|
||||
|
||||
> cron -e
|
||||
|
||||
You can run a script with:
|
||||
|
||||
*/10 * * * * /home/pi/script.sh
|
||||
|
||||
... which would run every 10 minutes.
|
||||
|
||||
To run something as root, do:
|
||||
|
||||
> sudo crontab -e
|
||||
|
||||
For example, you can update the database, meaning searches with 'locate' command will be faster.
|
||||
|
||||
> */30 * * * * /usr/bin/updatedb
|
||||
|
||||
|
||||
|
47
system/e-mail.md
Normal file
47
system/e-mail.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Terminology
|
||||
|
||||
|MTA | Mail transfer agent |
|
||||
|POP3| Post Office Protocol 3 |
|
||||
|SMTP| Simple Mail Transfer Protocol|
|
||||
|IMAP| Internet Message Access Protocol|
|
||||
|
||||
There are a number of Linux e-mail agents - postfix, sendmail, exim (insecure) and qmail (dead).
|
||||
|
||||
# Programs
|
||||
|
||||
> sudo apt-get install postfix mailutils
|
||||
|
||||
This will register your domain in the /etc/postfix/main.cf file.
|
||||
|
||||
# Internal Mail
|
||||
|
||||
> sendmail -t roach-1
|
||||
|
||||
Write a message and stop composition with Ctrl+D.
|
||||
|
||||
The mail is kept in /var/mail/ and you can read it with:
|
||||
|
||||
> mail
|
||||
|
||||
# Aliases
|
||||
|
||||
Aliases are groups of mail recipients. The lists are kept under /etc/aliases.
|
||||
|
||||
`crew: matthewlynas@gmail.com,ghost,danial@yahoo.com`
|
||||
|
||||
Update the list of aliases from this with:
|
||||
|
||||
> sudo newaliases
|
||||
|
||||
Then you can:
|
||||
|
||||
> sendmail -t crew
|
||||
|
||||
... and send to the whole crew.
|
||||
|
||||
|
||||
View pending e-mails using:
|
||||
|
||||
> mailq
|
||||
|
||||
|
41
system/elvish
Normal file
41
system/elvish
Normal file
@@ -0,0 +1,41 @@
|
||||
# Setup
|
||||
To run a shell as non-root, the shell must be listed in /etc/shells.
|
||||
|
||||
# Basics
|
||||
Elvish has an inbuilt calculator.
|
||||
|
||||
Basic commands include: *, ^, +. E.g.:
|
||||
|
||||
> 2*4+2
|
||||
|
||||
|
||||
#Lists
|
||||
|
||||
li = [orcs hobbits elves]
|
||||
|
||||
Then either
|
||||
|
||||
> echo $li
|
||||
|
||||
> echo $@li
|
||||
|
||||
> echo $path
|
||||
|
||||
|
||||
# Environmental Variables
|
||||
Summon with E:, e.g.
|
||||
|
||||
> echo $E:USER
|
||||
|
||||
# Commands
|
||||
|
||||
C-n - File manager
|
||||
|
||||
C-l - Recent locations
|
||||
|
||||
C-r - Recent commands
|
||||
|
||||
See all binding with:
|
||||
|
||||
> pprint $edit:insert:binding
|
||||
|
25
system/exiftool
Normal file
25
system/exiftool
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
Find metadata.
|
||||
|
||||
> exiftool image.jpg
|
||||
|
||||
Find info on all images in current directory.
|
||||
|
||||
> exiftool -ext .png .
|
||||
|
||||
You can make this recurring with the -r switch.
|
||||
|
||||
And overwrite all metadata:
|
||||
|
||||
> exiftool -all= -overwrite_original -ext jpg .
|
||||
|
||||
Or just GPS data:
|
||||
|
||||
> exiftool -gps:all= *.jpg
|
||||
|
||||
You can also use the imagemagick tool:
|
||||
|
||||
> identify -verbose
|
||||
|
||||
|
40
system/gpg.md
Normal file
40
system/gpg.md
Normal file
@@ -0,0 +1,40 @@
|
||||
#Making keys
|
||||
|
||||
Generate keys:
|
||||
|
||||
> gpg --full-gen-key
|
||||
|
||||
Follow the guide.
|
||||
|
||||
# Encrypting a file
|
||||
|
||||
> gpg -r malinfreeborn@googlemail.com -e file
|
||||
|
||||
`-r` specifies the recipient.
|
||||
|
||||
Check you have an encrypted version of your file.
|
||||
|
||||
# Changing Expiration Dates
|
||||
|
||||
gpg --list-keys
|
||||
|
||||
... and then use the second part of 'pub', which is the ID. But that's not appearing here so... on with gpg2?
|
||||
|
||||
# Making encrypted files with a local password
|
||||
|
||||
Make a password with a password (cypher encryption).
|
||||
|
||||
> gpg -c --output passwords.txt
|
||||
|
||||
or
|
||||
|
||||
> gpg -c > passwords.txt
|
||||
|
||||
Put in a password.
|
||||
|
||||
Write message then stop with Ctrl+d.
|
||||
|
||||
Get the message back out the file with:
|
||||
|
||||
> gpg -d passwords.txt
|
||||
|
25
system/kernel.md
Normal file
25
system/kernel.md
Normal file
@@ -0,0 +1,25 @@
|
||||
Check which kernet modules are loaded into memory
|
||||
|
||||
> sudo /sbin/lsmod
|
||||
|
||||
Check which virtual box modules are loaded into memory
|
||||
|
||||
> sudo /sbin/lsmod | grep vbox
|
||||
|
||||
Virtual box is using vboxpci, vboxnetadp, vboxnetflt, vboxdr.
|
||||
|
||||
Look at what's claiming wifi:
|
||||
|
||||
> sudo lshw -C network
|
||||
|
||||
If this shows that the device is 'unclaimed' then it's time to add a module, e.g. ath9k.
|
||||
|
||||
> sudo modprobe ath9k
|
||||
|
||||
Modules can also be 'restarted' by removing and adding them, e.g. the video module, 'uvcvideo':
|
||||
|
||||
> sudo rmmod uvcvideo
|
||||
|
||||
> sudo modprobe uvcvideo
|
||||
|
||||
|
1
system/keyboard/keyboard.md
Normal file
1
system/keyboard/keyboard.md
Normal file
@@ -0,0 +1 @@
|
||||
items under /etc/X11/xorg.conf.d/ for new keyboard layout. One package installed
|
37
system/keyboard/unicode-characters
Normal file
37
system/keyboard/unicode-characters
Normal file
@@ -0,0 +1,37 @@
|
||||
☢ ☣ s ☠ ⚠
|
||||
radioactive sign biohazard sign skull and crossbones warning sign
|
||||
☤ ⚕ ⚚ †
|
||||
caduceus staff of aesculapius staff of hermes dagger
|
||||
☯ ⚖ ☮ ⚘
|
||||
yin yang scales peace flower
|
||||
⚔ ☭ ⚒ ⚓
|
||||
crossed swords hammer and sickle hammer and pick anchor
|
||||
⚛ ⚜ ⚡ ⚶
|
||||
atom symbol fleur-de-lis lightning vesta
|
||||
☥ ✠ ✙ ✞
|
||||
ankh cross cross cross
|
||||
✟ ✧ ⋆ ★
|
||||
cross diamond star star
|
||||
☆ ✪ ✫ ✬
|
||||
star star star star
|
||||
✭ ✮ ✯ ✰
|
||||
star star star star
|
||||
≪
|
||||
☸ ✵ ❂ ☘
|
||||
wheel of dharma star sun shamrock
|
||||
♡ ♥ ❤ ⚘
|
||||
heart heart big heart flower
|
||||
❀ ❃ ❁ ✼
|
||||
flower flower flower flower
|
||||
☀ ✌ ♫ ♪
|
||||
sun V sign music note / melody music note / melody
|
||||
☃ ❄ ❅ ❆
|
||||
snowman snowflake snowflake snowflake
|
||||
☕ ☂ ❦ ✈
|
||||
cofee umbrella floral heart / leaf airplane
|
||||
♕ ♛ ♖ ♜
|
||||
white king / crown black king / crown white rook / tower black rook / tower
|
||||
☁ ☾
|
||||
cloud waning crescent moon
|
||||
|
||||
|
6
system/keyboard/xmodmap
Normal file
6
system/keyboard/xmodmap
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
xmodmap -e 'clear Lock' #ensures you're not stuck in CAPS on mode
|
||||
|
||||
xmodmap -e 'keycode 0x42=Escape' #remaps the keyboard so CAPS LOCK=ESC
|
||||
|
||||
|
17
system/logs.md
Normal file
17
system/logs.md
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
# Basic
|
||||
Keeping track of health problems. Mostly under /var/log/.
|
||||
|
||||
These logs are created by syslogd (or syslog in earlier distros).
|
||||
|
||||
# Rundown
|
||||
|
||||
`alternatives.log' has a bunch about other programs installing things around 5 times a day. This includes x-www-browser, which sets the default browser (supposedly - this doesn't work on i3).
|
||||
|
||||
It also seems to update cursor themes, man files and `montage'.
|
||||
|
||||
`apport.log' is empty.
|
||||
|
||||
`auth.log' shows keyring prompot times, `Gcr' prompter and a lot about CRON, the `power button'.
|
||||
|
||||
|
67
system/lxc.md
Normal file
67
system/lxc.md
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
LXC creates miniature virtual machines to play with.
|
||||
|
||||
# Configuration
|
||||
|
||||
## Templates
|
||||
|
||||
On Void you can install this with:
|
||||
|
||||
> # xbps-install -S jq skopeo umoci
|
||||
|
||||
After you've installed a whopping 46 Megabytes, you can configure it in /etc/lxc/default.conf if you want to change global configs, otherwhise, it's the usual ~/.config/lxc/dfault.conf.
|
||||
|
||||
## Networking
|
||||
|
||||
Make a virtual network:
|
||||
|
||||
> # ip link add dev BRIDGE type bridge
|
||||
> # ip link set dev BRIDGE up
|
||||
> # ip link set dev NIC master BRIDGE
|
||||
|
||||
Things in caps can be renamed.
|
||||
|
||||
#Create a machine
|
||||
|
||||
> lxc-create -n roach-1
|
||||
|
||||
This makes a machine with the name 'roach-1'. We can also apply a preconfigured theme with '-t', such as 'ubuntu'.
|
||||
|
||||
> lxc-create -n roach-2 -t ubuntu
|
||||
|
||||
Additionally, there we can examine, destroy and freeze containers.
|
||||
|
||||
> lxc-ls -n roach-1
|
||||
|
||||
> lxc-destroy -n roach-1
|
||||
* Add '-k' to kill a process without mercy.
|
||||
|
||||
> lxc-freeze -n roach-2
|
||||
|
||||
> lxc-unfreeze -n roach-1
|
||||
|
||||
#Example
|
||||
|
||||
> for r in $(lxc-ls -1); do
|
||||
|
||||
> lxc-info -n $r
|
||||
|
||||
> done
|
||||
|
||||
# Monitor
|
||||
|
||||
You can monitor a set of containeers.
|
||||
|
||||
> lxc-monitor -n "roach-1|roach-2"
|
||||
|
||||
Or monitor all containers.
|
||||
|
||||
> lxc-monitor -n ".*"
|
||||
|
||||
# LXD
|
||||
|
||||
Setup by starting the lxd service, and adding your user to the group "lxd", then:
|
||||
|
||||
> sudo lxd init
|
||||
|
||||
Default port is 8443.
|
158
system/partitions.md
Normal file
158
system/partitions.md
Normal file
@@ -0,0 +1,158 @@
|
||||
# FDisk Basics
|
||||
|
||||
> sudo fdisk /dev/sda
|
||||
|
||||
- m for help.
|
||||
|
||||
- n to make a partition.
|
||||
|
||||
- t to mark the partition type (see IDs below).
|
||||
|
||||
- w to write the changes to the disk.
|
||||
|
||||
Note the asterisk marking the boot partition.
|
||||
|
||||
|
||||
# IDs
|
||||
|
||||
| ID | Meaning |
|
||||
|----|:--------|
|
||||
|83 |Linux |
|
||||
| 5 |Extended |
|
||||
| 82 |Swap |
|
||||
|
||||
fdisk will not help with a GPT formatted drive. For this, use gdisk, which is mostly the same.
|
||||
|
||||
Now that we have a partition, we can make it into a filesystem. Most will use:
|
||||
|
||||
> sudo mkfs -t ext4 /dev/sdc1
|
||||
|
||||
or if you're making a swap partition, you can use:
|
||||
|
||||
> sudo mkswap /dev/sdb2
|
||||
|
||||
or for the reiser filesystem, we can use:
|
||||
|
||||
> sudo mkreiserfs /dev/sdc2
|
||||
|
||||
# File System Types
|
||||
|
||||
| Type | Advantages | Disadvantages |
|
||||
|------|:-----------|:--------------|
|
||||
|ext2 | |No journaling means that the file offers no crash recovery.
|
||||
|ext3 | Journaling |
|
||||
|ext4 | Journaling and handles files of up to 16TB.|
|
||||
|reiserfs| Journalin and stable.|
|
||||
|btrfs |Reliable and stable|
|
||||
|XFS |Journaling, great for large files.|
|
||||
|VFAT |Comptable with Windows, like FAT32|
|
||||
|
||||
# Parted
|
||||
|
||||
> sudo parted /dev/sdb
|
||||
|
||||
|
||||
# Monitoring
|
||||
Look at physical and virtual partitions:
|
||||
|
||||
> df -h
|
||||
|
||||
or divide things by inode - the thing which records where files are?
|
||||
|
||||
> df -i
|
||||
|
||||
Examine a filesystem with:
|
||||
|
||||
> sudo dumpe2fs /dev/sda1 | less
|
||||
|
||||
# Prevention
|
||||
There are multiple programs which work mostly the same way.
|
||||
|
||||
> sudo tune2fs -c 30 /dev/sda1
|
||||
|
||||
This will check sda1 every 30 boots. It can also be checked every month.
|
||||
|
||||
> sudo tune2fs -i 1m /dev/sda1
|
||||
|
||||
This thing can also make a new label for the system:
|
||||
|
||||
> sudo tune2fs -L new_name /dev/sdb3
|
||||
|
||||
# Repair
|
||||
Start by unmounting the filesystem.
|
||||
|
||||
> sudo umount /dev/sdc1
|
||||
|
||||
Then it's time to check.
|
||||
|
||||
> sudo fsck /dev/sdc1
|
||||
|
||||
And possibly repair damage:
|
||||
|
||||
> e2fsck -p /dev/sdc1
|
||||
|
||||
|
||||
or the same with:
|
||||
|
||||
> sudo debugfs /dev/sdc1
|
||||
|
||||
# Mounting
|
||||
You can mount with a specified filetype with:
|
||||
|
||||
> sudo mount -t ext3 /dev/sdc2 /mnt/stick
|
||||
|
||||
or if you don't know the type, just try the lot:
|
||||
|
||||
> sudo mount -a /dev/sdc1 /mnt/stick
|
||||
|
||||
# File Systems
|
||||
xfs and zfs can only be expanded.
|
||||
|
||||
# Shrink Filesystem
|
||||
|
||||
NB: When I followed these instructions, the process destroyed my data. Seemed fine on the YouTube video.
|
||||
|
||||
Check the filesystem's health:
|
||||
|
||||
> sudo e2fsck -f /dev/sdb1
|
||||
|
||||
Resize the file system to something smaller than what you want, so here I want 500G and so I resize to 450 G.
|
||||
|
||||
> resize2fs /dev/sdb1 450G
|
||||
|
||||
Then delete the partition with either gdisk or fdisk, depending upon the layout.
|
||||
|
||||
> sudo fdisk /dev/sdb
|
||||
|
||||
> d
|
||||
|
||||
Then make a new filesystem of the desired type with:
|
||||
|
||||
> n
|
||||
|
||||
And finally resize to the full size you want:
|
||||
|
||||
sudo resize2fs /dev/sdb1
|
||||
|
||||
And then check your disk again with e2fsck.
|
||||
|
||||
(The e2fsck saved my disk in the end, YMMV)
|
||||
|
||||
|
||||
# Logical Volume
|
||||
|
||||
Let's start with names. PV = 'Physical Volume', VG = 'Volume Group', and LV = 'Logical Volume'.
|
||||
|
||||
Now we can create a volume group out of sdb2 and sdc3:
|
||||
|
||||
> sudo vgcreate my-new-vg /dev/sdb2 /dev/sdc3
|
||||
|
||||
Then make a new logical volume out of the volume group:
|
||||
|
||||
> sudo lvcreate -n my-new-lv my-new-vg
|
||||
|
||||
Then have a look at all logical volumes:
|
||||
|
||||
> sudo lvscan
|
||||
|
||||
|
8
system/snaps.md
Normal file
8
system/snaps.md
Normal file
@@ -0,0 +1,8 @@
|
||||
> sudo apt-get purge -y snapd
|
||||
|
||||
#Hiding from Nautilus
|
||||
|
||||
> echo snap >> ~/.hidden
|
||||
|
||||
Moving the directory ~/snap to ~/.snap acts as expected.
|
||||
|
7
system/syncthing/syncthing.md
Normal file
7
system/syncthing/syncthing.md
Normal file
@@ -0,0 +1,7 @@
|
||||
Instructions [here](https://docs.syncthing.net/intro/getting-started.html).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
9
system/systemd/basic commands
Normal file
9
system/systemd/basic commands
Normal file
@@ -0,0 +1,9 @@
|
||||
> systemctl list-units
|
||||
|
||||
> sudo systemctl status mpd
|
||||
|
||||
> sudo systemctl daemon-reload
|
||||
|
||||
> sudo systemctl taskd.service start
|
||||
|
||||
> sudo systemctl status taskd.service
|
8
system/systemd/journal.md
Normal file
8
system/systemd/journal.md
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
Find errors since November
|
||||
|
||||
> journalctl --since=2018-11-01 --grep="EXT4-fs error"
|
||||
|
||||
Limit size to 2G.
|
||||
|
||||
> journalctl --vacuum-size=2G
|
34
system/systemd/making services.md
Normal file
34
system/systemd/making services.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Basics
|
||||
|
||||
A service can consist of two files - the .sh script to run, and the .service file which describes its run conditions.
|
||||
|
||||
The .service file goes in /etc/systemd/system. The scripts themselves might be best placed in $HOME/.local/bin.
|
||||
|
||||
# Example - tracker.service
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=Tracker
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/path/to/script
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
|
||||
```
|
||||
|
||||
After making the new service, systemd requires reloading:
|
||||
|
||||
> sudo systemctl daemon-reload
|
||||
|
||||
# Types
|
||||
|
||||
* simple - the service cannot be called on by others. It runs on repeat.
|
||||
|
||||
* oneshot - the service executes once, then stops.
|
||||
|
||||
|
||||
|
23
system/systemd/test.service
Normal file
23
system/systemd/test.service
Normal file
@@ -0,0 +1,23 @@
|
||||
[Unit]
|
||||
|
||||
Description=Test
|
||||
|
||||
[Service]
|
||||
|
||||
ExecStart=/home/ghost/.local/bin/test
|
||||
|
||||
Restart=always
|
||||
|
||||
Type=simple
|
||||
|
||||
User=ghost
|
||||
|
||||
Group=ghost
|
||||
|
||||
[Install]
|
||||
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Alias=test.service
|
||||
|
||||
|
23
system/systemd/users.md
Normal file
23
system/systemd/users.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Automatic Login
|
||||
|
||||
> cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty1@.service
|
||||
|
||||
Modify the lines to look like these:
|
||||
|
||||
`ExecStart=-/sbin/agetty --autologin <username> --noclear %I 38400 linux`
|
||||
|
||||
`Type=oneshot`
|
||||
|
||||
`Restart=no`
|
||||
|
||||
In the `[Install]` section:
|
||||
|
||||
`Alias=getty.target.wants/getty@tty1.service`
|
||||
|
||||
Then enable the service:
|
||||
|
||||
> ln -sf /etc/systemd/system/getty1@.service /etc/systemd/system/getty.target.wants/getty@tty9.service
|
||||
|
||||
> systemctl start getty@tty9.service
|
||||
|
||||
|
45
system/tmux.md
Normal file
45
system/tmux.md
Normal file
@@ -0,0 +1,45 @@
|
||||
Start with:
|
||||
|
||||
> tmux
|
||||
|
||||
Input a command with C-b
|
||||
|
||||
In addition to Windows, there are panes.
|
||||
|
||||
|Commands | Key |
|
||||
| ---- | ---- |
|
||||
| New Window | c |
|
||||
| Previous Window | p |
|
||||
| next window | n |
|
||||
| list windows | w |
|
||||
| vertical split | % |
|
||||
| horizontal split | " |
|
||||
| name a command | : |
|
||||
| kill pane | x |
|
||||
| kill session | d |
|
||||
|
||||
|
||||
|Name Commands|
|
||||
| --------|
|
||||
| split-window |
|
||||
| rename-window |
|
||||
|
||||
# Sessions
|
||||
|
||||
Crate a new session with the name 'backup'.
|
||||
|
||||
> tmux new -s backup
|
||||
|
||||
List sessions:
|
||||
|
||||
> tmux list-sessions
|
||||
|
||||
> tmux kill-session -t 2
|
||||
|
||||
> tmux attach -t backup
|
||||
|
||||
|
||||
# Control
|
||||
|
||||
Resize Panes with ^b then Esc+[direction].
|
||||
|
7
system/upx.md
Normal file
7
system/upx.md
Normal file
@@ -0,0 +1,7 @@
|
||||
upx compresses binaries, so they take up less disk space, but take longer to start.
|
||||
|
||||
Make a binary, such as ls, compressed:
|
||||
|
||||
> upx ls
|
||||
|
||||
|
1
system/urxvt.md
Normal file
1
system/urxvt.md
Normal file
@@ -0,0 +1 @@
|
||||
Perl scripts typically kept in /usr/lib/urxvt/perl
|
162
system/users.md
Normal file
162
system/users.md
Normal file
@@ -0,0 +1,162 @@
|
||||
#Basic Information
|
||||
|
||||
Let's get some entries with 'getent', e.g. passwd or group.
|
||||
|
||||
> getent passwd
|
||||
|
||||
> getent group
|
||||
|
||||
Obviously:
|
||||
|
||||
> getent shadow
|
||||
|
||||
will require sudo.
|
||||
|
||||
## Examples
|
||||
|
||||
> sudo adduser maestro
|
||||
|
||||
add user 'maestro'
|
||||
|
||||
|
||||
This depends upon the settings in the /etc/default/useradd file and /etc/login.defs
|
||||
|
||||
|
||||
> sudo useradd -m pinkie
|
||||
|
||||
add user 'pinkie' with a home directory
|
||||
|
||||
|
||||
> sudo adduser -m -e 2017-04-25 temp
|
||||
|
||||
add expiry date to user
|
||||
|
||||
> userdel maestro
|
||||
|
||||
delete maestro
|
||||
|
||||
> userdel -r maestro
|
||||
|
||||
delete maestro and hir homefolder
|
||||
|
||||
> groups
|
||||
|
||||
find which group you are in
|
||||
|
||||
|
||||
> id
|
||||
|
||||
same
|
||||
|
||||
> id -Gn maestro
|
||||
|
||||
Find which groups maestro is in
|
||||
|
||||
|
||||
> deluser --remove-home maestro
|
||||
|
||||
delete user maestro
|
||||
|
||||
|
||||
> usermod -aG sudo maestro
|
||||
|
||||
add user maestro to group sudo
|
||||
|
||||
|
||||
> cat /etc/passwd
|
||||
|
||||
list users' passwords (and therefore users)
|
||||
|
||||
|
||||
|
||||
> groupadd awesome
|
||||
|
||||
create the group 'awesome'
|
||||
|
||||
|
||||
|
||||
passwords are stored in /etc/shadow.
|
||||
|
||||
|
||||
there are user accounts for processes such as 'bin' and 'nobody' which are locked, so they're unusable.
|
||||
|
||||
|
||||
|
||||
> passwd -l bin
|
||||
|
||||
lock the user 'bin'
|
||||
|
||||
|
||||
|
||||
> more /etc/passwd | grep games
|
||||
|
||||
we find the name, password and user id of the user 'games'. I.e. the password is 'x', and the user id is '5'. The password is an impossible hash, so no input password could match.
|
||||
|
||||
|
||||
> groupdel learners | delete the group 'learners'
|
||||
|
||||
> gpasswd -d pi games | remove user 'pi' from the group 'games'
|
||||
|
||||
|
||||
> id games
|
||||
|
||||
find the id number of group 'games' (60)
|
||||
|
||||
|
||||
> usermod -aG sudo maestro
|
||||
|
||||
add user to group 'maestro'
|
||||
|
||||
user info is stored in /etc's passwd, shadow, group and gshadow
|
||||
|
||||
|
||||
# Defaults
|
||||
The default new user profiles are under /etc/skel.
|
||||
|
||||
# Shells
|
||||
A list of shells is in /etc/shells.
|
||||
|
||||
Only root can run shells not listed in /etc/shells
|
||||
|
||||
To change a user's shell:
|
||||
|
||||
usermod --shell /bin/bash user1
|
||||
|
||||
Alternatively, change the shell in /etc/passwd.
|
||||
|
||||
Usermod also lets you change a user's username:
|
||||
|
||||
> usermod -l henry mark
|
||||
|
||||
However, this will not change the home directory.
|
||||
|
||||
Lock a user out of an account:
|
||||
|
||||
usermod -L henry
|
||||
|
||||
# More Arguments
|
||||
|
||||
-G or -groups adds the user to other groups:
|
||||
|
||||
> usermod -G sudo henry
|
||||
|
||||
-s adds the user to a shell.
|
||||
|
||||
-u let's you manually specifiy a UID.
|
||||
|
||||
|
||||
# Groups
|
||||
|
||||
In /etc/group, a group file may look like this:
|
||||
|
||||
`sudo:x:27:mike,steve`
|
||||
|
||||
We can use groupmod, like like usermod, e.g. to change a name:
|
||||
|
||||
> groupmod -n frontoffice backoffice
|
||||
|
||||
Delte a group:
|
||||
|
||||
> groupdel frontoffice
|
||||
|
||||
|
57
system/virtualbox.md
Normal file
57
system/virtualbox.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Setup
|
||||
|
||||
## Arch Linux
|
||||
|
||||
> sudo pacman -S virtualbox-host-modules-arch virtualbox-guest-iso
|
||||
|
||||
> sudo modprobe vboxdrv
|
||||
|
||||
> # vboxreload
|
||||
|
||||
# Make dd image into vdi
|
||||
|
||||
> VBoxManage convertdd base.dd output.vdi --format VDI
|
||||
|
||||
If this doesn't work, try to make a new bite size with just
|
||||
|
||||
> sudo dd if=image.dd of=image2.dd bs=512 conv=sync
|
||||
|
||||
# CLI Management
|
||||
|
||||
List boxes:
|
||||
|
||||
> VBoxManage list vms
|
||||
|
||||
Start a headless instance
|
||||
|
||||
> VBoxManage startvm "rata" --type headless
|
||||
|
||||
To pause the machine:
|
||||
|
||||
> VBoxManage controlvm "rata" pause --type headless
|
||||
|
||||
You can do a number of things to virtualboxes this way:
|
||||
|
||||
- startvm
|
||||
|
||||
- pause
|
||||
|
||||
- resume
|
||||
|
||||
- poweroff
|
||||
|
||||
# Creating Disks
|
||||
|
||||
Creating a VM requires registering it:
|
||||
|
||||
> VBoxManage createvm --name Ubuntu19.04 --register --ostype Ubuntu
|
||||
|
||||
> VBoxManage modifyvm Ubuntu19.04 --memory 1042
|
||||
|
||||
> VBoxManage storagectl Ubuntu19.04 -name IDE --add ide --controller PIIX4 --bootable on
|
||||
|
||||
Create just a disk with:
|
||||
|
||||
VBoxManageg createhd --filename Ubuntu16.04 --size 5120
|
||||
|
||||
|
67
system/vncserver
Normal file
67
system/vncserver
Normal file
@@ -0,0 +1,67 @@
|
||||
# Ubuntu
|
||||
https://linuxconfig.org/vnc-server-on-ubuntu-18-04-bionic-beaver-linux
|
||||
|
||||
|
||||
# On server
|
||||
|
||||
Enable remote desktop access.
|
||||
|
||||
> sudo apt install vnc4server xfce4 xfce4-goodies
|
||||
|
||||
Disable the vncserver desktop:
|
||||
|
||||
> vncserver -kill :1
|
||||
|
||||
Replace the config in ~/.vnc/xstartup with:
|
||||
|
||||
`#!/bin/bash`
|
||||
|
||||
`startxfce4 &`
|
||||
|
||||
# Arch
|
||||
|
||||
Install tigervnc, then run it to set a password:
|
||||
|
||||
> vncserver
|
||||
|
||||
You'll get a session number.
|
||||
|
||||
Shut it down with the 'kill' command and the session's number:
|
||||
|
||||
> vncserver -kill :1
|
||||
|
||||
This will forward over port 5900+x where x is the session number. For the first server, that's port 5901.
|
||||
|
||||
# Create a systemd service
|
||||
|
||||
> sudo vim /etc/systemd/system/vncserver@:1.service
|
||||
|
||||
Then enter:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=Remote desktop service (VNC)
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=foo
|
||||
PAMName=login
|
||||
PIDFile=/home/%u/.vnc/%H%i.pid
|
||||
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
|
||||
ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg
|
||||
ExecStop=/usr/bin/vncserver -kill %i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Then enable that service:
|
||||
|
||||
> sudo systemctl start vncserver@:1.service
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1
system/wine.md
Normal file
1
system/wine.md
Normal file
@@ -0,0 +1 @@
|
||||
maybe run \n> sudo dpkg --add-architecture i386
|
13
system/xcp-ng/basics.md
Normal file
13
system/xcp-ng/basics.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# Make a local iso repository
|
||||
|
||||
> mkdir -p /var/opt/xen/ISO_Store
|
||||
|
||||
> xe sr-create name-label=LocalISO type=iso device-config:location=/var/opt/xen/ISO_Store device-config:legacy_mode=true content-type=iso
|
||||
|
||||
This creates a UUID for the new directory:
|
||||
|
||||
`e94e25bb-bcdc-801b-b62a-b51b686a3bdc`
|
||||
|
||||
|
||||
|
92
system/xcp-ng/xe.md
Normal file
92
system/xcp-ng/xe.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Shut Down VM
|
||||
|
||||
List VMs.
|
||||
|
||||
> xe host-list
|
||||
|
||||
> xe vm-list resident-on=<uuid_of_host>
|
||||
|
||||
> xe vm-shutdown uuid=<UUID from step 3> force=true
|
||||
|
||||
If this doesn't work, try:
|
||||
|
||||
> xe vm-reset-powerstate uuid=<UUID from step 3> force=true
|
||||
|
||||
Get the id:
|
||||
|
||||
> list_domains
|
||||
|
||||
And destroy the domain:
|
||||
|
||||
> /opt/xensource/debug/xenops destroy_domain -domid <DOMID from step 7>
|
||||
|
||||
|
||||
# Error: "Internal error:xenopsd internal error: Storage_interface.Illegal_transition" in XenServer
|
||||
|
||||
## Symptoms or Error
|
||||
|
||||
After a failed “Move VM”, “Copy VM”, or “Export VM” operation, the Virtual Machine (VM) being operated cannot start. Following is the error message displayed:
|
||||
|
||||
`User-added image`
|
||||
|
||||
## Solution
|
||||
|
||||
To resolve this error, complete the following procedure:
|
||||
|
||||
Open the Console to the XenServer that is hosting the VM and run the following command:
|
||||
|
||||
> list_domains
|
||||
|
||||
All the VMs running on that server are displayed.
|
||||
|
||||
Copy the UUID corresponding to id=0.
|
||||
|
||||
This is the UUID of the Control Domain. The Control Domain is a privileged Virtual Machine that handles all hyper calls received from running VMs to perform all virtual tasks.
|
||||
|
||||
Run the following command to obtain the UUID of the VBD (Virtual Block Device) object linking the Control Domain:
|
||||
|
||||
> xe vbd-list vm-uuid=<uuid of the Control Domain>
|
||||
|
||||
Run the following commands to unplug and destroy the VBD:
|
||||
|
||||
> xe vbd-unplug uuid=<uuid of the vbd>
|
||||
|
||||
> xe vbd-destroy uuid=<uuid of the vbd>
|
||||
|
||||
## Make a local iso repository
|
||||
|
||||
> xe sr-create name-label=LocalISO type=iso device-config:location=/var/opt/xen/ISO_Store device-config:legacy_mode=true content-type=iso
|
||||
|
||||
This creates a UUID for the new directory:
|
||||
|
||||
`e94e25bb-bcdc-801b-b62a-b51b686a3bdc`
|
||||
|
||||
# Import
|
||||
|
||||
xe vm-import filename=/mnt/blah.xva
|
||||
|
||||
|
||||
# USB
|
||||
|
||||
## Attack
|
||||
|
||||
Put in the USB.
|
||||
|
||||
Get the USB's uuid.
|
||||
|
||||
> xe pusb-list
|
||||
|
||||
Make the USB recognised as a device.
|
||||
|
||||
> xe pusb-param-set uuid=<uuid>
|
||||
|
||||
For passthrough, use this:
|
||||
|
||||
> xe pusb-param-set uuid=<uuid> passthrough-enabled=true
|
||||
|
||||
## Attach to host
|
||||
|
||||
(requires reboot of guest)
|
||||
|
||||
[link](https://github.com/xcp-ng/xcp/wiki/USB-Pass-Through)
|
||||
|
11
system/xdg.md
Normal file
11
system/xdg.md
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
What filetype is this file?
|
||||
|
||||
> xdg-mime query filetype aif.pdf
|
||||
|
||||
`application/pdf`
|
||||
|
||||
Make `application/pdf` open with zathura as default:
|
||||
|
||||
> xdg-mime default org.pwmt.zathura.desktop application/pdf
|
||||
|
10
system/xkbmap.md
Normal file
10
system/xkbmap.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Language Layouts
|
||||
|
||||
Polish
|
||||
|
||||
> setxkbmap pl
|
||||
|
||||
# Make Caps Key Escape
|
||||
|
||||
> setxkbmap -option caps:escape
|
||||
|
Reference in New Issue
Block a user