LINUX

Linux

RHEL Linux basic commands cat bzip gzip pwd cd mkdir

In our last assignment you perform some basic task related to system administration from normal user. In this assignment we will extend this further. To complete this assignment login form our normal user Vinita.
basic rhce commands

How to redirect the matter of files in a new file

Create two file and write some text in them.

$cat > one
This is first file
$cat > second
This is second file
Now we will combine these two files in a single file. In standard linux its call redirection of output.

$cat one second > new
$cat new
This is first file
This is second files
Linux system administration command
Then what exactly this command did? As you know cat command is used to display the matter of file so it will first display the matter of first file and then it will display the matter of second file. But as you put a > sign at the end of command so despite of showing this output on screen command will redirect this matter to a file.

How to execute multiple commands in a single row


$[command] ; [command] ; [command] ;[command]……..
To execute multiple commands from single row use a ; between them form example

$cat new ; mkdir xyz ; mkdir rat ; ls
This is first file
This is second files
new xyz rat
Linux system administration command
this command will first execute the first command which is cat new so it will display the matter of new file, further is mkdir xyz so it will create a xyz directory , further is mkdir rat so will create a rat directory and in the end we use ls command so it will list the contain of current directory.

How to create multiple sub directory form single command

To create multiple sub directory from a single command use –p switch with mkdir command for example

$mkdir –p a/b/c/d/f/g/h/i/j
In this example we created 9 subdirectories form a single mkdir command. Now verify it by listing.

$ls
new  xyz rat a
now change the directory to verify the depth of directories.

$cd a/b/c/d/f/g/h/i/j
$pwd
/home/vinita/a/b/c/d/f/g/h/i/j
Come back to home directory. Simple cd command without passing any argument will do this.

$cd
Linux system administration command

How to move multiple file in directory with a single commands?

Give all files name one by one with a single space between them and in the end give the destination directory name for example
$mv new first second xyz
Linux system administration command
This command will move three files new, one, second to the xyz directory.

$cd xyz
$ls
New one second
$cd ..

how to take back-up and restore files and directories.

tar command is used to take the back up with –cvf switches and the same tar command is used to restore the matter with –xvf switches. For example

$tar –cvf backup.tar xyz
$ls
$rm –rf xyz
Linux system administration command
In linux you cannot restore the data once deleted unless you have backup. Now restore these files and directory.

$tar –xvf backup.tar
$ls
$cd xyz
$ls
new first second
$cd ..

How to compress files to save disk space?

Create a large file and check how much disk space is consumed by this file

$man ls > manoj
$du –h manoj
12k manoj
File manoj is using 12k space on hard disk. For exam prospective you should familiar with two compress utilities.

$bzip2 [file name]                      {command syntax}
$bzip2 manoj
$ls
$du -h  manoj.bz2
4k manoj.bz2
Linux system administration command
To decompress file
$bzip2 –d manoj.bz2 $ls manoj as you can show file has been decompressed. Now use other utility to compress the file.

$gzip manoj
$ls
manoj.gz
$du –h manoj.gz
4k manoj.gz
$gzip –d manoj.gz
$ls
manoj
Linux system administration command

 

basic network configurations ip, hosts file, portmap and xinetd services

In this article we will discuss all those necessary steps which you need to perform before solving networking related questions in RHCE exam. Don't skip this tutorial, giving few minutes to this could save you from huge problems in exam. All steps are given in a sequences don't skip them whether you them or not.

Check LAN card driver is installed or not.

LAN driver is the top most part for network. To check it run setup command
setup commands
Select network configuration from list

If you see LAN card here mean you have LAN driver
select lan card
if you don't see here anything and Linux drop you back on list manu means you don't have LAN driver. Install is first.
If you don't know how to install LAN driver then follow this link.Installing lan card driver, location of important networking files and descriptions

Check proper IP configuration

All systems on RHCE exam should have an properly configured IP address. During this entire practical we are using three systems. There description is given below Check these systems for properly configured IP address. you can review our pervious article if you feel trouble in IP configuration.Network configuration commands ip ifconfig ping netstat arp mii-tool

Node Operating system Name IP
PC1 Linux RHEL Server 192.168.0.254
PC2 Linux RHEL Client1 192.168.0.1
PC3 Windows XP Client2 192.168.0.2

Change host name

If you have skipped hostname during installation then it would be localhost.localdomain. You can change hostname with hostname command but this change would be temporary. To change hostname permanently do editing in /etc/sysconfig/network.
set computer name as shown in table.
#vi /etc/sysconfig/network
sysconfig
On server system set it to Server and in client system set it Client1
network

Check /etc/hosts files for name resolution

Several Linux server depend name resolution. This file should have entry of all network systems. It will save you from naming related problem. In our network it should look like this on both Linux system Server and Client1
hosts files

Check firewall status

Firewall is the necessary security part of Linux system which is connected to Internet. But in exam we are not going to use Internet so it’s good practice to disable it.
To disable firewall run setup commands
setup
Now select firewall configuration from list and click on run tool
select firewall configurations
Select disable and click on ok and quit to return on command prompt.
diable firewall
System reboot require to take effect so reboot system with reboot -f commands
reboot

Check portmap and xinetd package status

Almost every Linux server needs these two rpm to function properly. First check that these rpm are install or not. If no rpm is install then install them via rpm commands. If you don't know how to install rpm then follow this link.Linux RPM Red Hat's Package Manager
rpm status
If you have rpm then check there status via setup commands
setup
Now select system service from menu
select system service
put a star in front the portmap service
select portmap
Now put star in front the xinetd service
xinetd
Click on ok and select quit to come back on command prompt
Now restart these two service.
service restart
To keep on these services after reboot on then via chkconfig command
chkconfig
After reboot verify their status. It must be in running condition
service status 



Linux Install Requirements:
·         /                       =          25000
·         /Boot               =          500
·         Swab               =          4000
·         /Usr                 =          6000
·         /Home             =          10000
·         /Var                 =          10000
FILE SYSTEM:
·         /                       =          Root
·         /Bin                 =          Binary File for User
·         /Sbin                =          Binary File for Administrator
·         /proc                =          Processing Status of System
·         /Usr                 =          User Level Application
·         /Var                 =          Variable Information
·         /tmp                 =          Temporary file of Directory
·          /Opt                =          Optional Dir Company
·         /Mnt                =          Mount of Unmount the file Dir
·         /Media             =          Removable Media
·         /dev                 =          Devk (or) Driver files
·         /lib                   =          Library file
·         /etc                  =          Configuration file
[Root@localhost ~]# (or) $
Root                      =          Currently Login User Name
Localhost              =          Computer Name
~                           =          User Home Directory
#                            =          Represent as Administrator
$                            =          User Shell
Shutdown Command
·      Shutdown  -h   Now      =          Immediate Shutdown
·      Shutdown  -h   20:00     =          Pc at 8.00 PM Shutdown
·      Shutdown  -h  +20         =          Pc in 20Min Shutdown

Restart Command
·         Shutdown  -r   Now    =          Immediate Shutdown
·         Shutdown  -r   20:00   =          Pc at 8.00 PM Shutdown
·         Shutdown  -r  +20       =          Pc in 20Min Shutdown
Cancel Shutdown
·         Shutdown –c
File Create
·         Cat > filename
eg:-Cat>kalai

Directory Create
·         Mkdir -  Directory Name
eg:-Mkdirkalai
CD Drive
Open
·         mount  /dev/cdrom  /mnt
·         Cd  /mnt
Eject
·         Cd\
·         Umount /mnt
·         Eject
Install Software
·         rpm  -ivh telnet-9.3.3
User Add with Password
Useraddkalai
Passwd kalai               =          to create a user
User Add without Password
Useraddkalai
Passwd -d kalai           =          to create a without Password
User Remove
            Userdel -r kalai            =          to remove user
Password change
            Passwd kalai               =          change Password
Move
1.      Cat mano>>kalai   =          to move all data to another file (kalai) without delete.
2.      Cat mano>kalai                 =          to move all data to a new file (kalai) with delete.
3.      Cat manokalai>kutty        =          to move 2 file another file (kutty).
4.      Cat kalai                            =          view file
5.      Vi kalai                              =          view & edit
6.      Cat > .mano                      =          Create hidden files
7.      Ls –d                                 =          view  hidden files
8.      Cat .mano                          =          to view hidden files
9.      Mkdir .mano                     =          to create a hidden Dir
10.  Cd .mano                          =          to view hidden Dir
11.  Cp                                                 =          Copy
12.  Cp kalaimano                    =          to copy file(kalai to mano)
13.  Cp –r kalaimano                =          copy to mano remove kalai  data.
14.  Ls                                      =          view all files
15.  Pwd                                   =          present working Dir.
16.  Alias                                  =          to view alias
17.  Alias c=clear                     =          create a shortcut clear alias.
18.  BC                                     =          Binary calculator.
19.  Gzipkalai                           =          to zip file (kalai)
20.  Gunzipkalai                       =          to unzip file (kalai)
21.  Cat kalaigz                        =          to view zip file (kalai)
22.  Neat                                  =          open network windows
23.  Help                                  =          Show all comment
24.  Ps  -ax                               =          to view Process ID.
25.  Kill -9                                =          kill Process ID.
26.  Cal                                     =          calendar
27.  Cal 2010                            =          view 2010  calendar
28.  Cal 9 1986                         =          view month in year.
29.  Wall                                   =          all user
30.  Write (user)                       =          sent message admin user.                                                                                                                                                                                                                                                
31.  Ls |less                               =          view page to page.
32.  :q!                                      =          without save
33.  :wq!                                   =          with save
34.  :w!                                     =          save without exit
35.  Setup                                 =          comment view setup.
36.  Ifconfig                             =          view IP Address.
37.  History                              =          to view all usage comment
38.  History –c                         =          to clear all comment
39.  Rpm –qa                            =          software check
40.  Chmod                              =          file permission
41.  Rm –rf                               =          remove files
=====================================================================
INTRO
         -KERNEL
               - CORE OS (OPERATING SYSTEM)
                     IT CONTROL THE HARDWARE
-------------------------------------------------------------------
Linux History

    1970: UNIX very popular

     1984: Richard Stallman

/dev/fd0      :
       /dev/fd1


      /dev/cdrom
      /dev/cdrecorder
cdwriter

     /dev/dvdreader
         /dev

tape drive
    /dev/mt0

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

  KERNEL
      CORE OS

       MAJOR VERSION
           1.0       2.0

      MINOR VERSION
         .6
         .18
            BUG VERSION (RELEASE)

      - FIX(PATCH)

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


ODD NUMBER KERNEL
           1.1    1.3   1.5--------2.1  2.3   2.5  2.7

         EVEN NUMBER KERNEL
          1.0   1.2  1.4   --------2.2  2.4 2.6 2.8



LINK IN LINUX

Soft link
Hard link

 More than one user working on single file, but diff link name


SOFTLINK:

   If source file is deleted, destination file will not be reachable

#ln -s sfile1 dfile1

HARD LINK:

  If source file is deleted, destinati0n file will be access
#ln sfile2 dfile2

NOTE:

  If source/destination file modified, both file will be updated


            #ln (command for create a link)

      --------------------------------------------------
REDIRECTION OPERATOR IN LINUX

>   :      write the output to file
     (If file is already existed it deletes the file
     and always create one)

>>  : append your data
           (If file is already existed it update the file)

1>  : write the success message

2> :write the error messages
UNDERSTANDING THE TYPES

-   : it refers the file
l: it refer the link
d: it refer the director
c: character device
s:network related
b: block device
---------------------------------------
copy : copy a file
  (cp): it refer the file
l : it refer the link
d : it refer the director
c :character device
s:network related
b : block device
Move/rename a file (mv)
cut
delimiter
------------------------------------------------
# cut -d: -f1 /etc/passwd | less

[root@client1 covai]# cut -d: -f1 /etc/passwd | less
----------------------------------------------------
Run More Than One Command In A Single Line
ls ; dir; cd /tmp; touch file10


How To Recover The Root Password

Forgot the Root

      1. ctrl+alt+del

      2. once the boot screen display press esc
press e edit
      3. select the line no 2  & press e

      4. linux single  <press enter>

      5.  b (boot) start the pc with single user mode

      6. without username/password it login as a root user

      7. #passwd
or

         #passwd root

 8. reboot
init 3
-------------------------------------------------------------------
PROCESS IN LINUX

     #ps -A | less
What is the first process in Linux?
init
pid : process id
teleterminal type
cmd
     #pstree
| less

  HOW TO START THE BACKGROUP PROCESS

     #startx&
     #xeyes&


   KILL THE PROCESS
  ------------------
      #kill 
      #gnome-system-monitor
      #top

-------------------------------------------------------------
CHANGE/SET THE PRIORITY OF THE PROCESS
  ---------------------------------------
  1. start the process with priority (nice )
  2. change the priority of the running process (renice)

Range
-20  to +19
(Highest)    (Lowest)
  Root     
---------------------------------------------------------------

HISTORY
   FOR ROOT USER
   FOR NORMAL USER

  $echo $HISTSIZE

  #cd /home/kalai
     #vi .bash_profile

-------------------------------------------------------------
Diff betweeninit 5
startx






NOTES: COMMAND
---------------
#env | less
#gnome-system-monitor &
#nice -n +15 xeyes&
#renice -n -15 2778
#echo $HISTSIZE
#jobs
#ps -a | less
#kill 2547
#ps -a
#ps -a
#pstree -i
#chkconfig --list level 3
#chkconfig --list --levels 3 | less
#chkconfig --list --levels 35


Package Installation

·         .exe/.dll not supported

·         .rpm ( RedHat package manager)[open source]  - method
            Install/unistall/update
            EL5: Server
            EL6: Package
·            .bin (binary executable format)
·            .dpkg

 ---------------------------------------------------------------
rpmMethod Of Installation (Text)

-q : query
      -a : all packages
      -i : install
      -e :erase
      -U : upgrade
      -v : verbose : it show the output in the console/terminal
      -f : force
      -h : hash symbol

DrawBack:
must install the dependencies before install the main package
------------------------------------------------------------------

YUM :Yellowdog Update Modified

It automatically installs the dependencies.
------------------------------------------------------------------

RPM PRACTICAL

how to verify list of packages installed in my system?
rpm -qa | less
find the particular installed or not?
rpm -qa | grep nfs
how to install
rpm -ivh<packagename>
how to uninstall
rpm -ef<packagename> without extension

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

Yum:

It is a client/server arch model
 DUMP Need to be store in any one pc in the network,

Yum server configuration

1.  #rpm -ivhcreaterepo

2.  verify the pack installed or not


#rpm -qa | grep createrepo

  3. create repository
            [Storage area: it refer where the installation
files are located]
#createrepo /backup/redhatdvd

#yum remove xsane*

#yum install -y  xsane* - without confrom

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















YUM CLIENT CONFIGURATION
------------------------
 #cd /etc/yum.repos.d
 #virhel-debuginfo.repo

rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=http//redhat.com
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta-2

                (change)


rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=file:///backup/redhatdvd
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta-2

#yum clean all
#yum list all


baseurl=http://192.168.1.101/backup/redahtdvd
ftp
nfs

          //: network
         ///: local file

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


tar : tape archieve
        -c : create
        -v : verbose
        -f : file
        -x : extract


gzip:

  1.  #gunzip   test.tar.gz
      #tar -xvf test.tar
          (or)
  2. #tar zxvf test.tar.gz

winzip : ark
--------------------------------------------------------

#./FILE

#./configure

system-config-packages


REGULAR EXPRESSION IN LINUX

^  (CARET)  : the line start with the character
$  (dollar) : the line end with the character
 [ab]        : set operator (a or b)
 [a-z]       : set operator (from a-z)
[A-Z]
[a-zA-Z]
 [0-9]       : set operator ( from o to 9 number)

[root@server1 covai]# grep "red" file1
 Red

[root@server1 covai]# grep "^r" file1
red
rvd
rcd
rkd




[root@server1 covai]# grep "e$" file1

this is sample
blue
orange
purchase

[root@server1 covai]# touch file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1 file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1:purchase file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: purchase
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown :sales file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: sales
user::rw-
group::-w-
other::-w-

[root@server1 covai]#
orange
sales
purchase
admin
rvd
rcd
rkd
data1
data2
[root@server1 covai]# grep "r[vck]d" file1
rvd
rcd
rkd

[root@server1 covai]# grep "[a-z]" file1
this is sample
red
green
blue
orange
sales
purchase
admin
rvd
rcd
rkd
data1
data2

[root@server1 covai]# grep "r[a-z]d" file1
red
rvd
rcd
rkd

[root@server1 covai]# grep "data[012]" file1
data1
data2

[root@server1 covai]# grep "data[0-9]" file1
data1
data2
data3

----------------------------------------------------------------------
File:
it show the type of the file

 #file file1
 [root@server1 covai]# file file1
file1: ASCII text
----------------------------------------------------------------------
UMASK VALUE IN LINUX
---------------------
Root User

when i create file in linux default permission by system : 644
when i create dir in linux default permission by system  :755

what is the umask value in root user ?              : 022


Normal User
When i create file in linux default permission by system : 664
  When i create dir in linux default permission by system:775

  What is the umask value in NORMAL user?                  : 002


How the permission will be implemented?   

LINUX DEFAULT PERMISSION

       FILE 666
DIR  777

ROOT USER
               FILE CREAATE
                  666 -
                  022
                 -----
                  644
 -----

             DIR CREATE
                777
                022
                ---
                755
                ---

How to change the umask?

1) Temporary
               #umask 055
666
055


2) Permanently change

#cd /root
                  #vi .bash_profile
umask 055

#cd ~ [ go the the user home]
#ls -a [ it show the hidden file
----------------------------------------------------------------------LINUX PERMISSION
       1. chomod
       2. setfacl/getfacl
setfacl :acces control list
getfacl : access
#groupadd purchase

[root@server1 covai]# setfacl -m u:vik1:rwx file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:vik1:rwx
group::r--
mask::rwx
other::r--

[root@server1 covai]# setfacl -x u:vik1:rwx file1
setfacl: Option -x: Invalid argument near character 8
[root@server1 covai]# setfacl -x u:vik1 file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::r--
mask::r--
other::r--[root@server1 covai]# touch file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1 file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1:purchase file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: purchase
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown :sales file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: sales
user::rw-
group::-w-
other::-w-

[root@server1 covai]#


CHANGE THE OWNER OF THE FILE
owner
group
owner:group

[root@server1 covai]# touch file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1 file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: root
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown vik1:purchase file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: purchase
user::rw-
group::-w-
other::-w-

[root@server1 covai]# chown :sales file1
[root@server1 covai]# getfacl file1
# file: file1
# owner: vik1
# group: sales
user::rw-
group::-w-
other::-w-

----------------------------------------------------------------------
wc :wordcount

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


working on grub.conf or menu.lst
   /boot/grub
grub.conf
menu.lst

----------------------------------------------------------------------
welcome message

motd : message of the data

   #cd /etc
   #vimotd
----------------------------------------------------------------------
shell in linux

shell : is an interpreter between user and the kernel

                $ cd /home
ls
user------->appln------------>shell----------->kernel------------>h/w

   #cat /etc/shells

   #finger rajan
   #chsh


----------------------------------------------------------------------
echo  : print command
create dir with subdir?
mkdir -p rspuram/covai

DHCP :DYNAMIC HOST CONFIGURATION PROTOCOL

·        It provide automatic ip to the client ip
·        we create a range of ip for number of client based on requirement.

PRACTICAL 1[provide dynamic ip]

PRACTICAL 2:  [fixed dynamic address][mac/hardware/physical address

DHCP SERVERCONFIGURATION [ 67/69]

1)                #rpm -qa | grep dhcp
2)                #yum install dhcp
3)                #cd /etc/dhcpd
4)                #vi dhcpd.conf     [ /usr/share/doc/dhcp/  [sample file]
5)                #service dhcpd restart
6)                #chkconfig dhcpd on
VERIFY THE LEASES
Fromserver , u can verify which ip assigned to which client
 #dhcp.leass


SAMBA:  File Server

·        It is a protocol, share the files between windows and linux
·        port number 137
·        smb : session message block

Practical 1:
           View the Linux files from windows

  Practical 2:
View the windows files from Linux

 Practical 1:

Samba Server Configuration

 A) TEXT MODE
B) #system-config-samba 
C) webmin


# rpm -qa | grep samba
 # Yum install samba
#cd  /etc/samba/
#cp smb.conf smbcpy.conf
 #vi smb.conf

Workgroup =<windows workgroup name>
Security = share

                [Covai]
Path = /tmp/covai

 #testparm[itverifies the confismbclient -L 192.168.1.103 -U Administrator
                   guration file syntax error]

#service smb restart [el6]
#service smb restart [el5]
#server nmb restart
#chkconfig smb on
#chkconfig nmb on


Verify the share is working or not
in win pc

 Double click the network--> it show linux pc name , if u dblclick it show the shared folder

[root@server1 samba]# setup
[root@server1 samba]# getsebool -a  | grep samba
samba_create_home_dirs --> on
samba_domain_controller --> off
samba_enable_home_dirs --> on
samba_export_all_ro --> on
samba_export_all_rw --> on
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> on
use_samba_home_dirs --> off
virt_use_samba --> off
[root@server1 samba]# setsebool -a samba_create_home_dirs=on

Practical 2:

          In Windows PC (F:\mydata ) shared
How to access from lin pc

#smbclient -L  192.168.1.102  [ it show the shares from windows]
#mount       //192.168.1.102/mydata   /mnt
Convert The Linux User As Samba User
#smbpasswd -a vik
#smbpasswd -a raj
smb.conf
101 : security = user
[covai]
291 path = /tmp/covai
292 valid users = vik raj
293 browseable = yes
294 writable = yes

FTP: FILE TRANSFER PROTOCOL
      • UPLOADING AND DOWNLOADING
      • PORT NUMBER 20/21 ( default port)
      • home dir (/var/ftp/pub
      • default user (anonymous )
vsftp : very secure file transfer protocol
File : server to client(download)
client to server (upload)
Practical 1 (Server[linux]-client[linux])
linux ftp server installation:
#rpm -qa | grep vsftp*
#yum install vsftp*
#cd /etc/vsftpd
#vivsftpd.conf
#service vsftpd restart
#chkconfig vsftpd on
for testing
#cd /var/ftp/pub
#touch file1 file2 file3
------------------------ -----------------------------------------------------------------------
Linux Client:
-----------------
#rpm -qa | grep ftp*
#yum install ftp
Text Mode Client verify
#ftp <ip of server>

command for upload a single file /multiple fileput filename
mput *
command for download a single file/multiple file
get<filename>
mget *

GUI MODE CLIENT
#yum install gftp*
application --> internet->gftp
FIREWALL
TCP WRAPPERS
service based firewall
/etc/hosts.allow
/etc/hosts.deny
      • if duplicate entries in both file control set the priorities for allow entry
      • the control look out the allow file, if allow file it go for deny file
      • if both file existed, first it goto the allow and deny file
PRACTIAL
how to block the telnet
IPTABLE (ipchanins)
ipaddress& port number basis
NIS SERVER(YELLOW PAGES)
NETWORK INFORMATION SERVICES
CLIENT /SERVER ARCHITECTURE INLINUX
server configuration
---------------------
    1. #vi /etc/sysconfig/network
NISDOMAIN= “STS”
    1. #service ypserv restart
    2. #service ypbind restart [ client/server]
    3. #service yppasswdd restart
    4. #service ypxfrd restart
    5. #nisdomainname
[ it show the domain name]
    1. u must initialize the nis database


File promising CHMODE

R : 4
w : 2
x : 1

 775
      (user) (g) (other)
---------------------------------------------------------------------

Inode

Information node

[root@server1 covai]# ll -i
total 0
523539 -rw-r--r--. 1 root root 0 Jan 25 13:29 file1
523814 -rw-r--r--. 1 root root 0 Jan 25 13:29 file2
[root@server1 covai]#

inode table:

When u copy a file the inode number will be change or not?
It create a new inode
When u move a file the inode number will be change or not?
It will not be change
When u rename a file the inode number will be change or not?
It will not change

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

Search The Data In The Vi Editor

/ : forward search
   ? : reverse search

Open a file with read only

#vi -R file1

3dd : delete a 3 line

----------------------------------------------------------------------
Sudo User:

Normal user act like a root user

sudo permission can only implement by root user

  $system-config-users

     1) With password permission

  #visudo

      78 rajan   ALL= (ALL)   ALL

 $sudo system-config-users


2) without password permission

 78 rajan   ALL=(ALL)   NOPASSWD: ALL

$sudo system-config-users
----------------------------------------------------------------------
  # cat /var/log/messages

dmesg : it show the details of what happend at booting time

df -h
du -

tr : translate
tee : it write the output to the file and also show the output in
console


REGULAR EXPRESSION
 -------------------
*  : any number of character
   ? : single character



NFS: NETWORK FILE SYSTEM

·               SHARE THE FILES BETWEEN LINUX/LINUX
orUnix based system
·               NFS is protocol, it share the files

·               port number : 2049 NFS

·               port number : 111 PORTMAP

NFS SERVER  CONFIGURATION( text/default gui/webmin)

File Server [Linux-Linux or UNIX based System]

1.   #rpm -qa | grep nfs
     # yum install nfs
     # cd /etc
2.   #vi exports
     /tmp/covai 192.168.1.101(rw,sync)[ particular host]
                192.168.1.0(rw,sync)  [ particular network]
                            *(rw,sync)
          /backup/redhatdvd  *(rw,sync)

:wq




3.  #/usr/sbin/exportfs -av
                    -a all
V verbose
activate the all share in the config file

exporting ( /tmp/covai)

4. #service nfs restart
#service portreserve restart [el6]    
#service portmap restart     [ el5]
#chkconfig nfs on
#chkconfig portreserve on

    #rpcinfo -p localhost [it show the port are running properly or
                     not]

TEST IN LOCAL
How to view what are the data mounted?
              #mount

NFS CLIENT CONFIG:
#rpm -qa | grep nfs
#yum install nfs
     #service portmap restart
#service nfs restart
#setup          [nfs should be enabled]

TEMPORARY MOUNT
#mount <source><destination>

#mount 192.168.1.101:/tmp/covai /mnt[]

PERMANENT MOUNT

1.modify the fstab
2.modifyautofs

#vi  /etc/auto.misc
#vi /etc/auto.master

#service autofs restart
#chkconfig autofs on

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








internet
256 Request

APACHE:Web Server


(name based)
 It locate your data in the net/find the data in the net


 

In Single PC (Server) how many web site can be host?

Single NIC: 255 IP

PORT NUMBER: 0 – 65536 (port number can be generate)

(0-1024 well defined port using by system)

    192.168.1.1:1   www.hotmail.com(/var/www/html/hotmail)

Virtual ip hosting

1:65536

 Single card (1) * 255 *65536


-----------------------------------------------------------------------------------------
 Single Web Site Hosting(IP Based)

http: 80
https :443

Apache Server Config:

# rpm -qa | grep http
 #yum install http*
 #cd /etc/httpd/config
 #vi httpd.conf
          {Do the configuration}
#service httpd restart
#chkconfig httpd on
1.                 gui mode browser
           http://192.168.1.101
2.                  #elinkshttp://192.168.1.101  [ default in dvd : install by yum]
3.                  #lynx http://192.168.1.101
------------------------------------------------------------------------------------------­

Home dir
     /var/www/html
<index.html>

 ---------------------------------------------------------------------------------------
Virtual IP Address:
#cd /etc/sysconfig-scripts/        [EL6]
#ls
#vi ifcfg-eth0

IPADDR=129.168.1.101
PREFIX=24

IPADDR=129.168.1.102
PREFIX=24

#cd /etc/sysconfig/network-scripts
#ls
#cp ifcfg-eth0 ifcfg-eth0:1
#vi  ifcfg-eth0:1
DEVICE eth0:1
IPADR=192.168.1.201







APACHE WITH PASSWORD

1.Createa two file
a).htaccess
    b).htpasswd
#vi/var/www/html/hotmail/.htaccess
#vivar/www/html/hotmail/.htpasswd
 (should be in web directory)
---------------------------------------------------------------------------------------------------------------------
#vi/var/www/html/hotmail/.htpasswd
AuthName "LOGIN "
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
---------------------------------------------------------------------------------------------------------------------
#cd /var/www/html/hotmail
Create password
[root@server2 hotmail]# htpasswd -c .htpasswdrajan
New password:
Re-type new password:
Adding password for user rajan
---------------------------------------------------------------------------------------------------------------------
HTTP VERBS
GET: IT SHOW PARAMETER DETAILS IN ADD.BAR
POST: IT DOES NOT SHOW

#Service httpd restart
---------------------------------------------------------------------------------------------------------------------
#ifconfig
#iwconfig
#ip add show
#ip link show
#hdparm -i /dev/sda
#cat /proc/partitions
#fdisk -l
#df -h
#du /etc
      /   [disk usage]
#dmidecode
#lsusb
#lspci
#dmesg  [ it show the details of the boot time]
---------------------------------------------------------------------------------------------------------------------



Linux Booting Process
-------------------------
1.                  power on
2.                  Post ( power on self test)
3.                  MBR ( Master boot record : in disk first sector 512 bytes)[grub]
4.                  lookup the booting files & load the kernel image/boot/grub
5.                  it start the first process in linux (init load the system)
6.                  init call /etc/rc.d/rc.sysinit
7.                  it lookup the /etc/inittab& /etc/fstab
8.                  it load the process from the /etc/rc.d/ <runlevel folder>
9.                  login prompt will be applear
---------------------------------------------------------------------------------------------------------------------
Process Schedule in Linux

One time process (at)
#at 5pm
#atq[ list of bending]
#atrm<jobnumber>
#cat /etc/at.allow
#cat /etc/at.deny
#cat /etc/cron.allow
#cat /etc/cron.deny

[root@server1 rc.d]# at 5PM
at> tar -cvf /tmp/backup/test.tar  /mydata
at> cd /mydata
at> rm -rf *     
at> poweroff
at><EOT>
job 1 at 2012-02-07 17:00



[root@server1 rc.d]# at 4PM
at> cp /backup/*      /tmp/backup/
at> rm /backup/*                                           
at><EOT>
job 2 at 2012-02-07 16:00

1.                  daily schedule at 5PM )
CRON TAB HAS 6 FILEDS
2.                  minute (0­59)
3.                  hour (0­23)                  
4.                  day of month (1­31)
5.                  month (1­12, or name such as jan, feb, etc)
6.                  day of week ( 0­6(6 = Sunday) or name such as mon, tue,etc)
7.                  command to run

       #crontab -e  [ edit the crontab]
       #crontab -l  [ list of job]
       #crontab -r  [ delete all job]
---------------------------------------------------------------------------------------------------------------------
Network Diagnostic Tools
·         ping [ default will be infinity]
·         ping -c 5  192.168.1.102
·         traceroute [ it analyses the packet path]
·         host
·         dig
·         netstat
·         Connected users: w
·         Recent Logins: last, lastb
·         iwconfig
---------------------------------------------------------------------------------------------------------------------
Switchdesk                                             
Change the d #ip link showesktop session
------------------------------------------------------
·         chkconfig –list | less
·         cat /etc/services
·         all port number with the service name
·         system-config-services
·         setup
·         serviceconf
·         top
·         ps -A
 

No comments:

Post a Comment