Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Friday, February 1, 2019

run command with sudo with piping.



You can invoke a new shell as root:
sudo sh -c 'echo clock_hctosys=\"YES\" >> /etc/conf.d/hwclock'
You could also just elevate a process to write to the file:
sudo tee -a /etc/conf.d/hwclock > /dev/null << EOF
clock_hctosys="YES"
EOF


https://unix.stackexchange.com/questions/106663/how-to-run-a-command-that-involves-redirecting-or-piping-with-sudo


--30--

Friday, January 11, 2019

Small web page template, with auto refresh.

Small refreshing web page. 

Also note on shell infinite loop to mechanize on the server side.

By running the shell script to generate the web page,  and adding the auto refresh you have a quick and dirty way to offloading information from the server via browser and simple script.

auto-refresh-code-in-html-using-meta-tags

bash-infinite-loop

Small example from temperature

<HTML>
<HEAD>
<TITLE>Odroid temp</TITLE>
<meta http-equiv="refresh" content="5">
</HEAD>
<BODY>
WEATHER-BOARD v1.6<br>
<br>======== si1132 ========<br>
UV_index : 0.01<br>
Visible : 206 Lux<br>
IR : -1486 Lux<br>
======== bme280 ========<br>
temperature : 30.18 'C<br>
temperature : 86.32 'F<br>
humidity : 31.18 %<br>
pressure : 1010.49 hPa<br>
altitude : 113.952599 m
<br></BODY>
</HTML>


--30--

Thursday, February 22, 2018

Diff on linux with lots of files


This is a post to record difference methods on linux or wherever for large numbers of files (3m to 4m)

https://stackoverflow.com/questions/4997693/given-two-directory-trees-how-can-i-find-out-which-files-differ

A utility that is useful for such compares is xargs.  A tutorial is below

http://www.linuxplanet.com/linuxplanet/tutorials/6522/1

Monday, January 11, 2016

find suid files (example using find in bash for loop iterator



Locate SUID files (just handy sounding example script snippet.

The find command also works without the -exec option.

#!/bin/bash
#  Find suid root files.
#  A strange suid file might indicate a security hole,
#+ or even a system intrusion.

directory="/usr/sbin"
# Might also try /sbin, /bin, /usr/bin, /usr/local/bin, etc.
permissions="+4000"  # suid root (dangerous!)


for file in $( find "$directory" -perm "$permissions" )
do
  ls -ltF --author "$file"
done


http://tldp.org/LDP/abs/html/moreadv.html








Friday, March 6, 2015

XFCE window manager tab setting switch window key

XFCE on cubox comes with a setting such that the tab character switches windows, rather than auto completing.

info on this page:

http://ubuntuforums.org/archive/index.php/t-1771058.html

Also

http://stackoverflow.com/questions/23418831/command-line-auto-complete-tab-key-not-work-in-terminal-for-ubuntu

Without changing any settings, use control-i to autocomplete.

Try using Ctrl-I instead of tab

For changing the setting in the XFCE xml config:

edit
~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

find the line 

<property name="&lt;Super&gt;Tab" type="string" value="switch_window_key"/>

and change it to 

<property name="&lt;Super&gt;Tab" type="empty"/>

reboot or whatever and then tab will work properly!

I have no idea why but when using vnc this file seems to override tab's normal behavior and makes it into a switch window key.

On Ubuntu 14.04, the xfce4 somehow resets the xfce4-keyboard-shortcuts.xml file each time you log in, so one needs a method to change the default

the Window manager keyboard shortcuts don't include a setting for the tab-complete Super tab, so it must be edited somewhere else.

Explanation of how to find and change what settings are in the Window Manager->Keyboard tab is here

http://forum.xfce.org/viewtopic.php?id=8860

Found explanation:
change "Switch window for same application" to clear from "alt tab"

xx