Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Tuesday, 5 November 2013

[Ubuntu] How to use ctags

ctags with vim editor are very helpful for code walk-through. Navigation is very easy in the large code bases like kernel, where we can jump to
function/identifier definition directly using simple keys.

ctags installation:
=============
ctags can be installed in ubuntu by

sudo apt-get install exuberant-ctags

How to use ctags:
==============

1. Generate tag file for the required code base.

change your current working directory to desired code base directory using cd command.
Now, run below command

ctages -R .

Output: We see "tags" file in the current working directory after successful.
It will store all index information of functions or identifiers in the tag file.

2. Now, open any file in the current working directory using vim editor.
   Place cursor on any funtion/identifier.

3. Press ctrl + ] together. We will redirect to the file where this function/identifier is defined.

If there are multiple entries for this definition, we can check one by one by following way

Goto vim's command mode by typing ":" and type tnext (goes to next tag)

4. Once you see the required definition, use ctrl+t to go back to your base point where you did step-3


Note: Instead of step-2, we can use vim’s command mode to jump to function/identifier definition:

:tag function_name
:ta function_name

The below commands will be used to accept regular expressions.

Example, :tag /^asserts_* would find all tags that start with ‘asserts_’.
By default vim will jump to the first result, but a number of commands can be used to sort through the list of tags:

:ts or :tselect shows the list
:tn or :tnext goes to the next tag in that list
:tp or :tprev goes to the previous tag in that list
:tf or :tfirst goes to the first tag of the list
:tl or :tlast goes to the last tag of the list
To show the tags you’ve traversed since you opened vim, run :tags.

For more info on ctags, please check here

Sunday, 27 October 2013

Ubuntu Basic Commands

There are few simple commands in Ubuntu operating system those we should know before using any Ubuntu machine. These commands would be very helpful and are easy for Ubuntu machine maintenance.

Man Pages

Linux OS provides a command named "man" for reading manual pages in the system. These manual pages contains description of general commands, system calls functions, library functions, file formats conventions etc.
These pages provides insight information of above mentioned categories.

man <command_name>

Example:
If something (like printf() function in C language) is not clear, what it do, what is the use and what is the syntax of this function etc information can be found in printf man pages. Below command should be used for this purpose

man printf

Similary, if we are not clear about any command, what it is, its use, where to use etc info is available in the manual pages
Try: man sudo

Once the manual page is opened in the terminal, use letter "q" to exit from the manual page.
-------------------------------------------------------------------------------------

"Sudo" Importance

In order to do administrative tasks like install, remove or upgrade applications/software in the Ubuntu machine, the logged user should have administrator privileges.
For this purpose, Ubuntu environment provides a special command called "sudo" (Super Used DO), which will allows us to install/remove/upgrade and system maintenance.
In Ubuntu there is no way to log in as Admin user (log in as ROOT) to do above tasks. So, Ubuntu added this command specifically to support above tasks.

Installing any application/software
Use: sudo apt-get install <package_name>

Un-Installing any application/software
Use: sudo apt-get remove <package_name>

Upgrade system software/applications
Use: sudo apt-get upgrade

sudo command will run the commands in administrator mode.

In ubuntu, all the application software are available in repositories unlike windows machine where we need to carry the software in external storage.

So, when we use command "apt-get", it will search required software/s (<package_name>) in the repositories, get that software program and will install/upgrade it without user intervention. It will automatically install software for us.
Note: Our Ubuntu machine should have Internet connection to use this facility from Ubuntu.
-----------------------------------------------------------------------------------------

Tasksel:

Tasksel (Task select) is also a special command in Ubuntu environment to install set of packages in one go.
For example, if we want to install FTP server or printer server or DNS server, they require so many dependency packages to install in order one by one to work.
Instead of installing them manually one by one, Ubuntu environment provides scripts for us to do above tasks using tasksel command. These scripts will have all information about the software and installs all required packages.
So, we don't need to worry about the dependency packages need to install before installing desired program.

Use: sudo tasksel
Result: It will promt a window, where we can select the software need to install from pre-avialble software lists (ex: DNS server, FTP server, Email sever etc). Select the required options and click OK. Done. 

-----------------------------------------------------------------------------------------

Control the service:
We can restart/start/stop any service using below command

Use:

sudo /etc/init.d/<service_name> start
sudo /etc/init.d/<service_name> stop
sudo /etc/init.d/<service_name> restart
-----------------------------------------------------------------------------------------

TOP command

The command "top" is very much similar to task manager in windows system.
Using top command, we will see the data like CPU utilization and memory utilization per process and in addition processes info that are running etc.

Use: sudo top
Task Manager in the UNIX world.
We see process ids (PID), CPU utilization and memory utilization info.

Abort any process using command "kill"
Use: 
kill -9 <process_id>
or
pkill -9 <process_name>
---------------------------------------------------------------------------------------

Navigation:

Navigation between the directories are simple in linux environment using command "cd" (Change Directory)

Use:
cd <directory_name>
   -->means that change the current working directory to <directory_name>

cd /<directory_name>
  --> means that change the directory to <directory_name> under ROOT (/) directory.

Under ROOT, we do find the directories named "home", "etc" and others.
So, if we need to navigate to any directories under ROOT (/) then use slash (/) before that directory name
i.e.  cd /home

Friday, 18 October 2013

Install Adobe Acrobat Reader in Ubuntu

Install Adobe Acrobat Reader in Ubuntu pc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Approach-1: Didn't work for me
----------------------------------
Step1) sudo add-apt-repository "deb http://archive.canonical.com/ precise partner"
Step2) sudo apt-get update
Step3) sudo apt-get install acroread
=============================
Result:
--------
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
  acroread: Depends: acroread-bin but it is not installable
E: Broken packages


Approach-2: Didn't work for me
-------------------------------
Download Adobe*.deb (i386 version .deb file) from ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/


sudo linux32 dpkg -i AdbeRdr9.5.4-1_i386linux_enu.deb
=======================================================
dpkg: error processing AdbeRdr9.5.4-1_i386linux_enu.deb (--install):
 package architecture (i386) does not match system (amd64)
Errors were encountered while processing:
 AdbeRdr9.5.4-1_i386linux_enu.deb

Approach3: Worked for me..hurray...
----------------------------------------
sudo dpkg -i --force-architecture AdbeRdr9.5.4-1_i386linux_enu.deb
=====================================================
dpkg: warning: overriding problem because --force enabled:
 package architecture (i386) does not match system (amd64)
Selecting previously deselected package adobereader-enu.
(Reading database ... 147879 files and directories currently installed.)
Unpacking adobereader-enu (from AdbeRdr9.5.4-1_i386linux_enu.deb) ...
Setting up adobereader-enu (9.5.4) ...

Processing triggers for man-db ...

Reference for Approach-3: http://notepad2.blogspot.in/2011/04/install-adobe-reader-on-64-bit-ubuntu.html


Tuesday, 16 July 2013

Reset/Recovery Ubuntu System Password

Ubuntu System Password recovery

We can reset the password (forgotten password) of your ubuntu system in FIVE simple steps.

Step1: Restart the system. Press Esc button when you see the message like "GRUB Loading ...". Then we will see the root shell window.

Step2: Select the recovery mode option in the root shell and then "Recovery menu" will be appeared on the screen then select "Drop to root shell prompt" option.

Step3: We will see a terminal
root@(none):/#
root@(none):/# passwd <user_name>

ExampleIf username of your system is hacker then please type passwd hacker and press enter.
Once you enter correct username, it is request you to set new password.
Please set your password.

Step4: Now, type sync and press enter
Step5: finally type reboot -f and press enter

You are now successfully reset your ubuntu system password.

You might also like

Related Posts Plugin for WordPress, Blogger...