Sls01 Lecture02 Linux In Practice
-
Upload
qasim-khawaja -
Category
Education
-
view
675 -
download
2
Transcript of Sls01 Lecture02 Linux In Practice
04/12/23
04/12/23
•
04/12/23
What is Linux?
04/12/23
Level of Abstraction
04/12/23
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.
04/12/23
Ubuntu DistrobutionLinux for human Beings
04/12/23
Hands-on at the Commandline
ls , mv , clear , mkdir , cd , pwd
04/12/23
•
04/12/23
•
04/12/23
•
04/12/23
Commands
1. Commands are executable binary files supplied with Linux2. Commands have arguments/options/switches to change the default actions of the command 3. alias mine=“echo Welcome SOMS”
04/12/23
•
04/12/23
•
04/12/23
•
04/12/23
•
04/12/23
•
04/12/23
All about Shell
Type commands directly to Linux The commandline offers power and flexibilityThe command-line utilized in Ubuntu is known as bash—the BourneAgain ShellCommand-line programs are sometimes known as shellsbash is the default in most popular Linux distros
04/12/23
Linux NavigationRoam 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
04/12/23
Default Directories
04/12/23
File System
04/12/23
Change and list directories You can use the following commands to change theactive directory and list the contents of a directory:1. pwdPrint Working Directory 2. lsList files and directories3. cdChange Directory
04/12/23
•
04/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/mailCopy tmp from user1 to user2>cp –r user1/Documets/tmp user2/DocumetsNavigate to user2’s tmp folder >cd user2/Documents/tmpRemove user1’s mail folder >rmdir /home/user1/Documents/mail
/home
user1 user2
Documents Documents
mail mailtmp tmp
04/12/23
Relative vs Absolute pathAbsolute path: Starting with “/”Relative path: Starting with the current directory Considering the previous tree >pwd <enter>/home/user1/Documents/mailNow navigate to user2’s mail >cd/home/user2/Documents/mail <enter> (Absolute)
>cd../../../user2/Documents/mail <enter>(Relative)
/home
user1 user2
Documents Documents
mail mailtmp tmp
04/12/23
File System
04/12/23
Personal extensions
Make a directory named “myext”>mkdir ~/myextWrite plain files using any editor like: “nano” >nano memo.maths memo.english>nano score.maths score.englishList files to confirm files creation>lsmemo.maths memo.english score.maths score.english One of the advantage of personal extensions >ls –al *.mathsmemo.maths score.maths
04/12/23
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
04/12/23
•
04/12/23
Mount DirectoriesMount even windows drives
04/12/23
Now we are going to mount Windows drives to UbuntuMounting Drive: C mkdir ~/Desktop/DriveC mount strage_device mount_point mount /dev/sda1 / ~/Desktop/DriveCUnmounting Drive: C umount /dev/sda1 / ~/Desktop/DriveCStorage devices like CD-ROM and USB mounted automatically as soon as u plug them in. /media/cdrom/media/<name of USB>
04/12/23
Customize filesystemmanaging files and directories
04/12/23
•
Create files
04/12/23
•
04/12/23
Exercise
1. View the hidden files on your ~ directory2. Create a directory called new_dir in your ~3. Create a file called old there4. Create a hard and symbolic link for this file5. View the inode numbers of these links6. Try removing new_dir using rmdir7. Remove new_dir and all its children
04/12/23
Exercise
1. View the hidden files on your ~ directoryls -a2. Create a directory called new_dir in your ~mkdir ~/newdir3. Create a file called old theretouch old4. Create a hard link for this fileln old link2old5. View the inode numbers of these linksls -i6. Try removing new_dir using rmdirrmdir new_dir
04/12/23
•
04/12/23
Manage User & Groupschmod
04/12/23
•
04/12/23
•
04/12/23
Exercise From Command LineSee the /etc/passwd Make a new user “hero” with default home directoryGive it the password “zero”See the changes in /etc/passwdSwitch to user “hero” and change its password to “d!g!t@l”Delete the account of “hero”
04/12/23
File permissions and modes
04/12/23
System Diagnostics Examining system health
04/12/23
Linux Utilities ssh, ftp, scp
04/12/23
SSH
04/12/23
SSH
Open protocol for network communication Functionality of SSH: Secure Command shell Secure File transfer Data tunneling/Port forwarding
04/12/23
Packages Snatch, configure and install and customize
04/12/23
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>
04/12/23
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 installTo run the software/package just type the name >package-name<enter>
04/12/23
Code compilationUsing gnu compiler
04/12/23
C source file compilation
Packages: gcc-*.*, g++Create a file >nano ~/hello.cPaste 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
04/12/23
Upcoming Lectures ?
SL03 - Exploit Shell Scripting SL04 - System Administration
04/12/23
Questions ?