Gibberish

Posts tagged ‘linux’

Run VIM

I’m a fan of SublimeText and it suits well for my work (I code Python, MATLAB, LaTeX and sometime C++). People often tell me that if something works well for me, I shouldn’t change it. However, I’m a curious guy and VIM is recommended to me several times in … 10 years and I was too lazy to try it. So I write this blog post as a simple tutorial, a simple first step for myself. If it isn’t suit my work-flow, it’s still nice to know about this tool. I also hope this would be useful for other people who want to learn VIM from zero.

There is a joke from linux users about Windows user: “The easiest way to generate a random string is telling a Windows User type in VIM”. Starting as a Windows user, it’s funny that it was true for me the first time I used VIM (long time ago) and I don’t have time to use it again, until recently.

To install vim:

 sudo apt-get install vim 

How to create a text file with vim:

Open vim by opening the terminal and input:

vim

Then press Enter, what we should have is like this:

To go to inter mode, press i, to return to command mode (default), press Esc.

We can navigate through text in the command mode with directional buttons as H-J-K-L, equivalent to left-up-down-right.

Now as told earlier, press i to go to Insert mode (VIM will tell us with INSERT at bottom left corner). Insert whatever text you like.

Now, to save it, we need

w

command, press Esc to quit Insert mode, type

:w testtxt.txt

and press Enter.

As a result, VIM will create a testtxt.txt file, note that because I run the terminal in Home folder, then the saved file is located there.

[to be continued…]

 

Advertisements

Feel more powerful in Ubuntu: kill all

This is some useful trick to kill task in Ubuntu (draft)

  • ps and kill

ps -A
sudo kill -9 pid

With the pid is the number we get from the first line.

  • Feel like windows’ task manager:
    sudo gnome-system-monitor
    This will open the system monitor tool, there we can view CPU+ Ram information, and a list of running program, kill what you need there by right click and choose End Process or Kill process

Those two methods can come to handy when we’re stuck, for example, in Ubuntu Software Center, that a package is not dpkg completely and the dpkg folder is locked and we can’t install another software due to this (installing apps in Ubuntu is one by one)

List of 5 (-1) apps you need on your Ubuntu as a newbie programmer

Everybody is not the same, but I assume that when you move to Linux in general, and Ubuntu in particular (Kubuntu, Xubuntu etc…), you will work with code, terminal .. a lot. So here is a list of very necessary apps that definitely should be installed on your lovely ubuntu machine. I’ll pass Synaptic Package Manager since it’s very popular (but it’s not installed by default for fresh Ubuntu, at least 12.04, I haven’t try another Ubuntu’s version yet), or ThunderBird, I will concentrate on apps that are useful, but probably not 100% people will know.

1. Ubuntu Tweak:

Don’t understand why it’s still not put in official ubuntu repository, since it’s really useful and give us a lot of shortcuts to system utilities: clean cache, modify desktop etc…

Link to apps: http://ubuntu-tweak.com/

2. VLC player: (all people know it)

This is a big, generous guy that does stuff smoothly, and this is one of the reasons why opensource users should be proud of: support almost every file type, fast, a lot of tools to play with. On Windows, before VLC, I use Media Classic, I also try WinAmp, Foobar, WMP, but with VLC, I forget them right away (and android users, FYI, VLC is available for you too)

3. System Indicator:

Ubuntu leaves us a system tray to put there useful informations, one of them should be the system indicator

Install it by

sudo apt-get install indicator-multiload

This will show us the CPU, Memory, Network… usage information as a dynamic diagram, also provide us a shortcut to system-monitor, just like Task Manager in Windows.

4. Geany IDE:

We can call this a text editor, but the way Geany helps us coding Python and some other languages is just genius. Clean text, easy commenting, intergrated terminal with clean view etc make it better for developper than gEdit, also, it’s easier than VIM. If it helps we do the jobs, it’s useful, just that simple.

Geany can be found in Ubuntu Software Center with ‘geany’ keyword.

5. Right Click Open Terminal here in nautilus.

If you’re using GNOME desktop and nautilus as your default file explorer, then the tool ‘Open in terminal’ in the context menu when clicking right click when you’re in some folder turns out to be extremely useful, trust me. The terminal will be open right there, with the path already into that folder, no need Ctrl+Alt+T and cd to that folder.

That utility can be installed by

sudo apt-get install nautilus-open-terminal

After installation is finished, restart nautilus, you’ll see that option when right-clicking in the folder, pretty awesome, huh? I stop at this point, there are still a lot of other apps (free + paid) but 5 is a nice number. Next time we’ll talk a bit about C++, Android tools, and some graphics tool for Presentation and Illustration.

Restore NVidia display on Ubuntu 12.04 after suspend mode

Suốt ngày lỗi kĩ thuật, đm. Nguyên đống kết quả chạy cả tối mất sạch, phát nản.

When reopen from suspend mode of a NVidia PC, probably we will see a fucking weird mess of color (display problem), to solve it, do as below:

1. Ctrl + Alt + F1, log in as usual via terminal

2. Run code:

sudo service lightdm restart

That’s all, the graphic log-in interface should appear.

For the lost data, sorry.

Side note: Linux + Windows 8

To boot Linux, enable the Legacy Boot Option. (ignore the raid notification for the mean time)

To boot Windows 8: reactivate UEFI boot mode. (Win8 seems slower though, maybe no more SSD’s strong points).

I hate this world.

 

Tag Cloud

%d bloggers like this: