A lot of *Nix Documentation and Know-hows, command snippets, code... \\ \\ ====== System Administration (Cheatsheet) ====== \\ ===== * Packages ===== * [[docu:csheet:sysadm:packages:fix_yum|Fix yum broken repositories db]] * [[docu:csheet:sysadm:packages:apt_changelog|Show changelog of a package using apt-get]] \\ ===== * Database Administration ===== ==== + :::: MySQL/MariaDB ==== * [[docu:csheet:sysadm:db:my:create_user|Create a new user in MySQL]] * [[docu:csheet:sysadm:db:my:57_date_problem|How to fix 5.7 datetime field problems on dump/restore]] * [[docu:csheet:sysadm:db:my:restore_1table|Restore 1 table from a Database dump]] * [[docu:csheet:sysadm:db:my:docker_run_easy|Automatically run a mysql interactive shell to the configured db on docker]] * [[docu:csheet:sysadm:db:my:database_migration_help|Helping commands when migrating MySQL databases to different servers]] ==== + :::: Postgres SQL ==== * [[docu:csheet:sysadm:db:psql:dumping|Dumping and restoring Postgres databases]] \\ ===== * Virtual Environments / Containers ===== ==== + :::: Linux chroot ==== * [[docu:csheet:sysadm:venve:chroot:setup_linux_chroot|Setup a Linux chroot with proc,sys,dev]] ==== + :::: QEMU/KVM ==== * [[docu:csheet:sysadm:venv:qemu:shrink_qcow2_img|Shrink a qcow2 image file using qemu-img tool]] * [[docu:csheet:sysadm:venv:qemu:resize_qcow2_img|Resize (expand) partitions on a qcow2 image using qemu-img and virt-resize]] * [[docu:csheet:sysadm:venv:qemu:proxmox_add_uso|Add an ISO to your proxmox installation on the server via SSH]] * [[docu:csheet:sysadm:venv:qemu:proxmox_local_pool|Crear a local directory storage pool on Proxmox (ex: sshfs or other)]] * [[docu:csheet:sysadm:venv:qemu:proxmox_nested_vm|Nest virtual machines on Proxmox]] ==== + :::: Docker ==== * [[docu:csheet:sysadm:venv:docker:run_kali|Run a process-isolated Kali Linux Rolling]] * [[docu:csheet:sysadm:venv:docker:inspect_sha256|Inspect the docker image sha256 sum from the repo to compare]] * [[docu:csheet:sysadm:venv:docker:netns_exec|Execute a command on the docker container network namespace]] ==== + :::: Podman ==== * [[docu:csheet:sysadm:container:podman:migrate_images|Move/Migrate docker images to Podman]] * [[docu:csheet:sysadm:container:podman:race_cond_container_storage|How to solve a race condition where container cannot be created with same name even if it does not exist]] \\ ===== * Web Servers ===== ==== + :::: Applications ==== * Nextcloud * [[docu:csheet:sysadm:web:apps:nextcloud:export_import_config|Export and import Nextcloud App configuration]] * WordPress * [[docu:csheet:sysadm:web:apps:wordpress:ssl_termination|How to configure WordPress behind SSL Reverse Proxy]] ==== + :::: Servers ==== * Apache2 * [[docu:csheet:sysadm:srv:apache:redirect_match|Redirect a matching url to another]] * HAProxy * [[docu:csheet:sysadm:srv:haproxy:how_to_ssl_proxy_site|SSL Proxy a website using HAProxy sni on server backend]] * [[docu:csheet:syadm:web:server:haproxy_sni|Route traffic via the ssl_sni header]] * [[docu:csheet:sysadm:srv:haproxy:replace_query|HAProxy 2.0 replace text in querystring]] \\ ===== * Programming / Scripting ===== ==== + :::: Bash ==== * [[docu:csheet:sysadm:script:bash:expand_aliases|Expand aliases on a bash script]] * [[docu:csheet:sysadm:script:bash:get_script_path|Get directory of the executed script in bash]] * [[docu:csheet:sysadm:script:bash:tcp_raw_bash|Check a TCP connection and response on raw BASH]] * [[docu:csheet:sysadm:script:bash:tcpdump_stdbuf_traffic|Analyze HTTP traffic with simple command line tools]] * [[docu:csheet:sysadm:script:bash:grep_displayonly|Use grep text to only highlight it showing original text]] * [[docu:csheet:sysadm:script:bash:cr_remove_tr|Remove ^M CR (carriage return) from output/file]] * [[docu:csheet:sysadm:script:bash:rename_spaces|Remove spaces from files in a directory recursively]] * [[docu:csheet.sysadm:script:bash:hex_to_decimal|Convert a hex string to decimal using built-in "printf"]] * [[docu:csheet:sysadm:script:bash:hex_convertions|Convertions and replacements on Linux command line using hex]] * [[docu:csheet:sysadm:script:bash:wget_all_website|Download/Get/Scrap/Crawl all static files from website using Wget]] ==== + :::: Git ==== * [[docu:csheet:sysadm:script:git:merge_upstream|Merge the upstream of your fork automatically]] * [[docu:csheet:sysadm:script:git:copy_branch|Copy branch from a remote to another remote]] * [[docu:csheet:sysadm:script:git:delete_branch|Delete branch from both local and remote]] * [[docu:csheet:sysadm:script:git:changes_directory|Show files changed history and commits in an specific directory]] ==== + :::: Python ==== * [[docu:csheet:sysadm:script:python:html_scraping|Simple guide for HTML Web Scraping]] * [[docu:csheet:sysadm:script:python:argparse|How to use argparse on python3]] * [[docu:csheet:sysadm:script:python:read_csv|Read a CSV file to JSON, using the first rows as field names definition]] * [[docu:csheet:sysadm:script:python:sort_by_key|Sort an Array by a key value]] ==== + :::: CURL ==== * [[docu:chseet:sysadm:script:curl:http_auth|curl a site with http basic auth]] ==== + :::: HTML/CSS ==== * [[docu:csheet:sysadm:htmlcss:fix_background|Fix Mobile parallax effect when setting a background image to the full document]] ==== + :::: Javascript ==== * [[docu:csheet:code:js:element_by_xpath|Get an element on the HTML document by XPath]] * [[docu:csheet:code:js:freeze_site_for_editing|Freeze the state of a website to be able to edit popups]] \\ ===== * Desktop Management ===== ==== + :::: Xorg ==== * [[docu:csheet:sysadm:desktop:xorg:remove_beep|Remove console feedback beeping sound]] * [[docu:csheet:sysadm:desktop:xorg:key_bindings|Guide to capture/setup key bindings on Linux]] * [[docu:csheet:sysadm:desktop:xorg:xhost_add_user|Add user to xorg auth (xhost) by username]] ==== + :::: i3 Window Manager ==== * [[docu:csheet:sysadm:desktop:i3wm:keyboard_layout|Set keyboard layout on i3]] ==== + :::: Printers/Printing ==== * [[docu:csheet:sysadm:desktop:print:setup_printing|Setup printing tools in your Debian-based Linux (if it doesn't have them)]] ==== + :::: PulseAudio ==== * [[docu:csheet:sysadm:desktop:pulseaudio:forward_pulseaudio_ssh|Forward Audio from a remote server to your host, using PulseAudio]] \\ ===== * Startup / Persistance ===== * [[docu:csheet:sysadm:init:common_ifnames|Set friendly network interface names]] * [[docu:csheet:sysadm:init:switch_kernel|Change the grub menu item using update-grub (Switching kernels)]] \\ ===== * Disk Management ===== * [[docu:csheet:misc:rpi_unzip_dd|Unzip raspberry pi OS to an sdcard (or disk) using unzip and dd]] * [[docu:csheet:sysadm:disks:mount_gz_image|Mount a .gz compressed image file using nbdkit and nbd-client (read-only)]] * [[docu:csheet:sysadm:disks:luks_change_key|Change passphrase on LUKS full encrypted disk/partition]] * [[docu:csheet:sysadm:disks:t2fs_reserved|Remove reserved blocks from an ext4 partition]] * [[docu:csheet:sysadm:disks:grow_partition|Resize partition to grow the filesystem (useful on Virtual Environment Disks)]] * [[docu:csheet:sysadm:disks:t2fs_labelname|Change ext3/ext4 disk label name]] * [[docu:csheet:sysadm:disks:get_rotational|Check a disk is HDD or SSD (rotational)]] * [[docu:csheet:sysadm:disks:get_disk_nice_info|Get interesting information about a disk/partition using tune2fs]] * [[docu:csheet:sysadm:disks:write_iso_to_dvd|Write/Burn an .ISO image file to a dvd-rw]] * [[docu:csheet:sysadm:disks:clone_partition_table|Export and clone partition table from 1 disk to another]] * [[docu:csheet:sysadm:disks:lvm_backup_restore|Backup and restore LVM configuration of a volume group (vg)]] * [[docu:csheet:sysadm:disks:physical_disk_resize|Resize virtual disk (vdX) to match it's new size (growpart, resize2fs)]] * [[docu:csheet:sysadm:disks:uuid_set_device|Manually set UUID of Linux swap/ext partition using cli]] * [[docu:csheet:sysadm:disks:iscsi_update_targets|Update ISCSI target list from a certain ISCSI host]] * [[docu:csheet:sysadm:disks:img_mount_loop|Mount .img partitions to separate loops so you can mount any partition inside image]] * [[docu:csheet:sysadm:disks:get_hw_info|Show hardware information of system disks (manufacturer, etc...)]] * [[docu:csheet:sysadm:disks:shred_ssd|Securely erase an SSD with hdparm]] ==== + :::: Privacy ==== * [[docu:csheet:sysadm:disks:privacy:wipe_disk|Wipe a disk entirely (for privacy) using shred]] \\ ===== * Memory Management ===== * [[docu:csheet:sysadm:mem:add_swapfile|Create a swap file in order to save your system from OOM killer]] * [[docu:csheet:sysadm:mem:get_hw_memtype|Get hardware memory information on the installed system]] \\ ===== * Networking ===== ==== + :::: Firewall ==== * [[docu:csheet:net:iptables:port_redirection|Redirect ports using iptables]] * [[docu:csheet:net:firewall:syn_flooding|Protect your *nix server from SYN flooding]] * [[docu:csheet:net:iptables:block_packets_by_content|Block TCP/UDP packets by string content using iptables]] * [[docu:csheet:net:iptables:accept_multicast_broadcast|Accept Multicast and Broadcast packets on iptables]] ==== + :::: Relays/Proxies ==== * [[docu:csheet:net:relays:socat_usage|Curated practical uses for socat, a whole TCP/UDP/UNIXSOCK relay tool]] * [[docu:csheet:net:relays:vpn_wireguard_vps|Setup a Wireguard VPN on your VPS to your local network (even with CG NAT)]] ==== + :::: Misc ==== * [[docu:csheet:net:misc:networking_install|Install ifupdown for "networking" service instead of network-manager or any other]] * [[docu:csheet:net:misc:ipforwarding|Enable/disable ip forwarding]] * [[docu:csheet:net:misc:switch_back2_interfaces|Disable netplan on Ubuntu to switch back to network iterfaces /etc/network/interfaces]] * [[docu:csheet:net:misc:rpi_pc_serial|Connect a Computer with Raspberry Pi over IP using a USB serial line]] \\ ===== * Data Processing ===== ==== + :::: SSL/TLS ==== * [[docu:csheet:dtproc:ssl:renew_verify|Renew certificates manually and verify chain elements]] * [[docu:csheet:dtproc:ssl:end_date|Get end-date from .pem encoded file with openssl]] * [[docu:csheet:dtproc:ssl:ssl_chain|Obtain SSL chain certificates and information about website with openssl]] * [[docu:csheet:sysadm:files:self_signed_cert|Generate a self-signed certificate using openssl]] ==== + :::: Images ==== * [[docu:csheet:dtproc:images:jpeg_optimize|Optimize JPG/JPEG images]] * [[docu:csheet:dtproc:images:qr_code_parsing|Encode/Decode QR Code Images to the text value]] * [[docu:csheet:dtproc:images:convert_png_svg|Convert PNG image to SVG on Linux]] ==== + :::: Documents ==== * [[docu:csheet:dtproc:docs|Extract selected page or range from a pdf document]] ==== + :::: Backups ==== * [[docu:csheet:dtproc:backups:borg_qstart|Borg-backup quick guide]] * [[docu:csheet:dtproc:backups:android_apps_backup|Backup Android Apps data and system apps]] ==== + :::: Files ==== * [[docu:csheet:sysadm:files:targz_list|Show contents of a tar.gz file]] * [[docu:csheet:sysadm:files:compress_vids|Insanely Compress videos using ffmpeg]] * [[docu:csheet:sysadm:files:share_ffmpeg_stream|Share an ffmpeg stream over tcp with netcat]] * [[docu:csheet:sysadm:files:cut_vids|Cut/split videos using ffmpeg]] * [[docu:csheet:sysadm:files:ffmpeg_separate_join_audio_video|Separate and join again the audio and video from a file using ffmpeg]] \\ ===== * (Offensive) Security ===== ==== + :::: Information Gathering ==== * [[docu:csheet:ofsec:info:mitmproxy_android_install|Install MitmProxy (or other) CA Certificate on Android System Trusted ca-certs (NEEDS ROOT!)]] * [[docu:csheet:ofsec:info:sslscan|Get SSL/TLS vulnerable information about a website]] * [[docu:csheet:ofsec:info:netdiscover|Scan network device manufacturers and IPs]] * [[docu:csheet:ofsec:info:whatweb|Gather information about the software used by a website]] * [[docu:csheet:ofsec:info:wpscan|Scan vulnerabilities of a WordPress site]] * [[docu:csheet:ofsec:info:nmap|Map IP network ports with Nmap]] ==== + :::: Packet capturing / analizing ==== * [[docu:csheet:ofsec:pcap|Dumpcap common snippets]] * [[docu:csheet:ofsec:wshark_live_cap_ssh|Capture live packets from server using Wireshark and SSH tunnel]] * [[docu:csheet:ofsec:wshark_tls_client_hello|Filter tls client hello on Wireshark]] ==== + :::: Hacking & Cracking ==== * Wireless * [[docu:csheet:ofsec:hack:wifi:hashcat|Cracking WPA handshakes with hashcat]] * [[docu:csheet:ofsec:hack:wifi:aireplay|Perform manual de-authentication attacks with aireplay-ng]] * SQL Injection * [[docu:csheet:ofsec:hack:sql:testing|Injection testing and exploiting with sqlmap]] * [[docu:csheet:ofsec:hack:sql:sqlserver|Gathering information about an SQL Server database]] * Security Hardening * [[docu:chseet:ofsec:sec:otp_comand_line|Use TOTP on *nix command line]] * Privacy & Metadata * [[docu:csheet:ofsec:priv:image_metadata|Remove all possible metadata from an image]] * [[docu:csheet:ofsec:priv:video_metadata|Remove all metadata from ANY video file using ffmpeg]] * [[docu:csheet:ofsec:priv:verify_gpg|Verify files with GPG signatures (example: TorBrowser)]] \\ \\ ====== Applications ====== \\ ===== * GNU Linux ===== * [[docu:tutos:apps:linux:ncmpcpp|How to use NCMPCPP (MPD console client)]] * [[docu:tutos:apps:linux:tmux|How to use Tmux (+some cheatsheets)]] \\ \\ ====== Tutorials ====== \\ ===== * Android ===== * [[docu:tutos:android:adb_tcp_forwarding|Forwarding adb over TCP/IP]] * [[docu:tutos:android:adb_root_reverse_shell_openssl|Spawn a usable root shell on your Android, without su, using "ADB as Root" developer option with and Termux with openssl]] \\ ===== * Linux ===== ==== + :::: Security ==== * [[docu:tutos:linux:pass_unix_usage|Install and use pass Unix-Philosofy password manager]] ==== + :::: Networking ==== * [[docu:tutos:net:rpi_to_router|Convert your Raspberry Pi into a Router]] ==== + :::: Misc ==== * [[docu:tutos:misc:gen_own_trusted_ca|Create your own Trusted CA Certificates]] * [[docu:tutos:misc:install_docker_debian10|Install docker on debian 10 (buster)]] \\ \\ ====== Snippets ====== \\ ===== * Programming ===== ==== + :::: PHP ==== * [[docu:snipper:program:php_upload_file|Run a simple php server to upload files]] ==== + :::: Python ==== * Networking * [[docu:snippet:net:pyth_iptables_once|iptables-once, never add repeated iptables again!]] ==== + :::: Protocols ==== * [[docu:snippet:protocols:smtp|SMTP protocol example]] \\ == Others == TODO: read, test and catalog this useful commands https://www.commandlinefu.com/commands/using/arecord