Last active
July 8, 2020 19:08
-
-
Save mohan43u/bee72e677c544dfcd5171d4ebbcbd931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2020-07-06 17:40:11 +mohan43u-we the first thing you do in a shell is to see where you are | |
2020-07-06 17:40:50 @mohan43u type pwd command to see in which place you are currently present. | |
2020-07-06 17:41:37 +mohan43u-we the path /home/trainer is the current working directory | |
2020-07-06 17:41:54 +mohan43u-we in unix, everything is a file | |
2020-07-06 17:42:07 +mohan43u-we a directory is also a file | |
2020-07-06 17:42:35 +mohan43u-we a file in unix is stored in one particular tree | |
2020-07-06 17:42:56 +mohan43u-we unix filesytem starts from root | |
2020-07-06 17:43:40 +mohan43u-we as you see in the presenter terminal, 'ls /' command will show the directories inside the root | |
2020-07-06 17:43:51 +mohan43u-we the command 'ls' means list | |
2020-07-06 17:44:19 +mohan43u-we here '/' represents the root of the file system | |
2020-07-06 17:45:02 +mohan43u-we every users will have one directory allocated to himself whenever his/her userid created in the unix system | |
2020-07-06 17:45:09 +mohan43u-we that is called home directory | |
2020-07-06 17:45:29 +mohan43u-we the home directory of all users will be under /home | |
2020-07-06 17:46:02 +mohan43u-we as you see in the presenter terminal, I showed user specific directories which are stored inside /home | |
2020-07-06 17:46:12 +mohan43u-we my userid is trainer | |
2020-07-06 17:46:40 +mohan43u-we so trainer userid have his home directory as /home/trainer | |
2020-07-06 17:47:21 +mohan43u-we as you see, ls command will list directory contents of whatever path you give | |
2020-07-06 17:48:01 +mohan43u-we 'ls' is a basic command which everyone should know | |
2020-07-06 17:48:19 +mohan43u-we there are few more options to 'ls' command to change its display behavious | |
2020-07-06 17:48:27 +mohan43u-we *behavious* | |
2020-07-06 17:49:46 +mohan43u-we as you see, '-l' option to ls make it show the listing in a different way | |
2020-07-06 17:50:16 +mohan43u-we when I do 'ls -l /' it show detailed listing of '/' root directory | |
2020-07-06 17:50:42 +mohan43u-we so every command in unix have *options* and *argument* | |
2020-07-06 17:50:57 +mohan43u-we to read more about what all options 'ls' command have, | |
2020-07-06 17:51:06 +mohan43u-we you have to read its manual page | |
2020-07-06 17:51:36 +mohan43u-we this is the manual page. I'll explain more in detail about manual page later | |
2020-07-06 17:52:06 +mohan43u-we as I previously told, everything in unix is a file | |
2020-07-06 17:52:25 +mohan43u-we even a directory is also a file | |
2020-07-06 17:52:38 +mohan43u-we to get more details about file, we use 'stat' command | |
2020-07-06 17:53:13 +mohan43u-we this stat command is very useful to know what exactly a file represents | |
2020-07-06 17:53:38 +mohan43u-we 'stat' command can provide you more details about a file or directory like when it created | |
2020-07-06 17:53:48 +mohan43u-we when a file got modified last | |
2020-07-06 17:53:53 +mohan43u-we etc. | |
2020-07-06 17:54:07 +mohan43u-we to give an example, I'm switching to my home directory | |
2020-07-06 17:55:12 +mohan43u-we as I explained before, we need to know which directory we are currently using in the entire filesystem before we begin changing the directories | |
2020-07-06 17:55:33 +mohan43u-we 'pwd' command is useful to see where we are currently in the filesystem | |
2020-07-06 17:55:58 +mohan43u-we the prsenter terminal currently show that I'm currently in /home/trainer directory | |
2020-07-06 17:56:02 +mohan43u-we which is my home directory | |
2020-07-06 17:56:13 +mohan43u-we to switch to '/' directory, we use 'cd' command | |
2020-07-06 17:56:59 +mohan43u-we as you can see, pwd command now shows '/' is my current directory | |
2020-07-06 17:57:43 +mohan43u-we 'cd' command is a shell build-in command | |
2020-07-06 17:57:52 +mohan43u-we there are three types of commands in unix | |
2020-07-06 17:57:57 +mohan43u-we one is regular commands | |
2020-07-06 17:58:07 +mohan43u-we second one is build-in commands | |
2020-07-06 17:58:18 +mohan43u-we and third one is 'aliases' | |
2020-07-06 17:59:05 +mohan43u-we as you see in presenter terminal, I just created one alias | |
2020-07-06 17:59:14 +mohan43u-we for 'ls' command called 'll' | |
2020-07-06 17:59:35 +mohan43u-we instead of typing 'ls -ltr' command, we can use 'll' to do the same function | |
2020-07-06 17:59:54 +mohan43u-we see, both commands did the same thing | |
2020-07-06 18:00:23 +mohan43u-we so this is how you created aliases in unix | |
2020-07-06 18:00:35 +mohan43u-we the other type of command is called 'build-in' command | |
2020-07-06 18:01:06 +mohan43u-we before explaining 'cd', just want to mention 'clear' command | |
2020-07-06 18:01:21 +mohan43u-we 'clear' command is used to clear the screen and put prompt in the top line | |
2020-07-06 18:01:58 +mohan43u-we as you see, I justtyped 'll' then followed by 'clear' which clears the terminal and put the prompt at the start of the line | |
2020-07-06 18:02:51 +mohan43u-we now, one more command to explain before explaining build-in command | |
2020-07-06 18:02:55 +mohan43u-we 'which' command | |
2020-07-06 18:03:15 +mohan43u-we 'which' command will show the full filename of a command | |
2020-07-06 18:04:07 +mohan43u-we as you see in the presenter terminal, I typed 'which which', here I'm asking which command to find out full filename of 'which' command (that is itself) | |
2020-07-06 18:04:33 +mohan43u-we so the which command says, its filename is '/usr/bin/which' | |
2020-07-06 18:05:13 +mohan43u-we 'which' command takes one argument and show the full filename of that command | |
2020-07-06 18:05:34 +mohan43u-we as you see, when I type 'which ls', it shows me full filename of ls command | |
2020-07-06 18:05:58 +mohan43u-we but, when I typed 'which cd' it doesn't show any output | |
2020-07-06 18:06:24 +mohan43u-we this is because 'cd' is a shell built-in command | |
2020-07-06 18:07:06 +mohan43u-we as you see, the manual page of 'sh' will explain what 'cd' command is doing | |
2020-07-06 18:07:35 +mohan43u-we a builtin command will not be present in the filesystem like the normal commands like 'ls' or 'which' | |
2020-07-06 18:07:45 +mohan43u-we they are built inside the 'sh' shell itself | |
2020-07-06 18:09:05 +mohan43u-we whenever you execute a built-in command, shell itself will execute it instead of searching for the command in filesystem and then start executing | |
2020-07-06 18:09:58 +mohan43u-we as you see in the presenter terminal, there are lot of build-in command each shell provides, it will be documented inside the manual page of that particular shell | |
2020-07-06 18:10:28 +mohan43u-we 'echo' is another important shell built-in command | |
2020-07-06 18:11:53 +mohan43u-we we already know 'which' command can provide location of a command | |
2020-07-06 18:12:18 +mohan43u-we but 'which' command uses 'PATH' variable to know the locations of the commands | |
2020-07-06 18:13:17 +mohan43u-we as you see in presenter terminal, PATH variable consists of paths like /usr/local/sbin, /usr/local/bin, seperated by ':' | |
2020-07-06 18:13:56 +mohan43u-we so everytime we execute a command, 'sh' shell will check whether the command is a built-in command first, if yes, then it will execute automatically | |
2020-07-06 18:14:34 +mohan43u-we if the given command is not built-in, then it will look for 'alias' list, if an alias matches with the given command, 'sh' shell will execute the alilas | |
2020-07-06 18:14:43 +mohan43u-we *alias* | |
2020-07-06 18:15:12 +mohan43u-we if the given command is not a built-in as well as alias, then it will search these paths one by one | |
2020-07-06 18:15:28 +mohan43u-we for example, when I give 'ls' comamnd to shell | |
2020-07-06 18:15:56 +mohan43u-we 'sh' will take PATH variable then go to the first path | |
2020-07-06 18:16:04 +mohan43u-we and see any filename matching 'ls' | |
2020-07-06 18:16:58 +mohan43u-we as you see, the 'stat' command tells that there is no filename called 'ls' in the first path mentioned in PATH variable | |
2020-07-06 18:17:06 +mohan43u-we then 'sh' shell takes the second path | |
2020-07-06 18:17:37 +mohan43u-we so there also, 'ls' filename is not available, then it checks /usr/sbin | |
2020-07-06 18:17:48 +mohan43u-we no, the command is also not there | |
2020-07-06 18:18:21 +mohan43u-we see, the last command 'stat /usr/bin/ls' show the details of the filename | |
2020-07-06 18:18:42 +mohan43u-we that means, 'ls' command is inside '/usr/bin' directory, this directory is also mentioned in PATH variable | |
2020-07-06 18:18:59 +mohan43u-we thats how 'sh' shell finds a command and executes that command | |
2020-07-06 18:20:04 +mohan43u-we after identifying the location, 'sh' will start creating a process for that program with filename '/usr/bin/ls' and executes that program | |
2020-07-06 18:20:20 +mohan43u-we so it is very important to know the purpose of PATH variable | |
2020-07-06 18:20:39 +mohan43u-we this variable consists of multiple directory paths seperated by ':' | |
2020-07-06 18:21:20 +mohan43u-we shell will for given command in each and every directory in left-to-right order | |
2020-07-06 18:21:48 +mohan43u-we so /usr/local/bin takes priority than /usr/local/bin | |
2020-07-06 18:22:00 +mohan43u-we /usr/sbin takes priority than /usr/bin | |
2020-07-06 18:22:03 +mohan43u-we like that | |
2020-07-06 18:22:45 +mohan43u-we I think I covered the topics for today | |
2020-07-06 18:23:25 +mohan43u-we we will be releasing the restriction now, so anyone have doubt please ask | |
2020-07-06 18:23:41 +mohan43u-we I hope everyone followed the commands I executed in the presenter terminal | |
2020-07-06 18:25:25 +mohan43u-we here are few links to start learning shell | |
2020-07-06 18:25:28 +mohan43u-we http://www.linuxtraining.co.uk/download/new_linux_course_modules.pdf | |
2020-07-06 18:25:38 +mohan43u-we https://freetamilebooks.com/ebooks/learn-gnulinux-in-tamil-part1/ | |
2020-07-06 18:27:20 -- Mode #ilugc [-m] by mohan43u | |
2020-07-06 18:27:23 aaryan7476 What's the difference between 'whereis' and 'which' command? | |
2020-07-06 18:27:35 aaryan7476 Also when will be the next session? | |
2020-07-06 18:27:45 +mohan43u-we whereis need 'locate' database | |
2020-07-06 18:27:45 ravisankar ? | |
2020-07-06 18:27:51 +mohan43u-we which uses PATH command | |
2020-07-06 18:27:57 +mohan43u-we ravisankar: go ahead | |
2020-07-06 18:28:14 ravisankar how to search in man | |
2020-07-06 18:28:39 ravisankar i mean how to find a particular text in manual page | |
2020-07-06 18:28:43 +mohan43u-we ravisankar: man -k <searnword> | |
2020-07-06 18:28:43 aaryan7476 How is sh different from my normal terminal screen? | |
2020-07-06 18:28:59 rajkumar ? | |
2020-07-06 18:29:01 +mohan43u-we aaryan7476: there are lot of terminals available for unix/linux | |
2020-07-06 18:29:13 ravisankar ? | |
2020-07-06 18:29:14 aaryan7476 So sh is standard we used | |
2020-07-06 18:29:20 +mohan43u-we aaryan7476: you typically land in 'bash' if you are using 'osx' and 'linux' | |
2020-07-06 18:29:34 +mohan43u-we aaryan7476: no 'bash' is standard for mordern unix | |
2020-07-06 18:29:41 +mohan43u-we ravisankar: go ahead | |
2020-07-06 18:30:22 ravisankar how to delete a particular alias | |
2020-07-06 18:30:36 +mohan43u-we ravisankar: unalias <alias> | |
2020-07-06 18:30:50 +mohan43u-we see the presenter terminal | |
2020-07-06 18:31:02 rajkumar ? | |
2020-07-06 18:31:05 +mohan43u-we the ll alias which I set now gone | |
2020-07-06 18:31:09 +mohan43u-we rajkumar: go ahead | |
2020-07-06 18:31:15 rajkumar Is 'sh' a file? So Linux boots with it? | |
2020-07-06 18:31:33 +mohan43u-we 'sh' is also a program | |
2020-07-06 18:31:50 +mohan43u-we see presenter terminal 'sh' lives inside /usr/bin | |
2020-07-06 18:32:09 bharath ? | |
2020-07-06 18:32:14 aaryan7476 So if I add an alias in my 'sh' it won't interfere with my normal 'bash' or 'zsh'(in OS X) | |
2020-07-06 18:32:19 aaryan7476 *x) | |
2020-07-06 18:32:20 +mohan43u-we but when you start a terminal, the terminal command typically will use /usr/bin/sh to show you one terminal | |
2020-07-06 18:32:25 +mohan43u-we bharath: go ahead | |
2020-07-06 18:32:48 bharath how to clear the whole terminal? | |
2020-07-06 18:32:50 +mohan43u-we aaryan7476: sh is a different terminal than bash or zsh | |
2020-07-06 18:32:55 Aachman_m_ how to see the presenter terminal | |
2020-07-06 18:32:58 +mohan43u-we bharath: 'clear' command | |
2020-07-06 18:33:10 rajkumar ? | |
2020-07-06 18:33:15 +mohan43u-we Aachman_m_: https://training.ilugc.in | |
2020-07-06 18:33:20 +mohan43u-we rajkumar: go ahead | |
2020-07-06 18:33:34 bharath but if we use clear command if we scroll up the terminal it show older commans | |
2020-07-06 18:33:40 rajkumar How to visualize a file as directory? Please elaborate. | |
2020-07-06 18:33:54 bharath i want to clear whole terminal any command? | |
2020-07-06 18:34:20 +mohan43u-we bharath: you want to clear history, then use 'history -c' | |
2020-07-06 18:34:48 +mohan43u-we rajkumar: not able to understand your question, visualize means? | |
2020-07-06 18:35:25 rajkumar You said files are files and directories are also files. I'm trying to understand this. | |
2020-07-06 18:35:45 Aachman_m_ clear is the comand | |
2020-07-06 18:36:16 ravisankar ? | |
2020-07-06 18:36:49 +mohan43u-we rajkumar: normally, we use to store data in file and files inside directory, when we say everything is a file, the directory is also like a file whose contents are details about files | |
2020-07-06 18:37:44 +mohan43u-we rajkumar: when we do 'ls', that command basically read the a content of a file (but represented as directory) in the filesystem | |
2020-07-06 18:37:52 +mohan43u-we ravisankar: go ahead | |
2020-07-06 18:38:01 ravisankar once we get into shell using sh comman, tab key wont give results... why? | |
2020-07-06 18:38:32 +mohan43u-we ravisankar: sh is not bash, it is oldest created for original unix | |
2020-07-06 18:39:11 +mohan43u-we ravisankar: there are lot of shells available for unix based os, like csh, ksh, bash, ksh, fish, dash, ash, etc., | |
2020-07-06 18:39:28 +mohan43u-we ravisankar: each shell provides you more functionalities | |
2020-07-06 18:39:37 aaryan7476 Where are these terminals located? | |
2020-07-06 18:39:43 aaryan7476 in my fs | |
2020-07-06 18:39:44 +mohan43u-we ravisankar: bash give you tab completion | |
2020-07-06 18:40:08 +mohan43u-we ravisankar: sh is not that advanced, but it is simple | |
2020-07-06 18:40:42 +mohan43u-we aaryan7476: mostly in /usr/bin, if the shell is not available, then you have to install through your distro's package manager | |
2020-07-06 18:41:02 ravisankar ? | |
2020-07-06 18:41:26 +mohan43u-we ravisankar: go ahead | |
2020-07-06 18:41:30 aaryan7476 Thank you :) | |
2020-07-06 18:41:37 ravisankar how do i know my default shell name? and also how do i know the available shells in my os? | |
2020-07-06 18:41:39 +mohan43u-we aaryan7476: welcome | |
2020-07-06 18:41:52 +mohan43u-we ravisankar: echo $0 | |
2020-07-06 18:43:05 ravisankar how do i know the available shells in my os? | |
2020-07-06 18:43:14 +mohan43u-we ravisankar: there is no seperation between shells and other commands, everything lives inside /usr/bin directory nowadays | |
2020-07-06 18:43:39 +mohan43u-we ravisankar: if you have installed that shell through your package manager, then it will be available in /usr/bin | |
2020-07-06 18:43:55 Aachman_m_ am I late? | |
2020-07-06 18:44:05 +mohan43u-we Aachman_m_: when you joined? | |
2020-07-06 18:44:53 Aachman_m_ 6:27 | |
2020-07-06 18:44:56 ravisankar what are all the variables that we could pass it as argument to echo? | |
2020-07-06 18:45:23 +mohan43u-we Aachman_m_: session started properly at 5.40 and I completed around 6.30 | |
2020-07-06 18:45:43 +mohan43u-we ravisankar: I'll explain about variable in coming days | |
2020-07-06 18:45:56 ravisankar ok, thank you | |
2020-07-06 18:46:09 +mohan43u-we ravisankar: echo is a simple command, it doesn't know the different between 'hi' and '${hi}" | |
2020-07-06 18:46:41 -- Mode #ilugc [-v mohan43u-we] by mbuf | |
2020-07-06 18:46:48 mohan43u-we ravisankar: the magic is done by shell, echo is just as its name says, echos whatever we give | |
2020-07-06 18:47:13 mohan43u-we ravisankar: see presenter terminal | |
2020-07-06 18:48:14 ravisankar ok | |
2020-07-06 18:48:29 ravisankar (y) | |
2020-07-06 18:48:34 mohan43u-we so 'echo' is just going to dump whatever we give it as its argument | |
2020-07-06 18:49:11 mohan43u-we ravisankar: but the second echo I executed was specally processed by shell, it is called parameter expansion | |
2020-07-06 18:52:15 mohan43u-we anyone have other doubts, feel free to ask here. today's session is now completed. see you tomorrow at 5.00 pm. | |
2020-07-06 18:52:33 ravisankar thank you, looking for the next session.. :] | |
2020-07-06 18:52:42 rajkumar mohan43u-we: The session was simple and to the point. Thank you! Logistics can be improved in coming classes. Like preventing people from posting roll numbers. Good start! | |
2020-07-06 18:52:45 aaryan7476 Thank you so much mohan43u-we | |
2020-07-06 18:53:23 _181CS166 Thankyou | |
2020-07-06 18:53:47 Aachman_m see you tommorow | |
2020-07-06 18:56:04 shrini thanks mohan43u-we for the good start | |
2020-07-06 18:56:19 shrini Did not expected this high number of participants | |
2020-07-06 18:56:28 gnurenga Thank you mohan43u-we | |
2020-07-06 18:56:38 mohan43u-we rajkumar: yes, we will make sure we put the channel into restricted mode before we start the session. | |
2020-07-06 18:57:04 mohan43u-we gnurenga: the website broke in high load :) | |
2020-07-06 18:57:31 gnurenga yes mohan I came to know why | |
2020-07-06 18:57:47 gnurenga Mohan I have your no will call you | |
2020-07-06 18:57:57 gnurenga in 30 mins | |
2020-07-06 18:58:03 mohan43u-we gnurenga: sure | |
2020-07-06 19:15:51 SATHISHKUMARPVR reply me anyone is there to chat | |
2020-07-06 19:16:07 shrini yes SATHISHKUMARPVR | |
2020-07-06 19:16:08 shrini tell | |
2020-07-06 19:16:12 mohan43u-we yes | |
2020-07-06 19:16:30 mohan43u-we SATHISHKUMARPVR: ask your question | |
2020-07-06 19:18:16 SATHISHKUMARPVR sorry the connection with web is problematic here so i cane late i want to know | |
2020-07-06 19:19:34 SATHISHKUMARPVR where do our commands actually saved and where they run | |
2020-07-06 19:21:25 SATHISHKUMARPVR anyone here reply | |
2020-07-06 19:21:50 SATHISHKUMARPVR Mr.mohan just quit | |
2020-07-06 19:24:21 mohan43u SATHISHKUMARPVR: sorry, not able to understand your question, can you rephrase again? every shell command lives in one of the directories specified in PATH variable | |
2020-07-06 19:25:50 mohan43u SATHISHKUMARPVR: "where they run"? wherever you invoke, from there commands run. there is something called 'present working directory' or 'current working directory' | |
2020-07-06 19:26:11 mohan43u SATHISHKUMARPVR:'pwd' is the command to see where your current locaiton is in the shell | |
2020-07-06 19:26:32 mohan43u SATHISHKUMARPVR: you invoke shell commands from the current working directory | |
2020-07-06 19:26:44 mohan43u SATHISHKUMARPVR: did I answer your question? | |
2020-07-06 19:27:02 SATHISHKUMARPVR i mean if i type whoami where did it execute | |
2020-07-06 19:28:01 SATHISHKUMARPVR t/4 | |
2020-07-06 19:28:02 mohan43u SATHISHKUMARPVR: you execute 'whiami' from the current directory, the executable file of 'whoami' command resides in /usr/bin/whoami | |
2020-07-06 19:29:23 SATHISHKUMARPVR it means it will go using path env vatiable and execute it right | |
2020-07-06 19:32:49 mohan43u SATHISHKUMARPVR: yes, it uses PATH variable, I explained it briefly during the session. you might have missed the session. We will upload the session logs and provide you link to rewind | |
2020-07-06 19:36:16 jacke123 df | |
2020-07-06 19:40:53 mohan43u jacke123: command not found | |
2020-07-06 19:42:54 jacke123 help | |
2020-07-06 19:46:13 mohan43u jacke123: what kind of help you need? | |
2020-07-06 19:46:35 jacke123 I have log out | |
2020-07-06 19:46:58 mohan43u jacke123: you want to quit from IRC? type /quit | |
2020-07-06 19:47:43 jacke123 do you provide the video link of today session | |
2020-07-06 19:49:41 Nero007 Hi folks | |
2020-07-06 19:56:33 shrini2 hi Nero007 | |
2020-07-06 19:58:29 Nero007 I think many people here are from Linux durgapur group... | |
2020-07-06 20:12:34 shrini2 yes Nero007 | |
2020-07-06 20:12:44 shrini2 many were from a engg college in tamilnadu | |
2020-07-06 20:13:30 Nero007 Ah I see |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment