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.
7. Hands-on at the Commandline ls , mv , clear , mkdir , cd , pwd
8.
9.
10.
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”
12.
13.
14.
15.
16.
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
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
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
22.
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
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
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
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
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>
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
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
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”
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>
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>
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