Helpful-Commands
Remove many/thousands of files
Sometimes the rm (Remove) command will not work when there are too many files in a folder or will take forever. You can use a for loop to remove the files in a folder. Just change your directory to the folder where you want to remove the files and run the below command. This will delete all files in the directory except folders
Remove files older then x
Sometimes you only want to keep x iterations of files for example of zipped backups, so you need to remove all files older then x days. With the below command you can remove all files older then 5 days.
Search recursive through files with a pattern
Sometimes you need to find all files with a specific pattern, for example a domain or ip-address in a config. The -r option searche recursive, -n shows the line number for every finding and -w searches for whole words.
Outbound NAT iptables
With the below command you can NAT your traffic from a routed network via a local interface, in this example all packets from a local network on LAN gets NATed through the wifi interface.
Set file permissions recursive for every file or folder in a path
Files
Folder
Convert text to base64
Split large files to smaller ones
Sometimes you need to split a large file into a few smaller ones so you can upload them to systems with a file limitation. After that you can recreate the source file. Split large files
Recreate the source fileListen on a specific port with tshark
Create bootable linux USB key
Show lldp neighbour
With the below command you can see to which switch or device you are connected on the LAN port.
Show all disks in AVAGO raid controller
Create a zip with all files from a folder via cli
Create WiFi QR-Code
Clear systemd DNS cache
or for older versionsShow systemd DNS cache statistics
Test disk performance with dd
The below command writes a 10GB file directory to disk without using RAM as cache.
Show file permissions as number
Create one log file from many
All Logs
Logs with pattern
List files by size
** Files and directories**
Directories only
Mount qcow2 image
Mount
Unmount
Delete empty files in folder
Forever loop
Update dynamic nameserver entry from cli
Show Output of all commands in Shell script
Show and sort swap usage by process
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
fail2ban
Show status for jail
Unban IP
Ban IP