Clado Solutions

Loading

Archives 2020

How to install Centos on your system ?

Hi, Here I will show you how to install CentOS 6 on your system. It has been derived entirely from the Red Hat Enterprise Linux distribution. CentOS exists to provide a free enterprise class for computing platform and strives to maintain 100% binary compatibility with its upstream source, Red Hat.[2] Here CentOS stands for Community ENTerprise Operating System.

GNU GPL license has release Centos and it is entirely freely available to download from official website. Once download ISO image, burn it into DVD using your favourite burner and Boot from DVD by making the DVD ROM to boot first in BIOS.

Follow the bellow steps to install CentOS 6

Step 1: Select the Install Button or you can update existing the system and then Press Enter.

Step 2: Choose Skip option the installation media check.

Step 3: Click Next button on Welcome Window.

Step 4: Choose the language you want and click Next.

Step 5: Choose Keyboard type and click on the Next button.

Step 6: Select the installation device type and click on Next.

Basic Storage Devices – It includes normal SATA or IDE Hard disk, This option will work mostly for all PC’s

Step 7: Specify the Host Name you want. If you want to configure network connection click on Configure Network.

Step 8: Select your network device and click on Edit to continue.

Step 9: Check on Connect automatically and click on IPv4 Setting tab.

Step 10: Setup your network setting and click on Apply, Click Close in the Network Configuration Window.

Step 11: Select your Time Zone and click on Next button.

Step 12: Type the password for root account and click Next. the password should use strong words so that becomes strong password.

Step 13: Select the Type of the installation and click on Next button.

Step 14: Select Customize now and click Next button.

Step 16: Select the package of software that y to install and click Next.

Installation will begin

Click on Reboot to Finish the installation process

Only the installation of CentOS 6 is finished, but Post installation configuration are still pending so Once machine rebooted it will prompt you for post configuration.

What is Netstat command and how to use netstat command ?

Netstat command is a command which is used to print information about the Linux networking subsystem. The type of informations that’s printed are controlled by the first argument: (none) By default, netstat displays a list of open sockets. If you didn’t specified any address families, then the active sockets of all configured address families will be printed. –route, -r Kernel routing tables are displayed. netstat -r and route -e these commands give us the same output. –groups, -g Displays the multicast group membership informations for IPv4 and IPv6. –interfaces, -i A table of all network interfaces are displayed. –masquerade, -M A list of masqueraded connections are displayed. –statistics, -s Summary statistics for each protocol are displayed.

OPTIONS
–verbose , -v
Tells the user what’s going on by being verbose. It prints some useful information about unconfigured address families.

–numeric , -n
Shows numerical addresses rather than trying to determine symbolic host, port or user names.

–numeric-hosts
shows numerical host addresses are shown without affecting the resolution of port or user names.

–numeric-ports
shows numerical port numbers but it will not affect the resolution of host or user names.

–numeric-users
shows numerical user IDs but it won’t affect the resolution of host or port names.

–protocol=family , -A
It specifies the address families of which the connections are to be shown.
separated list of address family keywords like inet, inet6, unix and ddp. This has the same effect as using the –inet, –inet6, –unix (-x), –ipx, –ax25, –netrom, and –ddp options.

raw, udp, tcp, inet sockets are included in the address family

-c, –continuous
netstat will print the selected informations every second repeatedly with this option.

-e, –extend
Display additional information. You can use this option to get maximum detail.

-o, –timers
Includes the informations related to networking timers.

-p, –program
It shows the process id (PID) and name of the program to which each socket belongs to.

-l, –listening
Show only listening sockets. (These are displayed by default.)

-a, –all
Show both listening and non-listening for established connections (ie TCP) sockets. With the –interfaces option, shows interfaces that
are not marked.

-F
Prints routing information from the FIB. (This is the default.)

-C
Prints routing informations from the route cache.

-Z –context
If SELinux is enabled then it will print the SELinux context.

-T –notrim
Stops trimming long addresses.

Example:

Listing only TCP port connections using netstat -at.

# netstat -at

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:48541 *:* LISTEN
tcp 0 0 192.168.0.11:43970 del11s06-in-f2.1e100.:https TIME_WAIT
tcp 0 0 192.168.0.11:52680 maa05s10-in-f14.1e100:https TIME_WAIT
tcp 0 0 192.168.0.11:36820 maa03s31-in-f10.1e100:https ESTABLISHED

Listing all ports (both TCP and UDP) using netstat -a option.

# netstat -a

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
\tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:48541 *:* LISTEN
tcp 0 0 192.168.0.11:43438 maa05s06-in-f3.1e100.:https ESTABLISHED
tcp 0 0 192.168.0.11:36820 maa03s31-in-f10.1e100:https ESTABLISHED
tcp 0 0 192.168.0.11:55236 maa05s12-in-f14.1e100:https ESTABLISHED
tcp 0 0 192.168.0.11:45854 13.83.65.43:https ESTABLISHED
tcp 0 0 192.168.0.11:59160 kul06s17-in-f229.1e10:https ESTABLISHED

 

Listing only UDP port connections using netstat -au.

# netstat -au

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:827 *:*
udp 0 0 *:bootpc *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
udp 360 0 192.168.0.11:48777 192.168.0.1:domain ESTABLISHED
udp 0 0 *:60564 *:*
udp 488 0 192.168.0.11:52509 192.168.0.1:domain ESTABLISHED
udp 488 0 192.168.0.11:49323 192.168.0.1:domain ESTABLISHED
udp 0 0 *:corba-iiop *:*
udp 0 0 *:41037 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:corba-iiop *:*

INODE

How to check availability of inode ?

What is inode?

Inode is a database which stores various basic informations about a file in Linux, such as access modes (read, write, execute permissions),file size, group, number of links, ownership, file type, , etc. An inode is assigned to file when it is created. Each inode is identified by integer number.

Command to find Inode number:

ll -i

so why inode ?

Every time a file is opened or created, the inode of the file is read by kernel of the server. The more files and folders you have, the more inodes are use. And more inodes you use,Your account consumes more system resources. This is the reason why it is a important to practice among hosts to limit number of inodes on shared server. It is not possible for one account to use system resources and leave no option for other accounts.
In case your account reaches the maximum number of inodes,you could experience several issues while file uploading, receiving mails,experience errors when accessing your website.

Command used to find the Inode value is

find . -printf “%h\n” | cut -d/ -f-2 | sort | uniq -c | sort -rn

Shared and Reseller servers only allowed upto 100,000 inodes.

Linux Commands

Essential Linux Commands for Beginners

Basic Linux/Unix Commands with Examples

1.alias

The ‘alias’ is another name for a command. If no argument is given, it shows current aliases. Aliases can be used for short names of commands. For example, you might use the cd command frequently. You can create an alias for it:

$ alias CD=’cd Desktop’

2.cal

Displays the calendar of the current month.

$ cal

November 2020

Su Mo Tu We Th Fr Sa

1 2 3 4 5 6 7

8 9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

29 30

3.cat

The ‘cat’ command is actually a concatenator but can be used to view the contents of a file.

$ cat /etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

halt:x:7:0:halt:/sbin:/sbin/halt

4.cat

Change the current working directory to the directory provided as argument. If no argument is given to ‘cd’, it changes the directory to the user’s home directory. In the given example change the directory to ‘/’.

$ cd /

5.chgrp

The chgrp will change the group of the file.

$ chgrp red file1

6.chown

The chown will change the owner of the file.

$ chown visitor file1

7.Clear

This command clears the screen.

$ clear

8.copy

Copy files and directories. If the source is a file, and the destination (file) name does not exit, then source is copied with new name i.e. with the name provided as the destination.

$ copy source destination

If the destination is a directory, then the file is copied with its original name in that directory.

$ cp backup.txt folder1

$ ls -l folder1

total 0

-rw-r–r–. 1 root root 0 Nov 8 02:28 backup.txt

9.date

Displays current time and date.

$ date

Sun Nov 8 02:33:35 IST 2020

10.df

The df reports file system usage. For example,

$ df

Filesystem 1K-blocks Used Available Use% Mounted on

devtmpfs 480828 0 480828 0% /dev

tmpfs 497840 0 497840 0% /dev/shm

tmpfs 497840 8684 489156 2% /run

tmpfs 497840 0 497840 0% /sys/fs/cgroup

/dev/mapper/centos-root 17811456 4615632 13195824 26% /

/dev/sda1 1038336 216240 822096 21% /boot

tmpfs 99572 28 99544 1% /run/user/1000

/dev/sr0 4669162 4669162 0 100% /run/media/pardhan/CentOS 7 x86_64

11.df

The du command determines disk usage of a file. If the argument given to it is a directory, then it will list disk usage of all the files and directories recursively under that directory:

$ du

0 ./.mozilla/extensions

0 ./.mozilla/plugins

0 ./.mozilla

0 ./.cache/gdm

8 ./.cache/imsettings

0 ./.cache/libgweather

0 ./.cache/evolution/addressbook/trash

0 ./.cache/evolution/addressbook

0 ./.cache/evolution/calendar/trash

0 ./.cache/evolution/calendar

0 ./.cache/evolution/mail/trash

$ du /etc/passwd

4 /etc/passwd

12.echo

This command will echo whatever you provide it.

$ echo “hello world”

hello worlds

13.fdisk

The fdisk is a tool for getting partition information, and for adding and removing partitions. The fdisk tool requires super user privileges. To list all the partitions of all the hard drives available:

$ fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0009329d

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 2099199 1048576 83 Linux

/dev/sda2 2099200 41943039 19921920 8e Linux LVM

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

The fdisk is an interactive tool to edit the partition table. It takes a device (hard disk) as an argument, whose partition table needs to be edited.

$ fdisk /dev/sda

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

14.grep

The ‘grep’ command searches for a pattern in a file (or standard input). It supports regular expressions. It returns a line if it matches the pattern in that line. So, if we wish to find the lines containing the word ‘nologin’, we use ‘grep’ as follows:

$ grep nologin /etc/passwd

bin:x:1:1:bin:/bin:/sbin/nologin

15. file

The file command determines the file type of a given file. For example:

$ file /etc/passwd

/etc/passwd: ASCII text

16.halt

This command in Linux is used to instruct the hardware to stop all the CPU functions. Basically, it reboots or stops the system.

$ halt
17.head

Displays the first few lihaltnes of a file. By default, the ‘head’ command displays the first 10 lines of a file. But with -n option, the number of lines to be viewed can be specified.

$ head /etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

halt:x:7:0:halt:/sbin:/sbin/halt

mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

operator:x:11:0:operator:/root:/sbin/nologin

18.history

This command shows the commands you have entered on your terminal so far.

$ history

1 SU –

2 su –

3 alias CD=’cd Desktop’

4 clear

5 cal

6 cat /etc/passwd

7 cd

8 cd /

9 clear

10 cd

11 chown visior file

12 useradd visitor

13 ll

14 touch file1

15 useradd visitor

16 chown visitor file1

17 grpadd

18 groupadd red

19 su –

20 date

21 df

22 dn

23 du

24 du /etc/passwd

25 echo “hello world”

26 fdisk -l

27 su –

28 su –

29 head /etc/passwd

30 history

19.help

With almost every command, ‘–help’ option shows usage summary for that command.

$ date –help

Usage: date [OPTION]… [+FORMAT]

or: date [-u|–utc|–universal] [MMDDhhmm[[CC]YY][.ss]]

Display the current time in the given FORMAT, or set the system date.

20.id

This command prints user and groups (UID and GID) of the current user.

$ id root

uid=0(root) gid=0(root) groups=0(root)

21.info

Info documents are sometimes more elaborate than the man pages. But for some commands, info pages are just the same as man pages.

$ info date

22.last

Displays information about the users who logged in and out of the system. A similar command is ‘lastb’ that shows the last unsuccessful login attempts. But this command must be run as root otherwise you would get an error saying permission denied.

$ lastb

root pts/0

root pts/0

Sun Nov 8 07:45 – 07:45 (00:00)

Sat Nov 7 11:29 – 11:29 (00:00)

btmp begins Sat Nov 7 11:29:39 2020

23.ln

The ln command is used in linux to create links. Links are a kind of shortcuts to other files. The general form of command is:

$ ln TARGET LINK_NAME

25.ls

List files and/or directories. If no argument is given, the contents of current directory are shown.

$ ls

anaconda-ks.cfg backup.txt folder1 initial-setup-ks.cfg

25.man

To see a command’s manual page, man command is used.

$ man date

26.mkdir

To create a directory, the ‘mkdir’ command is used.

$ mkdir clado

27.move

Move files or directories. The ‘mv’ command works like ‘cp’ command, except that the original file is removed. But, the mv command can be used to rename the files (or directories).

$ mv source destination

$ mv folder1 clado

28.netstat

The ‘netstat’ is a command used to check the network statistics of the system. It will list the current network connections, routing table information, interface statistics, masquerade connections and a lot more information.

$ netstat | head

Active Internet connections (w/o servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

Active UNIX domain sockets (w/o servers)

Proto RefCnt Flags Type State I-Node Path

unix 2 [ ]

unix 3 [ ]

unix 2 [ ]

unix 5 [ ]

unix 24 [ ]

unix 3 [ ]

29.pwd

DGRAM 14215

DGRAM 9194

DGRAM 9196

DGRAM 9207

DGRAM 9209

STREAM CONNECTED

/run/systemd/shutdownd

/run/systemd/notify

/run/systemd/cgroups-agent

/run/systemd/journal/socket

/dev/log

40577

‘pwd’ command prints the absolute path to current working directory.

$ pwd

/home/pardhan

30.reboot

reboot command is used restart or reboot the system.

$ reboot

31.remove

remove command is used to remove a file or directory. A directory must be removed recursively with -r option.

$ rm –r clado

32.stat

To check the status of a file. This provides more detailed information about a file than ‘ls -l’ output.

$ stat file1

File: ‘file1’

Size: 0 Blocks: 0 IO Block: 4096 regular empty file

Device: fd00h/64768d Inode: 17668947 Links: 1

Access: (0664/-rw-rw-r–) Uid: ( 1000/pardhan) Gid: ( 1000/pardhan)

Context: unconfined_u:object_r:user_home_t:s0

Access: 2020-11-08 01:09:53.005082195 +0530

Modify: 2020-11-08 01:09:53.005082195 +0530

Change: 2020-11-08 01:09:53.005082195 +0530

Birth: –

33.sudo

sudo (Super User DO) command in Linux is generally used as a prefix of some command that only superuser are allowed to run.The -V (version) option causes sudo to print the version number and exit.

$ sudo -V

Sudo version 1.8.23

Sudoers policy plugin version 1.8.23

Sudoers file grammar version 46

Sudoers I/O plugin version 1.8.23

34.tail

The ‘tail’ command shows the last 10 lines by default, and -n option is available as well.

$ tail -n 4 /etc/passwd

postfix:x:89:89::/var/spool/postfix:/sbin/nologin

ntp:x:38:38::/etc/ntp:/sbin/nologin

tcpdump:x:72:72::/:/sbin/nologin

pardhan:x:1000:1000:Pardhan:/home/pardhan:/bin/bash

[pardhan@MyFirstLinuxVM ~]$

35.touch

For creating an empty file, use the touch command.

$ touch file3

$ ls -l

total 4

drwxrwxr-x. 2 pardhan pardhan 6 Nov 8 09:28 clado

-rw-rw-r–. 1 pardhan pardhan 0 Nov 8 01:09 file1

-rw-rw-r–. 1 pardhan pardhan 0 Nov 8 10:13 file2

-rw-rw-r–. 1 pardhan pardhan 0 Nov 8 10:14 file3

36.tty

Displays current terminal.

$ tty

/dev/pts/

37.which

w command is used to check which users are logged in to the system, and what command they are executing at that particular time.

$ w

10:30:14 up 1:08, 2 users, load average: 0.34, 0.13, 0.09

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

pardhan :0 :0 09:23 ?xdm? 1:57 0.52s /usr/libe

pardhan pts/0 :0 09:27 6.00s 0.73s 0.27s w

38.wc

Word count

This command counts lines, words and letters of the input given to it.

$ wc /etc/passwd

43 88 2275 /etc/passwd

39.whatis

This command gives a one line description about the command. It can be used as a quick reference for any command.

$ whatis cal

 

cal (1)

 

cal (1p)

 

40.whoami

 

– display a calendar

– print a calendar

This command reveals the user who is currently logged in.

$ whoami

pardhan

 

Disk Partition in Centos 7

Disk Partition in Centos 7

HOW TO CREATE DISK PARTITION ON CENTOS 7

In the following steps I will show you how to create partitions in Centos 7 with fdisk command.

1. Specify the disk device to create the partition.

Here I am using the utility fdisk to create a new partition. First find the name of the device and use fdisk command like this.

The syntax is fdisk <hard-disk> and hit enter.

# fdisk /dev/sda

After hitting enter it will ask you commands to create partitions.

2. Request a new primary or extended partitions

Enter ‘n’ to request a new partition and hit enter. In the next step it will ask you to specify whether the partition should be created a primary or extended partition. The default selection is primary partition type.

Command (m for help): n

Partition type:

p primary (2 primary, 0 extended, 2 free)

e extended

Select (default p):

3. Select the size of partition

In this step it will ask you a partition number, enter 1 or don’t enter anything, just you can hit enter it will take 1 as default. Next it will ask you first sector value, here also just hit enter or don’t enter any values, by default it will take 2048.

In the next step it will ask you last sector size. Here you can mention the size of our partition. I am choosing 20 gb partition, for that I need to enter +20G.

The syntax is +numberG

If you want more size you can choose as your wish.

Partition number (1-4, default 1):

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

4. Verifying the partitions

To verify the partitions created or not by typing p and hit enter. It will show you all partitions in your hard drive. Here my hard drive is /dev/sda. Just now we have created one new partition, you can see new partition /dev/sda1.

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0008c000

Device Boot Start End Blocks Id System

/dev/sda1 2048 41943039 20970496 83 Linux

5. Save the created partition.

We have created the partition, but it is not saved for that we need to enter w command. So type w and hit enter. Now we have successfully created partition /dev/sda1 in hard drive /dev/sda.

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

6. Partprobe

Partprobe command informs the OS kernel to re read the partitions in hard drive. Then our newly created partitions will become active.

The syntax of partprobe is,

partprobe <hard-drive>

partprobe /dev/sda

7. Reboot

After completing all the above steps, you can reboot your machine. So you can only visible the partitions.

To reboot your machine you can use the command below.

reboot