Chapter 2
BASIC COMMANDS
Working with physical system
When ever we login into your system, you are going to see a nice GUI
environment. By default when we install a Desktop version of RHEL 6, we
will get GNOME (GNU Network Object Model Environment) desktop.
We can also work as six different users at a time. We use keys
ALT+CTRL+F1 to ALT+CTRL+F6 to login as six different users at a time.
If we have installed Desktop versionm then first one is dedicated to GUI
and all are for CLI. If we have installed Basic Server then all keys from
ALT+CTRL+F1to ALT+CTRL+F6 are dedicated to CLI only.
2.1. Working with physical system
Basic Linux Commands
Here we are going to start our journey towards opensource. First we
need to learn some basic commands which will make us familier with the
linux environment.
ls
This is used to list the directory content. We have different options in
this. Let us discuss some important options.
-a It lists all files and directories including hidden. Some
files/directories starts with dot (.) they are called hidden files/directories.
-l Long list of files/directories. Here we can see the properties of
files/directories like permissions, size, ownership, timestamp and
name. Basing on the first character in the long list
We divide them as follows.
- it is an ordinary file
d it is a directory
c it is a character file
l it is a link file
s it is a socket file
-ld lists the directory properties.
-lh if we use h along with l, it is going to display file/directory size in
human readable format like K for Kbs, M for Mbs and G for Gbs.
-ltr long list of files/directories basing on the time it lists in reverse
order. That is latest modified file will be available at the end of the list.
-R It is going to print directory content recursively.
-Z It lists along with th securiy context.
mkdir
We use this command to create a directory.
#mkdir dir1
If we want to create a directory structure like 1/2/3/4/5, we have to use
use option p.
#mkdir –p 1/2/3/4/5
pwd
It gives you the present working directory.
cd
We use this command to change our directory.
Assueme that we are under /root . Now I change my directory to
1/2/3/4/5, I use this command as follows
#cd 1/2/3/4/5
#pwd
/root/1/2/3/4/5
To goto one step back, we use the following command.
#cd ..
To goto two steps back, we use the following command.
#cd ../..
To goto the previous directory, we use the following command.
#cd –
To goto our home directory, we use the following
commands. #cd or #cd ~
cp
We use this command to copy the contet from one place to another
place.
#cp <source> <destination>
#cp a.txt dir1/ (copying file a.txt to the directory dir1/)
If we want to copy directory content, where the directory is having files
and directories from one place to another place, we use this command as
follows.
#cp –r <source> <destination>
#cp –r dir1/* dir2/
If we want to preserve timestamp and ownership, we use p option.
#cp –p <source> <destination>
#cp –p /home/tom/* dir1/
-r recursively
-p preserve
mv
We use this command to rename files/directories or to move
files/directories from one location to another location.
Renaming
#mv <oldname> <newname>
#mv a.txt b.txt
Moving
#mv <source> <destination>
#mv dir1/a.txt dir2/