The gMan nixWiki

Because the mind is made of Teflon...

User Tools

Site Tools


general_commands

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
general_commands [2022/09/26 02:24] – [sed] gmangeneral_commands [2024/06/19 22:27] (current) gman
Line 1: Line 1:
 ====== CLI: Commands & Usage ====== ====== CLI: Commands & Usage ======
 +
 +===== apt =====
 +
 +<code>
 +# [1] Update package repo
 +apt update
 +
 +# [2] Upgrade your distro
 +apt full-upgrade -y
 +
 +# [3] Remove obsolete packages left after the upgrade 
 +apt autoremove
 +
 +# [4] Clear local repo of useless package files
 +apt autoclean
 +
 +# Or do it all in one line:
 +apt update && apt full-upgrade -y && apt autoremove && apt autoclean
 +</code>
 +
 +----
  
 ===== arp ===== ===== arp =====
  
 Running ''arp'' at the command line will print the arp table (shows the IPs mapped to MAC addresses). Running ''arp'' at the command line will print the arp table (shows the IPs mapped to MAC addresses).
 +
 +----
  
 ===== check distro ===== ===== check distro =====
Line 20: Line 43:
  
 pending pending
 +
 +----
 +
 +===== dd =====
 +
 +==== wipe a disk ====
 +
 +Fill the disk with all zeros (may take a while; it switches every bit to 0):
 +
 +
 +<code>
 +dd if=/dev/zero of=/dev/sdX bs=1M 
 +
 +# replace X with the target drive letter.
 +</code>
 +
 +To secure wipe, populate the entire disk with random data rather than zeros (takes longer):
 +
 +<code>
 +dd if=/dev/urandom of=/dev/sdX bs=1M 
 +
 +# replace X with the target drive letter.
 +</code>
 +
 +Sincd ''dd'' does not have a verbose setting, you can get some visual feedback with this (run each in a separate term window):
 +
 +<code>
 +watch vmstat -d
 +htop
 +</code>
  
 ---- ----
Line 146: Line 199:
  
 ^  Option  ^ Description ^ ^  Option  ^ Description ^
-|  -a, –all  | Print all remote mounts in the format hostname:directory, where hostname is the name of the client and directory is the root of the filesystem that has been mounted. | +|  ''-a''            | Print all remote mounts in the format hostname:directory, where hostname is the name of the client and directory is the root of the filesystem that has been mounted. | 
-|  -d, –directories  | List directories that have been remotely mounted by clients. | +|  ''-d''            | List directories that have been remotely mounted by clients. | 
-|  -e, –exports  | Print the list of exported filesystems. | +|  ''-e''            | Print the list of exported filesystems. | 
-|  -h, –help  | Provide a short help summary. | +|  ''-h''            | Provide a short help summary. | 
-|  no-headers  | Do not print headers. | +|  ''--no-headers''  | Do not print headers. | 
-|  -v, –version  | Report the current version of the program. |+|  ''-v''            | Report the current version of the program. |
  
 ---- ----
Line 177: Line 230:
  
 <code> <code>
-tee [OPTIONS] [FILE]+tee [OPTIONS] [FILE_NAMES]
 # #
 # OPTIONS : # OPTIONS :
Line 188: Line 241:
  
 <code>[cli program] | tee output_file.txt</code> <code>[cli program] | tee output_file.txt</code>
 +
 +To strip off the color codes, pipe through sed: 
 +
 +<code>
 +[cli program] | sed -r 's/\x1b\[[0-9;]*m//g' | tee output_file.txt
 +
 +#  -r   use extended regular expressions
 +#     s/regexp/replacement/
 +# \x1b  The ASCII "escape" character (octal: \033, hex: \x1B or ^[ , or in decimal: 27).
 +#       Used to start a series of characters called a control sequence or escape sequence
 +</code>
 +
 +And you could always alias that in your ''.bashrc'' file:
 +
 +<code>
 +alias tee="sed -r 's/\x1b\[[0-9;]*m//g' | tee"
 +</code>
  
 ---- ----
  
 +===== tr =====
 +
 +**Translate:** Use this to (among other things) convert lower case to upper case. Example:
 +
 +<code>
 +sha256sum filename.ext | tr [:lower:] [:upper:]
 +</code>
 +
 +----
  
 ===== untar ===== ===== untar =====
general_commands.1664159066.txt.gz · Last modified: by gman