27

Click here to load reader

mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

  • Upload
    hakhanh

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

Page 1: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

sLinux Class Notes:

Ticketing tools: SNOW- Service Now and JIRA.

CLI- Command Line Interface aka LUI- Line User Interface.

Default in most Linux nowadays: Bash (bourne again) Shell. There might be other shells e.g. Korn K-Shell (ksh), C Shell (csh), tcsh, zsh, rc, es etc. for Shell to interact with the Kernel.

Basic Linux Commands

| pipe will take the previous output as an input. e.g. cat a | wc –lwhich ls shows where it iswhatis ls shows what it does

ls lists the filesls –l detailed listing of the file/directory:

permission- copies/links –ownership- size- modification timels –la shows hidden file tools –lt shows sorted by timels –ltr shows files sorted by time, in a reverse order

ls –l | grep b shows files with filename ‘b’ inside it

pwd print working directorycd /var/log changes directory to /var/logdate display and edit the datewho or w shows who is logged in, w also shows who is doing whatwhoami displays the loginnameowner name of the current user, you can use id tooman head shows manual, eg: man head shows manual for head command, q to exitinfo ls shows information about ls command-help or –h shows help, eg: mkdir –help or head –help (double dash= flag + dash).

head –n x myfile displays the first n (default 10) lines of the file eg: head –n 8 myfiletail -n x myfile displays the last n lines, eg: tail -n 20 myfile, default 10Tail –f /var/log/messages shows real time log information and history, useful while

troubleshooting

cd change directory

Page 2: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

mkdir create directoryrmdir remove directorycp copy files or directory, eg: copy source destination, copy file1 rootmv cut (move) files and directory, also can change the filename

eg: move sourceDir destinationDir

rm removes files and directorytouch create empty file and change the time stampecho to show/print. e.g.: $echo My name is Aashishcat concatenate, link, display, show file on screen

echo $PATH shows all the path, contents and files undervi vi editor, to edit texts inside files, save :wq!

vimtutor tutors the vi editor> redirect symbol, instead of printing on screen it will be saved to a file>> upend (not overwrite) to a file, content of a file will be added to a fileread like echo but replaces the word with a different wordwc word count and statistics, eg: wc file1.txt, wc –w file1.txt will show the

total word count, and wc –c file1.txt will show total characters

sort organize alphabetically or remove it, eg sort file1.txtsort –r file1.txt will reverse the order, and sort –n file1.txt will numerically order eg 1-20

uniq cleans and filters out repeated or matching lines from input.eg: text1.txt has: My name is Aashish.

My name is Aashish.My name is the Aashish.

Then: uniq text1.txt will print only 1st and 3rd line.

locate Similar to whereis & find command.eg: locate passwd, will show full pathfind locates file on system eg: locate . (period = current directory).

find /root -name komal search starting from (/) –name directory

more Shows top of the file, press enter to go downless read upward and downward of a filehistory display the history of commands, or use up arrow to show the history

history –c clears out historytree Give a tree structure of directoryupdated updates the databasetar zip file

GREP:

grep search a string in our file eg: grep –in dhcp var/log/messages (-i) flag lets grep search without case sensitivity

Page 3: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

(-in) flag shows which lines the content are ingrep bb abc.txt will find anything that has bb in abc.txt file

grep cc$ abc.txt lines that end in cc

grep ab abc.text

grep ^ab abc.text shows anything in abc.txt file that starts with ab

grep .cc abc.txt anything that follows by cc, eg; acc, 1cc, ucc etc

grep ^.b abc.txt beginning of anything that is 1 character and followed by b

grep ^…$ abc.txt search beginning of line that can have 3 single character and at the end of line. eg anything that starts and ends with 3 characters

ls file* list command of files that have file name file1, file4, filex etc

grep ^3server hostnames line items that has 3 servers in it in the host

grep [ser] hostnames anything that is s or e or r

grep [^ab] hostnames anything that is NOT a or b

HardLinks (another name) and Softlinks (symbolic links/ shortcuts):

Harddrive:Superblock: Type, size, status of file systeminode: Info about the files in system, mode, who owns, create date, sizeDatablocks: Data is stored actually in the data block, every file has reference

ls –l gives the - Filetype: Links : Groups: Creation date

Links Soft links are just like the shortcuts in Microsoft windows. Hard links are just different name for same files. Hard link means creating new file names. inode value same means its same file.

ls –li test shows inode value and details about the file: test

ln –s test myShortcut Give test file new name: myShortcut, like shortcut on desktop

Page 4: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

ls –li test mySHortcut shows inode value & details about the files: test and myShortcutThe softlink is different color and new inode number. for the shortcut the first alphabet on the permission is: “l” i.e. lrwxrwxrwx, which stands for link.

cat test & cat myShortcut give the same result. If test file is deleted, myShortcut will give error, because there is no file to link or point to.

ln file1.txt hardlink1 Creates a hard link for the file1.txt, both will have exact same inode and will have 2 links, if we delete file1, there will still be hardlink1. Hard link is not allowed in directories, only for files.

6 Stages of Linux Boot Process (Startup Sequence):

http://www.thegeekstuff.com/2011/02/linux-boot-process/

BIOS Basic Input/Output System executes MBRMBR Master Boot Record executes GRUB GRUB Grand Unified Bootloader executes KernelKernel Kernal executes /sbin/initInit init executes runlevel programsRunlevel Runlevel programs are executed from /etc/rn.d/rc*/d/

df –h Shows partitions custom install details

Space allocation for VMware ESXi:

Dynamically: Thin: Useful when there is not enough space on Machine. Pros: You can install as many OS as you want. Cons: You will have to constantly monitor it.

Fixed: Thick: Space is fixed and allocated directly.

RAID: Redundant array of independent disks

http://mazzakolinux.com/raid-redundant-array-of-independent-disks/

RAID 0: Stripped Disk Array: Data written across 2 hard drives at same time. Performance high. No fault tolerance, doesn’t take a backup.

Page 5: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

RAID 1: Mirroring: Minimum 2 disks required. Same data written at two disks as mirror data. Good for fault tolerance. If one fails, other can keep working. Performance slow. Data saved.

RAID 5: Raid with parity: Minimum 3 hard disks. Data written across 2 (half and half) and mirror on third. Data is saved this way. Most used. Write operations will be slow.

RAID 10 (1+0): Combines the mirroring of RAID 1 with the stripping of RAID 0. Best performance but expensive. Ideal for highly utilized database servers.

File System Types:

Ext2, Ext3, Ext4, BtrFS (prncd: Butter), XFS, JFS, ZFS, SWAP.

Ext2- Second extended file system. Can be max 32TB. Max 2TB file size. Used in flash drives. No journaling feature.

Ext3- Third extended file system. Allows journaling. Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling. 32TB. 2TB.

Ext4- Fourth extended file system. 16TB file. 1PB =1024 TB max ext4 file system. Can turn journaling off and on. New features: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc

Partition types:

Primary Partition: is a partition that is needed to store and boot an operating system. In general, you would install the operating system in a primary partition. Maximum of four primary partition can exist. If we need more than four partition, we can make Three primary partition and make one Extended partition and many logical partition under Extended partition.

Extended Partition: can be sub-divided into logical drives and is viewed as a container for logical drives, where data proper is located. An extended partition is not formatted. The extended partition is used only for creating a desired number of logical partitions.

Logical Partition: are the partitions that are created in the extended partition area. A logical partition is a way to extend the initial limitation of four partitions. An extended partition can contain up to 24 logical partitions.

……………….Swap space in Linux is storage allocated from hard drive to act as virtual ram. Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more

Page 6: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

Logical Volume Manager (LVM) is a device mapper target that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume.

• Physical Volume• Volume Group• Logical Volume

In order to create a logical volume, we need to follow a certain procedure. Logical volume can only be created under Volume Group, and Volume group can only be created under Physical Volume. Physical volume can be created from partitions. One partition equals to one physical volume. Whole physical volume has to be given to one volume group. One volume group can be created from multiple physical volume. One volume group can contain multiple logical volume.

Custom Install:

http://mazzakolinux.com/install-linux-vm-coustom-partition/

Boot: Boot filesSWAP: After RAM space if full, allocated SWAP space from hard disk space, for just in

case so that system doesn’t crash, although it means the system gets slower. Recommended SWAP: If n < 2, SWAP = n x2, Where n= Physical RAM

If n > 2, SWAP = n +1

Root \:

Partition types: Primary, Extended and Logical.

Logical Volume partitions: 1. /opt 2. /var 3. /tmp 4. /home 5. /usr

Mount Point: Directory files where devices are mounted.

File system type: Eg: Like FAT 32, Linux has EXT4, XFS, SWAP etc.

Max Primary Partition = 4. So we make 3 primary partition (boot, swap and \) and we make the 4th one (extended volume) and divide it into LPV Logical Physical Volumes. In order to create Logical volume, we need to have a physical volume, create a volume group and create logical

Page 7: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

volume inside it. It is nice to put a custom name for Volume Group Name, not a default name, to minimize confusion.

lsblk Shows details of the custom installs. Where, sda is first hard disk. If there was second and third, it will be sdb and sdc. Sda is divided into sda1, sda2, sda3, sda4, sda5. sda5 has logical volumes.

df –h Details on human readable formdf –PTh Details on custom install

lsblkfdisk –l /dev/sdb to see sdbfdisk /dev/sdb to add and remove partitions in /dev/sdb

pvs to see physical volumepvcreate to create physical volumevgs to see physical volumevgcreate to create volume grouplvs to see logical volumelvcreate to create logical volume

lvextend to extend logical volumevgextend to extend volume group

Volume group takes space from Physical volume. For volume group you MUST have a physical volume. I partition can only have one physical volume. Whole physical group has to go to one volume group, which can be a combination of lots of physical group. Volume group can be created with multiple physical volume though.

fdisk /dev/sdb To create partition for sdb and follow instructions using helppvscan Like pvs command, but more info on physical grouppvdisplay Like pvscan and pvs but more info on physical group

pvcreate /dev/sdb1 To create physical volume (for Volume group) on sdb1, which is empty when it comes to physical volume

vgs Check how many volume group we have

vgcreate datavg /dev/sdb1 To create a volume group called datavg on physical group sdb1

lvcreate –L 3G –n /dev/datavg/dholilv datavg To create a logical volume with –n (name) dhonilv and with 3GB size and goes to datavg volume group

Page 8: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

mkfs.ext4 /dev/datavg/dhonilv Format logical volume type to EXT4 (file system types).

mount –t ext4/dev/datavg/dhonilv Mount a type of file system (-t ,ext4) to the file dhonilv to a

directory /dhoni

umount /dhoni To unmount a directory

To mount permanently:

vi /etc/fstab Open /ect/fstab in vi editor and enter:

/dev/datavg/dhinilv /dhoni ext4 defaults 1 2

In vi editor:

EscGo to lineShift v to selectpress d = cutGo where you want to pastep = paste

df –h Shows whatever is mountedcat /etc/mtab See mount and directoriescat /roc/mounts Shows whatever is mounted

resize2fs /dev/datavg/bablilv Resizes the logical volume

REVIEW:

Creating Partition, physical volume, volume group, logical volume and Mounting:

Partition: fdisk /dev/sdb into sdb1, sdb2, sdb3Create Physical Volume: pvcreate /dev/sdb1Create Volume Group (datavg): vgcreate datavg /dev/sdb1Creating Logical Volume (dhonilv): lvcreate –L 3072M –n dhonilv datavg L=sizeFormat Logical Vol to EXT4: mkfs.ext4 /dev/datavg/dhonilv

Page 9: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

To Mount:s-

Make directory: mkdir /dhoniOpen vi /etc/fstab: /dev/datavg/dhonilv /dhoni ext4 defaults 1 2Mount now: mount –aTo check: df –hIncrease logical volume: lvextend –r –L +2G /dev/datavg/dhonilv To create a direct primary partition from /dev/sdb3 and mount on /baje:

mkdir /bajeFormat the partition: mkfs.ext4 /dev/sdb3vi /etc/fstab: Type: /dev/sdb3 /baje ext4 defaults 1 2mount –a

mount -o remount, rw /

To remove partition, we need to start from the bottom:

Use unmount command: unmount /dhonilv check with: df –h and lvsRemove logical volume: vgremove /dev/datavgRemove physical volume: pvremove /dev/sdb1 check with: pvsDelete partitions: fdisk /dev/sdb check with: fdisk –l /dev/sdb

To create swap from partition:

mkswap /dev/sdc2vi /etc/fstab type: /dev/sdc2 swap swap defaults 0 0swapon –s

Permissions:

UGO: RWX-421g

ls –lh Check size file, human readable formdu –sh Check size of directorydu –ch –max-depth 1 Check size of directory and files and total size of directorystat file1 Checks the file name, size, blocks, type, inodes, excess permissions,

owner’s id (0= root) etc. Access, modify and change time for file1file aashish1 Finds types and details of the file aashish1

Page 10: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

vi test.sh Write script and end with .sh means it was hand written. starts with shebang

#!/bin/bashecho “Hello World”save :wq!

chmod +x test.sh Make the test.sh file executable by adding permission

./test.sh Open the test.sh file

chmod u+rx a.txt Give user read and execute permission for a.txt filechmod uo+rx a.txt Give user and owner read and execute permissionchmod a+rx a.txt Give all (user, group, others) read and execute permissions

chown Changing the ownershipchgrp Changing the group

chown username:groupname file1 Change ownership and group at same time

useradd userX Create userX in a default waycat /etc/passwd Shows all the users created

Groups can be divided into primary and secondary group. If user has only 1 group, by default it will be its primary group. If multiple group, his main group is his primary group e.g. Cricket group in a class.

id root Will show the UID, Group ID and shows the primary groupgroupadd Admin Add a group called Admin

Useradd:

When we create a user, we have to write it down somewhere so that the machine will know. We write it in: /etc/passwd where user information is written, such as username, user id, group id, comments about user, home directory, default shells.

getent passwd Shows list of usersgetent group Shows list of groups/etc/group Has the group information and its members

Page 11: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

/etc/shadow Has the password information about user, including password expiration and hashed password

/etc/login.defs Information about password info if you create from useradd command without custom password expiration information

/etc/defaults/useradd It will have info about the defaults/etc/skel This is a directory. Contents of this directory will be added to

users home directory when user is created. It has dot (.) hidden files.

cat /etc/passwd | grep bablu Shows info about bablu: username, ID, group ID, comment, path to home, path for the Shell

If we create a user: useradd Aashish it will have info in: cat /etc/passwd | grep Aashishand cat /etc/group will have its group info and its home directory in ls –l /home.

passwd Aashish Change Aashish passworduserdel –Rf Aashish Deletes Aashish user

Question: When we create a user called Hari, these things are added:

username: HariUID: 524GID (primary): developer = 532Secondary groups= hr, sales, humanityHome directory: /home/developeruser’s default shell: /bin/bash

cat /etc/group | grep developer Check if we have a group called developer. If not:groupadd developer Add a developer group. Will have default id.groupdel developer Delete the groupgroup –g 532 developer Add groupid 532 to the developer

groupadd humanity Add a group called humanity

useradd –u 524 hari Created a user with uid 524

useradd –u 524 –g 532 –G hr, sales, humanity –c “dev” -d /home/developer –m –s /bin/sh hari

Where, g= Primary, G= secondary, -c = ms, -d = home directory, -s = shell Check: id hari

cat /etc/passwd | grep hari

Page 12: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

If we made a mistake:usermod –u 528 –c “developer” –s /bin/bash hari Modify user information

To add without removing: add –a too usermod –a –G hr, sales, ihumanity hari

To change password of user Aashish:

chage –l Aashish Shows password aging info about Aashish

chage –d 0 Aashish Force Aashish to change password on 1st login

chage –m 2 –M 90 –I -1 –E -1 –W 4 Aashish

-m 2   minimum number of days between password change, here Aashish won’t be able to change his password for 2 days after he changes he password

-M password will expire after 90 days

-I -1 will set the password inactive to never

-E -1 account will never expire, Maximum # of days

-W 4 user will start getting warning 4 days before password expires

IF YOU GOTO ROOT AND CHAGE USER YOU CAN CHANGE THE ABOVE INFO MANUALLY!

Lecture: System files, Special files, and Sticky Bits

setuid This flag is used to allow multiuser accesssetgid This flag is used to allow multi group accesssticky bit This flag prevents accidental delete by users or groups

For group collaboration:

chmod Change permission on files and directorychown Change ownership of files and directory

Page 13: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

Special directories and files:

/var contains files that change often such as mail, logs etc. Under /var folder is:/var/tmp contains files that do NOT get deleted on reboot/tmp contains temporary files that do get deleted on reboot

/tmp folders can be written by any users on Linux file systems and delete it too. The problem is if I write, another can delete it. It can create havoc. The problem with temporary files is that it has permissions 777 eg: rwx rwx rwx . But, when we add sticky bit to a folder, it makes it so that only users that create their own folders and files even if it has 777 permissions.

cd /sticky ls –l

The sticky directory (because it has a ‘d’ in front) and has drwxrwxrwx permission.

user@dr: touch file1.txt create a filevi file1.txt edit the filerm file1.txt ls –l /sticky/ shows 777 permissions for sticky folder

To add sticky bits: chmod o+t /sticky t=sticky flagls –l shows new permission: drwxrwxrwxt with ‘t’ at the end,

meaning only the creator can remove the file now even if it has 777 permissions.

Let’s add 4th octet while adding permission now, since we know sticky bit:

chmod 0777 /sticky removes the sticky on the /sticky folderchmod 777 filename will default no sticky bit, 0 is invisible, and we only use to add:chmod 1777 will add sticky bit permissions

chmod o-t /sticky will remove the sticky, o=other, t= sticky chmod 1777 /sticky or chmod o+t /sticky to add it back

Whenever we are to open or execute a file, it forks a new process as a person executing a file ad also has the privilege. Example:

which passwd Shows where is passwdcd /usr/bin shows passwords for users

Page 14: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

Only root user and group can call the passwd file. But if we want some user to give a permission to navigate the file, in addition to read write and execute permission, they have something called sticky bit which is four 4 words long, shown in the permissions. This allows the user to navigate as if it is the original user or root of the file. To set these sticky or change the bash files, it is a loop-hole, so only the root is allowed to assign some users this permission, or setuid or setting the user this special id or permission. Same thing for setgid.

setgid means execute with permission as a group not as a user owning the file

Using octal notation, for this, there must be 4 numbers where the 1st one is the setgid. E.g:

chmod 6500 file1 It has permission for 6 = user and group

Stikcybits prevents unauthorized removal or rename of directory and file.

chmod +t test1 +t = write protected, adds sticky bits. It is at the end of permission and shows as T.

ACL: Access Control List

tune2fs-l /dev/mapper/datavg-testlv To check if ACL is enabled or not

vi /etc/fstab And type:

/dev/mapper/datavg-testvg /test ext4 defaults,acl 1 2

mount –o remount /test/mount –s To check if acl is activated

To give user sruti read, write and execute permission to the folder class without changing the original permission of user root and group root:

setfacl –m u:sruti:rwx classls –lgetfacl class to check the aclsetfacl –m g:admin:rwx class give the group permission the same way

Page 15: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

Commands:

1. To add group called hr: groupadd hr check: getent group2. To add user: useradd Ram delete: userdel –Rf Aashish

3. To add a password: su root and then passwd user

check: chage –l Ram and passwd –S Rampasswd –l Ram Locks the passwordpasswd –u Ram Locks the password

4. Add secondary groups to user Ram: usermod –a –G admin,hr Ram5. Change password info: chage –m 2 –M 90 –W 4 Ram6. To edit comments: vi /etc/passwd check: getent passwd7. To check details: id Ram or vi /etc/passwd | grep ram8. Create directory and change 777: mkdir /share then chmod 777 –R /share9. Create files: touch students.txt user.txt10. Add permissions for different users:

df -h /Share Share directory location before mounting

Check acl default: tune2fs –l /dev/mapper/datavg-dhonilv

vi /etc/fstab and type: defaults,acl

mount –o remount /share/mount –s Check mounted files and if acl is activated

See permissions:

getfacl user.txt

Set permissions:

setfacl –m u:shyam:rwx test.txt m= modify

Check: getfacl user.txt

Page 16: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

To add users to sudoers file:

vi /etc/sudoers and add the user chmod o+rwx –R /share

Switch user: su ramThen to add rw: sudo chmod u+rw /share/user.txt Put password for ram

All packages in Linux are in .rpm format. The command to install it is called RPM itself.

Yum Install:

http://mazzakolinux.com/yum-setup-from-dvd/

0 = ON1= offIf you put gpgcheck=1, you have to give a path. Just do gpg=0

Common Services and Ports:

OSI: Open System Interconnection

To enter permanent IP address in the system:

vi /etc/sysconfig/network-scripts/ifcfg-eth0 and enter:

DEVICE=eth0ONBOOT=yesBOOTPROTO=dhcpTYPE=Ethernet

service network restartifconfig

route –n Will get you the gateway

cat /etc/resolve.confg

Page 17: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

Attach an adapter in virtual box at same time you can use upto 4 adapters. Our main goal is to get an ipaddress and get others to connect in the network. For this we will work on:

/etc/sysconfig/network-scripts/ifcfg-eth0 (the 1st adapter will be 0, then second will be 1 then

2 then 3). The configuration is for dhcp.DEVICE=eth0TYPE=EthernetONBOOT=yesBOOTPROTO=dhcp Bootprototype = dynamic

:wqservice network restartifconfig

For static IP address setup at work:

ifconfig Note down IP address i.e. inet addr (1) Note down Mask (this will be the netmask) (2)

Now do:

route –n Look for UG under flags, on that line go under Gateway and note down the ipaddress (that will be your gateway) (3)

cat /etc/resolv.conf Note down search name and also name server ipaddress will be DNS (4). Search will be your DOMAIN (5)

So after you have all these information, you will be able to setup static ip address. To do that:

vi /etc/sysconfig/network-scripts/ifcfg-eth0 Copy the above^ Purple but replace BOOTPROTO= none.

DEVICE=eth0TYPE=EthernetONBOOT=yesBOOTPROTO=noneIPADDR=(1)NETMASK=(2)/GATEWAY=(3)DNS1=(4)DOMAIN=(5)

Page 18: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

service network restartifconfig

If someone asks you to setup network, then you need to ask what VLAN, then ask password netmask for it, gateway for it and domain. It should be in and nameserver or DNSserver.

Things to remember:

LAN: Local Area Network: Internal connection of machines/computers. To connect outside, our router will act as a gateway, so that we can get to the internet. It will connect different

networks and act as a doorway to connect to different network around the world.

Our router will also act as a DHCP server (Domain controller), DNS server and gateway. When we

type www.google.com, the DNS server translates name into IP address. When you set up a website you choose a web-name which is attached to an IP address, which the DNS server

tracks and communicates. DHCP server provides with IP address, Gateway connects to outside world internet, DNS server will help you translate name into IP address. DNS server will have all the computer’s name in the network and their IP address, so we don’t have to remember the IP address to connect with each other. DNS server is a Yellow Page for IP address and hostname. Active directory server is also like DNS server but is a Yellow Page for username and passwords.

Change Hostname:

http://mazzakolinux.com/change-hostname/

hostname NewName followed by exit Change Hostname Temporarilyvi /etc/sysconfig/network Change hostname Permanently

Other network services:

Temporary: service network restartservice servicename start (Options: restart stop)

/etc/init.d/servicename start (Options: restart stop)

Permanent: chkconfig - - list

Page 19: mazzakolinux.commazzakolinux.com/wp-content/uploads/2017/02/Linux-Cl…  · Web viewsLinux Class Notes: Ticketing tools: SNOW- Service Now. and . JIRA. CLI- Command Line Interface

E.g: chkconfig iptables off

setenforce 0 Will disable SELinux (temporary)

vi /etc/sysconfig/selinux Change permanently

vi /etc/inittab To check init types

To change into 6 different terminals in console: Fn + Alt (Option) + F-2/3/4/5/6

To share files:

vi /etc/exports Add share name: * = everybody/share1 *(rw,sync,no_root_squash)

service nfs restartservice exportfs restartservice … (check website)

exportfs To see which directories are sharednetstat –tulpn Check ports, ports at end of local addresstelnet chandu 22 Check port 22 for telnet for chandu or his ip addrservice iptables start Turns Firewall ONservice iptables status Checks firewall status

To manually setup firewall:

setup press enter, select press space *=ON

rpcinfo –p chanduIP Pings –p = ping Chandurpcinfo –p localhost Check own ports/etc/init.d/ press enter Shows services name list

cat /etc/sysconfig/iptables Check Firewall status