Posts Tagged command line

Working with Xamarin Android Player from command line

It is possible to start appropriate Android VM in Xamarin Android Player using the following command in command line on Mac

/Applications/Xamarin Android Player.app/Contents/Helpers/Xamarin Android Player.app/Contents/MacOS/Xamarin Android Player --name "Nexus 5 (Lollipop) NEW"

You can pick the information how to start it from command line using the following command (start VM first using usual way, from Xamarin Android Player):

ps -f -x | grep Xamarin

, , ,

Leave a comment

Starting command line program/script in background as job (Linux, Mac)

It is important to  use the command “nohup” and also redirect everything, otherwise the job will be killed after leaving console

nohup ./your_program_or_script_here > copyout.log 2> copyout.err < /dev/null &

On the other side, if you need just to run something in background because you are afraid that you will loose the session, the best way for it is using tmux, it can be installed with “apt-get install tmux” in Ubuntu Linux or “brew install tmux” on Mac

Open new session:

tmux new -s session_name

Attach to the lost session:

tmux attach -t session_name

, , , , ,

Leave a comment

How to create manually string for basic http authentication

If you need to test Basic authentication, you can manually add header like this into HTTP request:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

The line after Basic is formed from your username and password the following way in Mac or Linux command line:

echo -n "username:password"  | openssl base64 -base64

On the other hand, you can use “curl” directly from command line to call the request with basic authentication, use the following command (it is GET in the example below):

curl --user username:password https://your_webservice_here

, , , ,

1 Comment

Change default console editor in Linux

I do not like default console editors in Linux, if you have the same issue and want to use another editor in your terminal by default, use the following command:

update-alternatives –config editor

This command will show you alternative editors as below, select the one you like more ( I personally like mcedit, it comes together with midnight commander) 🙂

There are 5 choices for the alternative editor (providing /usr/bin/editor).

 Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
 1 /bin/ed -100 manual mode
 2 /bin/nano 40 manual mode
 3 /usr/bin/mcedit 25 manual mode
 4 /usr/bin/vim.basic 30 manual mode
 5 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number: 3

, , , , , ,

1 Comment

Install applications on Mac from command line

If you have .dmg file

  1. Mount dmg file: hdiutil mount your_favorite_app.dmg
  2. Copy app to “/Applications” folder: sudo cp -R “/Volumes/your_favorite_app/your_app.app” /Applications
  3. Unmount dmg file: hdiutil unmount “/Volumes/your_favorite_app/”

If you have .pkg file:

installer -pkg your_app.pkg -target /

, ,

Leave a comment

Disk usage in command line for Linux & Mac

Quick way to get disk usage for current folder in command line for Linux:

du * -h –max-depth=0 | sort -h

For Mac:

du -hm -d 1 | sort -n

Free disk space can be checked in both systems the same way:

df -h

 

, , , ,

Leave a comment