Useful Gibberish

Posts tagged ‘Ubuntu’

Hello world by fortran

This is just a very basic script to run a Hello world! program by the language Fortran in Ubuntu.

program hello
print *, "Hello world!"
end program hello

Save the text file as fortran extention, here I save it as hello.f90

To compile in, open terminal and navigate to that folder, run this:

gfortran -o hello hello.f90

Explain: This code define the compiler gcc-fortran, output file has name “hello” and the script file is “hello.f90”.
When the compilation is finished, in that folder we will see the hello program, in terminal, to run it, just input

./hello

And you will see the line “Hello world!” in the terminal window.
Have fun programming!

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.

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.

 

Batch install fonts in Ubuntu and Windows OS

Font is a beautiful thing.

To install a font, you must open it with a font viewer and click the Install button in that opened window. The problem is, when you have too much fonts and you want to install all of them in one click, it would be a big nuisance.

In Ubuntu (i use Ubuntu 12.04 LTS), we can do this trick:

Method 1:

For TTF (truetype font), we can copy all of those fonts and put them in this folder:

/usr/share/fonts/trutype

/usr/share/fonts/opentype

Method 2: Would be the same as above you can say, but this time we do it terminally 😀

In the home folder, create a hidden folder and copy all fonts there

gksu nautilus /usr/share/fonts/truetype

Then copy.

For method 1, if there isn’t the folder there, you can create it.

In window, just batch choosing the fonts and then right click –> install.

Windows sometimes makes me breath more easily. 🙂

Further reading: The difference between TrueType, OpenType and PS font

How did I install YADE for source code

The way

sudo apt-get install yade

or

sudo apt-get install yade-stable

is history. Now I have to work with CPP code, and I really have some trouble installing some of that shit, but finally it seems to be working.

First: download the source code at:

https://launchpad.net/~yade-pkg/+archive/stable or whatever link (CPP and HPP file that you are using with yade-daily can be modified or copied later, or you can download the yade-daily package, not sure, none of my business right now)

Then extract the zip file downloaded into a folder.

Open terminal inside that folder and run this:

cmake -C path_to_that_folder

Wait for the terminal to work, and wait for cmake to prepare necessary files, if somethings happen, it’s because of the missing package, view in the terminal, search for the key words of the package and install them from Synaptic (thanks God this Synaptic is on Earth, installing from terminal and code is like hell)

Once finish, cmake again, and run:

make install

what is being waited for is a list and percentage of CPP files are being configure (compiled).

That’s that. Continue my research.

[Ubuntu] Khắc phục lỗi không thấy màn hình login

Khi nâng cấp kernel hoặc có thể là tò mò táy máy cài cái gì đó trong Ubuntu (mà đa phần dân Linux ai cũng tò mò táy máy), nhiều khi phá xong khởi động lại không thấy màn hình login đâu cả, đó là vì bị mất X-Org Server (cái này chuyên quản lý card đồ họa và mấy cái linh tinh khác liên quan đến hiển thị). Vậy thì cài lại nó thôi.

Khi trong màn hình boot, chọn Linux ở chế độ Recovery, từ này trở về sau, ta sẽ làm việc trên Terminal.

[Qua một số bước đơn giản để vào màn hình chính của Terminal]

Trong màn hình của Terminal, login với tài khoản root, và chạy code sau:

sudo apt-get install xserver-xorg

Sau đó khởi động lại là xong.

Ubuntu trên lab labo chạy được rồi mừng rớt nước mét :)))))

Tag Cloud