NetWiki

I can make net work

User Tools

Site Tools


linux:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:start [2023-08-26 14:13] davelinux:start [2024-02-27 15:19] (current) dave
Line 1: Line 1:
 ====== Linux ====== ====== Linux ======
 Info on that horrible operating system that's a million times better than Micro$oft Windoze. Why do I say it's horrible? Mostly because I don't spend enough time there to know how to do things and figuring it out is often a PITA.  Info on that horrible operating system that's a million times better than Micro$oft Windoze. Why do I say it's horrible? Mostly because I don't spend enough time there to know how to do things and figuring it out is often a PITA. 
 +
 +  * [[Bash]]
 +  * [[inputrc]]
 +  * [[Services]]
 +  * [[rclone]]
 +
 +-----------------------
 +===== Commifying a number in Linux =====
 +<code>
 +grep MemTotal /proc/meminfo | tr -s ' ' | cut -d ' ' -f 2 | xargs printf "%'d\n" 
 +</code>
 +Bonus: That particular command tells you how much memory is installed. I think.
 +-----------------------
 +===== Pad IPs to Make Them Sortable =====
 +<code>
 +echo 172.16.16.112/30 | awk -F '[./]' '{printf "%03d.%03d.%03d.%03d/%03d\n", $1,$2,$3,$4,$5}'
 +172.016.016.112/030
 +</code>
 +-----------------------
 +===== Date =====
 +My preferred date/time format is ISO 8601.
 +<code>date '+%Y-%m-%d_%H:%M:%S'</code>
 +Can also be accomplished with...
 +<code>date '+%F_%T'</code>
 +Specific timezone and 3 hours in the future...
 +<code>TZ="America/New_York" date -d "+3 hours" '+%Y-%m-%d_%H:%M:%S'</code>
 +-----------------------
 +===== Find =====
 +I never remember how to find old files... either of these will work. The second one uses minutes (I don't know why you'd want to) and shows how to exclude files.
 +  find DIR -name "*_FILENAME-*.gz" -mtime +45
 +  find . ! -name '*NOT_THIS*.gz' -mmin +$((45*24*60))
 +
 +Add this to the end and anything that matches will be deleted.
 +<code>
 +-exec rm -f {} \;
 +</code>
 +
 +Limit depth to current directory.
 +<code>
 +find . -maxdepth 1 -name "v*.tar.gz" -mtime +30
 +</code>  
 +
 +# to delete empty dirs
 +<code>
 +find  -type d -empty -delete
 +</code>
 +# to delete files over some age & empty dirs
 +<code>
 +find /some/path -depth \( \( -type f -daystart -mtime +100 \) -o -type d -empty \) -ls
 +</code>
 +
 +-----------------------
 +===== Find the Fat Folder =====
 +Useful for finding which directory is sucking up all your disk space.
 +<code>
 +du -h --max-depth=1 | sort -hr
 +</code>
  
linux/start.1693059200.txt.gz · Last modified: 2023-08-26 14:13 by dave

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki