Linux basics part 1

Download Linux basics part 1

Post on 14-Jan-2017

26 views

Category:

Education

1 download

Embed Size (px)

TRANSCRIPT

<p>PowerPoint Presentation</p> <p>LINUX</p> <p>Linux OverviewSHELLDirectory StructureBasic CommandsText Editor for linuxUser and Group ManagementPermissionsGRUBTAR file RPMNetworking (Assign IP)Hard Disk Management</p> <p>LINUX</p> <p>Linux is an operating system based on UNIX, and was first introduced by Linus Torvalds commonly used in servers. </p> <p>It is based on the Linux Kernel, and can run on different hardware platforms manufactured by Intel, MIPS, HP, IBM, SPARC and Motorola. Another popular element in Linux is its mascot, a penguin figure named Tux.</p> <p>Its free and available in open source.</p> <p>Open source: Open source is a platform that allows you to distribute your software, including source codes freely to anyone who is interested. People would then be able to add features and even debug and correct errors that are in the source code. They can make it run better by adding some new features and then redistributes these enhanced source code freely again. This eventually benefits everyone in the community.</p> <p>SHELL</p> <p>The shell is a program that takes keyboard commands and passes them to the operating system to carry out. Almost all Linux distributions supply a shell program from the GNU project called BASH.BASH: the name BASH acronym for Bourne Again Shell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional function to make it easier and more convenient to use. It has since been adapted as the default shell for the most system running shell.Terminal Emulators: When using a graphical user interface we need another program called a terminal emulator to interact with the shell. Its likely called simply terminal on our menu.Launch the terminal:[root@localhost ~] #This is called a shell prompt and it will appear whenever the shell is ready to accept input. </p> <p>Directory Structure</p> <p>/bin:normal command execution directory/sbin:administrative command execution directory/boot:boot loader directory it contains GRUB/etc:configuration file directory/proc:current process info directory/media:external media device mount point/mnt:network or local mount point/opt:third party software installation directory/usr:entire installation and own software installation directory/lost+found :recovery directory/selinux :security directory/var:log directory/root:root user home directory/home:normal user home directoryIn Linux / work as a drive, as C: in Windows</p> <p>BASIC Commands</p> <p>Generally we use two prompts in Linux :# :root user (Administrative authentication)$ :normal user (restricted authentication)# lsList command to show the content of directory</p> <p># ls -l To get detailed list of directory content</p> <p># ls -aTo get the list of all file/dir including hidden object.</p> <p># pwdPrint working directory</p> <p># mkdir To create a directoryStructure of command in Linux:# - [* always use before option]</p> <p>BASIC Commands</p> <p># mkdir -p //To create parent directory</p> <p># mkdir To create multiple directory</p> <p># touch To create a new file</p> <p># touch To create multiple file</p> <p># cd To change directory</p> <p># cd ..To close any directory</p> <p># cat To view the data of any file</p> <p>BASIC Commands</p> <p># cat &gt; To input data in file with input mode</p> <p># cat &gt;&gt; To input data in file with append mode</p> <p># rm -r To delete file/dir</p> <p># rm -rf To delete file/dir forcefully</p> <p># cp -rv To copy file/dir and paste</p> <p># mv To move/cut a file/dir and paste</p> <p># man To get the help of command</p> <p>BASIC Commands</p> <p># --helpTo get brief details of command</p> <p># which To get the location of command execution</p> <p># who To get the info of logged-in user</p> <p># haltTo shutdown</p> <p># rebootTo restart</p> <p>Text Editor</p> <p>Text editor is a software to create or edit text files.Text editor can be GUI and CLI.</p> <p>GUI text editor used in Linux:GeditLeafpad</p> <p>CLI text editor used in Linux:ViVimNanoemacsVI (Visual Editor)vi or vim is a terminal text editor.Commands:</p> <p># vim To create or edit existing file </p> <p>Text Editor</p> <p>There are three modes in vi editorCommand mode (default mode)Insert modeEX modeCommand Mode (ESC) : It is used to do cut, copy, paste.</p> <p>yy:to copy a line yy:to copy multiple linesyw:to copy a worddd :to cut a lineD:to delete a lineD:to delete multiple linesdd:to cut multiple linesdw:to cut a wordp:to paste</p> <p>Text Editor</p> <p>2. Insert Mode (to enter in insert mode press i or a)data input or edit mode.3. EX mode (to enter in EX mode press ESC then SHIFT + : )This mode is used for file saving and quieting.: w: to save: q:to quit: wq:to save and quit: w!:to save forcefully: q!:to quite forcefully:/:to search any word:;%s///g:to replace any word: set nu:to set line number: set nonu:to unset line number</p> <p>User Group Management</p> <p>User:Users are the login account through which we can access the resources and features of an operating system.Group:Groups are the place where user accounts are placed for security and policy implementation.Important file locations:</p> <p>/etc/passwd:users details file/etc/shadow:users encrypted password file/etc/group:groups details fileCommands:# groupadd To create new group</p> <p># useradd To create new user</p> <p>User Group Management</p> <p># passwd To create or change user password</p> <p># useradd -g -G To create a user with specific primary group and secondary group.[-g :Primary group,-G :Secondary group]</p> <p># usermod -g To modify primary group name</p> <p># usermod -G , To change or modify secondary group</p> <p># useradd -d directory name with location To give a new home directory</p> <p># useradd -c comment -g To give comment for a user</p> <p># usermod -c comment To change or modify user comment</p> <p>User Group Management</p> <p>root : x : 0 : 0 : root : /root : /bin/bash</p> <p>root :user namex:link to shadow file0:user ID0:Group (primary) IDroot:comment of user/root:home directory of user/bin/bash:user shell# useradd -s /sbin/nologin To create no-login user</p> <p># userdel -r To delete user</p> <p># groupdel To delete group (firstly delete group members)</p> <p>Permissions</p> <p>It is used to implement access control on objects (files and dir) of operating system.</p> <p>There are three permission in LinuxReadr4Writew2Executex1# ls -l or llTo check the permissions of any file/dir</p> <p># chmod UGO To give or change permissions</p> <p># chmod -R UGO To give or change permissions of sub file/dir (parent file/dir)Each objects (file/dir) have three pairs of permissionsLike:rwxrwxrwxusergroupothers</p> <p>Permissions</p> <p># chmod -R : To change the ownershipDefault permission</p> <p>Root User:</p> <p>File:644Dir:755User home dir:700</p> <p>Normal User:</p> <p>File:664Dir:775</p> <p>GRUB</p> <p>It is the boot loader for the linux. GRUB is short for GNU Grand Unified Boot Loader.Location of Grub file is :</p> <p>/boot/grub/grub.conf:Original file/etc/grub.conf:shortcut fileWe can reset boot user password using two methods:Single user mode (Using grub menu)Rescue mode (Using linux DVD)# grub-md5-crypt:to create encrypted password</p> <p>TAR (Tap Archiver)</p> <p>It is used for making TAR and compressed file. It is like making zip file and rar files in windows. It also considered as backup and restore method.Commands:# tar -cvf To create a tar file</p> <p># tar -tvf To check the contents of tar file</p> <p># tar -xvf To extract the contents of tar or compressed file</p> <p># tar -zcvf To create compressed tar file</p> <p># tar -jcvf To create compressed .bz2 tar file</p> <p>RPM (Redhat Package Manager)</p> <p>RPM is used to install packages in Redhat Linux OS. The extension of Redhat Linux package is .rpm like .exe in windows.</p> <p>Note: RPM command do not resolve dependency packages automatically.Commands:# rpm -ivh To install package</p> <p># rpm -e To uninstall package/software</p> <p># rpm -qa To get the list of all installed software</p> <p># rpm -qa grep To get the list of installed software using filter</p> <p># rpm -qi To get info of all installed software</p> <p>RPM (Redhat Package Manager)</p> <p># rpm -ql To get the list of file/dir copied to system and its location by package</p> <p># rpm -qf To know the responsible package name of file/dir</p> <p># rpm -ivh --force --nodeps --aid To install any package forcefully</p> <p>Networking</p> <p>It is assign used to assign IP address in our OS.We can assign IP in two ways1. Temporary IP setting2. Permanent IP setting (using manual and DHCP)Commands:# ifconfigTo check the IP address and interface# ifup To enable LAN interface# ifdown To disable LAN interface# hostnameTo check the hostname of computer</p> <p>Networking</p> <p># hostname To change the hostname# ifconfig To assign IP# route add default gw To assign gateway IP# vim /etc/resolv.confnameservernameserver : to assign DNS IP:wqTemporary IP settingPermanent IP setting# system-config-networkTo assign IP, Netmask, Gateway, Hostname, DNS1, DNS2 etc.# service network restartTo restart the service of network</p> <p>Networking</p> <p>Important Files:/etc/sysconfig/network-scripts/ifcfg - This file contains IP, Netmask, Gateway, MAC etc/etc/sysconfig/networkThis file contains hostname/etc/resolv.confThis file contains DNS IP/etc/hostsLocal DNS entry file</p> <p>Harddisk Management</p> <p>It is used to configure and maintain HDD partitions, volumes and file system in Linux OS.Commands used in HDD management# fdisk -l# fdisk To enter in HDD management modeCommands used in HDD management mode:: m:for all command and detailsTo check the partition table and HDD details: p:for print current partition table: n:to create new partition or volumes: t:to change file system table: l:to list file system hex code: d:to delete a partition: w:to save and quit: q:to quit without saving# mkfs.ext4 To format Linux partitionAfter any changes done using fdisk command, Restart is compulsary</p> <p># mkfs.vfat To format windows partition in Linux</p>