Fundamentals, Linux/Unix Commands, Regular Expressions, Variables, VI Editor
Fundamentals, Linux/Unix Commands, Regular Expressions, Variables, VI Editor
Linux/Unix commands,
Regular Expressions,
Variables,
VI Editor
What is linux:
1. Open source operating system like Mac, microsoft, apple, iOS,
android,Windows etc
2. Unix is also an operating system like linux; it is an commercial
OS and has three parts kernal,Shell,and programs.
3. What is OS? It helps in enabling communication between
hardware and software. It conveys input to get processes by the
processor and brings output to the hardware to display it.
4. Developed by Linus Torvalds in 1991, idea was to improve the
unix OS. Used in wristwatches to supercomputers, every possible
hardware devices.
5. Its structure:
1. Kernal:
Linux kernal is core part of OS. establishes communication between
devices and software. Has 4 responsibilities:
I) Device management: A system has many devices connected to it lik
CPU, memory chip, graphic card, sounds card etc. A kernal stores all the
data related to all the devices in device driver. Thats why kernal knows
everything about the devices and knows how to manipulate it to bring
the best out of it. Helps in managing communication between devices.
II) Memory management: the kernal keeps track of used and unused
memory and makes sure that processes shouldnt manipulate data of
each other using virtual memory addresses
III) Process management: kernal assigns enough time and gives
proorities to processes before handling CPU to other processes. Deals
with security and ownership info.
IV) Handling system calls: programmer can write a query or ask karnal
to perform the task.
2) System libraries;
I. This helps in accessing the kernel’s features. A kernel has to be
triggered to perform some tsk and this is done by applications.
II. But applications must know how to place a system call because each
kernel has a different set of system calls. Programmers have
developed a standard library of procedures to communicate with the
kernel.
III. Each operating system supports these standards, and then these are
transferred to system calls for that operating system.
IV. The most well-known system library for Linux is Glibc (GNU C
library).
3) System Tools:
I. Linux OS has a set of utility tools, which are usually simple
commands.
II. It is a software which GNU project has written and publish under
their open source license so that software is freely available to
everyone.
III. With the help of commands, you can access your files, edit and
manipulate data in your directories or files, change the location of
files, or anything.
4) Development tools:
I. With the above three components, your OS is running and working.
But to update your system, you have additional tools and libraries.
II. These additional tools and libraries are written by the programmers
and are called toolchain.
III. A toolchain is a vital development tool used by the developers to
produce a working application.
5) End User tools:
I. These end tools make a system unique for a user. End tools are not
required for the operating system but are necessary for a user.
II. Some examples of end tools are graphic design tools, office suites,
browsers, multimedia players, etc.
Linux features:
1. Multiuser capability
2. Multitasking
3. Portability
4. Security
5. Live CD/USB
6. Graphical user interface
7. Support’s customized keyboards
8. Application support
9. File system
10. Open source
Top 50 commands:
command syntax use
pwd pwd Used to display
location of the current
working directory
mkdir mkdir<directory name> Used to create a new
directory under any
directory
rmdir rmdir<directory name> Used to delete a
directory
ls ls Used to display list of
content of a directory
cd cd<directory name> Change the current
directory
touch touch<file name> Create empty files, we
touch<file1><file2> can create multiple
empty files by
executing it once
cat cat[OPTION]…..[FILE] It is a multi-purpose
cat><file name> utility in the linux
//enter file content system. It can be used
CTRL+D SAVE the keys to create a file,display
content of the file,
copy the content of
one file to another file
and more
rm rm<file name> Remove file
cp cp <existing file name> <new file name> Copy a file or directory
Linux regular expression called regex or regexp. Regular expression is a pattern fir matching
string that follows some pattern.
Metacharacter Description
. Replaces any character.
^ Matches start of string and represents characters not in the string.
$ Matches end of string.
* Matches zero or more times the preceding character.
\ Represents the group of characters.
() Groups regular expressions.
? Matches exactly one character.
+ Matches one or more times the preceding character.
{N} Preceding character is matched exactly N times.
{N,} Preceding character is matched exactly N times or more.
{N,M} Preceding character is matched exactly N times, but not more than N times.
- Represents the range.
\b Matches empty string at the edge of a word.
\B Matches empty string if it is not at the edge of a word.
\< Matches empty string at the beginning of a word.
\> Matches empty string at the end of a word.
Regex Versions
There are three versions of regular expressions syntax:
BRE : Basic Regular Expressions
ERE : Extended Regular Expressions
PRCE: Perl Regular Expressions
Depending on tool or programs, one or more of these versions can be used.
A global replacement:
In the above example only first 'txt' was replaced in 'atxt.txt'. To replace both the 'txt' we can use
a global replacement 'g'.
rename 's/string/other string/g'
Example;
Rename ‘s/txt/TXT/g’ atxt.txt