Made a quick script thatβll keep checking a file and run it if itβs been changed.
Unlike watch itβll only run the file once per modification instead of once per interval.
sudo nano /usr/bin/watchforchange
# Copy/paste the following:
#!/usr/bin/env sh
FILEPATH=$1
INTERVAL=$2
if [ -z "$INTERVAL" ]; then INTERVAL=1; fi
if [ ! -f "$FILEPATH" ]; then echo "Not a file"; exit; fi
while true
do
LAST_MODIFIED=`stat -c "%Y" $FILEPATH`
if [ "$LAST_MODIFIED" != "$LAST_MODIFIED_LAST" ]; then
LAST_MODIFIED_LAST=$LAST_MODIFIED
clear
$FILEPATH
fi
sleep $INTERVAL
done
# Save & exit
sudo chmod +x /usr/bin/watchforchange
# Test:
watchforchange ./MY_PROJECT.sh 0.5
watchforchange ./MY_PROJECT.sh
If you want to know your public IP you can do that comfortably from the terminal:
wget http://ipinfo.io/ip -qO -
You can also use net-tools to find what is on your local network:
arp -a
Because that was very basic, letβs go back to the Debian world with one very important command. You all probably know how to edit your sources list involving a text editor that points to /etc/apt/sources.list. But you can have it more automated, just type:
sudo apt edit-sources
Select an editor. To change later, run 'select-editor'.
1. /bin/nano <---- easiest
2. /usr/bin/vim.basic
3. /usr/bin/vim.tiny
4. /bin/ed
Choose 1-4 [1]:
It will only make sense on Debian proper and its derivatives. I would not use it on Ubuntu based distributions. But you still can have a look at it anyway.
In a default Debian install it makes sense because you can switch Debian releases (stable, unstable, experimental), do release upgrades and add non-free sources and even other repositories to your install.
Not so much a command line trick than a continuation of editing and choosing apt sources.
Linux Mint has a nifty feature where they choose the fastest mirror for their Mint and Ubuntu repos. You can do that by yourself in Debian with the program netselect-apt.
If you e.g. run Debian sid enabled with experimental then just run:
netselect-apt sid and later netselect-apt experimental
and it will print out the best options. Edit your sources list accordingly.
I am not sure which back-end is used by Linux Mint.
Nice. My DE is xfce. I have the following script that runs every 10 seconds and reports the various temps to a panel on my second monitor:
#!/bin/bash
#The following is for the Asus P8P67 MB
sensors 2>/dev/null | grep Core | cut -b1-24 | awk '{print " " $0}'
One of the things I love about Linux is that you can actually run βwidgetsβ like this all of the time and not take a performance hit. Back in my days of Windoze, I would never run a weather widget or temp widget as it would make the system crawl and leak resources.
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Lets you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and directory names