Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

23 September 2017

Linux Ubuntu Server Important Commands

  • Adding new user: adduser {username}
  • Adding user to sudo group (seperti administrator) gpasswd -a {username} sudo
  • Change user from root su - {username}
  • Update package dengan versi terbaru seandainya ada, atau updating packages dari repository sudo apt-get update
  • Upgrade software dengan versi terbaru sudo apt-get upgrade
  • Memberi nama kepada host (hostname) echo "{yourHostname}" > /etc/hostname
  • Editing hosts /etc/hosts file nano /etc/hosts
  • Editing local timezone dpkg-reconfigure tzdata
  • Setelah kamu menginstall MongoDB, kamu bisa men-run mongodb server dengan sudo service mongodb start
  • Untuk melihat daftar program yang sedang berjalan 'running processes' ps -ef
  • Untuk menghentkan suatu program atau running process kill {processID} atau kill -9 {processID}
  • Seandainya kamu menggunakan 'putty' untuk mengakses remote server, pasti kamu tahu bahwa ketika kita mengakhiri suatu session, maka program yang berjalan di foreground akan mati. Untuk mengakalinya, kita bisa menggunakan programm 'screen'. Setelah kamu menginstall screen sudo apt-get install screen, kamu bisa memulai screen dengan mengetik screen dan untuk keluar dari session tanpa mematikan process yang sedang berjalan kamu bisa men-detach screen dengan CTRL + A + D. untuk kembali masuk ke screen yang tadi kamu detach, kamu bisa ketik screen -r {screenID} untuk men-rettach screen tersebut

24 February 2017

How to access your windows documents folder from the ubuntu bash

  1. make sure you are in root. cd ~
  2. type in cd /mnt and ls to list the content
  3. Now you can go to the volume where your data stored using cd path/../
  4. To go to 'Documents' from root, cd /mnt/c/Users/YourUserName/Documents

How to install Ubuntu linux bash on windows 10

As developer, it sometimes easier to use bash to do some process. e.g. it's easier to install Git from the bash and also it's easier to commit a file or create and delete a branch from the command line.

Steps:
  1. Go to start >> settings >>  Update & security
  2. Go to For developers and active the Developer mode radio button. 
  3. Go to Programs and Features >> Turn Windows features on or off
  4. Select the check box on Windows Subsystem for Linux(Beta)
  5. Reboot your computer
  6. To use the bash, go to start, type in "Ubuntu" or "bash"

22 February 2017

Ruby on Rails | Production

Add Admin role in Production

  • Go to heroku console heroku run rails console grab the user you want to set to admin. user = User.find(id) or user = User.first and use this command to toggle the admin from false to true. user.toggle!(:admin)
  • Rails console at heroku

21 February 2017

Git | Github | Basic Knowledge

  • If we work on feature of an application, we have to be careful that changes that have been made aren't going to break the application. In Git, we have a master branch where the application is stored in production and we can also have a feature branch to work on a feature in development. Any changes made in this branch will not affect our master branch. this allows many developers to work on different features of an application without touching the application in production. 
  • to create a new branch type in this command in the application directory: git checkout -b branchName
  • To check in what branch you are currently in and to see all existing branches in git: git branch (your current location will be marked with asterisk)
  • To go back to master branch: git checkout master
  • When creating new branch, keep in mind that you cannot "git push" from your new branch. You'll have first to create a new branch in your github. You can use this one command line to set up a new branch and pushing all at once: git push --set-upstream origin yourNewBranch
  • If you're using Rubymine and you want to merge your branches. I recommend to use merging function from Rubymine interface, not from terminal. I often have merging issues wenn merging from terminal. 
  • Merging is done from the master-branch otherwise changes wont be merge to master and you'll get a message "branch is already up to date.

Useful Command Line

  • To delete a branch (if you're in master branch): git branch - d branchName
  • To delete a folder in git but not in local git rm -r --cached myFolder

Virtual Box | Windows Host & Ubuntu Guest | Shared Folder

Follows this steps to create a shared folder between windows host and ubuntu guest

  • Create shared folder at Vbox -> settings -> Shared Folders -> plus button -> specify path 
  • Go to your ubuntu guest create new folder somewhere: sudo mkdir newFolder
  • Mount your shared folder to the new folder you just created sudo mount -t vboxsf sharedFolder newFolder change shared folder with the folder you specified in Virtual box settings