author: Ouso D. O.
date: 09-08-2018
autosize: true
========================================================
- Understand basic Linux terminologies
- Reasons to adopt Linux
- Understand basic Linux filesystem
- Differentiate between relative and absolute paths
- Learn to make dirs and common operations with directories
- Be able to explain the "ls" output
- Know how to manipulate files and file contents
- Basics of shell scripting
-
Kernel - the core functionality of an operating system, translates commands from other software directly to the hardware interfaces.
-
Distributions - operating systems based on the Linux kernel, eg. Ubuntu (Deb), CentOS (Fedora) & openSUSE (SUSE)
-
CLI/Terminal - a method of interaction with the computer based on text commands entered at the prompt
-
GUI - a method of interaction with the computer that makes use of visual representations of elements
- It is FLOSS-based
- World's largest and most prevalent open source
- Long Term Support (LTS)
- Many developers around the world contribute to it
- Most secure
- Customizable
- Multi-user, multi-tasking (servers)
- A Major force in computing, eg. supercomputers, phones, stock exchanges etc
- Partition - a logical part of a disk
- Filesystem - a method of storing/finding files on a hard disk Linux uses '/' to separate paths, windows uses ''.
Below is the partial Linux FS representation
A comparison between Win and Linux filesystems is illustrated in the image below
- For more details see the Linux Filesysytem Hierarchy Standard
- A new terminal will land you in the home directory
- While on the terminal you will be associated to one directory at a time called working dir/current dir
- The command pwd (present working directory) returns the absolute path to your working dir
Two types of paths exist:
- Absolute path - describe the path of a file/dir from the root (/) all the way to it
- Relative path - describe the path to a file/dir from the current working dir
What is the absolute path to "README.md"? /home/oface/Git/Images/README.md
What is the path to "LinuxFS.png" assuming my current working directory is PythonCoding? ./../Images/LinuxFS.png
- In Linux "Directories" are equivalent to Windows "Folders"
Some of the commands associated with directories include:
- To create a dir use mkdir <dirName>
- To remove a dir use rmdir <dirNmae>
- To move from one dir to another, use cd <dirPath>
- To list dir content, use ls while inside the dir or ls <dirPath> from a different dir
- To rename a dir, use mv <oldName> <newName>
- File(-) or Directory(d) or Symlink(l)
- Owner file permissions
- Group file permissions
- Global user file permissions
- Number of links
- Owner name
- Owner group
- File size
- Date and time of last modification
- File/Directory name
"total BLOCKS" means the total disk allocations of the dir content listed
- cd~ or cd: takes you to home dir from wherever
- cd -: takes you to previous dir
- cd ..: takes you to parent dir
- Ctrl+L: clears terminal
- Ctrl+C: cancels a running program
- Crtl+D: exit terminal
- Tab: auto complete
- Tab Tab: display possibities for autocomplete
- touch: to create, modify and change timestamp of a file; syntax touch <fileName>
- gedit: to create a text file; syntax gedit <fileName>
- wget: is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies; syntax wget <option(s)> <URL>
- cp: copy file/dir; syntax cp <origiLocation> <finalLocation>
- rm: delete files; syntax rm <file>
- mv: move file/dir; syntax mv <origiLocation> <finalLocation>
To figure out the many possible options of a command use man <command> to get a summary manual of how to use that command. Linux commands generally follow the syntax command <option(s)> <argument(s)>
- cat: to view content of a small file in stdout; syntax cat <file>
- more: to view a large file in stdout by scrolling unilaterally - downwards; syntax more <file>. Use keyboard "Spacebar" to scroll page by page
- less: to view a large file in stdout by scrolling bilaterally - up/downwards; syntax more <file>. Use keyboard "Spacebar" to scroll page by page
- head: explore, by default, ten top lines of a file: syntax head <file>
- tail: explore, by default, ten last lines of a file: syntax tail <file>
- wc: word count, to explore number of lines, words and characters of a file: syntax wc <file>
- sort: re-order file content alphabeti/numeri-cally; syntax sort <file>
- uniq: remove redundancies; syntax uniq <file>
- join: compare content; syntax join <file1> <file2>. Output common entries
- diff: compare content; syntax diff <file1> <file2>. Output the differences
- grep: Global Regular Expression Pattern, search for patterns; syntax grep <pattern> <file>
Wildcards: special characters used as patterns to help with quick targeting of files or file sections/dirs, see document on wildcards starting from page 23
What is a script? A short program written in the programming languages used for automation, especially when handling huge amounts of data which require similar treatment. A shell script file basically contains a set of instructions in a shell language to be performed on files
What is shebang? Begins a shell script, to set the interpreter environment to be used to execute the set of instructions that follow, "bash" is such an interpreter, several others exist. Syntax #!AbsolutePathOfInterpreter eg. #!/bin/bash or #!/usr/bin/python
After writing your script you will need to make it executable by using the chmod command before you can run it
=============================================================================================
email: [email protected]
twitter: @ousodanos