Wednesday, July 31, 2013

There are many devices or mount points mounted on system.
But sometimes, we need to mount these mount points by unique ID. This case
generally happens in network because in same network, might have same name
mount points on different disks. To avoid this conflict, we will mount the
mount points by their block ID which is always unique.

Before doing entry in /etc/fstab file, we need to find block
ID of that file. We will do it by following commands as follows:

root@hello:~/myhome/test#
blkid
/dev/sda1

/dev/sda1:
UUID="s91ed12-d675-46bf-a42f-07fgc2313505" TYPE="ext3"

root@hello:~/myhome/test#

root@hello:~/myhome/test#
blkid
/dev/sda3

/dev/sda3:
UUID="k4161839-0b4d-45aa-b4d5-49c76g989628" TYPE="ext3"

root@hello:~/myhome/test#

As per above example, block id will show for only created
partitions and we need to provide one parameter for this command and that is
partition name.

After this, we can mount file system or partition on operating
system with this block ID. It is permanent block id for this partition and it
will never change. For each physical partition, there is unique block id for
it.

Example of /etc/fstab file configuration by UUID.

# swap was on
/dev/sda5 during installation

UUID=72c7301e-239b-44a0-9ccd-41693680d91c none swap sw 0 0

If you see in above example, we have used UUID for that
device not device or partition name while mounting it in /etc/fstab file.

There are many shells which are not coming by default in our
operating system. So, that time we need to install it externally by downloading
rpm package for Linux, deb package for Solaris, do apt-get for Ubuntu etc. But
when we install this shell and somehow it is not working then we need configure
it with following steps:

Step 1:

Install shell’s rpm, deb etc. package into operating system.

Step 2:

Now try to access
that shell or try to switch that shell if it is not working then run following
steps.

Step 3:

Check configuration file /etc/shells and make entry for that
shell like /bin/csh/ or /usr/bin/es or /usr/bin/rc or /bin/rbash etc. If entry
is already present then don’t do anything.

But this step has to execute after installation only.

Step 4:

Run following command after making entry in /etc/shells.

root@hello:~/home/test# add-shell shell-name

add-shell command is used to add shell in kernel. i.e. it
updates the kernel information for this shell if it is not present in kernel’s
database.

Tuesday, July 30, 2013

Vi editor works
as text editor in Linux. We can create, modify, search and replace patterns in
a file like these multiple operations, we can do using vi editor. Vi and vim
editors are almost same commands but vim is having many advanced features as
compared to vi editor. Vim is advanced version of vi editor.

Mostly vi search
operation is very useful for us to while editing any file or changing any
configuration file. Below are some of the examples of vi/vim editor commands:

Monday, July 29, 2013

There are many commands which needed to know beginner of Unix
OS. But it is not possible to understand all commands in one day. If you really
new to Linux then please go through this article and understand the most used
commands in Linux.

If you are new to Linux then, you will need to know, how to
create directory, how to create file, how to read file, open file and edit it,
copy file, move file, delete file and directories etc. let’s see how we are going to do this operations by commands
with examples:

mkdir Command

1.Once you logged on to machine and opened
terminal then first of all you need to create directory for your work. Create
directory by following command:

login as: root

root@192.168.136.132's
password:

[root@localhost
~]#

[root@localhost
~]#mkdir
test

[root@localhost
~]#ls

anaconda-ks.cfg install.log
install.log.syslog test

[root@localhost
~]#

cd command

2. Once you create directory then you have to go
inside the directory for this purpose, you can do it as follows:

[root@localhost ~]#

[root@localhost
~]#cd
test

[root@localhost test]#

touch command

3. Once you go inside the directory then we need to
create a file. It is as :

[root@localhost
test]#

[root@localhost
test]# touch test.txt

[root@localhost
test]# ls

test.txt

[root@localhost
test]#

Vi editor

4. There are different ways of creation of files
and generally touch, vi, cat or redirection output used to create a files. We
will use vi to create one more file. But we can edit above created file by this
way as well. Vi editor creates file
if it is not present and if it is present then vi editor edits that file. If you want to know more about VI editor
then please click here : VI editor in Linux

[root@localhost
test]#

[root@localhost
test]#vi
test1.txt

[root@localhost
test]#

cat command

5. Once you edit that file and want to read it then
use following command.

[root@localhost
test]#

[root@localhost
test]# cat test1.txt

Hello
Linux Concepts and Commands Author

How
are you?

[root@localhost test]#

more command

6. Sometimes, file will be very big and you can’t
see it on one single screen output then you can read that file as follows:

More
command reads file page by page. You just need to press Enter key for next
page and backward page press b.

[root@localhost
test]#

[root@localhost
test]# vi
test2.txt

[root@localhost
test]#

[root@localhost
test]# cat
test2.txt | more

[root@localhost
test]#

##We can use
more command like cat also

[root@localhost
test]# more
test2.txt

cp command

7. Now copy the one file to other i.e. create one
more copy of test2.txt file and give name to new file as : test2.txt_bak

[root@localhost test]#

[root@localhost
test]# cp
test2.txt test2.txt_bak

[root@localhost
test]#

[root@localhost
test]#
ls

test1.txt test2.txt
test2.txt_bak test.txt

[root@localhost
test]#

mv command

8. Now rename to existing file (test1.txt) to test3.txt.

[root@localhost test]# ls

test1.txt test2.txt
test2.txt_bak test.txt

[root@localhost test]#

[root@localhost test]# mv test1.txt
test3.txt

[root@localhost test]# ls

test2.txt test2.txt_bak test3.txt test.txt

[root@localhost test]#

rm command, rmdir command

9.

Now delete the file by rm command, delete
directory by rmdir command and if you have many directories inside the one directory
then remove that main directory as follows: