0% found this document useful (0 votes)
45 views56 pages

Ubuntu

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views56 pages

Ubuntu

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

WINDOW

SUBSYSTEM
for LINUX - UBUNTU
Table of contents

01 02
Introduce Install

03 04
Command line MAKEFILE
01 Introduce
What is Window Subsystem for
Linux?
WSL

● The Windows Subsystem for Linux lets developers run a GNU/Linux environment --
including most command-line tools, utilities, and applications -- directly on Windows,
unmodified, without the overhead of a traditional virtual machine or dualboot setup.
● Features:
○ Run command line tool
○ Run Bash shell scripts
02 Install
Run Windows 10 version 2004 and
higher (Build 19041 and higher) or
Windows 11 to use the commands
below
Terminal

● dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all


/norestart
● dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
● Download update kernel package: Packet
● wsl --set-default-version 2
● To list distro name, wsl - - list - - online.
● wsl --install –d <distro name>.
● Set up user and password
GUI

● Turn on WINDOW FEATURES for WSL.


● Download update kernel package for wsl (if needing).
● Download Ubutu(newest) from Microsoft Store.
● Set up user and password
03 Command lines
whoami Show current user
man <command> Get manual of <command>
clear Clear the screen
pwd Show present working directory
ls List whatever in current directory
cd Change directory (sequence)
cd . . Back to previous directory
mkdir Create folder
touch Create empty file
rmdir Delete folder
rm Remove file or directory
open Open file, folder
mv <file> <path>/ Move <file> to <path>
cp <src> <dest> Copy contents of src to dest
head <file> -n lines Output the first (lines) part of file
tail <file> -n lines Output the last (lines) part of file
date Show date-time
> Redirect standard output
cat –n <file> Read file and show number of lines
less <file> Show content of file in a nice & interactive UI
echo Print input parameter to screen
wc <file> Print lines, word, byte counts of file
find <where> <pattern> Find files or folders matching a particular search pattern
recursively.
grep Search in files or combine it with pipes to filter the
output of another command.
history Display all the history.
ps Show currently running processes.
top List the processes running in real time.
kill <PID> Send variety signals to a program <PID>
Default: send ‘TERM’ signal to <PID>
nano <file_name> Open and modify file.
sudo Run command as root
Understanding permissions

 The very first character indicates the type of file:


○ - : regular file
○ d : directory
○ c : character special file
○ l : symbolic link

 File type specification:

OWNER GROUP WORLD

rw- r-- r--


Permissions

Character Effect on File Effect on Directory


r read List
w modify Modify
x execute Execute
- none none
chmod

 To change permissions of a file or a directory.


 To use “chmod”, we need to tell it:
○ Who:
○ What:
○ Which:
 Who:
o u – user: the owner of the file
o g – group:
o o – other:
o a – all:
 What:
o - remove permission
o + grant permission
o = set the permission and remove others
 Which:
o r – read
o w – write
o x - execute

 Ex: chmod g+w file1.txt: group can modify file1.txt


 chmod a-w file2.txt: remove write permission from all
 chmod a=r file3.txt: Set read permission only for all
04 MAKEFILE
Introduction
● Makefile is a program building tool which runs on Unix, Linux, and their flavors. It
aids in simplifying building program executables that may need various modules. To
determine how the modules need to be compiled or recompiled together, make takes
the help of user-defined makefiles. This tutorial should enhance your knowledge about
the structure and utility of makefile.
● Makefiles are special format files that help build and manage the projects
automatically.
● Install : sudo apt-get install make
Variables

● Variables representing constants a user might want to customize on the command line
or in the environment are written in all uppercase, by convention.
● To use variables, using ${var} or $(var).
● Operators:

= Recursively expanded variables.


:= | ::= Simply expanded variables.
?= Set variable value if it’s not been set before.
+= Append the variable.
Syntax
 A Makefile consists of a set of rules. A rule generally looks like this:

 If you want all target to run with a command -> The all target
 Or you can run multiple targets rule.
main.o: main.c sum.h
Rule
gcc –c main.c

Tab

Dependency
Target
Action
Implicit rule

 This implicit rule says how to make x out of x.c -- run cc on x.c and call the output x.
The rule is implicit because no particular target is mentioned.
Macros
● The make program allows you to use macros, which are similar to variables. Macros
are defined in a Makefile as = pairs.
● Some special macros: (self learning -> for the homework)

Variables Description
AS Program to compiling assembly files; default is `as'.
CC Program to compiling C programs; default is `cc'.
CXX Program to compiling C++ programs; default is `g++'.
CPP Program to running the C preprocessor, with results to
standard output; default is `$(CC) -E'.
Wildcards

* wildcard
 % wildcard
 When used in “matching” mode, it
 Searches your filesystem for matches one or more characters in a
matching filenames. string
 may be used in the target,  When used in “replacing” mode, it
prerequisites, or in wildcard function. takes the matching and replaces that in
a string.
 Static Pattern rules?
 Pattern rules?
Automatic variables
$@ Name of target.
$% The target member name in archive.
$< The name of the first prerequisites.
$? The name of all the prerequisites that are newer than the
target, with spaces between them.
$^ The name of all the prerequisites, with spaces between
them.
Static Pattern Rules

 Static pattern rules are another way to write less in a Makefile.


 Syntax:

 target . . . : target-pattern : pre-req – patterns . . .


command

 The essence is that the given target is matched by the target-pattern (via a %
wildcard).Whatever was matched is called the stem. The stem is then substituted into
the pre-req-pattern, to generate the target's pre-reqs.
 Example 3.2
Static Pattern Rules and Filter

 Filter function remove files that are not suitable in a file list.
 Syntax: $(filter pattern . . . , text)
 Example 3.3, 3.4
Condition

 Syntax:
Ifeq | Ifneq
action
Else
action
Endif
 Example 3.5
Functions

 Functions are mainly just for text processing.


 Syntax: $(fn, arg) | ${fn, arg).
 String Substitution:
1. $(subst {from}, {to}, {text_source})
Each occurrence of from is replaced by to.

2. $(patsubst pattern, replacement, text)


Finds whitespace-separated words in text that match pattern and replaces them
with replacement.
Substitution reference: $(var : pattern = replacement)
Function

● Foreach: $(foreach var, list, text) ?


● If: $(if condition, then-part [, else-part])
● $(wildcard pattern …)
● $(addprefix prefix, names…..)
● $(addsuffix suffix, names…..)
● $(basename names…..)
How to write a standard Makefile

 Step 1: Tool macros


o CC := gcc
o CCFLAGS := -Wall
o DBGFLAGS := -g
o CCOBJFLAGS := $(CCFLAGS) -c
 Step 2: path macros
o BIN_PATH := bin
o OBJ_PATH := obj
o SRC_PATH := src
o DBG_PATH := debug
 Step 3: Target name
o TARGET_NAME := main
o TARGET := $(BIN_PATH)/$(TARGET_NAME)
o TARGET_DEBUG := $(DBG_PATH)/$(TARGET_NAME)
 Step 4: source & obj files
○ SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $
(x)/*,.c*)))
○ OBJ := $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(notdir $
(basename $(SRC)))))
○ OBJ_DEBUG := $(addprefix $(DBG_PATH)/, $(addsuffix .o, $
(notdir $(basename $(SRC)))))
 Step 5: clean files
○ DISTCLEAN_LIST := $(OBJ) \$(OBJ_DEBUG)
○ CLEAN_LIST := $(TARGET) \$(TARGET_DEBUG) \$(DISTCLEAN_LIST)
 Step 6: write rules
VIM | NANO
05 Commands
Text Editor in Ubuntu
VIM

● Vim is a text editor that is an upgraded version of the Vi editor and is more compatible with Vi.
The most usage of vi editors is to create a new file, edit an existing file, or just read a file. Vim
editor is more useful in editing different kinds of plain text. This command is more used in editing
programs.
● Operating modes in vim editor:
• Command Mode: By default, command mode is on as soon as the vim editor is
started. This command mode helps users to copy, paste, delete, or move text. We
should be pressing [Esc] key to go to command mode when we are in other
modes.
• Insert mode: Whenever we try to open vim editor, it will go to command mode
by default. To write the contents in the file, we must go to insert mode. Press ‘I’
to go to insert mode. If we want to go back to command mode, press the [Esc]
key.
Basic commands of VIM
● To open or create a file: vim {filename}.
● To enable editing that file: [Insert] key or [I] key
● [ESC] -> normal mode

:set number Display line number

:$ Move to the end of file

:0 Move to the beginning of file

dd Delete line where cursor is currently


placed
u Undo

:syntax on/off Turn on/off syntax highlighting

:wq Save and exit


● Copy and Paste command:
1. Key [v] and use ← → to highlight text. Using [V] (capslock) to select a whole line.
2. Key [y] – yank mode and copy it to clipboard.
3. Create a new line with key [o].
4. Paste: [ESC] + p.
NANO
Instructions for use
If you have a free account, in order to use this template, you must credit Slidesgo by keeping the Thanks slide. Please
refer to the next slide to read the instructions for premium users.

As a Free user, you are allowed to:


- Modify this template.
- Use it for both personal and commercial projects.

You are not allowed to:


- Sublicense, sell or rent any of Slidesgo Content (or a modified version of Slidesgo Content).
- Distribute Slidesgo Content unless it has been expressly authorized by Slidesgo.
- Include Slidesgo Content in an online or offline database or file.
- Offer Slidesgo templates (or modified versions of Slidesgo templates) for download.
- Acquire the copyright of Slidesgo Content.

For more information about editing slides, please read our FAQs or visit Slidesgo School:
https://slidesgo.com/faqs and https://slidesgo.com/slidesgo-school
Instructions for use (premium users)
As a Premium user, you can use this template without attributing Slidesgo or keeping the "Thanks" slide.

You are allowed to:


● Modify this template.
● Use it for both personal and commercial purposes.
● Hide or delete the “Thanks” slide and the mention to Slidesgo in the credits.
● Share this template in an editable format with people who are not part of your team.

You are not allowed to:


● Sublicense, sell or rent this Slidesgo Template (or a modified version of this Slidesgo Template).
● Distribute this Slidesgo Template (or a modified version of this Slidesgo Template) or include it in a database or in
any other product or service that offers downloadable images, icons or presentations that may be subject to
distribution or resale.
● Use any of the elements that are part of this Slidesgo Template in an isolated and separated way from this
Template.
● Register any of the elements that are part of this template as a trademark or logo, or register it as a work in an
intellectual property registry or similar.

For more information about editing slides, please read our FAQs or visit Slidesgo School:
https://slidesgo.com/faqs and https://slidesgo.com/slidesgo-school
Fonts & colors used

This presentation has been made using the following fonts:

Audiowide
(https://fonts.google.com/specimen/Audiowide)

Karla
(https://fonts.google.com/specimen/Karla)

#031126 #ffffff #10355f #3b8794 #51afdb


Storyset

Create your Story with our illustrated concepts. Choose the style you like the most, edit its colors, pick
the background and layers you want to show and bring them to life with the animator panel! It will boost
your presentation. Check out how it works.

Pana Amico Bro Rafiki Cuate


Use our editable graphic resources...

You can easily resize these resources without losing quality. To change the color, just ungroup the resource
and click on the object you want to change. Then, click on the paint bucket and select the color you want.
Group the resource again when you’re done. You can also look for more infographics on Slidesgo.
JANUARY FEBRUARY MARCH APRIL MAY JUNE

PHASE 1

Task 1

Task 2

PHASE 2

Task 1

Task 2

JANUARY FEBRUARY MARCH APRIL

PHASE
1

Task 1

Task 2
...and our sets of editable icons

You can resize these icons without losing quality.


You can change the stroke and fill color; just select the icon and click on the paint bucket/pen.
In Google Slides, you can also use Flaticon’s extension, allowing you to customize and add even more icons.
Educational Icons Medical Icons
Business Icons Teamwork Icons
Help & Support Icons Avatar Icons
Creative Process Icons Performing Arts Icons
Nature Icons
SEO & Marketing Icons

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy