Tuesday, January 10, 2012

Editing config files in linux pico vs vim

As it appears Linux servers usually run without graphical shell and you only can arrange it using command prompt(terminal). I am trying Ubuntu 11 on my laptop and by the way u can start graphical shell with startx command if you need and to start cmd (terminal) in grahic mode press Ctl+Alt+T. In linux there are lots of config editing in files that you need to do an of course you need an editor. Out of the box I have pico. just type >sudo pico /etc/group


The sudo before pico means "Super User DO"  (RunAsAdmin).  If you omit sudo the file will open but in readonly mode. After editing press Ctl+X then Y(es) and [Enter].

By the way the file /etc/group defines groups in your system. To just list content use >less /etc/group

Keep in mind instead of Alt+F4 I use Ctl+Z to close active program in terminal screen.

Everything is great I can edit my groups file :).

But one problem is that if the file is long it is hard to edit it without syntax highlighting. So you can install vim editor using >sudo apt-get install vim-gnome

After installing vim you can use it instead of pico:>sudo vim /etc/group

now if you are following thease steps and tried editing file in vim you may be surprised, you cannot edit anything and even close it. And if you google for vim commands you can find quit command which is :q! . After reading a little I understood that by default vim is not in edit mode , it is in command mode , meaning everything you type is treated as a command to vim if you want to insert a line into vim just press [i] and you will see that you can edit the file. To go back to command mode press [ESCape]. Now if you want to close program write :q  in command mode (the command starting with : will appear in the bottom). If vim is unable to close you can force it using :q! which immediately quits vim without saving any changes. To save and close type :wq and :w filename to save using different filename(save as).

Thats all happy config editing :)

Saturday, December 31, 2011

Hello Linux

Hi Im a hardcore Windows dev using great tool VisualStudio2010, .NET framework, ASP.NET and other MS tools. Using Windows for my everyday tasks I got used to it but something forced me to install Linux on my Laptop. I cant say wether one is better than another although some say that Linux is and always will be faster than windows thats not my pont and with with Windows8(have seen just devprev) things might change but I think Linux also has contributions into Win8.
I have installed Ubuntu 11 on laptop. First I felt like a fish out of water. And I cant use cmd (it is called terminal here and can be opened with CTL+ALT+T). I cant find things when I need them, Ubuntu uses new desktop env called Unity and it is too simple I cant use it. To be able to configure things (except basic things) you need to configure additional software. But if you know which  app you need it is easy to install it , I even began using cmd  oops terminal to install software >sudo apt-get install interestingAppName. By the way by my Linux user does not have permissions to do many things. And I need to use sudo in front of the command and as I understood it impersonates command as root user.
 The other problem I had was when trying to change CLASS_PATH environment variable. I found that in a file /ets/environment and again I dont have permission to change that text file and I have to impersonate.
terminal> sudo pico /etc/environment
after changing the content press CTL+O to save.
Some apps are opensource and you need to compile them to use. Java programs use ant scipts. An app I have tried has a ANT.sh file (*.sh=>*.bat) and first I didnt know how to use it. At last had success with this command. It ishummiliating to be unable performing such simple tasks :(.
terminal> sudo bash ant.sh UsedAntBuildName

I need a dictionary CMD to SH command list :)