Linux
How to add publickey to Unix SSH when VNC like console lacks of copy/paste functionality
1. Copy Your publickey to a file and add it to some webpage (for ex. pubkey.txt and added to tomain example.com) 2. Log on to console as user needed 3. Get remote file to under Your account: curl 'https://example.com/pubkey.txt' > tempfile 4. Add it to authorized_keys file: cat tempfile >> .ssh/authorized_keys
Snippet for replacing certain code within PHP code
Replaces/searches by row on unix commandline: find folder/* -type f -name \*.php -exec sed -i.bak.php "s/function_name('blahblah');/\$variable['blahblah'];/" {} \; – searches in certain folder – searches in .php files – makes backup of modified files NB! Some things must be escaped with \ mark
All local mail sent out via external smarthost (Exim4 on Ubuntu 16.04)
Steps to do: 1. First run (start basic exim conf): sudo dpkg-reconfigure exim4-config And use these config options: General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail System mail name: IP-address to listen on for incoming SMTP connections: 127.0.0.1, ::1 Other destinations for which mail is accepted: Machines to relay […]
NetBeans on Ubuntu
Earlier I had version NB 8.0.* on my laptop – worked like a charm. On Ubuntu 16.04 I installed NB 8.1.* via official repo – and that’s where the problems started… I had no luck enabling auto-completion from included file – Interwebs was full of probable “solutions” to remove cache and/or to check settings and/or […]
Bash script to run via command-line to lowercase all file- and folder names in current folder recursively
#!/bin/bash # first, rename all folders for f in `find . -depth ! -name CVS -type d`; do g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` if [ "xxx$f" != "xxx$g" ]; then echo "Renaming folder $f" mv -f "$f" "$g" fi done # now, rename all files for f in `find . ! -type d`; […]
How to change Linux files/folders permissions under same directory recursively 644/755
One approach would be: find . -type d -print0 | xargs -0 chmod 0755 find . -type f -print0 | xargs -0 chmod 0644 Other approach: find /full/path/to/your/files -type f -exec chmod 644 {} \; find /full/path/to/your/files -type d -exec chmod 755 {} \; NB! Please do note that -f option is for files and […]
Nifty feature to change text inside large file over Linux commandline
sed -i 's/original/new/g' file.txt sed = Stream EDitor -i = in-place (i.e. save back to the original file) s = the substitute command original = a regular expression describing the word to replace (or just the word itself) new = the text to replace it with g = global (i.e. replace all and not just […]
Letsencrypt on Ubuntu 16.04 LAMP howto commandline
1. Install Letsencrypt with apache addon: sudo apt-get install python-letsencrypt-apache 2. Generate only cert for domain letsencrypt –apache certonly If above fails: 1. For different webroot letsencrypt certonly -a webroot –webroot-path=/var/www/ -d your.domain.name 2. If apache fails or port 443 fails – do manual over HTTP letsencrypt certonly –standalone-supported-challenges http-01 NB! Apache needs fullkeychain and […]
Restoring MySQL root user privileges when corrupt (in linux)
1. On commandline (shut down mysql and start mysqld_safe without grant tables): sudo /etc/init.d/mysql stop sudo mysqld_safe –skip-grant-tables & 2. On new terminal window (log on and execute code as shown): mysql UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES; GRANT ALL ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES; 3. Kill mysqld_safe instance 4. Log […]
Torrentid ja jälgimine
Siinkohal kirjutan enda tarbeks põhiliselt kokkuvõtva teabe P2P võrgu võimalikest “turvavigadest” ja nende “parandamisest”. (Enamus lingid teistele lehtedele või nendel olev teave võib olla natuke vananenud…) Et siis… – enamus inimestest kasutab reeglina P2P networki failide jagamiseks/laadimiseks – suur osa sellest moodustavad torrentid. Viimasel ajal (loe: viimase 3 aasta jooksul) aga on hakatud “tasuta torrent […]