Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Learning Linux v2.1

335 views

Published on

Published in: Technology
  • Be the first to comment

Learning Linux v2.1

  1. 1. Learning Linux – Part 2 CentOS 6.2
  2. 2. Topics• Command-Line Basics• Permissions• Using the man Command• Hard and Soft Links• Network settings• Creating RPMs• Repositories and working with YUM• Kernel Modes• Resizing Partitions
  3. 3. Command-line InterfacesCtrl + Alt + <F2 - F6> (multiple logins simultaneously)
  4. 4. Navigating Files and Directoriesman <command> manuals lists information about the commandls list lists all non-hidden contents of a directorycd <directory> change directory moves into a directory located within current directorycat <file> concatenate files print file contents to screencp <file1> <file2> copy creates a new file2 with file1 contentsrm <file name> remove removes the filemv <file1> <new filename> move renames file1mv <file1> <location> move moves file1 to a new locationcd .. change directory moves up a foldermkdir <new directory name> make directory makes a new directorypwd print working directory lists pathname of the current directorycd ~<username> change directory move into the home directory of usercd <directory path> change directory moves into the directoryrm -r <directory name> remove recursively removes a directory and its contents
  5. 5. Tar Archiving and Gzip CompressionArchiving - grouping multiple files together in a single file to save spaceand make it easier to transfer the files aroundCompressing - replacing a single file with a smaller/compressedversion to save spaceTar - a type of archiver most common to LinuxGzip - a type compressor most common to LinuxTo extract .tar.gz files:    tar -xvzf <filename>        tar -xvzf example.tar.gzTo create a new .tar.gz file:        tar -cpzf <filename> <foldername>              tar -cpzf newArchive.tar.gz images
  6. 6. Users and GroupsCommand Definition Purposesu substitute Similar to logging into your computer user as administratoruseradd  <username> user add adds a new userpasswd <username> password changes or creates new passwordgroupadd <groupname> group add creates new groupusermod  <options> <username> user modify modifies the user Ex. adding user to groupuserdel  <username> user delete deletes a usergroupdel  <groupname> group delete deletes a group
  7. 7. Permissions Format• A permission has a total of 10 characters.• There are no empty spaces ugo Permission Format u - user/owner g - users of the owning group o - any other user
  8. 8. Permissions CharactersIdentifier categories • -     file identifier • d directory identifier  rwx categories • r     read (able to open/view files as well as view contents of folders) • w write (able to edit/rename/save files and folders) • x execute (able to run a program) • -     place holder (does not have the privilege)
  9. 9. Permissions Commands • Changing permissions can be done with the command chmod in the terminal  Command Definition Purpose ls -lh list lists a long humanly readable list of all files chmod <u,g,o> <+,-,=> <r,w,x> change mode changes permissions of files  • chmod can be used with multiple modifiers Modifier Purpose + adds to current permissions - takes away from current permissions = erases previous permissions and sets new ones
  10. 10. Permissions• You can set who can access specific files by changing user and group owner• The superuser (root) has full access and can change any permission, even for files that dont belong to the root account.  Command Definition Purposechown <username> <filename> change owner changes the owner of a filechgrp <groupname> <filename> change group changes the group owner of a file
  11. 11. The man command• The Linux man pages are the most helpful tool to the for the test.• The above is a manual page for the ls command
  12. 12. Strategies and Use• The manual pages are organized in the order: – Name, Synopsis, Description, and Options• The options are organized into subcategories: – User Commands, System Calls, C Library Functions, Devices and Special Files, File Formats and Conventions, Games, Miscellanea, System Administration.• If you know what you are looking for and where to look it saves a lot of time• Syntax for the command is as follows: man <command> <options> man –k <something> | less    
  13. 13. Strategies and Use• Once you are in a man page, there are other ways to help narrow down what you are looking for.• By typing /<search parameter> and hitting Enter, you can search for key words within the manual. Sequentially typing / and hitting Enter bring up the next occurrences of your search.
  14. 14. Strategies and Use• When searching, pressing the space bar will take you down one page and help ensure you don’t miss anything• To close a manual page, type q or hit ctrl-c which is the stop current command hot key• One other method for finding the correct command is through /sbin where all the executable commands are stored. Scrolling through the list with | less can help jog a person’s memory
  15. 15. Hard and Soft Links• Every file has two parts, a data structure and file name structure.• The data structure is associated with an inode.• The file structure is the name and the associated inode number that references where the data is stored.• A hard link refers to more than one file with the same inode number.• A soft link is a reference to another file or directory with a different inode number than the original file.
  16. 16. Hard and Soft Links• ls –lia Shows inode numbers of filesCreate hard links• ln <source-filename> <link-filename>Create soft Links• ln –s <source-filename> <link-filename>
  17. 17. Network SettingsTo display the current network settings, use the command: ifconfigThis will list all the different interfaces. Choose the one you want anduse the command: ifconfig <interface> <ip address> netmask <netmask> upTo set the default connection, use the command route add default gw <default gateway>To set the DNS, modify the /etc/resolv.conf with the vi or grep texteditor.It should resemble nameserver <DNS Address>To configure network with DHCP, run the command dhclient –r whichwill release the current client. After run dhclient to obtain a new IP.
  18. 18. Creating RPMsRPM is the package management system used by Red Hat Enterprise Linux and many other Linux distributions.Basic Usage: $ rpm -ivh demofile-1.0.0-i386.rpm i for install, v for verbose, h for process hash $ rpm -ql demofile q for query, l for list files $ rpm -e demofile e for eraseSetup:$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}$ mkdir -p ~/rpmbuild/RPMS/{noarch,i386,i686}
  19. 19. YUM RepositoriesYellowdog Updater ModifiedPackage manager for .rpm files that allows the installation of new packages, removal of old packages, andautomatic system updatesyum install <application>    yum install nanoyum update <application>    yum update flash-pluginyum update (no other parameters)yum remove <application>    yum remove vimyum list
  20. 20. Kernel Modes• Within every Linux operating system there are the six basic runlevels.• The runlevel is the state of the machine after boot.• A typical computer boots into runlevel 5. This usually contains a GUI and networking.
  21. 21. Kernel Modes• These runlevels can be accessed in three main ways – With the init command – Modifying the /etc/inittab file that controls what the computer boots into – Changing command sent by the GRUB Bootloader**Note when running init command or modifying innitab file, you need root privileges.**
  22. 22. Kernel Modes• When you start up a computer, press any key to load the grub menu when the loading screen appears• It will then take you to the GRUB menu• Once in the menu, you can scroll up and down to chose which version of Linux you would like to load.
  23. 23. Kernel Modes• You also have the option to open the grub command line when you press c.• To modify boot command, press e.• To change the runlevel the computer boots into, add a space at the end of the command and type the runlevel code (1-6) and hit Enter• Once loaded into one of the runlevels you can modify the root password with passwd• To change runlevels after loading into a runlevel, use init <runlevel id #> (Root only).
  24. 24. Kernel Modes• How is this secure?• You can establish a GRUB menu password with the command grub-md5-crypt, but this has its drawbacks. – If you forget GRUB password, you may need to backup your computer and reinstall the operating system through the BIOS and wipe the hard drive.
  25. 25. Summary• Command-Line Basics• Permissions• Using the man Command• Hard and Soft Links• Network settings• Creating RPMs• Repositories and working with YUM• Kernel Modes• Resizing Partitions
  26. 26. Questions?

×