Linux
Usefull Programms (Nice To Have)
Wireshark (Network analysing tool)
HexChat (IRC-Chat with filetransfering capabilities)
irssi (IRC-Clinet CLI)
IntelliJ (IDE)
MySQL Workbench
krita (raster graphics editor)
shotcut (video editing)
dc or bc (CLI-Calculator)
lynx (CLI-Browser without Graphics)
Watch Star Wars over IPv6
telnet 2001:980:ffe:1::42
Check Memory usage
smem -t -P firefox
Check Occupied Storage Space
Whole Disk
df -h
In Folder
du -h | sort -h -r
Over whole Filesystem (fast)
ncdu
Check how many files are in subfolders
find . -type f -printf '%h\n' | cut -d/ -f2 | sort | uniq -c | sort -n
-maxdepth 2 # Can be added to only list files in direct subfolder, instead of recursive files in all folders
Show Hardware Info
sudo lshw -short
Monitor CPU-Clock Speed
watch -n1 "cat /proc/cpuinfo | grep "^[c]pu MHz""
Find out OS Version
cat /etc/*-release
lsb_release -a
Find out Processor Architecture
lscpu
Find out NIC-Speed
sudo ethtool eth0 | grep Speed
Find out MAC-Addresses of Network Devices
ping <IP-Address of Target>
arp -a
ping -I eth0 fe80::...:
Create Password in Shell
date +%s | sha256sum | base64 | head -c 32 ; echo
Interact with date in CLI
$(date "%d-%m-%Y_%H-%M-*" -d "-20 minutes")
$(date "%d-%m-%Y_%H-%M-%S" -d "-20 minutes")
Distributed Computing
BOINC
Setup:
cd /var/lib/boinc-client
boinccmd --project_attach https://milkyway.cs.rpi.edu/milkyway/ <secret_key>
boinccmd --project_attach https://einsteinathome.org/ <secret_key>
boinccmd --project_attach https://setiathome.berkeley.edu/ <secret_key>
boinccmd --project_attach https://boinc.bakerlab.org/rosetta/ <secret_key>
boinccmd --get_state
Disallow more Work:
boinccmd --project https://milkyway.cs.rpi.edu/milkyway/ nomorework
boinccmd --project https://einsteinathome.org/ nomorework
boinccmd --project https://setiathome.berkeley.edu/ nomorework
boinccmd --project https://boinc.bakerlab.org/rosetta/ nomorework
Allow more Work:
boinccmd --project https://milkyway.cs.rpi.edu/milkyway/ allowmorework
boinccmd --project https://einsteinathome.org/ allowmorework
boinccmd --project https://setiathome.berkeley.edu/ allowmorework
boinccmd --project https://boinc.bakerlab.org/rosetta/ allowmorework
Abort specific Task:
--task URL task_name abort
FAH (Folding at Home)
--user=<user_name> --team=<team_id> --passkey=<secret_key> --gpu=false --smp=true
Record Streams/Mediathek aufnehmen
ARD
ffmpeg -i "https://dasersteuni-vh.akamaihd.net/i/int/2018/11/16/2ee8249b-c8f0-4a25-b8ac-260bd7caba5a/,640-3,512-3,1280-3,320-3,960-3,480-3,.mp4.csmil/index_2_av.m3u8?null=0" -bsf:a aac_adtstoasc -c copy "tatortTreibjagd.mp4"
ZDF
ffmpeg -i "http://zdfvoddach-vh.akamaihd.net/i/meta-files/3sat/smil/m3u8/300/18/11/181119_weit_film/3/181119_weit_film.smil/master.m3u8" -c copy "video.mp4"
Funk.net
ffmpeg -i https://funk-02.akamaized.net/22679/files/21/06/11/3409640/22679-vhDVH6jMpQC2Yf3.ism/manifest.mpd -codec copy out.mp4
Twitch Recording
Required:
vlc
streamlink
streamlink https://www.twitch.tv/rocketbeanstv best
or
streamlink --output /home/<user>/Videos/twitchCapture.mp4 https://www.twitch.tv/rocketbeanstv best
streamlink --output /home/<user>/Videos/youtubeCapture.mp4 https://www.youtube.com/watch?v=p3n0wLkXpoI best
Note
Bei YouTube Downloads muss *–demux=ffmpeg* bei der wiedergabe mit vlc gesetzt werden.
Audio editing
split cue file
sudo apt install shntool cuetools flac wavpack
shntool split -f *.cue -o flac -t '%n - %p - %t' *.ape shntool split -f *.cue -o flac -t '%n - %p - %t' *.flac
or
shntool split -f <cue-File>.cue -o flac -t '%n - %p - %t' <flac-File>.flac
flac to mp3
ffmpeg -i title.flac -qscale:a 0 title.mp3
for f in *.flac; do ffmpeg -i "$f" "mp3/${f%.flac}.mp3" ; done
mkv to mp3
ffmpeg -i *.mkv -b:a 320K -vn title.mp3
Mappings for “page up” and “page down” to search in history
sudo vi /etc/inputrc
"e[5": history-search-backward
"e[6": history-search-forward
Note
To take immediate Effect run: exec bash -l
rdesktop
rdesktop -u <user> <IP/NameOfServer> -g 1920x1040 -r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]
Hide Data in Images
Change Color of PDF-Text for semi-working printers… ;)
convert -density 300 test.pdf -fuzz 10% -fill blue -opaque black result.pdf
Shred Drive/HDD
shred -vfz -n 5 /dev/sdX
Check S.M.A.R.T-Info
Note
Install with sudo apt install smartmontools
sudo smartctl -a /dev/sdb
Search for file
find . -name *foo*
or
sudo apt install mlocate
sudo updatedb
locate <search_string> (Case Sensitive)
locate -i <search_string> (Case Insensitive)
Search inside file
grep -nHo "search" * # Display filename and line-number
Rip Movies
Release downloaden und als sudo config und make ausführen (Siehe INSTALL) Handbreak (per apt installieren) Mit Handbreak DVD rippen (selbserklärend)
Sokoban
Next Level to play: 16
dosbox (Alt Return = Fullscreen)
mount c ./Downloads/Sokoban
c:
skb.exe
U = Undo, L = Leave, P = Pause Remapping the keyboard and joystick
When you start the mapper (either with CTRL-F1 or -startmapper as a commandline argument to the DOSBox executable)
vim
save file: ‘:w’
quit editing: ‘:q’
search for pattern: ‘/<pattern>’
search for a pattern without case: ‘/c<stringToSearch>’
repeat search in same direction: ‘n’
repeat search in oposite direction: ‘N’
replace ‘old’ with ‘new’ ‘:%s/old/new/g’
‘:%s/ //g’
Create Bootable USB-Stick
sudo dd if=<ISO-File> of=/dev/sdX status=progress
Mount Drive on Boot
Hard-Drive
Get the blockid with blkid
Edit /etc/fstab
and insert the follwing:
UUID=<uid-got-from-blkid> <path-to-mount> <filesystemtype (auto,ntfs,ext4)> rw,user,auto,errors=continue 0 0
Test with sudo mount -a
sshfs
Note
If no SSH-Key exists, run ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C “<comment for this key>” followed by cat .ssh/id_rsa.pub | ssh <user>@<domain/ip> ‘cat >> .ssh/authorized_keys’
To test mounting the remote drive:
sudo sshfs -o IdentityFile=/home/tidoni/.ssh/id_rsa,allow_other,default_permissions <user>@<domain/ip>:/media/Data/ /mnt/NeoPI/
Set in /etc/fstab
sshfs#<user>@<domain/ip>:/media/Data/ /mnt/NeoPI/ fuse default_permissions,allow_other,IdentityFile=/home/tidoni/.ssh/id_rsa 0 0
Hint
to test the inserted mount command run mount -a
Execute Command for multiple files
for f in *; do cp "$f" "foo/$f" ; done
Rename all files in folder
for file in *; do mv "$file" `echo $file | sed 's/ /./g'` ; done
pdftk
Split a PDF file:
pdftk fileToSplit.pdf burst
or .. code-block:: bash
pdftk source.pdf burst output source-%d.pdf
Merge multiple PDF files:
pdftk firstFile.pdf secondFile.pdf thirdFile.pdf ... output mergedFile.pdf
Hint
Use *.pdf to merge all PDF-Files in the current Folder
To rotate some pages ‘within’ a pdf, you can use:
pdftk in.pdf cat 1-10 11right 12-16 17-18right 19-23 24-26right 27-end output out.pdf
Hint
possible options are right, left, down or west, east, south.
Console shortcuts
Resize or Move Consol with Alt + F5-F8
Networking
Find devices in Subnet
nmap -sP <ip_Address>/<size_of_Subnet>
nmap -sP 192.168.178.0/24
nmap -p- <domain>
Showing local (open)Ports
nmap -sT -O localhost
RSYNC
rsync -av -r -e 'ssh -p <port>' <local_Folder> <user>@<remote_Domain_or_IP>:<remote_Path>
Autostart programm on startup
Insert command into /etc/rc.local
sudo vim /etc/rc.local
Show running processes atteched to terminal
jobs
ps
Data rescue/recovery
Create 1 to 1 image of drive:
dd if=<device to be imaged/copied> of=<where to put image>
If the drive is having physical problems:
ddrescue <device to be imaged/copied> </example/path/rescue.img> </example/path/rescue.map>
From https://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html:
-r n
–retry-passes=n
Exit after the given number of retry passes. Defaults to 0. -1 means infinity. Every bad sector is tried only once in each pass. The direction is reversed after each pass. To retry bad sectors detected on a previous run, you must specify a non-zero number of retry passes. A command like ‘ddrescue -f -r-1 /dev/sdcard /dev/null mapfile’ can be used to read repeatedly until the device controller succeeds and remaps the bad sectors internally.
Hint
<device to be imaged> could be ‘/dev/sdf’ for usb stick or ‘/dev/sda’ for first hard drive <where to put image> ‘./someFolder/recover.image’
Try to extract files from image/partition
photorec [/log] [/debug] [/d recup_dir] [device|image.dd|image.e01]
Photo conversion
Tiff in jpg
Move to folder containing tif images, create jpg folder if not exist (mkdir jpg)
for f in *.tif;
do
echo "Converting $f";
convert "$f" "jpg/$(basename "$f" .tif).jpg";
done
Manjaro setup xrp
yay -S xrdp
OBS Camera streaming
sudo modprobe v4l2loopback
sudo obs
Tools → v4l2sink /dev/video2 YUV420 starten
CLI View Network Traffic (Slurm)
slurm -z -s -d 1 -i <Your-Network-Interface>
Refresh time from ntp
sudo ntpdate pool.ntp.org
Setting to sync time automatically
timedatectl set-ntp yes
Create NFS (Network File System)
Install on Host:
sudo apt install nfs-kernel-server
sudo mkdir /<path>/<to>/<dir> -p
sudo chown nobody:nogroup /<path>/<to>/<dir>
sudo vim /etc/exports
/<path>/<to>/<dir> <ip-address_of_receiver>(rw,sync,no_subtree_check)
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
To Mount Drive on IRC-Client
Install on Client:
sudo apt install nfs-common
sudo mount <ip-address_of_host>:/<path>/<to>/<dir> /<path>/<where>/<to>/<mount>
/etc/fstab
<ip-address_of_host>:/<path>/<to>/<dir> /<path>/<where>/<to>/<mount> nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
Libs (Updates the necessary links for the run time link bindings)
sudo ldconfig
Run command for sequence (1…10)
for i in $(seq 1 10);
do
echo $i
done
Use Laptop as server
Do nothing on lit closed For 13.10 - 21.10:
To disable Ubuntu doing anything closing the laptop lid:
Open the /etc/systemd/logind.conf
file in a text editor as root, for example,
If HandleLidSwitch is not set to ignore then change it:
HandleLidSwitch=ignore
Make sure it’s not commented out (it is commented out if it is preceded by the symbol #) or add it if it is missing.
Restart the systemd daemon (be aware that this will log you off) with this command:
sudo systemctl restart systemd-logind
or, from 15.04 onwards:
sudo service systemd-logind restart
Setup SWAP on Linux
swapon --show
free -h
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
swapon --show
Make SWAP permanent in fstab
sudo cp /etc/fstab /etc/fstab.back
Edit /etc/fstab
and add
/swapfile none swap sw 0 0
or run
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Adjust swappiness
The swappiness parameters specifies how often the swap space is beeing used. The value can be between 0 and 100. Higher value means the swap space will be used more often.
The default swappiness in Desktop PCs is 60 (Ubuntu) while in server it is 1.
You can check the swappiness with the following command:
cat /proc/sys/vm/swappiness
Because swap is slower than RAM, in servers this value is small, so the RAM gets used as much as possible, befor falling back to swap.
You can change the swappiness on a live system with the following command:
sudo sysctl vm.swappiness=25
To make the change permanent, change the /etc/sysctl.conf
and add the swappiness value to the end of the file:
vm.swappiness=25
Setup a second Network(card)
Check Hardware and current configuration
ip a
sudo lshw -class network
Create a new file under /etc/netplan/...
with the settings for the new network.
network:
ethernets:
<device-name>:
addresses:
- <ip-address>/<subnet>
gateway4: <gateway-ip-address>
nameservers:
addresses:
- <dns1-ip-address>
- <dns2-ip-address>
search:
- <search-domain>
version: 2
Test config by running
sudo netplan apply
The second network may not have a gateway or dns-servers, depending on the particular setup.
Show Network/DNS Settings
nmcli dev show
Send Mail using Relay-Host
edit /etc/postfix/main.cf
insert relayhost = <your_mail_host>
restart postfix /etc/init.d/postfix force-reload
In a Windows Mail Environment goto exchange controll panel (https://<your_exchange_server>/ecp/); there go to Nachrichtenfluss -> empfangsconnectors and add your server to the noAuthenticate Groupe.
Kali
Find WiFi-Key
sudo wifite --kill
sudo wifite --kill --dict <wordlist.txt> --no-wps --no-pmkid
Find key of ZIP
zip2john <zipFile> > <writeHere.hash>
john <writeHere.hash> --wordlist=<wordlist.txt>
Scan Wordpress installation for a vulnerability
wpscan
Vergrößern der VM LVM Festplatte OHNE NEUSTART
sudo cfdisk
sudo growpart /dev/sda 3 # (Schau erst welche Partition vergrößert werden soll, hier SDA3)
sudo lvmdiskscan
sudo lvextend -l+100%FREE /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv