Sunday 13 January 2013

monitoring command in linux rhel 5 or 6


# Tty                          [to open terminal]

# w                                [show login user]

# who                             [show login user]

# pinky                           [show remotely login user]

# who –a                           [show all login user at every terminal]

# last                                   [show last login]

# last b                                   [show bad login]

# uptime                                    [show login duration]

# vi /var/log/temp                            [last log file]

# vi /var/log/wtmp                            [view last bad login file]

# top                                                          [show process]

# uname                                                        [show kernel]

# uname –r                                                        [kernel release]

# uname –v                                                            [kernel version]

# uname –o                                                               [operating system]

# cat /proc/cpuinfo                                                        [cpu information]

# cat /proc/meminfo                                                        [memory information]

# cat /proc/mdstat                                                               [status of raid]

# free                                                                                       [show ram]

# free –m                                                                                      [show ram in mb]

# swapon –s                                                                                      [status of swap]
 
#df -TH                                                                                                 [show partition space]
 
#du -sh  /Vijay                                                                               [show particular directory of folder]


how to remove EFS in linux rhel6 ?


#umount /crpt

#vim /etc/fstab

delete entry

:wq! (save n quit)

#mount -a

#vim /dev/crypttab

delete the entry

:wq!

#cryptsetup luksClose /dev/mapper/storage

#cryptsetup luksRemoveKey /dev/sda5 /root/key

#rm -rf key

#ll /dev/mapper

fdisk /dev/sda

delete the partition

#partx -a /dev/sda (run 2 times.)

how to make Encryptition File System in linux rhel 6


Efs basically provide encryption over the partition or hard disk. It works on LUKS (linux unifine keys setup) utility.


Paccage – crypt-utils

Tool = cryptosetup

step 1 #yum install crypto* -y (install the paccage.)

step 2 # create partition with 2G (this is not mendetory you can give any size.)

#cryptsetup luksFormat /dev/sda5 (after luks all firsl starting character in capital.)


YES (type yes in capital)

(******) (type password)

(******) (again)




How to chack mapper points ?

#ll /dev/mapper (show presant mapper)

#cryptsetup luksOpen /dev/sda5 storage (make mapper over on partition with name storage)

#mkfs.ext4 /dev/mapper/storage (format mapper storage)

#mkdir /crypt

#mount /dev/mapper/storage /crypt (temprory mount mapper on /crypt)

#vim /etc/fstab

/dev/mapper/storage /crypt ext4 defaults 0 0

:wq!

(for permanent mount make this entry in fstab save and quit)

#mount -a

#mount

#df -TH (show all size)

#vim /etc/crypttab

storage /dev/sda5 (password) which is you set in starting of the cryptFormat

:wq!

(leave it once without password and restart the system u can see the password on booting.)

#dd if=/dev/urandom of=key bs=4096 count=1

(to make a random password key )

#dd if=/dev/urandom (to create randoom file)

#cryptsetup luksAddKey /dev/sda5 /root/key

(to add key in root for partition 5)

#chmod 400 /root/key (set the permission on root/key )

#vim /etc/crypttab

storage /dev/sda5 /root/key

:wq!

#umount /crypt/

#cryptsetup luksClose /dev/mapper/storage

#ll /dev/mapper

#cd /crypt

#ls

#cd

#cryptsetup luksOpen /dev/sda5 storage

#ll /dev/mapper

#mount /crypt

#cd /crypt

#ls

#man cryptsetup (read all the manuel of the cryptsetup)

how to delete swap partition in linux rhel 6


#swapoff /dev/sda5 (off the swap on partition)


#vim /etc/fstab


delete this entry save and quit


:wq!


#mount -a


#fdisk /dev/sda

d - 5 - w

#partx -a/ dev/sda (run 2 time for activate the partition table.)

how to create swap partition in linux 6

It is a file system type which is used to enhance of the system performence or it will act always

virtual memory.

#create one partition

#fdisk /dev/sda

press n - blank enter - +2G - p - press t -5 - for change the partition code give the 82 for swap id - p - w

#partx -a /dev/sda (press two time.)

#mkswap /dev/sda5 (to make swap)

#swapon /dev/sda5 (for activate the swap)

#swapon -s (show status of the swap)

#vim /etc/fstab

press i for insert mode and type this entry on last of line

/dev/sda5 swap swap defaults 0 0

press esc and

:wq! (save)

#mount -a (activate all mounts)

#free -m

#free -m -t

#cat /proc/swaps

#cat /proc/meminfo (all commands is use to check the swap status.)

how to delete any partition in linux?


#umount /data (unmount the directory on the partition)

#vim /etc/fstab

remove line entry with /dev/sda5 /data (press dd in esc mode and :wq! Save and exit )

#mount -a

#fdisk -c /dev/sda (go to hdd)

press d enter and partition number which is you select in the mounting point.

5 enter

p (print to see the table)


w (save the table)

#partx -a /dev/sda (always run this command two time )

how to mount any partition wid UUID ?

#blkid (show all partition uuid)

#blkid /dev/sda5 (show any particular partition id)

after that copy the content which is in " "

#vi /etc/fstab (and rewrite the previous entry remove the /dev/sda5 and paste with UUID=)


UUID=paste here code /

#mount -a

#blkid -U (uuid code) (to check partition with uuid )

How to mount ant partition on a Directory Step by Step

step 1 creat one  parttion :-
#fdisk -l

(check the HDD name)

#fdisk -c /dev/sda

(dev/sda is mine system name find yours and its commant to create the partition.)

#Press M for help

N (new Partition)

there is two option don't make it primary now

press E for extended

and after hit two time blank enter (dont change first time.)

after you can see there is 2 or 3 primary partition or of the last is extended with Press P for Print

now press again N for new partition

first blank enter

after that give the size of partition Syntex is like that: + 20G and enter you can also creat in K,M,G, (kb,mb,gb).

Now press p to print table see there is another partion which u make

now press W to save the partition

#partx -a /dev/sda

(to activate your partition and run this command two time.)

Note: This command is working only Rhel6 if you have any other then you can put this command

#partprobe /dev/sda

#mkfs.ext4 /dev/sda5

(format the partition make sure always define partition like /dev/sda5, sda6,)

#mkfs -t ext4 /dev/sda5

(also use to format with file system like ext2,ext3,ext4, )

#mkdir /data (make a directory.)

#mount /dev/sda5 /data

(this is temprery mount if can parmanent then make entry in vi /etc/fstab,)

#vim /etc/fstab

(go in this file and make this entry in insert mode for insert press i in the file)

/dev/sda5 /data ext4 defaults 0 0

press escape and :wq! (to save changes in the file.)


#mount -a (to activate the mount point.)


#mount (show all mount points.)


#df -TH (show all partition )


#du -sh /data (show only folder size.)