indictvs

Linux notes

Bash

Misc

File permissions

Processes

Kernel modules

Files/Hardware

Networking

Change extension to a bunch of files

sudo apt get install rename
# rename .org files to .md
rename 's/\.md$/\.org/' *.md

Create USB flash from iso image file (bootable too)

sudo dd bs=4M if=~/Downloads/archlinux-2016.09.03-dual.iso of=/dev/sdb && sync

Zip entire folder using terminal

zip -r ~/Desktop/myzipfile.zip ~/Desktop/MyFolder/

More find examples

Duplicity

Create an encrypted backup

duplicity --progress ~/Documents file:///media/nick/backup-dir/

Restore backup

duplicity --progress file:///media/nick/backup-dir/ /home/nick/Documents/restore/

Find and remove found files using -exec.

$ find -name "*.swp" -exec rm {} ’;’

The same, but ask first :

$ find -name "*.swp" -ok rm {} ’;’

Find duplicate files

Using fdupes to find duplicate files

 sudo apt-get install fdupes
# find duplicates
 fdupes -r /media/nick/Data/iTunes/
# find and delete after confirmation duplicates
 fdupes -r -d /media/nick/Data/iTunes/iTunes\ Media/Music/A*

Radio on the command line

mpg123

Listen to a radio station

sudo apt-get install mpg123 
mpg123 http://radiostreaming.ert.gr/ert-deftero

Play randomly your mp3 collection (at ~/Music)

mpg123 -z ~/Music/\*/\*/\*

Cmus

Cmus project page

cmus

  1. Load up your library: Pressing ‘5’ will go to the Directory browser. Locate your music directory and press ‘a’.
  2. Go to library view pressing ‘1’. You can navigate by artist/album on the left-hand side and see the tracks on the right. Press the TAB key to switch between them and ENTER to start playing the selected track. You can also use the Sorted library view by pressing ‘2’.
  3. Toggle Shuffle and continuous play: While listening to your first track, press ‘C’ (uppercase) once to toggle continuous play. I think this should be on by default. If you don’t toggle this on, the music will stop after the end of the current track. If you want to shuffle tracks press ’s’ (lowercase).
  4. Searching: If you want to find a specific artist, album or track just type ‘/’, the name you’re looking for and ENTER (eg. /Hey joe). The cursor will be on the first result. Press ‘n’ to look for the next result and ‘N’ for the previous.

Copy m3u playlist files in a folder

Run this script where the m3u playlist is stored

sed "s/#.*//g" < starFM.m3u | sed "/^$/d" | while read line; do (( COUNTER++ )); filename="{line##*/}"; cp "${line}" "/home/nick/export/starFM/$COUNTER - $filename"; done

Deactivate and activate the build in camera

- deactivate : `sudo modprobe -r uvcvideo`
- activate: `sudo modprobe uvcvideo`

Split flac, cue files

shnsplit is the program used to split tracks, while cuebreakpoints reads the break-points from file.cue and pipe them to shnsplit

# Install tools
sudo apt-get install cuetools shntool flac
# Make the split
cuebreakpoints file.cue | shnsplit -o flac file.flac

Real example

# Step 1

cuebreakpoints Album.cue | shnsplit -o flac Album.flac  -f Album.cue -t "%n. %t" Album.flac < Album.cue 

# Step 2
# fill the tags (make sure the original flac is in another dir)
cuetag Album.cue *.flac

Block internet access for a user

# Temporary block access
# for user test5
sudo iptables -A OUTPUT -p all -m owner --uid-owner test5 -j DROP

# for group test5group
sudo iptables -A OUTPUT -p all -m owner --gid-owner test5group -j DROP

Make it persistent

The iptables firewall is the built-in firewall for protecting a Linux machine from online threats. But the settings are not save upon a re-boot. This is easily alleviated by installing the iptables-persistent package for Ubuntu. Once this is installed, you will be greeted with a screen that will ask you if you wish to save your iptables rules. Answer yes to both questions and the application will save your rules safely in case of a re-boot of the desktop or server the firewall is on.

Type this command to install this application.

sudo apt-get install iptables-persistent

Lightdm set default user

Edit this file

/usr/share/lightdm/lightdm.conf.d/01\_debian.conf

Then change the command greeter-hide-users from false to true and save

greeter-hide-users=true

Wake linux from a usb keyboard

How to: https://askubuntu.com/a/1213465

The script I chose to use enables all the USB ports.

Also map this command to a key to suspend systemctl suspend

Spell check for Greek

Libre Office

sudo apt-get install myspell-el-gr

Spelling greek dict for emacs

sudo apt-get install aspell-el then change dictionary with ispell-change-dictionary

Play among us on Linux

https://www.addictivetips.com/ubuntu-linux-tips/play-among-us-linux/

Install Quake 3 on Linux

https://www.videogames.ai/How-to-Install-Quake3-on-Linux