DAY 1 CONTINUATION OF LEARNING BASIC LINUX COMMAND NOTE: <strong>/</strong> is known as root directory <strong>~/</strong> is known as home directory lets create a directory name 'cohort_3' in the ~/ directory ![Screenshot from 2025-06-17 08-48-16](https://hackmd.io/_uploads/SyEWR5Cmll.png) lets create another directory in our cohort_3/ name 'web2' ![Screenshot from 2025-06-17 08-51-49](https://hackmd.io/_uploads/SkMfyoAXex.png) Okay lets quickly sharpen our knowledge a little with what we've learn. TASK 1 1. Create a directory name 'tasks' in the web2/ ![Screenshot from 2025-06-17 08-56-30](https://hackmd.io/_uploads/B1-RyiCQex.png) 2. Create the following text files in the tasks/ directory a. notes b. ideas c. todos ![Screenshot from 2025-06-17 19-16-17](https://hackmd.io/_uploads/B1DzZVJVle.png) 3. Append a text to each of the listed files above. e.g welcome to my note file ![Screenshot from 2025-06-17 19-20-11](https://hackmd.io/_uploads/rypxG41Exg.png) to view each of the files to be sure the text where appended ![Screenshot from 2025-06-17 19-22-32](https://hackmd.io/_uploads/rkSKM4k4lg.png) 4. Lets copy all the files in tasks/ to web2/ ![Screenshot from 2025-06-17 19-26-09](https://hackmd.io/_uploads/HkKL7NkNlx.png) NOTE: <strong>cp</strong> means <em>copy</em>, then followed by the name of the file(s), then the destination of the directory. In this case, the directory web2/ is one step backward hence the use of <strong>../</strong> To confirm the files where copied successfully, lets list(ls) all the files and folders in web2/ ![Screenshot from 2025-06-17 19-28-13](https://hackmd.io/_uploads/H1D0mNJVel.png) NOTE: the command <strong>ls ../</strong> will take you one step backward to where the web2/ folder is. 5. Rename the files in the web2/ folder and append <strong>_backup</strong> ![Screenshot from 2025-06-17 19-38-57](https://hackmd.io/_uploads/SJ9L84y4gx.png) NOTE: <strong>mv</strong> stands for move (which is use to rename a file and can also be use to move files or directory from one directory to another) then followed by the name of the file, then the new name. e.g <strong>mv ideas.txt idea_backup</strong> 6. Lets copy contents of notes and ideas into todos. First, lets check the contents of todos using the command <strong>cat todos.txt</strong> ![Screenshot from 2025-06-17 19-46-18](https://hackmd.io/_uploads/B1lXdEJNlg.png) Now its done using the command <strong>cat ideas.txt notes.txt >> todos.txt </strong> ![Screenshot from 2025-06-17 19-48-53](https://hackmd.io/_uploads/r1xnuV14ex.png) Alright, now we've learn some new things. Lets go further to do more greater things with the terminal. TASK 1 1. Create a <strong>trial/</strong> in the <strong>~/ </strong> This is simply saying we should create a directory name <strong>trial/</strong> in the <strong>home</strong> directory. ![Screenshot from 2025-06-17 19-56-25](https://hackmd.io/_uploads/SJJucNkNlx.png) 2. Lets copy the entire <strong>tasks/</strong> into <strong>trial/</strong> ![Screenshot from 2025-06-17 20-04-25](https://hackmd.io/_uploads/BkULh41Vgl.png) NOTE: <strong>r</strong> means <strong>recursive</strong> 3. Lets copy the entire <strong>web2/</strong> into <strong>trial/</strong> with <strong>trial/</strong> as our <strong>pwd (present working directory)</strong> ![Screenshot from 2025-06-17 20-15-49](https://hackmd.io/_uploads/BJtZyH1Exx.png) NOTE: The <strong>period (.)</strong> means the present working directory, which is saying the folder is been copied to the present working directory. 4. Lets <strong>cd (change directory)</strong> into <strong>tasks/</strong> and create a folder in <strong>~/</strong> name <strong>test/</strong> ![Screenshot from 2025-06-17 20-30-55](https://hackmd.io/_uploads/BkqYGSkNel.png) 5. Lets move the text files in <strong>web2/</strong> into the newly created directory <strong>test/</strong> with <strong>tasks/</strong> as our <strong>pwd (print working directory)</strong> This can be achieved by two(2) methods Method 1 is by moving the text files one after the other. ![Screenshot from 2025-06-17 20-43-46](https://hackmd.io/_uploads/BkgnRrBkVex.png) Method 2 is by the use of a <strong>wildcards (*)</strong> followed by the unique name or file format they all contain. In this case, <strong>_backup</strong> is the same format the files contain. ![Screenshot from 2025-06-17 20-48-37](https://hackmd.io/_uploads/H1r08SyNxg.png) 6. Lets create a hidden folder name <strong>hidden</strong> ![Screenshot from 2025-06-17 20-54-15](https://hackmd.io/_uploads/HJXfdrk4ex.png) NOTE: The folder <strong>.hidden</strong> was created but its not listed among the directories that are contained in the <strong>~/</strong> directory, why? because <strong>.hidden</strong> is a hidden directory which was created using the <strong>period (.)</strong>. How to view or list hidden file or directory using the command <strong>ls -a</strong> ![Screenshot from 2025-06-17 21-03-07](https://hackmd.io/_uploads/HyNmqSkNle.png) How to delete or remove hidden file or directory using the command <strong>rm -rf 'name of directory'</strong> where <strong>rm</strong> means remove, while <strong>rf</strong> means recursive force. ![Screenshot from 2025-06-17 21-06-33](https://hackmd.io/_uploads/H1Lyjr1Vex.png) NOTE: All the files or directories with the <strong>period(.)</strong> sign are regarded as hidden files or directories. DAY 2 GREP COMMAND Is a command that is use to search for matching patterns in a file. Grep stands for "Global Regular Expression Print". Regular expressions are sequence of character pattern. ![Screenshot from 2025-06-19 09-01-54](https://hackmd.io/_uploads/rk0WEHW4lg.png) NOTE: In the picture above, we're trying to find the matching pattern of 'to' in the todos.txt file. Grep is also case sensitive but to ignore that, we use <strong>-i</strong>. ![Screenshot from 2025-06-19 09-06-46](https://hackmd.io/_uploads/S1fESB-Eex.png) CHMOD COMMAND (change mode) Is a command that allows you change the permissions of a file or directory to all types. SYNTAX: chmod <Operations> <File/Directory Name> These operations are categorised into; <strong>USER LEVEL PERMISSIONS</strong> It control permissions on the user level. Here's the commands you can use: u – Grant permission to a user g – Grant permission to a group (A Group of users) o – Grant permission to others (who do not come under either of the above). <strong>FILE LEVEL PERMISSIONS</strong> It control permissions on the file level. r – Grants read permission w – Grant write permission x – Grant execute permission These operations need to be preceded with a '+' or '-' operator. '+' indicates adding a new permission, example <strong>chmod +r sample.txt</strong> '-' indicates removing an existing permission, example <strong>chmod -r sample.txt</strong> Now lets change some permisions on our txt file. ![Screenshot from 2025-06-19 10-27-26](https://hackmd.io/_uploads/ByOfdLZEge.png) THE USE OF RECURSIVE FLAG <strong>(-R)</strong> TO ADD OR REVOKE PERMISSIONS FOR A PARENT DIRECTORY DOWN TO THE LAST CHILD OF THE DIRECTORY Linux manages a very granular level of file permissions. If you want to apply the permissions to the parent directory and all its child directories, you need to pass an exclusive flag with the chmod command. That flag is <strong>-R</strong>. It basically means applying the same permissions recursively to all sub-directories (child directories). So this permission will apply to the end child of a file/directory. Here's the syntax for that: <strong>sudo chmod -R <permission> <filename></strong> Remember that running the command to do a recursive operation needs root permission. So you need to add sudo at the beginning of this command. Here's what it looks like: <strong>sudo chmod -R -r locked_directory</strong> OCTAL REPRESENTATION Octal representation is another way to control file permissions. Let's see the syntax for using octal mode: <strong>chmod <user><group><others> install.sh</strong> Here's an example of octal mode: <strong>chmod 777 install.sh</strong> NOTE: The syntax above is granting read, write and execute permisions to <strong><user><group><others></strong> where; read, r = 4 write, w = 2 execute, x = 1 TOTAL = 7 DAY 3 SHELL SCRIPTING Shell is a program that allows you to interact with the OS via command line. Shell scripting on the other hand is a file containing a sequence of commands that are executed by the shell program line by line. The terminal is a shell. TYPES OF SHELL 1. Bash shell (Bourn-Again): The default prompt is represented by a dollar sign <strong>$</strong> 2. C - shell: The default prompt is represented by a percentage sign <strong>%</strong> SOME KEY TERMINOLOGIES USED IN WRITING A SHELL FILE INCLUDE <strong>i</strong> (insert): allows you to insert the commands <strong>Esc</strong> (escape key): on the keyboard allows you to exit the insert mode. <strong>w</strong> (write): this mode allows a user to save all the changs made in the file. <strong>q</strong> (exit): to exit the text editor <strong>vim</strong>: text editor Lets create a shell file by name <strong>practise.sh</strong> and store some commands to do the following; 1. create a directory name demo/ 2. create a shell file name sample.sh in the demo/ 3. echo Hello world into the sample.sh 4. cd to demo/ 5. then ls SOLUTION creating a shell file name practise.sh ![Screenshot from 2025-06-21 11-33-01](https://hackmd.io/_uploads/S1Md9-EEll.png) open with vim using the command <strong>vim practise.sh</strong> It will then open the vim editor as seen below. ![Screenshot from 2025-06-21 11-34-21](https://hackmd.io/_uploads/B1jA9ZNNlx.png) Lets press i to activate the insert mode which allows the user to type in the editor. ![Screenshot from 2025-06-21 11-41-25](https://hackmd.io/_uploads/H1DP3-44xx.png) lets press Esc to exit the insert mode ![Screenshot from 2025-06-21 11-42-30](https://hackmd.io/_uploads/HJU32WVExg.png) To save our changes, we use <strong>:w</strong> and press enter as seen in the down left-corner of the picture below ![Screenshot from 2025-06-21 11-44-19](https://hackmd.io/_uploads/rktd6Z4Nll.png) After is has been saved, it will print some captions below as seen in the picture. ![Screenshot from 2025-06-21 11-46-35](https://hackmd.io/_uploads/ByJm0-4Vel.png) To quit the vim editor, type <strong>:q</strong> and press enter. ![Screenshot from 2025-06-21 11-51-10](https://hackmd.io/_uploads/HyZ30-VElg.png) After exiting, it will navigate us back to the terminal to execute the file. ![Screenshot from 2025-06-21 11-52-32](https://hackmd.io/_uploads/Sk5G1fN4ge.png) To execute the file, lets use the command <strong>./practise.sh</strong> but this will throw an error requiring a user permission to execute the file. ![Screenshot from 2025-06-21 11-57-16](https://hackmd.io/_uploads/B1PrlzEEge.png) If we <strong>ls -l practise.sh</strong>, you'd see that the user has no executable permissions to execute the file. ![Screenshot from 2025-06-21 12-01-59](https://hackmd.io/_uploads/BkKPZfE4gx.png) To grant the user executable permission, lets use the command <strong>chmod u+x practise.sh</strong> ![Screenshot from 2025-06-21 12-03-41](https://hackmd.io/_uploads/ry-ibGNEle.png) Now we can execute our file using the command <strong>./practise.sh</strong> ![Screenshot from 2025-06-21 12-05-15](https://hackmd.io/_uploads/HJf-GGEVll.png) If we ls to home/, we should see our demo/ followed by the shell file we created in the demo/ then the Hello world! we echo into the file. ![Screenshot from 2025-06-21 12-08-30](https://hackmd.io/_uploads/HkZafGNNex.png) CONCLUSION This week has been an awesome and mind blowing week. From learning basic linux commands to writing shell scripting files, isn't that pretty awesome? Indeed i'm learning a lot. Looking forward to what will be achieved neext week. Stay with me in my journey to becoming the best version of myself. Cheers!