old stuff can be found on
- https://github.com/equivalent/scrapbook/blob/master/wisdom_inside/scraps/fedora_lxde
- https://github.com/equivalent/scrapbook/blob/master/wisdom_inside/scraps/linux-unix
- https://github.com/equivalent/scrapbook/blob/master/wisdom_inside/scraps/ubuntu_linux
- https://github.com/equivalent/scrapbook/blob/master/wisdom_inside/scraps/mint-mate
nohup command &
sudo systemd-resolve --flush-caches
sudo systemd-resolve --statistics
https://vitux.com/how-to-flush-the-dns-cache-on-ubuntu/
espeak -s 250
sudo vim /etc/hostname
sudo vim /etc/hosts
sudo service hostname restart
sudo netstat -tulpn
ffmpeg -i source.mp4 -c:v libx264 -ar 22050 -crf 28 destinationfile.flv
ffmpeg ubuntu installation with libx264
(mkv) othervise default mp4 videos are crap !
cd /my/path/where/i/keep/compiled/stuff
git clone http://source.ffmpeg.org/git/ffmpeg.git
cd ffmpeg
./configure --enable-gpl --enable-libx264
make
make install
ldconfig
how to convert
# images must be in order like this:
# a1.jpg
# a2.jpg
# ...
# a709.jpg
# ..
ffmpeg -y -i "a%d.jpg" /tmp/output.m4v
# for framerate use `-r 30` option (30 is fps)
# or for lumion out Photo000001.jpg format
ffmpeg -y -i "Photo%06d.jpg" /tmp/output.m4v
-
Make sure that every user can access the common media folder on the unix side (without samba)
-
Make sure each user has a samba password set. You can set it with
sudo smbpasswd -a your_user
-
Look at /etc/samba/smb.conf: check if the line
security = user
is set in the[GLOBAL]
section -
Set your shares in /etc/samba/smb.conf, example:
# This will be accessible via `\\yourserver\allaccess` [allaccess] path = /media/common read only = no writeable = yes browseable = yes valid users = one, two, three, four create mask = 0644 directory mask = 0755 # if you set this, all files get written as this user force user = one [special] path = /home/two/onlytwo read only = no writeable = yes browseable = yes valid users = one create mask = 0640 directory mask = 0750
-
sudo service smbd restart
tput setaf 9; echo 'test text'
tput setab 7; tput setaf 9; echo 'test text with bg'
# given in ~/doge.txt you have image of doge
tput setab 7; tput setaf 9; printf '%b\n' $(cat /home/my-user/doge.txt)
if someone is ssh'd to your computer
who # list of all conected ppl ...the ip adresess are ssh connections
ps -ef | grep sshd | grep -v root | grep -v 12345 | grep -v grep | awk '{print "sudo kill -9", $2}' |sh
who
synclient TouchpadOff=1
synclient TouchpadOff=0
toggle
if synclient -l | egrep "TouchpadOff.*= *0" ; then
synclient touchpadoff=1 ;
else
synclient touchpadoff=0 ;
fi
I recommend to put this to a sh script (e.g.: ~/.hp_5330_misc/touchpadoff.sh
) and set ubuntu keyboard shortcut to trigger this script
source
- http://askubuntu.com/questions/65951/how-to-disable-the-touchpad/67724
- http://unix.stackexchange.com/questions/50440/how-to-create-script-that-toggles-one-value-in-synclient
add this to /usr/share/X11/xorg.conf.d/10-evdev.conf
# ...
Section "InputClass"
Identifier "Kensington Kensington USB/PS2 Orbit"
Driver "evdev"
MatchProduct "Kensington"
MatchDevicePath "/dev/input/event*"
MatchIsPointer "yes"
Option "ButtonMapping" "1 2 3 4 5 6 7 8"
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "3"
Option "EmulateWheelTimeout" "200"
Option "ZAxisMapping" "4 5"
Option "XAxisMapping" "6 7"
Option "Emulate3Buttons" "true"
Option "Emulate3Timeout" "50"
EndSection
it's from a discussion I cannot find as I restarted my X server (btw you need ot restart Xorg in order to this to work) therefore I have no source link. but the author was mentioning than the middle button is not working but scrolling is
replace wifi card for intell otherwise all should be good
http://hgdev.co/install-ubuntu-15-10-on-the-dell-xps-13-9343-2015-a-complete-guide/ http://hgdev.co/optimize-battery-life-on-ubuntu/
palm detection :
# to unable palm detection
synclient PalmDetect=1
or :
sudo vim /usr/share/X11/xorg.conf.d/10-evdev.conf
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "Ignore" "on"
EndSection
sudo apt-get install encfs
encfs /home/user/Documents/encrypted_folder/ /home/user/mount_point
fusermount -u /home/user/mount_point # unmount
notes:
- encrypted_folder and mount_point needs to be empty when init encrypt
- make sure you have read write permissions
ssh -i ~/Downloads/my-key.pem [email protected]
http://ubuntuhandbook.org/index.php/2014/04/enable-hibernate-ubuntu-14-04/
sudo vim /etc/systemd/logind.conf
#HandleLidSwitch=suspend
sudo restart systemd-logind
resize one image
convert my-img.jpg -resize 900x90
resize bulk / batch of images
mogrify -resize 900x900 *.jpg
bulk of images to pdf
convert *jpg -compress jpeg test.pdf
note badblocks seems to me destructive program, rather never use it on HDD of wich data you need
more info https://wiki.archlinux.org/index.php/badblocks#Testing_for_Bad_Sectors
badblocks -nsv /dev/sdb # run read-write Test (non-destructive) ...but read more
# about destructivity in that link above (will overide and return data)
e.g. You can have multiple ssh_keys on one comuputer, you may want to store one of you keys in separate encrypted container (e.g. work comupter, store personal in Truecrypt while leave work one in Home dir)
vim ~/.ssh/config
IdentityFile ~/my_mount_for_crypted_dir/personal_private key
http://stackoverflow.com/questions/84096/setting-the-default-ssh-key-location
current number of worspaces
dconf read /org/compiz/profiles/unity/plugins/core/hsize
dconf read /org/compiz/profiles/unity/plugins/core/vsize
set new number
dconf write /org/compiz/profiles/unity/plugins/core/hsize 2
source:
http://askubuntu.com/questions/447673/how-to-change-number-of-workspaces-from-command-line http://askubuntu.com/questions/459284/how-to-use-different-workspaces-on-ubuntu-14-04
keywords: myip my ip my-ip
curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
# same thing in var
myip=$(curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
echo $myip
## depricated:
#myip=$(dig +short myip.opendns.com @resolver1.opendns.com)
source: http://askubuntu.com/questions/95910/command-for-determining-my-public-ip
//192.168.1.66/MyVolume/ /mnt/my_drive cifs uid=1000,gid=1000,vers=1.0,rw,username=enrike,password=iglasias 0 0
# old
# //192.168.1.66/MyVolume/ /mnt/my_drive cifs uid=1000,gid=1000,vers=1.0,rw,username=enrike,password=iglasias,nobootwait 0 0
... or how to mount NAS folder as local linux folder
ubuntu 16.04 you need to
sudo apt-get install cifs-utils
mkdir /mnt/my_nas_drive
mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/my_nas_drive
# you can skip -o option on public
http://www.cyberciti.biz/tips/how-to-mount-remote-windows-partition-windows-share-under-linux.html
sudo apt-get install secure-delete
srm # - securely delete an existing file
smem # - securely delete traces of a file from ram
sfill # - wipe all the space marked as empty on your hard drive
sswap # - wipe all the data from you swap space.
source: http://superuser.com/questions/19326/how-to-wipe-free-disk-space-in-linux
free -m
if you run out of space on Linux (Ubuntu) server machine, you may still have enough space with
df -h
but your inodes are taken
# show inode usage overal in system
df -i
# show what folders are consuming most inod in current folder
sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
delete stuff in those folders (simple rm -rf
) ...just be carefull what you delete
source:
- http://stackoverflow.com/questions/653096/howto-free-inode-usage
- collegue Sean (thx dude)
... or how to output time in bash ... or how to output date in bash ... or how to name file with date
echo "foo_$(date +%Y-%m-%d_%s)_bar"
# foo_2014-07-07_1404729340_bar
mkdir "foo_$(date +%Y-%m-%d_%s)"
...or restart soundcard
pulseaudio -k && sudo alsa force-reload
curl server headers (As seen in NginX scrapbook )
curl -kvI https://my_application.com
curl Json POST on https:// (-k no igrore self signerd warning)
curl -i -k -H "Content-type: application/json" -H "Accept: application/json" -X POST http://0.0.0.0:3000
token
curl localhost:3000/api/v1/status -H 'Authorization: Token token="key"'
post json from a file
curl -X POST -H 'Content-Type: application/json' -d @spec/fixtures/application.json localhost:3000/api/v1/applications
ssh -t [email protected] 'tail -f ~/apps/my_app/current/log/trial.log'
or ping ip range
nmap -sP 192.168.1.*
nmap -sP 192.168.1.0-255
# sudo apt-get install mailutils # if mail comm not worknig ...also you need postfix
echo "<h1>Hi</h1><p>test hello</p>" > /tmp/my_mail_content.html
mail -a 'Content-Type: text/html' -s "some subject" [email protected] < /tmp/my_mail_content.html
sudo apt-get install x11vnc vnc-java # install
x11vnc -storepasswd # this will set up password
x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800 # open server
# add x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800
sudo vim /etc/xdg/lxsession/Lubuntu/autostart
http://linuxlubuntu.blogspot.co.uk/2011/02/setup-vnc-server-for-lubuntu.html
lunch safari
and vnc://192.168.1.123
(your IP )
trickle -u (upload limit in KB/s) -d (download limit in KB/s) application
trickle -u 15 -d 2000 /usr/bin/google-chrome-stable --incognito %U
sudo apt-get wondershader
sudo wondershaper eth1 800 200
sudo wondershaper clear eth1
http://jwalanta.blogspot.co.uk/2009/04/easy-bandwidth-shaping-in-linux.html
su
iptables -I INPUT -p tcp --dport 666 --syn -j ACCEPT
iptables -F # flush, this will reload the rules so that new changes are applyied
... of course this wont work if you are not using iptables or external firewal
http://www.tixati.com/optimize/open-ports-linux.html
nmap -sS -O 127.0.0.1
netstat -lntu
# -l = only services which are listening on some port
# -n = show port number, don't try to resolve the service name
# -t = tcp ports
# -u = udp ports
# -p = name of the program
netstat -vatn
whereis nginx
# nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx /usr/share/man/man1/nginx.1.gz
which nginx
# /usr/sbin/nginx
ffmpeg -i small.mp4 small.gif
https://davidwalsh.name/convert-video-gif
tar -zxvf backup.tar.gz
#extract to folder
tar -zxvf /tmp/nginx-1.4.4.tar.gz.1 -C /tmp
# tar only
tar -xvf /tmp/backup.tar -C /tmp
# gzip only
gzip -d /tmp/backup.gz
tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
# sudo apt install p7zip-full
7z a -p git.7z /path/to/git
# extract
7z x git.7z
``
## copmpress with aes password
encrypt
tar cz folder_to_encrypt | openssl enc -aes-256-cbc -e > out.tar.gz.enc
Decrypt
openssl aes-256-cbc -d -in out.tar.gz.enc | tar xz
Or using gpg
gpg --encrypt out.tar.gz
* http://superuser.com/questions/162624/how-to-password-protect-gzip-files-on-the-command-line
## disk usage and what's the size of directory
```bash
du -sh ./my_folder # overal directory size
df -h # whole system size & space left
du -h --max-depth=1 # what is dir is taking most spoce
keywords: space left on linux machine
delete downloaded packages, remove unnecesary kernels
Entire topic moved to miniblog here: https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md
on Ubuntu server VM I had a problem tat log was over 2GB and the system throw
No space left on device
error (and application 405 error). When I deleted the
log file the system was still complaining that it's out of space. I had to restart
the VM and for future to prevent this do this:
whatever your log directory is, empty it and then use a ramisk
for that folder: eg
mount -t tmpfs -o size=1024M tmpfs /var/log
# or /home/deploy/apps/my_app/log/
ssh-keygen -t rsa -C "[email protected]"
grep -rl 'I am a car' ./ | xargs sed -i 's/I am a car/I am a Plane/g'
grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'
grep -e 'as_json' -rl . | xargs sed -i '' 's/as_json/as_api/g'
ls -ld
xscreensaver-command -lock
sudo apt-get install motion
sudo chmod 755 /etc/motion/motion.conf
sudo chown pi:pi /var/run/motion/motion.pid
vim /etc/motion/motion.conf
# change the target_dir to /home/user/Dropbox/motion
## if you get "Failed to open video device /dev/video0: No such file or directory"
# sudo modprobe bcm2835-v4l2
# to start run
motion
setxkbmap -layout us
yum install mutt
echo "mail body" | mutt -a stats.tar.gz -s "files" -- [email protected]
yum install mail
mail -a /tmp/school_counts.csv -s 'blaa subject' "[email protected]" < /dev/null
sudo apt-get install postfix
sudo apt-get install mailutils
echo 'Teeeeest maaaaail' > mail.txt
mail -s "some subject" [email protected] < mail.txt
# if this wont work do
sudo dpkg-reconfigure postfix
ubuntu 12.04 or mint 13 date: 2013-03-20 keys: postfix, sendmail , mail rubymail, linux, send email from command line
sed -i 's/what/with_what/g' app/*/*.rb
sed -i 's/lambda/->/g' app/*/*.rb
in Ubuntu
sudo ifconfig wlan0 down
sudo ifconfig wlan0 hw ether xx:xx:xx:xx:xx
sudo ifconfig wlan0 up
in OsX
sudo ifconfig en0 ether d4:33:a3:ed:f2:12
you can generate random with:
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
remember, it depends on hardwar if it's possible to change mac adress