tiistai 20. syyskuuta 2016

Learning Linux at University

I had to learn more about Linux at the university and so far I have learned couple of handy things.


  1. You can configure nano settings with .nanorc file
  2. Add alias commands to  .bash_aliases
  3. Make some ALIAS. ls --color=auto for ls
  4. Alias O for ls -latr listing all files in order, newest at bottom.
  5. SCP files with scp filename username@host:/Where in remote
  6. ssh-keygen -t RSA -b 4096 Generates ssh keys
  7. ssh-add starts ssh-agent until computer is shutdown. 
  8. Adding id_rsa.pub file content to authorized_keys in server allows ssh without typing password
  9. in ~/.ssh create config file without file extension and set ssh configs. Like:
    Host NAME
        HostName nikiahlskog.com
        User USERNAME
        Identityfile ~/.ssh/id_rsa.pub
    Then you can just use ssh name for example.
  10. RSYNC. It copies only changed files. Very handy! use it like: rsync --progress filename user@server:dir handle -a copies folder content
  11. Crontab. Using crontab -e is dangerous. Because crontab -r empties whole table and there is no undo. Create folder for cronjobs and create file for example cron.tab add your job to the file for example: 0,30 * * * * echo `date +%Y-%m-%H\ %k:%M:%S` cron job done then add this file to crontab with crontab ~/cronjobs/cron.tab see all your cron jobs with crontab -l to remove cronjobs juse handle -e


tiistai 5. huhtikuuta 2016

Mount shared folder on Virtualbox. Windows host, linux guest.

To mount / share a folder between host and guest OS first create a folder in windows which you want to share.

For example: C:\myshare

Then assign it from the virtualbox settings-->shared folders-->+ icon: set folder path, tick Auto-Mount

Then boot up your guest os. Create a folder where you want to point the host os folder, for example /~share/. Then launch terminal and type:

sudo mount -t vboxsf myshare ~/share/

Then you should see items inside that folder.


torstai 21. tammikuuta 2016

OpenVpn save Username and Password to a file.

So I have created ShellScript which opens VPN connection but everytime it asks my password and I wanted to automate this. So do the following:

Inside your vpn key folder should be file called config.opvn or something that ends with .ovpn. Open it up and look for auth-user-pass if your file doesn't contain this add it to the bottom. Right after it add one space and filename.txt like this:

auth-user-pass vpnpass.txt

Then inside the same folder where your .ovpn file is add new file called vpnpass.txt and insert your username and password separated with enter. Like this:

myusername
mypassword

Save both files and now your VPN shouldn't ask password or username.