Friday, December 23, 2016

How to check FileSystem usage ?

df -h / df -k are the commands to check filesystem usage .



Form the below example lets take /linuxtechnotes file system  as example .

Size :- is total size of /linuxtechnotes filesystem which is 582M.
used  :-  is total usage  of /linuxtechnotes filesystem which is 11M.
Avail :-   is total size of /linuxtechnotes filesystem which is 542M.
Use% :- is total % usage  of  of /linuxtechnotes filesystem which is 2%.
mounted on is the filesystem name .


How to Extend a filesystem ?(Pv/Vg/Lv extend) ?




LV Extend :-

Syntax :- lvextend -L +size  /dev/<vgname>/<lvname>

resize2fs  /dev/<vgname>/<lvname>






VG Extend :-

               vgextend  <VGNAME> <PV>


How to create a filesystem in Linux ?(Pv/Vg/Lv Create) ?


PV Create :-

Syntax :- pvcreate <diskname>

"pvs"  is the command to see current Physical Volumes.

VG Create :-
Syntax :- vgcreate <vgname>

"vgs"  is the command to see current  Volume Groups.

LV Create :-

 Syntax:-  lvcreate -L size -n  <lvname> <vgname >

"lvs"  is the command to see current Logical Volumes

How to create file system ?   In below example I am showing for ext3. You can replace it with ext4/xfs as needed .


syntax:- mkfs.ext3 /dev/<vgname>/<lvname>




How to Mount FileSystem ?

syntax:-  mount -t  <filesystemType> /dev/<vgname>/<lvname>  <mount directory>
ex:- mount -t ext3 /dev/vglinuxtechnotes/lvlinux  /linuxtechnotes

In order to get  auto mount during system boot add to /etc/fstab file as below .






How to Scan the new Disks in Linux ?




Syntax: - echo “- - -“>  /sys/class/scsi_host/host?/scan

Examples :-
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan

echo "- - -" > /sys/class/scsi_host/host3/scan
echo "- - -" > /sys/class/scsi_host/host4/scan



Before Scan :-



After Scan :-





How to Add New Disk to Linux Virtual server ?



"fdisk -l"  is the command to check current disks .




To add a Disk , Right Click on the server >> click on Settings/Edit settings   as below .


Then it will prompt to below screen , Then select Hard Disk and click on Add as shown below .


Click on Next as shown below



Specify the Size as you needed . In below example I have mentioned 1Gb and then click on Next.




Then click finish as show Below .



   Then once you scan the Disks you can see the new disk from the OS.                        
                       
                How To Scan New Disks In Linux ?                                                                                                                                      
Syntax :-  echo “- - -“>  /sys/class/scsi_host/host?/scan                                                                                          
                                                                                                  
Below you can see new Disk was discovered after scan the hosts .                                                                       
                                                           


                                                                                         

Thursday, December 22, 2016

How to Delete a user ?

syntax :- userdel <username>
syntax:- userdel -r <username >       

-r will delete home directory aswell .






Below you can see when your deleting with -r option its removing home directory aswell .







Monday, December 19, 2016

How to login a server using putty ?

using  'ifconfig' command you will get the IP address of the server .



Below you can see how can we login with putty.

In putty tool enter your hostname or IPaddress of server at below highlighted tab . Then hit enter or click on open


           

Then you will get prompt to below screen . You can click on yes and it will ask you only first time you login to server . once you click yes it wont ask you for next login as your computer saves the host key .





After that enter your login credentials as shown below .




How create a file in Linux ?


we can create a file in 3 different ways.
1)touch
2)vi
3)echo

1) Touch Command :-

syntax:-  touch <filename>

lets assume you want to create file called linuxtechnotes.
# touch linuxtechnotes



using below command we can create multiple files in single command. lets assume you want to create files called linux1,linux2,linux3.
#touch linux1 linux2 linux3



2) vi :-

using 'vi' command we can edit the existing files and create the new file as well.

syntax:- vi <filename>

In below example created a file called file1 with context.








3) echo:-  

syntax :- echo "context" > <filename>

In below example created a file called file2 with context .




Note :-  using any of touch,vi,echo we are able to create a file . But did you notice any difference ?

The difference is using 'touch' command we can create a file without any context . But to create using " 'vi'and 'echo' we need context aswell and also we can create both file and context during same time .


How to find IP address and login remotely ?

using  'ifconfig' command you will get the IP address of the server .



There are many tools which you can login a server remotely . Below you can see how can we login with putty.

In putty tool enter your hostname or IPaddress of server at below highlighted tab . Then hit enter or click on open


             

Then you will get prompt to below screen . You can click on yes and it will ask you only first time you login to server . once you click yes it wont ask you for next login as your computer saves the host key .





After that enter your login credentials as shown below .





Sunday, December 11, 2016

How to reboot the server ?


once you login-ed to the console  run 'reboot'  as below .


Then server will reboot as showed in below screens .





Once server got boot and its up you will get below login prompt .


How to get terminal in VMware work station ?



First login using your credentials  as showed in below examples.




Once you get logged in .


Right click and press open in terminal .


You will get the terminal like below .



How to login with other user from VMware work station ?


Lets assume below is the screen which you get by default . In below example its linux-vm user . what if you want login with other user ?



As showed in below screen press down arrow to go to other tab . And then press enter key .


You will get below screen .


Then enter your user name . In below screen i am logging as user "root". Then press enter key .


Then it will prompt for password .


Give your password accordingly . If your not sure about password check here  on How to change password.


Ignore the below error and close it .


Now you can see below your able to login the server.


Then you  can do right click and enter open in terminal as showned below .



Below you can see the terminal was opened .




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Please do comment below for any queries , will get back to you soon .