Sls01 Lecture02 Linux In Practice

779 views
734 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
779
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
46
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Sls01 Lecture02 Linux In Practice

  1. 3. What is Linux?
  2. 4. Level of Abstraction
  3. 5. 1. Linux is multitasking and multi-user operating system. 2. The shell is a program that interprets your commands and passes them to kernel for processing. 3. The kernel is written is C which makes it relatively easy to port from one machine to an other . 4. The kernel is the mastermind program that schedules jobs and allocate resources (time, memory, disks and other peripherals) thereby shielding the user from hardware.
  4. 6. Ubuntu Distrobution Linux for human Beings
  5. 7. Hands-on at the Commandline ls , mv , clear , mkdir , cd , pwd
  6. 11. Commands 1. Commands are executable binary files supplied with Linux 2. Commands have arguments/options/switches to change the default actions of the command 3. alias mine=“echo Welcome SOMS”
  7. 17. All about Shell Type commands directly to Linux The commandline offers power and flexibility The command-line utilized in Ubuntu is known as bash—the B ourne A gain Sh ell Command-line programs are sometimes known as shells bash is the default in most popular Linux distros
  8. 18. Linux Navigation Roam around in filesystem Remove Directory pwd cd mkdir rmdir ls Print Working Directory Change Directory Make Directory List files and directories cp Copy mv Move file/folder ln Link files
  9. 19. Default Directories
  10. 20. File System
  11. 21. Change and list directories You can use the following commands to change the active directory and list the contents of a directory: 1. pwd Print Working Directory 2. ls List files and directories 3. cd Change Directory
  12. 23. Create a user > sudoadduser “ur name without quotes” Create an other user > sudoadduser “someone else name without quotes” Navigate to “home” directory and list file/folders there > cd (enter)> pwd (enter)> ls (enter) Make directories as shown in the tree > mkdir user1/Documets/mail user1/Documets/tmp user2/Documets/mail Copy tmp from user1 to user2 > cp –r user1/Documets/tmp user2/Documets Navigate to user2’s tmp folder > cd user2/Documents/tmp Remove user1’s mail folder > rmdir /home/user1/Documents/mail /home user1 user2 Documents Documents mail mail tmp tmp
  13. 24. Relative vs Absolute path Absolute path : Starting with “/” Relative path : Starting with the current directory Considering the previous tree > pwd <enter> /home/user1/Documents/mail Now navigate to user2’s mail > cd /home/user2/Documents/mail <enter> (Absolute) > cd ../../../user2/Documents/mail <enter> (Relative) /home user1 user2 Documents Documents mail mail tmp tmp
  14. 25. File System
  15. 26. Personal extensions Make a directory named “myext” > mkdir ~/myext Write plain files using any editor like: “nano” > nano memo.maths memo.english > nano score.maths score.english List files to confirm files creation > ls memo.maths memo.english score.maths score.english One of the advantage of personal extensions > ls –al *.maths memo.maths score.maths
  16. 27. Two names for the same file? / home etc media user1 user2 Desktop Desktop … Every file and folder has a unique i-node ln geeko.txt gg <enter> nano gg <enter> (geeko.txt will be displayed) Practical application: To avoid long paths
  17. 29. Mount Directories Mount even windows drives
  18. 30. Now we are going to mount Windows drives to Ubuntu Mounting Drive: C mkdir ~/Desktop/DriveC mount strage_device mount_point mount /dev/sda1 / ~/Desktop/DriveC Unmounting Drive: C umount /dev/sda1 / ~/Desktop/DriveC Storage devices like CD-ROM and USB mounted automatically as soon as u plug them in. /media/cdrom /media/<name of USB>
  19. 31. Customize filesystem managing files and directories
  20. 32. Create files
  21. 34. Exercise 1. View the hidden files on your ~ directory 2. Create a directory called new_dir in your ~ 3. Create a file called old there 4. Create a hard and symbolic link for this file 5. View the inode numbers of these links 6. Try removing new_dir using rmdir 7. Remove new_dir and all its children
  22. 35. Exercise 1. View the hidden files on your ~ directory ls -a 2. Create a directory called new_dir in your ~ mkdir ~/newdir 3. Create a file called old there touch old 4. Create a hard link for this file ln old link2old 5. View the inode numbers of these links ls -i 6. Try removing new_dir using rmdir rmdir new_dir
  23. 37. Manage User & Groups chmod
  24. 40. Exercise From Command Line See the /etc/passwd Make a new user “hero” with default home directory Give it the password “zero” See the changes in /etc/passwd Switch to user “hero” and change its password to “d!g!t@l” Delete the account of “hero”
  25. 41. File permissions and modes
  26. 42. System Diagnostics Examining system health
  27. 43. Linux Utilities ssh, ftp, scp
  28. 44. SSH
  29. 45. SSH Open protocol for network communication Functionality of SSH: Secure Command shell Secure File transfer Data tunneling/Port forwarding
  30. 46. Packages Snatch, configure and install and customize
  31. 47. Using apt utility - Automatic > apt-get install <package name> This is automatically snatch the package from the repositories listed in /etc/apt/sources.list and install on your distro > apt-cache search <package name> To remove the package > apt-get remove <package name> To intsall the <package-name.deb> > dpkg <package name>
  32. 48. Get Source package - Manual Download source code in compressed format Decompress the package Navigate into the package folder Apply the triangle command in sequence > ./configure > make > make install To run the software/package just type the name > package-name <enter>
  33. 49. Code compilation Using gnu compiler
  34. 50. C source file compilation Packages: gcc-*.*, g++ Create a file > nano ~/hello.c Paste the following code lines #include<iostream.h> void main(){ cout<<“Hello Geeks”; } </code> Compile the file using gcc compiler > gcc hello –o hello <enter> This will drop a file hello in the same folder Give permission to make it executable > chmod a+x hello <enter> > ./hello <enter> Hello Geeks
  35. 51. Upcoming Lectures ? SL03 - Exploit Shell Scripting SL04 - System Administration
  36. 52. Questions ?

×