lwc:programming:bash

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lwc:programming:bash [2022/11/04 14:04] John Harrisonlwc:programming:bash [2024/09/27 12:48] (current) – [Superuser] John Harrison
Line 121: Line 121:
 convert -threshold 75% input.pdf output.pdf convert -threshold 75% input.pdf output.pdf
 </code> </code>
 +
 +determine resolution of images inside a pdf: ''pdfimages -list EXAMPLE.pdf''
 ==== INTERNET ==== ==== INTERNET ====
  
-**ssh no password:** follow [[http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/|these]] instructions +  * **ssh no password:** follow [[http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/|these]] instructions 
- +  **vpn on Linux 64 bit**: follow [[http://kb.mit.edu/confluence/display/istcontrib/Cisco+AnyConnect+Certificate+Error+on+Linux|these]] instructions 
-**vpn on Linux 64 bit**: follow [[http://kb.mit.edu/confluence/display/istcontrib/Cisco+AnyConnect+Certificate+Error+on+Linux|these]] instructions +  **Remote Desktop (VNC through SSH tunnel)** 
- +    * ssh -L 5901:localhost:5900 UserName@host.com 
-**Remote Desktop (VNC through SSH tunnel)** +    * (in a separate terminal): xtightvncviewer -encodings tight localhost:
- +  * ssh to a host through another (jump) host 
-  * ssh -L 5901:localhost:5900 UserName@host.com +    * use ''-J'' i.e. ''ssh -J user@jumphost user@host'' 
-  * (in a separate terminal): xtightvncviewer -encodings tight localhost:+    * also works for scp i.e. ''scp -J user@jumphost file user@host'' 
  
 **DHCP Server and Firestarter (on 12.04)** **DHCP Server and Firestarter (on 12.04)**
- 
   * sudo apt-get install dhcp3-server   * sudo apt-get install dhcp3-server
   * sudo ln -s /etc/dhcp/dhcpd.conf /etc/dhcpd.conf   * sudo ln -s /etc/dhcp/dhcpd.conf /etc/dhcpd.conf
Line 181: Line 181:
  
 <code>sudo lsof -i:8078</code> <code>sudo lsof -i:8078</code>
 +==== Superuser ==== 
 +=== Execute sudo cmd without needing to type password === 
 +== Staying Safe == 
 +  - backup ''/etc/sudoers'' file i.e. copy to somewhere safe 
 +  - leave at least one terminal window open as root 
 +  - edit ''/etc/sudoers'' with ''visudo'' not ''sudo''. It's a wrapper for your already configured editor (not necessarily vi) 
 +== The Magic == 
 +  * create a wrapper script that does all your magic for you. Don't add sudo to the cmds in the wrapper script 
 +  * using ''visudo'' add to the end of your ''/etc/sudoers'' file ''USERNAME ALL=(ALL:ALL) NOPASSWD: FULL_PATH_TO_SCRIPT'' substituting in USERNAME and FULL_PATH_TO_SCRIPT as necessary 
 +  * to execute the cmd without password type ''sudo FULL_PATH_TO_THE_SCRIPT''
 ===== Misc ===== ===== Misc =====
    * write to dmesg: ''echo Some message > /dev/kmsg''    * write to dmesg: ''echo Some message > /dev/kmsg''
-   * add timestamp to log entries that are piped. Add to pipe: '' awk '{ print strftime(), $0; fflush() }' ''+   * add timestamp to log entries that are piped. Add to pipe: ''gawk '{ print strftime(), $0; fflush() }' '' 
 +     * ''awk'' is supposed to do this but at least when then piping to ''grep'' only ''gawk'' worked.
    * remove package with all its dependencies. As root: ''apt-get purge `apt-get -s purge <PKG> | grep '^ ' | tr -d '*'`''    * remove package with all its dependencies. As root: ''apt-get purge `apt-get -s purge <PKG> | grep '^ ' | tr -d '*'`''
    * [[https://tldp.org/LDP/abs/html/tabexpansion.html|autocomplete parameters in bash script]]    * [[https://tldp.org/LDP/abs/html/tabexpansion.html|autocomplete parameters in bash script]]
    * traverse through to see what is using disk space: ''du -cha --max-depth=1 /var | grep -E "M|G"''    * traverse through to see what is using disk space: ''du -cha --max-depth=1 /var | grep -E "M|G"''
 +   * find out what app is on a particular port: ''netstat -anpe | grep "1234" | grep "LISTEN"''
  
  • lwc/programming/bash.1667588647.txt.gz
  • Last modified: 2022/11/04 14:04
  • by John Harrison