MyCheatSheet (Raspberry Pi - Debian - Bash - Java - Python) v164steemCreated with Sketch.

in #linux5 years ago (edited)

debian.png
Image source: Willi Glenz - MyDebianDesktop


UPDATE

2018-12-12 BASH v3
2018-12-12 SYSTEMCHECK v5
2018-12-12 VIM v2
2018-12-12 ctrl-h : Generate a backspace character

LINUX ABC

B - BASH
D - DEBIAN
J - JAVA
L - LANGUAGE-SETTINGS
S - SYSTEM-CHECK SYSTEM-MANAGEMENT
V - VIM

A - alias apt apt-cache apt-get apt-config apt-key apt-cdrom archivemount atop awk
B - badblocks bashrc basket bc bleachbit bg blkid
C - cacti cat cd cherrytree chkrootkit clear clipit chown cp cups curl cut
D - dd df diff dmesg dpkg du
E - echo
F - fdisk fg file find finger fish free fuser
G - git glances gnome-clocks grub-mkconfig guake
H - head hostname hostnamectl htop hwinfo
I - ifconfig info ip iwconfig
J - java javac jobs
K - kismet
L - lastlog less ls lsb_release lsblk lshw lspci lsusb lvm lxc
M - man mc mkdir mount mtr mv
N - netatop netbeans netstat nmap nl
O - open
P - perldoc pinfo printf pwd pwgen
R - R raspi-config rpi-update rsync
S - screen script sed service set shellcheck sort ssh steghide stat sudo su swapon sync
T - tac tail tasksel top touch tripwire tune2fs
U - ufw uniq update-alternatives users
V - veracrypt vim vimtutor visudo vlc
W - w watch wc w3m whoami
X - xdotool xsel
Y - youtube-dl


KEYBOARD SHORTCUTS
ctrl-a : Go to the beginning of the line
ctrl-e : Go to the end of the line
ctrl-h : Generate a backspace character
ctrl-e ctrl-u : Clear the line 
esc #  : Making the line a comment
ctrl-l : Clear the screen
ctrl-r : Search the history
ctrl-s : Stop output to the screen
ctrl-q : Allow output to the screen


RASPBERRY PI
Homepage      : raspberrypi.org 
Configuration : raspberrypi.org/documentation/configuration/
Download      : raspberrypi.org/downloads/raspbian/

MagPi - The official Raspberry Pi magazine
Issue 75 2018-11 : raspberrypi.org/magpi-issues/MagPi75.pdf
Issue 74 2018-10 : raspberrypi.org/magpi-issues/MagPi74.pdf
Issue 73 2018-09 : raspberrypi.org/magpi-issues/MagPi73.pdf

$ clear; lsblk; lsblk -l
$ dd bs=4M if=2018-10-09-raspbian-stretch.img of=/dev/sdX status=progress conv=fsync
# raspi-config


CUPS
Homepage      : cups.org
Configuration : /etc/cups/cupsd.conf 
//
// $ apt-cache show cups
// # service --status-all | grep cups; service cups status
// # service cups start | stop | status
// $ w3m http://localhost:631
// $ ls -l | lp


TRIPWIRE
# apt-get install tripwire
$ apt-cache show tripwire
$ man tripwire
$ w3m https://github.com/Tripwire/tripwire-open-source
> Creating a baseline: # tripwire --init
> Running a check: # tripwire --check --verbose
> Printing a report: # twprint -m r -t [0-4] -r /path/to/reportfile.twr
> Updating the database: # tripwire --update --accept-all


VIRTUALBOX
# apt-get install apt-transport-https
# wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

// # vim /etc/abt-get/sources.list
// > # Manuel entry
// > deb https://download.virtualbox.org/virtualbox/debian stretch contrib

# apt-get update
# apt-get install virtualbox-5.2

Extension Pack : https://download.virtualbox.org/virtualbox/5.2.20/Oracle_VM_VirtualBox_Extension_Pack-5.2.20.vbox-extpack
UserManual : https://download.virtualbox.org/virtualbox/5.2.20/UserManual.pdf


LXC
linuxcontainers.org
/etc/subuid /etc/subgid
//
// # apt-get install lxc
// $ lxc-checkconfig


PROGRAMMING
HTML
w3schools.com/html/default.asp
tutorialspoint.com/html/index.htm

<!DOCTYPE html>
<html>
   <head>
      <title>Title</title>
   </head>
   <body>
      <h1>Heading</h1>
      <p>Document</p>
   </body>
</html>


ECLIPSE
Homepage : eclipse.org
Help     : help.eclipse.org/2018-09/index.jsp
//
// shift + ctrl + f : Format
// shift + ctrl + l : Keybindings
//
// ctrl + F11   : Run
// ctrl + d     : Delete line
// ctrl + /     : Toggle Comment
// ctrl + l     : Goto line number
// ctrl + space : Content assist
// ctrl + 3     : Quick Access
// ctrl + z     : Undo
//
// alt + F11    : Full Screen
//
// main sysout


NETBEANS
netbeans.apache.org
docs.oracle.com/cd/E50453_01/doc.80/e50452.pdf
netbeans.org/project_downloads/usersguide/shortcuts-80.pdf
// alt+insert : Generate code
// alt+shift+f : Format selection
// ctrl + x : Delete line
// ctrl + e : Delete line
// shift-ctrl-minus | plus : Collaps Expand all


PERL
Homepage       : perl.org
Beginning Perl : learn.perl.org/books/beginning-perl
Modules        : cpan.org
// # apt-get install perldoc
// $ perldoc perlintro
// learn.perl.org/books/beginning-perl
// 
// #!/usr/bin/perl
// use strict;
// use warnings;


PYTHON
Python from Scratch : open.cs.uwaterloo.ca/python-from-scratch/
CheatSheet          $ w3m cheat.sh/python/:learn
$ python -m SimpleHTTPServer


R
Introduction to R Programming : youtu.be/92zCRV3eQxw
An Introduction To R : cran.r-project.org/doc/manuals/r-release/R-intro.pdf
An Introduction to R > help.start()
$ R


APPLICATION MANAGEMENT
SCREEN
/etc/screenrc

strg-?  : Key bindings
strg-ac : New
strg-aa : Toggle 
strg-ah : Hardcopy


TASKWARRIOR
taskwarrior.org 
taskwarrior.org/docs 
taskwarrior.org/docs/30second.html 
linux.die.net/man/1/task

$ man task
$ apt-cache search taskwarrior
$ apt-cache show taskwarrior
# apt-get install taskwarrior
$ vim ~.taskrc
$ w3m https://linux.die.net/man/1/task

Basic Task Management

$ task
$ task add Task1
$ task add Task2
$ task
$ task 1 modify priority:H
$ task 1 modify due:eow
$ task 1 start
$ task 1 stop
$ task 1 information
$ task
$ task 1 done
$ task 2 delete
$ task
$ task burndown
$ alias t='clear; task'
$ alias tt='clear; task burndown.daily'


HARDWARE MANAGEMENT
tldp.org/LDP/Mobile-Guide/html/index.html
raspberrypi.org/documentation
badblocks blkid dmesg fdisk hwinfo ifconfig iwconfig lsblk lshw mount lvm sync tune2fs
/var/log/messages

# badblocks -v /dev/sda
# blkid /dev/sda1
$ cat /sys/devices/virtual/thermal/thermal_zone0/temp
# fdisk -l
# hwinfo --short | less
# hwinfo --disk
# ifconfig eth0
# iwconfig
# lshw -short | less
$ mount | column -t
# mount -t tmpfs -o size=2048M tmpfs /media/ramdisk
# mount -o loop /home/user/iso/xyz.iso /mnt/
# smartctl -i /dev/sda
$ sync
# tune2fs -l /dev/sda2 | less

USB 
# clear; fdisk -l; lsblk -l; echo; dmesg | tail; echo; tail -f /var/log/messages

LVM
# apt-get install lvm2
$ apt-cache show lvm2
$ man lvm
# fdisk -l


FILE MANAGEMENT
cd chown cp df dpkg du file find for java ln ls man mkdir mv open pwd rm sort stat touch type veracrypt vim visudo watch
/etc /var/log /bin /usr/bin /sbin
veracrypt.fr/en/Documentation.html

# chown userXYZ file.txt
$ df -hT
$ dpkg -L vim-doc
# du -hs / 2> /dev/null
$ du -h --max-depth=1 | sort -rh
$ du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e'
# find /home -user userxyz -size +1G
# find /home -user userxyz -mtime -3
# find / -uid 1000 -exec chown -v 1002:1002 {} \;
$ find . -name "*.jpg" -exec convert {} -scale 50% +repage {} \;
$ find ~ -maxdepth 1 -type f -mtime 3
$ find ~ -maxdepth 1 -type f -exec grep "^alias " '{}' \; -print
# find / -user userxyz -type f -exec rm -f {} \;
$ find /etc -type f -print 2> /dev/null | less
$ find /etc/*tab -type f -print
$ for x in *; do mv "$x" "${x,,}"; done
$ java -jar filename.jar
$ ls -l | xsel --clipboard
$ man hier
$ sort -t: -k1 -n /etc/passwd
$ stat /home/user
$ type date
$ type echo
# visudo 
> Defaults:userxyz timestamp_timeout=30
$ watch -d -n 5 ls -l
# vim /etc/sudoers

BACKUP
$ archivemount archive.tar.gz ~/mnt/
# dd if=/dev/sdABC of=/dev/sdXYZ bs=64K conv=noerror,sync
$ tar -cvzf ~/backup/backup.tar.gz ~/java
$ tar -tvf backup.tar.gz
$ ssh [email protected] "tar -zcf - /home/user/scripte" > scripte.tar.gz

RSYNC
$ rsync -avzP --delete --stats --exclude ’Backup*‘ /home/user/ /media/xyz
$ rsync -avzP --delete --stats --exclude-from '/home/user/exclude.txt'  /home/user/ /media/xyz

MD5SUM
$ vim abc.txt
$ md5sum abc.txt > abc.md5
$ md5sum -c abc.md5


USER MANAGEMENT
finger groups id passwd su sudo visudo
adduser useradd ~ deluser userdel ~ usermod chage
addgroup groupadd ~ groupdel delgroup ~ groupmod newgrp

~/.bashrc ~/.profile /etc/group /etc/passwd /etc/profile /etc/shadow /etc/adduser.conf /etc/default/useradd

# adduser userxyz
$ clear; finger; echo; finger userxyz; echo
$ cut -d: -f1 < /etc/passwd | sort | xargs
# chown -R userxyz:userxyz /home/userabc
# find /home -uid 1000 | wc -l
# find /home -uid 1000 | tee 1000-files.txt
# find / -uid 1000 -exec chown -v 1002:1002 {} \;
$ fuser -v /media/xyz
$ getent passwd userxyz
$ id -u userxyz
$ id -u root
$ id userxyz
$ ls -l /etc/skel
$ su -p
# useradd -D
# userdel -r userabc
# usermod -c "UserXYZ" userxyz
# vim /etc/sudoers

PASSWORD
# passwd user1
# passwd -S user1


SYSTEM MANAGEMENT
atop dstat free glances htop info inxi kill man pinfo ps pwd top tuptime uptimeusers vmstat w whoami 
cd ls man mv cp open less
bg fg jobs ctrl-z 

veracrypt.fr/en/Documentation.html sectools.org kernel.org zabbix.com

/var/log

# apt-get update && apt-get upgrade && apt-get dist-upgrade
$ cat /etc/shells
# chkrootkit
# vim /etc/sudoers
# visudo
$ gnome-<tab><tab>
$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
# init 0
# ls<tab><tab>
$ pwgen -s 12
# rpi-update
# rkhunter --check --sk
# service netatop start && atop
# shutdown -r now
# shutdown -c
# shutdown -h 1:00
$ sudo !!
$ sudo su
# tripwire --init
$ uname -v
$ unset HISTFILE
# update-alternatives --config editor
$ PI=$(echo "scale=10; 4*a(1)" | bc -l)
$ apt-cache show vlc | less
# apt-get install kismet
$ cat /etc/fstab | grep -i swap
# cat /var/log/messages | awk '{print substr($0,0,12)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i<$1 ; i++) {printf("*")};}' | less
$ dstat -f 60 24
$ df -hT
$ efibootmgr
$ find ~ -maxdepth 1 -type f -mtime 3
$ find ~ -maxdepth 1 -type f -exec grep "^alias " '{}' \; -print$ lastlog | less
$ find /etc -type f -print 2> /dev/null | less
$ find /etc/*tab -type f -print
$ free -h
$ inxi -v7
$ lastlog | less
$ lsblk
$ lsb_release -a
$ ps hax -o user | sort | uniq -c
$ script sessionlog_2018-10-30
$ set | less
# service cron status
# swapon -s
$ tuptime
$ vmstat 2 10
$ watch -n 5 free -m
$ whowatch
$ xload -update 1 -nolabel &

KERNEL
$ lsmod | wc -l

LOGGING
# tail -f /var/log/messages
# tail -fvn 25 /var/log/messages
# less +F /var/log/messages
# dmesg --facility=kern -H
# dmesg --level=err,warn -T


MULTIMEDIA
$ mpg123 -zvC /home/user/music/*
$ youtube-dl -F https://youtu.be/xyz
$ youtube-dl -f 22 https://youtu.be/xyz

SWAPPING
//
// $ free -h
// $ top
// $ vmstat -w
// $ cat /proc/swaps
// # fdisk -l
//
// # swapon -s
// # ls -lh /tmp 
// # dd if=/dev/zero of=/tmp/swap_tmp bs=1024 count=1000000
// # ls -lh /tmp
// # chmod 600 /tmp/swap_tmp
// # mkswap /tmp/swap_tmp
// # swapon /tmp/swap_tmp
// # swapon -s
//
// # blkid
// # vim /etc/fstab
// # Emergency swap partition
// UUID= (value from blkid)     none     swap     sw    0     0

TIME
# vim /etc/crontab
$ ls -l /etc/cron* | less

TROUBLESHOOTING
# dstat
# testdisk
# grub-mkconfig -o /boot/grub/grub.cfg
# service netatop start && atop


NETWORK MANAGEMENT
curl ifconfig mtr netstat python ssh 
myip.is
/etc/hosts

$ speedometer -r eth0
# arp-scan 192.168.0.0/24
# iw dev wlan0 scan | egrep "SSID|signal" | awk -F ":" '{print $2}' | sed 'N;s/\n/:/' | sort
$ curl ifconfig.me
# netstat -tulpn
$ netstat -a | less
# clear; netstat -tupanc
# clear; echo; netstat -i; echo; netstat -r

# ifconfig -a | grep -Po '\b(?!255)(?:\d{1,3}\.){3}(?!255)\d{1,3}\b' | xargs nmap -A -p0-
$ ssh -X [email protected]

CONFIGURATION
# vim /etc/ssh/ssh_config
$ cat /etc/hosts
# vim /etc/hosts
# macchanger -r eth0

IP-ADDRESS
$ ip addr show
# ifconfig
$ hostname -I

HOSTS
$ sntop
$ ip a
$ sshfs name@server:/path/to/folder /path/to/mount/point
# ifconfig eth0 down | up
$ nmap --iflist
$ nmap -A -T4 192.168.x.y
$ nmap -sP 192.168.x.y/24

ROUTING
$ nmap --iflist
$ ip -r

DOCUMENTATION
$ w3m http://www.linuxhowtos.org/Security/understandssh.htm
$ w3m https://linux.die.net/Intro-Linux/chap_10.html


SERVER MANAGEMENT
# tasksel
# tasksel --list-tasks
# service --status-all | less
# service ssh status
# service apache2 start | restart | stop
# apt-get install printer-driver-cups
# ufw status


DHCP-SERVER
isc.org/downloads/dhcp/
help.ubuntu.com/community/isc-dhcp-server
tools.ietf.org/html/rfc1531

$ apt-cache show isc-dhcp-server
# apt-get install isc-dhcp-server
# man dhcpd
# man dhcpd.conf

# ifconfig; ip a
# vim /etc/dhcp/dhcpd.conf
> option broadcast-address 192.168.0.255;
> option domain-name "linux.local";
> default-lease-time 3600; 
> max-lease-time 7200;
> authoritative;
>
> subnet 192.168.0.0 netmask 255.255.255.0 {
>       option routers 192.168.0.1;
>       option subnet-mask 255.255.255.0;
>       option domain-search "linux.local";
>       option domain-name-servers 8.8.8.8, 8.8.4.4;
>       range 192.168.0.10 192.168.0.100;
>       range 192.168.0.150 192.168.0.200;
> } 

# service isc-dhcp-server start | stop | restart
# systemctl start isc-dhcp-server
# systemctl enable isc-dhcp-server
# ufw allow 67/udp
# ufw reload


PI-HOLE-SERVER
$ ssh [email protected]
# raspi-config
# curl -sSL https://install.pi-hole.net | bash


SOURCES
B
* Bitcoin - $ curl rate.sx
F
* Fish Tutorial - fishshell.com/docs/current/tutorial.html
G
* Gimp - https://www.gimp.org 
* GIT - git-scm.com/book/en/v2
* GIT $ man gittutorial
* Grub - gnu.org/software/grub/manual/grub/grub.html
I
* Info Pages $ info info
L
* LibreOffice - libreoffice.org
* Linux - linux.com
* Linux - kernel.org
* Linux - linuxlinks.com
* Linux - tldp.org/LDP/intro-linux/html/index.html
* LinuxFromScratch - linuxfromscratch.org
O
* Open Books - O'Reilly - www.oreilly.com/openbook
* Open Books - Rheinwerk - rheinwerk-verlag.de/openbook/
S
* Scribus - scribus.net
T
* TLDP - tldp.org
M
* MAN Pages $ man -t man | ps2pdf - man.pdf
* MAN Pages $ man -k scanner
* MAN Pages $ apropos . | shuf -n 1 | awk '{print$1}' | xargs man
* MAN Pages $ man man


WEATHER
$ curl wttr.in/~wasserkuppe?lang=de
$ curl wttr.in/bad+kissingen?lang=de
$ curl wttr.in/fulda?lang=de
$ curl wttr.in/~odenwald+reichelsheim?lang=de
$ curl wttr.in/~valletta
$ curl wttr.in/:help

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.033
BTC 64320.07
ETH 3154.23
USDT 1.00
SBD 4.34