Browsing all articles tagged with Linux
Aug
29

Vim: How to Copy Multiple Lines

If you are using vim as editor and you are using vim inside a pseudo-terminal such as PuTTY, you might have less trouble with copy and paste function as you can use your mouse to highlight text, copy, and paste it inside the file.

However, if you have difficulty copying multiple lines in vim without access to mouse, or in tty, you might want to utilize the command ‘v’ or ‘V’.

To yank (copy) multiple lines:

1) Place the cursor on the first position of the first line you want to yank.
2) In vim command mode, press ‘v’ (without the quotes). You will notice that the message “– VISUAL –” will appear on the lower left part of the screen. This is an indicator that you are now in ‘Visual’ mode.
3) Use your arrow keys to move the cursor to highlight the lines of texts you want to manipulate.
4) After highlighting, press the ‘y’ key to yank (copy) the highlighted lines. You will notice the message similar to “9 lines yanked” on the lower left side of the screen. This means you have successfully copied the lines and ready to be pasted!
5) Place your cursor on the line you want to insert your copied lines to and press ‘p’ to paste below the cursor, or ‘P’ to paste above the cursor.

Voila!

If you would rather cut the lines, press ‘d’ instead of ‘y’.

Aug
22

Required Packages for Oracle 11gR2 on Red Hat Enterprise Linux 6

binutils.x86_64
compat-db43.i686
compat-glibc-headers.x86_64
compat-glibc.x86_64
compat-libcap1.x86_64
compat-libstdc++-33.i686
compat-libstdc++-33.x86_64
elfutils-libelf-devel.x86_64
gcc-c++.x86_64
gcc.x86_64
gdbm.i686
gdbm.x86_64
glibc-common.x86_64
glibc-devel.i686
glibc-devel.x86_64
glibc-headers.x86_64
glibc.i686
glibc.x86_64
kernel-headers
ksh.x86_64
libaio-devel.i686
libaio-devel.x86_64
libaio.i686
libaio.x86_64
libgcc.i686
libgcc.x86_64
libgomp.x86_64
libstdc++-devel.i686
libstdc++-devel.x86_64
libstdc++.i686
libstdc++.x86_64
libXi.i686
libXp.i686
libXp.x86_64
libXtst
make.x86_64
mksh.x86_64
ncompress
nfs-utils
openmotif21.i686
portmap
sysstat.x86_64
unixODBC-devel.i686
unixODBC-devel.x86_64
unixODBC.i686
unixODBC.x86_64
unzip.x86_64
util-linux-ng.x86_64
xauth
xorg-x11-libs-compat.i386
xorg-x11-utils.x86_64
binutils.x86_64
compat-db43.i686
compat-glibc-headers.x86_64
compat-glibc.x86_64
compat-libcap1.x86_64
compat-libstdc++-33.i686
compat-libstdc++-33.x86_64
elfutils-libelf-devel.x86_64
gcc-c++.x86_64
gcc.x86_64
gdbm.i686
gdbm.x86_64
glibc-common.x86_64
glibc-devel.i686
glibc-devel.x86_64
glibc-headers.x86_64
glibc.i686
glibc.x86_64
kernel-headers
ksh.x86_64
libaio-devel.i686
libaio-devel.x86_64
libaio.i686
libaio.x86_64
libgcc.i686
libgcc.x86_64
libgomp.x86_64
libstdc++-devel.i686
libstdc++-devel.x86_64
libstdc++.i686
libstdc++.x86_64
libXi.i686
libXp.i686
libXp.x86_64
libXtst
make.x86_64
mksh.x86_64
ncompress
nfs-utils
*openmotif21.i686
portmap
sysstat.x86_64
unixODBC-devel.i686
unixODBC-devel.x86_64
unixODBC.i686
unixODBC.x86_64
unzip.x86_64
util-linux-ng.x86_64
xauth
*xorg-x11-libs-compat.i386
xorg-x11-utils.x86_64
xterm

* Downloadable from http://oss.oracle.com/projects/compat-oracle/files/Enterprise_Linux/

Aug
21

How Replace Space with Newline in Vim

In vim, you can run commands to simplify tasks. One case is to replace spaces with newline, or any character.

Inside vim, go to command mode by pressing the ESC key. Then enter the following command:

:%s/\s/\r/g

This will substitute (%s) spaces (\s) with return or newline (\r) and continue the replacement until end of line (g).

This is the command to use if you need to replace newline with spaces:

:%s/\n/\s/g

This will substitute (%s) newline (\n) with space (\s) and continue the replacement until end of line (g).

You may notice that newline and return characters are used differently and not interchangeable. This is because \r means ‘carriage return’ and if ever you had one of those typewriting classes wherein you learn how to use a typewriter (not a computer!), you will know what carriage return means. Anyway, in computing, it means the same thing, to move the cursor to the beginning of the line. Although it means almost the same, newline or \n does things differently. Newline character, or ‘line feed’, instructs the cursor to move to the next line.

So how is this relevant to the vim commands above?

When the user presses the ‘Enter’ key, the equivalent command is actually ‘CR-LF’, a combination of carriage return (CR) and line feed (LF)on Windows systems. In Linux systems, the ‘Enter’ key is just ‘LF’, it is understood that you want the cursor the start at the beginning of the line.

However, in replacing \n and \r characters in vim, these two are not interchangeable. If you need to add line feed, use the CR character, \r. If you need to remove the line feed, use the LF \n character.

Aug
19

What are Libraries in Linux?

If you are new to Linux, you are most likely to encounter libraries, which can be either static or shared.

But what are libraries?

When someone writes a program, object codes are used inside these programs. Sometimes, these object codes are repeatedly used, hence it would be more practical to create an archive of these common functions than write the same function again and again. The archives containing these common functions are called libraries, therefore, libraries are object codes grouped together into one entity. There are two types of libraries, it can either be static or shared.

Static Libraries

Static libraries are libraries that is, well, statically linked and copied into the application. Basically, it means that the object codes are available only to the application that calls these codes, therefore if you have ten programs running, you will need a copy of objects for each program as static libraries are not shared to another program.

Shared Libraries

Shared libraries are object codes that are shared by and common among many programs. This means that a shared library can be referenced by any program that can access the library.

Advantages and Disadvantages

Static libraries require that each program has a copy of the objects, therefore it does not have dependency problems with shared libraries. A shared library can have this issue, for example, if someone has updated the library, it can break another program that uses the same library. Hence, it is important to make sure that the shared library remains compatible to all the programs that uses it.

Shared libraries minimizes the size of an application for it does not have to come with the common libraries, an advantage over static linking where all the libraries it needs are included in the application.

Shared libraries can also utilize a kind of linking called dynamic linking. Dynamic linking basically means that the libraries are called during the application loads or executes. These types of libraries are called dynamic shared objects or DSO, these libraries are linked by a linker, ld.so in Linux systems.

Aug
19

How to Add or Remove Library Path in RHEL

In Red Hat Enterprise Linux systems, you can modify the list of library paths that is not loaded by default.

What are Linux libraries?

If you have libraries outside the common and trusted library directories such as /usr/lib, /usr/lib64, /lib, or /lib64, you can add the directory by using the ldconfig command.

If you have compiled a new set of libraries, it is placed in the /usr/local/lib directory, in most cases. We are going to use the /usr/local/lib library path, the location of our newly compiled unixODBC 2.3 libraries, that we need to check, add, or remove in our examples.

Checking if the Library Path is Loaded

To check if the directory containing your libraries are already loaded, run the following command to verify:

ldconfig -v

The command `ldconfig -v` will list all the current library paths loaded by ldconfig.

Adding a Library Path

Use the following steps to add library paths:

1. Create the file unixODBC-2.3.conf and place the directory in this file. This will serve as a container for the library path.

echo "/usr/local/lib" > /etc/ld.so.conf.d/unixODBC-2.3.conf

2. Reload the ldconfig command to update the dynamic linker.

ldconfig

3. Check if the path is now in the list of links.

ldconfig -v

You should see something like this:

     /usr/local/lib:
            libodbc.so.1 -> libodbc.so.1.0.0
            libodbcinst.so.1 -> libodbcinst.so.1.0.0
            libodbccr.so.1 -> libodbccr.so.1.0.0

Removing a Library Path

1. Remove the file unixODBC-2.3.conf.

rm -f /etc/ld.so.conf.d/unixODBC-2.3.conf

2. Reload the ldconfig command to update the dynamic linker.

ldconfig

3. Check if the path has been removed from the list of links.

ldconfig -v

Powered by 1and1.comDomain Registrations starting at $9.98* Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Recent Comments

Site Stats