Difference between revisions of "Linux - Smart Linux Tricks"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:


= Restart a service =
= Restart a service =
<code>sudo service FOOBAR restart</code>
* <code>sudo service '''FOOBAR''' restart</code>


or
or


<code>sudo systemctl restart FOOBAR.service</code>
* <code>sudo systemctl restart '''FOOBAR'''.service</code>


Where "FOOBAR" is the name of the service you want to restart...
Where "'''FOOBAR'''" is the name of the service you want to restart...


= Taking a screenshot (in Mint Cinnamon) =
= Taking a screenshot (in Mint Cinnamon) =
Line 17: Line 17:
{{!}}-  
{{!}}-  
{{!}} Take a screenshot
{{!}} Take a screenshot
{{!}}  <code>Print</code>
{{!}} ''' <code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Take a screenshot of a window
{{!}} Take a screenshot of a window
{{!}} <code>Alt</code> + <code>Print</code>
{{!}}   <code>Alt</code> + '''<code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Take a screenshot of an area
{{!}} Take a screenshot of an area
{{!}} <code>Shift</code> + <code>Print</code>
{{!}}   <code>Shift</code> + '''<code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Copy screen to clipboard
{{!}} Copy screen to clipboard
{{!}} <code>Control</code> + <code>Print</code>
{{!}}   <code>Control</code> + '''<code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Copy window to clipboard
{{!}} Copy window to clipboard
{{!}} <code>Control</code> + <code>Alt</code> + <code>Print</code>
{{!}}   <code>Control</code> + <code>Alt</code> + '''<code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Copy area to clipboard
{{!}} Copy area to clipboard
{{!}} <code>Shift</code> + <code>Control</code> + <code>Print</code>
{{!}}   <code>Shift</code> + <code>Control</code> + '''<code>Print</code>'''
{{!}}-  
{{!}}-  
{{!}} Toggle recording desktop
{{!}} Toggle recording desktop
{{!}} <code>Shift</code> + <code>Control</code> + <code>Alt</code> + <code>R</code>
{{!}}   <code>Shift</code> + <code>Control</code> + <code>Alt</code> + <code>R</code>
{{!}}}
{{!}}}
 
'''<code>Print</code>''' may have its own special label on your keyboard. On mine the '''<code>Print</code>''' key is labeled '''<code>PrtSc</code>'''.
<code>Print</code> may have its own special label on your keyboard. On mine the <code>Print</code> key is labeled <code>PrtSc</code>.


= Testing Network Connectivity =
= Testing Network Connectivity =
Line 44: Line 43:
== A handy little script: ==
== A handy little script: ==


#!/bin/bash  
#!/bin/bash  
  if nc -zw1 pfSense 443
  if nc -zw1 pfSense 443
  then
  then
Line 53: Line 52:
   exit
   exit
  fi
  fi
Uses [https://linux.die.net/man/1/nc netcat] (nc) to simply check if the router ([[NetMan - pfSense{{!}}pfsense]]) is currently findable by name & responding to HTTPS (port 443).
Uses [https://linux.die.net/man/1/nc netcat] (nc) to simply check if the router ([[NetMan - pfSense{{!}}pfsense]]) is currently findable by name & responding to HTTPS (port 443).


Then either tells you if it's OK or asks for your password to restart the [https://www.man7.org/linux/man-pages/man8/systemd-resolved.8.html DNS resolver].
Then either tells you if it's OK or asks for your password to restart the [https://www.man7.org/linux/man-pages/man8/systemd-resolved.8.html DNS resolver].


= Kind of a silly little on-liner to paint a rainbow in the terminal... =
= Less "Useful" Stuff =
 
== Kind of a silly little on-liner to paint a rainbow in the terminal... ==


*<code>yes "$(seq 231 -1 16)" {{!}} while read i; do printf "\x1b[48;5;${i}m\n"; sleep .02; done</code>
*<code>yes "$(seq 231 -1 16)" {{!}} while read i; do printf "\x1b[48;5;${i}m\n"; sleep .02; done</code>


= Create custom fortune cookies files =
== Create custom fortune cookies files ==


#Open your favourite editor and add the strings that you want to be shown when running "fortune" in terminal. BE SURE to add a single line with a letter % in it, between every string.
#Open your favourite editor and add the strings that you want to be shown when running "fortune" in terminal. BE SURE to add a single line with a letter % in it, between every string.
Line 70: Line 72:
#Might wanna put this in <code>/usr/share/games/fortunes</code> if you want it to actually work tho...
#Might wanna put this in <code>/usr/share/games/fortunes</code> if you want it to actually work tho...
(Do note... It's a <code>sudo</code> thing...)
(Do note... It's a <code>sudo</code> thing...)
= Some other tips... =
= Some other tips... =
* [https://www.cyberciti.biz/faq/linux-copy-clone-usb-stick-including-partitions/ Copy and clone USB stick including partitions]
* [https://www.cyberciti.biz/faq/linux-copy-clone-usb-stick-including-partitions/ Copy and clone USB stick including partitions]
* [https://www.cyberciti.biz/tips/how-do-i-save-recover-data-from-crashed-disks-with-dd-and-ddrescue-command.html Save and Recover Data From Crashed Disks With ddrescue Command Like a Pro]
* [https://www.cyberciti.biz/tips/how-do-i-save-recover-data-from-crashed-disks-with-dd-and-ddrescue-command.html Save and Recover Data From Crashed Disks With ddrescue Command Like a Pro]
* [[Linux - Process Supervision using Monit{{!}}Process Supervision using Monit]]
* [[Linux - Process Supervision using Monit{{!}}Process Supervision using Monit]]
* [https://www.youtube.com/watch?v=C3sPd3slAho How to Make Linux Hate You]
* [https://unix.stackexchange.com/questions/254477/linux-alternative-to-altnumpad-codes Linux alternative to alt+numpad codes]
* [https://unix.stackexchange.com/questions/254477/linux-alternative-to-altnumpad-codes Linux alternative to alt+numpad codes]
* [https://unix.stackexchange.com/questions/159094/how-to-install-a-deb-file-by-dpkg-i-or-by-apt How to install a deb file, by dpkg -i or by apt?]
* [https://unix.stackexchange.com/questions/159094/how-to-install-a-deb-file-by-dpkg-i-or-by-apt How to install a deb file, by dpkg -i or by apt?]
Line 83: Line 85:
** Right click on an empty-is spot...Verify it's not in '''Panel edit mode'''
** Right click on an empty-is spot...Verify it's not in '''Panel edit mode'''
* [https://forums.linuxmint.com/viewtopic.php?t=249705 <nowiki>[SOLVED]</nowiki> gnome-keyring-daemon prevents shutdown]
* [https://forums.linuxmint.com/viewtopic.php?t=249705 <nowiki>[SOLVED]</nowiki> gnome-keyring-daemon prevents shutdown]
 
[[Category:Linux]]
=  =
[[Category:Knowledge]]

Latest revision as of 18:28, 27 January 2022

A collection of tips & tricks for using Linux...

Restart a service

  • sudo service FOOBAR restart

or

  • sudo systemctl restart FOOBAR.service

Where "FOOBAR" is the name of the service you want to restart...

Taking a screenshot (in Mint Cinnamon)

Here are the default shortcuts. You can customize them in Keyboard Settings, as shown in the image that started this post.

Action Shortcut
Take a screenshot Print
Take a screenshot of a window Alt + Print
Take a screenshot of an area Shift + Print
Copy screen to clipboard Control + Print
Copy window to clipboard Control + Alt + Print
Copy area to clipboard Shift + Control + Print
Toggle recording desktop Shift + Control + Alt + R

Print may have its own special label on your keyboard. On mine the Print key is labeled PrtSc.

Testing Network Connectivity

A handy little script:

#!/bin/bash 
if nc -zw1 pfSense 443
then
  echo "We have DNS..."
else
  echo "NOPE!  No DNS..."
  sudo systemctl restart systemd-resolved
  exit
fi

Uses netcat (nc) to simply check if the router (pfsense) is currently findable by name & responding to HTTPS (port 443).

Then either tells you if it's OK or asks for your password to restart the DNS resolver.

Less "Useful" Stuff

Kind of a silly little on-liner to paint a rainbow in the terminal...

  • yes "$(seq 231 -1 16)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .02; done

Create custom fortune cookies files

  1. Open your favourite editor and add the strings that you want to be shown when running "fortune" in terminal. BE SURE to add a single line with a letter % in it, between every string.
  2. Save this file to whatever file name you want; this guide uses "yourlist" as example.
  3. When done adding strings, the following command will create a .dat file for your cookie file, which contains a header structure and a table of file offsets for each group of lines. This allows random access of the strings.
    • strfile -c % yourlist yourlist.dat
  4. Run fortune yourlist to eat the fruit of your work. That's it!
  5. Might wanna put this in /usr/share/games/fortunes if you want it to actually work tho...

(Do note... It's a sudo thing...)

Some other tips...