Category Archives: linux
Accessing localhost from virtual machine or Android Emulator
Two problems- one solution i.e. 10.0.2.2
Sometime back, I faced an issue that I had installed a virtual machine on mu linux machine. I had a server/ website running which I wanted to access from virtual machine. http://localhost/site simply refused to work. A little googling helped with an answer to use http://10.0.2.2/site
Again faced similar issue. Was trying to access local website from within android emulator. Again localhost refused to work. And guess who was the rescuer? yep 10.0.2.2 again
Quick notes for Linux commands- 2
Creating shortcuts in linux- It can be a pain to write down long linux commands again and again. So here is how you can create quick shortcuts for all reusable commands.
1. Edit bashrc: You will have a “.bashrc” file in your root folder. open it up for editing (emacs .bashrc) and add commands to be added for shortcut at the bottom of this file like
alias connect=’ssh kamal@kamal.com’
This will simply create a shortcut for the command ‘ssh kamal@kamal.com’ which will get executed by typing connect.
2. Compile bashrc: Before you can actually use your shortcuts, you will need to compile the .bashrc file by
. .bashrc
3. Use shortcuts: Just type the shortcut command connect and you will see that it actually executes the command for which ‘connect’ is an alias.
Quick notes for Linux commands- 1
1. How to check if a user exists on a node?
emacs /etc/passwd (look for u
2. How to check if a group exists on a node?
emacs /etc/group
3. How to check number of lines in a file?
wc -l file.name
4. How do I securely connect to a node?
ssh kamal@node.com
references: http://www.cyberciti.biz/faq/linux-check-existing-groups-users/