SlideShare a Scribd company logo
1 of 11
Download to read offline
SOI Asia Workshop 2008
Pre-workshop Unix Basic Assignment

This document aims to provide basic Unix commands that operator needs to know to be
able to follow lecture content of SOI Asia operator workshop. Participant should review
the usage and do a practice on SOI Asia server with guidance and further explanation
from senior SOI Asia operator at your site.

To do practice, you need a user account on SOI Asia server machine and root password.
Remember to always use your user account to do practice unless the practicing command
really require root permission.

1. User account command

passwd : Change your password.
This will let you enter a new password. Please use a password that is not a real word or
name and has numbers or punctuation in it.


        Practice. Login your user and change password to new one. Do not
        practice this command with root user.

        # passwd


su : Become another user
“su username” attempt to login as another user, system authenticate by prompting
password. Without specifying username, it is attempt to login as root.

exit : Logout
When you are login as a user, you logout by this command.

whoami : Check the current being user
It returns username that you are using now.



        Practice. Login your user, and check current being user. “su” to be root,
        and check that your user is changing to root. Logout user root, and check
        your user again.

        # whoami
        # su
        # whoami
        # exit
        # whoami
2. Manual and Process command

man : Show any UNIX command usages
“man command” shows purpose of command, its format, how to specify options and
usage examples. Operator should use “man” to learn more about Unix commands given
in this documents.


        Practice. Use man to learn how to use following commands
        # man passwd
        # man su
        # man whoami



ps : Show process status
“ps” show processes own by your user. “ps –ax” shows all processes currently running
on your server. The output is formatted in columns. First column is process ID, third
column is process status and last column is command name. Please find more information
of other columns, how to interpret status information and how to use ps in a more
complex manner by “man ps”.



        Practice. Use ps to show processes of your user
        # ps
        Show all processes, and find what is process ID of /usr/sbin/sshd
        # ps –ax
3. Directory Command

ls : List the contents of a directory
“ls option dirname” lists content of “dirname” directory. If “dirname” is omitted, it lists
current directory. Option “–l” gives a more information showing file type, size, owner
and modification date of each file, option “-la” lists all files including those filenames
begin with a dot such as . , .. (“.” represents current directory, “..” represents parent
directory).


        Practice. Show content of current directory with different options and
        observe different outputs.
        # ls
        # ls –l
        # ls -la

        Show content of “/etc” directory and parent directory(“..”).
        # ls –la /etc
        # ls –la ..



cd : Change to a directory.
“cd dirname” move working directory to “dirname” directory. If “dirname” is omitted, it
will move back to home directory.

pwd : Show current working directory
It prints out current working directory.


        Practice. Change directories and check where you are. Notice where is
        your home directory.

        # cd
        # pwd
        # cd ..
        # pwd
        # cd /etc
        # pwd
        # cd
        # pwd
mkdir : Create a new directory.
“mkdir dirname” will create a new subdirectory called “dirname”.

rmdir : Remove a directory.
“rmdir dirname “will remove a subdirectory “dirname”. The directory must be
completely empty of files before this command will work.


        Practice. Create a directory name “test” on your home directory and
        remove it. During each step, observe the changing contents of your home
        directory.

        # cd
        # ls
        # mkdir test
        # ls
        # cd test
        # pwd
        # ls
        # cd ..
        # rmdir test
        # ls




4. File Copy/Move/Remove Command

cp : Copy a file.
“cp src dest” will make an exact copy of file “src” , with the name “dest”. If “dest” is a
subdirectory name, the command will instead copy file “src” into the subdirectory “dest”
and use its original file name.

mv : Move (rename) a file.
“mv src dest” will move file “src” to file “dest”. If “dest” is a subdirectory name, the
command will instead move file into the subdirectory “dest” and use its original file
name.

** Difference between “cp” and “mv” is that “mv” will delete the “src” file while “cp”
will leave “src” file untouched **

rm : Remove (delete) a file.
“rm filename” will delete “filename”. Once it is removed, there is no way to get it back!
Practice. Copy a file “/usr/share/man/man1/tar.1.gz” to home directory.
You will find a new file in home directory with its original name.

# cd
# cp /usr/share/man/man1/tar.1.gz ./
# ls

Copy tar.1.gz to another name, you will find a new file with new name
and source file is still there.

# cp tar.1.gz tar.2.gz
# ls

Move tar.1.gz to another name “test”, you will find a new file “test” and
source file”tar.1.gz” disappears.

# mv tar.1.gz test
# ls

Remove “test” file
# rm test
# ls

Create a “test” directory, move file to the directory. Notice how “mv
tar.1.gz test” command in previous step and “mv tar.2.gz test” works
differently.

# mkdir test
# mv tar.2.gz test
# ls
# ls test

Remove “test” directory. The following commands cannot remove
directory “test”. Why? Because “rm” is for remove file only and “rmdir”
cannot be used if directory is not empty.
# rm test
# rmdir test

Remove file in test directory and Remove test directory and practice file
# rm test/tar.2.gz
# rmdir test
# ls
5. File Display Command

cat : Display the content of a file all at once.
“cat filename” will output content of “filename” to terminal at once. For long file, the
beginning of the file will scroll off the top of the display window and you cannot see it.

more : Display the contents of a file one display screen at a time.
“more filename” will show you the contents of “filename”. It will show the first page and
then wait. Then you can press the spacebar to show the next page or press the return key
to show the next line, or press the “q” key to quit viewing file.

less : Display the contents of a file a screen at a time. It is enhanced version of more, has
more options and functions. If operator have time, check man page of less.


         Practice. Display file content using different commands and observe
         differences.

         # cat /etc/group
         # more /etc/group
         # less /etc/group


grep : Search file and print lines that match pattern.
“grep pattern filename” will print out each line in file “filename” that contains
“pattern”. It is case-sensitive search.


         Practice. Print line in file “/etc/group” that contain word “wheel”

         # grep wheel /etc/group


| : Pipe sign for output redirection
“ command1 | command 2 ” will send output of “command1” to be input of “command2”


         Practice. Display all process in the system page by page
         # ps –ax | more

         Search if process sshd is running or not
         # ps –ax | grep sshd

         Display Directory content page by page
         # ls /etc | more
6. File Editing Command

Vi is a Unix text editor program to be used in the SOI Asia operator workshop.
Typing “vi filename” will start an editor program to edit file “filename”, it can be an
existing file or a new file that you want to create.

Once you get into Vi program, there are two operating modes.

Command mode
This is the mode you are in whenever you begin to use vi. In this mode, you can type
several types of commands, for examples, command to move around text, command to
start editing text, command to save file, command to exit vi program or searching text. In
this mode, whatever you type will be not be inserted into text file, but rather considered
as commands. Pressing the ESC key will put you at command mode.

Insert mode
This is the mode you use to type (insert) text into a buffer. Whatever you type will be
going into text file, you cannot use vi command in this mode.



Following are commands you can use to manipulate your text file, make sure you use
them in command mode only. (Press ESC to get to command mode)

Saving and exiting vi

          Save file and exit vi                                  :wq!
          Exit vi                                                   :q
          Exit vi without saving file                              :q!
          Save file to name “filename”                   :w filename

Entering text

To type text into file, you must enter insert mode. Choose the command that is best suited
to the present position of the cursor and the editing task you want to do. After you type
any of these letters, you will be in Insert mode and everything you type will be inserted
into text file. Once finish inserting text or want to use any vi commands, press the ESC
key to back to command mode.

          Insert text after cursor                                  a
          Insert text before cursor                                  i
          Append text at the end of current line                    A
          Insert text at the start of current line                   I
          Open a new line below current line                        O
          Open a new line below current line                        o
Deleting text

          Delete current character                               x
          Delete current word                                   dw
          Delete current line                                   dd
          Delete next N line                                   Ndd
          Undelete a word or a line                              p

Moving in text file

          Use arrow key                                    ←↑↓→
          Move to beginning of current line                    0
          Move to end of current line                          $
          Move to beginning of file                           1G
          Move to end of file                                  G
          Move to line N                                     NG

Copy and paste text

          Copy current line                                     yy
          Copy N line including current line                   Nyy
          Paste in next line                                     p

Search text

          Search pattern                                    /pattern
          Repeat previous search                                   n

Replace text

          Replace pattern1 with pattern2 on        :s/pattern1/pattern2
          the same line
          Replace every pattern1 with            :s/pattern1/pattern2/g
          pattern2 on the same line
          Replace every pattern1 with          :g/pattern1/s//pattern2/g
          pattern2 in whole file
VI Exercise

Ex 1. At your home directory, create a new file “test1” which contains following 2 lines,
save and exit.

           Hello, This is my vi test file
           SOI Asia project stands for School of Internet Asia project



Ex 2. Edit file “test1” to contain following content. Change content on first line by using
command “x” to delete unwanted characters and then inserting desired texts. Then use
“G” to go to last line and press “o” to insert text at the last line..

           Hello, This is my second practice
           SOI Asia project stands for School of Internet Asia project
           And I am one of operator team member of SOI Asia project

Ex 3. Search all occurrences of word “project” in file “test1” using command “/” and “n”.

Ex 4. Replace all occurrences of word “project” with word “activity”, save to new file
name “test2”. Check that content of file “test1” and “test2” are different.

Ex 5. Edit file “test2” and delete the last line using command “dd”. Then copy remaining
2 lines and paste it 5 times. Now “test2” will contain following content, save but don’t
exit vi.

           Hello, This is my second practice
           SOI Asia activity stands for School of Internet Asia activity
           Hello, This is my second practice
           SOI Asia activity stands for School of Internet Asia activity
           Hello, This is my second practice
           SOI Asia activity stands for School of Internet Asia activity
           Hello, This is my second practice
           SOI Asia activity stands for School of Internet Asia activity
           Hello, This is my second practice
           SOI Asia activity stands for School of Internet Asia activity

Ex 6. Moving to Line 7 of file “test2” using command “7G” and delete last 4 lines of file
by command “4dd” and then undelete using “p”.

Ex 7. Copy and paste first line 3 times, save and exit. Final content of file “test2” is

           Hello, This is my second practice
           Hello, This is my second practice
           Hello, This is my second practice
Hello, This is my second practice
          SOI Asia activity stands for School of Internet Asia activity
          Hello, This is my second practice
          SOI Asia activity stands for School of Internet Asia activity
          Hello, This is my second practice
          SOI Asia activity stands for School of Internet Asia activity
          Hello, This is my second practice
          SOI Asia activity stands for School of Internet Asia activity
          Hello, This is my second practice
          SOI Asia activity stands for School of Internet Asia activity

Ex 8. Practicing command “0”, “$”, “1G”, “G” and “NG” to move cursor to different
positions of the file “test2”.

Ex 9.Try to do Ex1-Ex8 practices many times until you are familiar with vi commands.


7. Basic network command

ifconfig – Show/set configuration of machine’s network interfaces
“ifconfig ifname” shows information of network interface “ifname”. If “ifname” is
omitted, it shows all network interfaces. Output can be varies by OS but they commonly
show link media type, MAC address, IPv4 and IPv6 of each interface.

ping – Use to check network reachability to a host
“ping host” sends an ICMP packet to query a machine “host”, “host” can be specified as
either hostname or host’s IP. Target host will send an ICMP response back to the
querying host. Ping will show querying result which is used to indicate the connectivity
between your machine and that target host. Press Ctrl+c to stop ping.



        Check IP of your machine using ifconfig command.
        # ifconfig

        Ping to your machine using IP gather from previous step
        # ping your_machine_ip

        Ping to servers in SFC, Japan.
        # ping 202.249.25.193
        # ping www.soi.wide.ad.jp
traceroute - Print the route a packet takes to network host
“traceroute host” will print the network route from your machine to “host”, “host” can
be specified as either hostname or host’s IP.


        Traceroute to your machine using IP gather from previous step
        # traceroute your_machine_ip

        Traceroute to servers in SFC, Japan.
        # traceroute 202.249.25.193
        # traceroute www.soi.wide.ad.jp



tcpdump – Dump traffic on network
“tcpdump –i ifname” prints out the headers of all packets on a network interface
“ifname”. “tcpdump –i ifname expression” prints out packets matching expression. The
“expression” can be specified in many ways, please use “man tcpdump” to check how to
use it. You need to be root to be able to run this command. Press Ctrl+c to stop tcpdump.


        Check interface name and IP of your machine using ifconfig command.
        # ifconfig

        Tcpdump to see all packets on interface by using following command.
        Replace your_interface_name by your machine interface name.
        # tcpdump –i your_interface_name

        Tcpdump to see packets that source and destination address is your
        machine. Replace your_interface_name by your machine interface name
        and replace your_machine_ip with your machine’s IP gathered from
        ifconfig command.
        # tcpdump –i your_interface_name host your_machine_ip

        Tcpdump to see multicast packets and ipv6 packets
        # tcpdump –i your_interface_name ip multicast
        # tcpdump –i your_interface_name ip6

More Related Content

What's hot

What's hot (20)

Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Linux shell env
Linux shell envLinux shell env
Linux shell env
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Unix shell scripting tutorial
Unix shell scripting tutorialUnix shell scripting tutorial
Unix shell scripting tutorial
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Shell programming in ubuntu
Shell programming in ubuntuShell programming in ubuntu
Shell programming in ubuntu
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
 
Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
 
Bash shell
Bash shellBash shell
Bash shell
 

Viewers also liked

10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01Gina Gu
 
PMSight References
PMSight ReferencesPMSight References
PMSight ReferencesPaul Viviers
 
Fatca ii defusing the bomb (ban) uab magazine september 2012
Fatca ii   defusing the bomb (ban) uab magazine september 2012Fatca ii   defusing the bomb (ban) uab magazine september 2012
Fatca ii defusing the bomb (ban) uab magazine september 2012Bachir El-Nakib, CAMS
 
Cassandra basic
Cassandra basicCassandra basic
Cassandra basiczqhxuyuan
 
Theory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheoryTheory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheoryStephanie Lynch
 
Primero 2012 dgf presentation final v001 c5mf92
Primero 2012 dgf presentation final v001 c5mf92Primero 2012 dgf presentation final v001 c5mf92
Primero 2012 dgf presentation final v001 c5mf92primero_mining
 
Laminar Flow And Turbulence Modeling For Domestic Scale Wind Turbine Siting
Laminar Flow And Turbulence Modeling  For Domestic Scale Wind Turbine SitingLaminar Flow And Turbulence Modeling  For Domestic Scale Wind Turbine Siting
Laminar Flow And Turbulence Modeling For Domestic Scale Wind Turbine Sitingchittaranjang
 
Assignment 9 final
Assignment 9  finalAssignment 9  final
Assignment 9 finaldebbie14
 
PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011Dermot Donnelly
 
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...Tiziana Possemato
 
Vijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation CardVijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation Cardvijay_soft2u
 
Primero pms geneva presentation final
Primero pms geneva presentation finalPrimero pms geneva presentation final
Primero pms geneva presentation finalprimero_mining
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01Gina Gu
 

Viewers also liked (20)

10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
 
Brain and language
Brain and languageBrain and language
Brain and language
 
PMSight References
PMSight ReferencesPMSight References
PMSight References
 
Fatca ii defusing the bomb (ban) uab magazine september 2012
Fatca ii   defusing the bomb (ban) uab magazine september 2012Fatca ii   defusing the bomb (ban) uab magazine september 2012
Fatca ii defusing the bomb (ban) uab magazine september 2012
 
Cassandra basic
Cassandra basicCassandra basic
Cassandra basic
 
Documentary codes and conventions
Documentary codes and conventionsDocumentary codes and conventions
Documentary codes and conventions
 
Theory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheoryTheory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheory
 
Mekanika teknik II
Mekanika teknik IIMekanika teknik II
Mekanika teknik II
 
Primero 2012 dgf presentation final v001 c5mf92
Primero 2012 dgf presentation final v001 c5mf92Primero 2012 dgf presentation final v001 c5mf92
Primero 2012 dgf presentation final v001 c5mf92
 
Evaluation
EvaluationEvaluation
Evaluation
 
Laminar Flow And Turbulence Modeling For Domestic Scale Wind Turbine Siting
Laminar Flow And Turbulence Modeling  For Domestic Scale Wind Turbine SitingLaminar Flow And Turbulence Modeling  For Domestic Scale Wind Turbine Siting
Laminar Flow And Turbulence Modeling For Domestic Scale Wind Turbine Siting
 
Assignment 9 final
Assignment 9  finalAssignment 9  final
Assignment 9 final
 
Omega City Plots on NH8
Omega City Plots on NH8Omega City Plots on NH8
Omega City Plots on NH8
 
PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011
 
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
 
Sentence types
Sentence typesSentence types
Sentence types
 
Q2 report website
Q2 report websiteQ2 report website
Q2 report website
 
Vijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation CardVijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation Card
 
Primero pms geneva presentation final
Primero pms geneva presentation finalPrimero pms geneva presentation final
Primero pms geneva presentation final
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
 

Similar to Unix commands (20)

Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
11 unix osx_commands
11 unix osx_commands11 unix osx_commands
11 unix osx_commands
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command Line
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Assignment OS LAB 2022
Assignment OS LAB 2022Assignment OS LAB 2022
Assignment OS LAB 2022
 
Linux com
Linux comLinux com
Linux com
 

Recently uploaded

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 

Recently uploaded (20)

THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 

Unix commands

  • 1. SOI Asia Workshop 2008 Pre-workshop Unix Basic Assignment This document aims to provide basic Unix commands that operator needs to know to be able to follow lecture content of SOI Asia operator workshop. Participant should review the usage and do a practice on SOI Asia server with guidance and further explanation from senior SOI Asia operator at your site. To do practice, you need a user account on SOI Asia server machine and root password. Remember to always use your user account to do practice unless the practicing command really require root permission. 1. User account command passwd : Change your password. This will let you enter a new password. Please use a password that is not a real word or name and has numbers or punctuation in it. Practice. Login your user and change password to new one. Do not practice this command with root user. # passwd su : Become another user “su username” attempt to login as another user, system authenticate by prompting password. Without specifying username, it is attempt to login as root. exit : Logout When you are login as a user, you logout by this command. whoami : Check the current being user It returns username that you are using now. Practice. Login your user, and check current being user. “su” to be root, and check that your user is changing to root. Logout user root, and check your user again. # whoami # su # whoami # exit # whoami
  • 2. 2. Manual and Process command man : Show any UNIX command usages “man command” shows purpose of command, its format, how to specify options and usage examples. Operator should use “man” to learn more about Unix commands given in this documents. Practice. Use man to learn how to use following commands # man passwd # man su # man whoami ps : Show process status “ps” show processes own by your user. “ps –ax” shows all processes currently running on your server. The output is formatted in columns. First column is process ID, third column is process status and last column is command name. Please find more information of other columns, how to interpret status information and how to use ps in a more complex manner by “man ps”. Practice. Use ps to show processes of your user # ps Show all processes, and find what is process ID of /usr/sbin/sshd # ps –ax
  • 3. 3. Directory Command ls : List the contents of a directory “ls option dirname” lists content of “dirname” directory. If “dirname” is omitted, it lists current directory. Option “–l” gives a more information showing file type, size, owner and modification date of each file, option “-la” lists all files including those filenames begin with a dot such as . , .. (“.” represents current directory, “..” represents parent directory). Practice. Show content of current directory with different options and observe different outputs. # ls # ls –l # ls -la Show content of “/etc” directory and parent directory(“..”). # ls –la /etc # ls –la .. cd : Change to a directory. “cd dirname” move working directory to “dirname” directory. If “dirname” is omitted, it will move back to home directory. pwd : Show current working directory It prints out current working directory. Practice. Change directories and check where you are. Notice where is your home directory. # cd # pwd # cd .. # pwd # cd /etc # pwd # cd # pwd
  • 4. mkdir : Create a new directory. “mkdir dirname” will create a new subdirectory called “dirname”. rmdir : Remove a directory. “rmdir dirname “will remove a subdirectory “dirname”. The directory must be completely empty of files before this command will work. Practice. Create a directory name “test” on your home directory and remove it. During each step, observe the changing contents of your home directory. # cd # ls # mkdir test # ls # cd test # pwd # ls # cd .. # rmdir test # ls 4. File Copy/Move/Remove Command cp : Copy a file. “cp src dest” will make an exact copy of file “src” , with the name “dest”. If “dest” is a subdirectory name, the command will instead copy file “src” into the subdirectory “dest” and use its original file name. mv : Move (rename) a file. “mv src dest” will move file “src” to file “dest”. If “dest” is a subdirectory name, the command will instead move file into the subdirectory “dest” and use its original file name. ** Difference between “cp” and “mv” is that “mv” will delete the “src” file while “cp” will leave “src” file untouched ** rm : Remove (delete) a file. “rm filename” will delete “filename”. Once it is removed, there is no way to get it back!
  • 5. Practice. Copy a file “/usr/share/man/man1/tar.1.gz” to home directory. You will find a new file in home directory with its original name. # cd # cp /usr/share/man/man1/tar.1.gz ./ # ls Copy tar.1.gz to another name, you will find a new file with new name and source file is still there. # cp tar.1.gz tar.2.gz # ls Move tar.1.gz to another name “test”, you will find a new file “test” and source file”tar.1.gz” disappears. # mv tar.1.gz test # ls Remove “test” file # rm test # ls Create a “test” directory, move file to the directory. Notice how “mv tar.1.gz test” command in previous step and “mv tar.2.gz test” works differently. # mkdir test # mv tar.2.gz test # ls # ls test Remove “test” directory. The following commands cannot remove directory “test”. Why? Because “rm” is for remove file only and “rmdir” cannot be used if directory is not empty. # rm test # rmdir test Remove file in test directory and Remove test directory and practice file # rm test/tar.2.gz # rmdir test # ls
  • 6. 5. File Display Command cat : Display the content of a file all at once. “cat filename” will output content of “filename” to terminal at once. For long file, the beginning of the file will scroll off the top of the display window and you cannot see it. more : Display the contents of a file one display screen at a time. “more filename” will show you the contents of “filename”. It will show the first page and then wait. Then you can press the spacebar to show the next page or press the return key to show the next line, or press the “q” key to quit viewing file. less : Display the contents of a file a screen at a time. It is enhanced version of more, has more options and functions. If operator have time, check man page of less. Practice. Display file content using different commands and observe differences. # cat /etc/group # more /etc/group # less /etc/group grep : Search file and print lines that match pattern. “grep pattern filename” will print out each line in file “filename” that contains “pattern”. It is case-sensitive search. Practice. Print line in file “/etc/group” that contain word “wheel” # grep wheel /etc/group | : Pipe sign for output redirection “ command1 | command 2 ” will send output of “command1” to be input of “command2” Practice. Display all process in the system page by page # ps –ax | more Search if process sshd is running or not # ps –ax | grep sshd Display Directory content page by page # ls /etc | more
  • 7. 6. File Editing Command Vi is a Unix text editor program to be used in the SOI Asia operator workshop. Typing “vi filename” will start an editor program to edit file “filename”, it can be an existing file or a new file that you want to create. Once you get into Vi program, there are two operating modes. Command mode This is the mode you are in whenever you begin to use vi. In this mode, you can type several types of commands, for examples, command to move around text, command to start editing text, command to save file, command to exit vi program or searching text. In this mode, whatever you type will be not be inserted into text file, but rather considered as commands. Pressing the ESC key will put you at command mode. Insert mode This is the mode you use to type (insert) text into a buffer. Whatever you type will be going into text file, you cannot use vi command in this mode. Following are commands you can use to manipulate your text file, make sure you use them in command mode only. (Press ESC to get to command mode) Saving and exiting vi Save file and exit vi :wq! Exit vi :q Exit vi without saving file :q! Save file to name “filename” :w filename Entering text To type text into file, you must enter insert mode. Choose the command that is best suited to the present position of the cursor and the editing task you want to do. After you type any of these letters, you will be in Insert mode and everything you type will be inserted into text file. Once finish inserting text or want to use any vi commands, press the ESC key to back to command mode. Insert text after cursor a Insert text before cursor i Append text at the end of current line A Insert text at the start of current line I Open a new line below current line O Open a new line below current line o
  • 8. Deleting text Delete current character x Delete current word dw Delete current line dd Delete next N line Ndd Undelete a word or a line p Moving in text file Use arrow key ←↑↓→ Move to beginning of current line 0 Move to end of current line $ Move to beginning of file 1G Move to end of file G Move to line N NG Copy and paste text Copy current line yy Copy N line including current line Nyy Paste in next line p Search text Search pattern /pattern Repeat previous search n Replace text Replace pattern1 with pattern2 on :s/pattern1/pattern2 the same line Replace every pattern1 with :s/pattern1/pattern2/g pattern2 on the same line Replace every pattern1 with :g/pattern1/s//pattern2/g pattern2 in whole file
  • 9. VI Exercise Ex 1. At your home directory, create a new file “test1” which contains following 2 lines, save and exit. Hello, This is my vi test file SOI Asia project stands for School of Internet Asia project Ex 2. Edit file “test1” to contain following content. Change content on first line by using command “x” to delete unwanted characters and then inserting desired texts. Then use “G” to go to last line and press “o” to insert text at the last line.. Hello, This is my second practice SOI Asia project stands for School of Internet Asia project And I am one of operator team member of SOI Asia project Ex 3. Search all occurrences of word “project” in file “test1” using command “/” and “n”. Ex 4. Replace all occurrences of word “project” with word “activity”, save to new file name “test2”. Check that content of file “test1” and “test2” are different. Ex 5. Edit file “test2” and delete the last line using command “dd”. Then copy remaining 2 lines and paste it 5 times. Now “test2” will contain following content, save but don’t exit vi. Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Ex 6. Moving to Line 7 of file “test2” using command “7G” and delete last 4 lines of file by command “4dd” and then undelete using “p”. Ex 7. Copy and paste first line 3 times, save and exit. Final content of file “test2” is Hello, This is my second practice Hello, This is my second practice Hello, This is my second practice
  • 10. Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Hello, This is my second practice SOI Asia activity stands for School of Internet Asia activity Ex 8. Practicing command “0”, “$”, “1G”, “G” and “NG” to move cursor to different positions of the file “test2”. Ex 9.Try to do Ex1-Ex8 practices many times until you are familiar with vi commands. 7. Basic network command ifconfig – Show/set configuration of machine’s network interfaces “ifconfig ifname” shows information of network interface “ifname”. If “ifname” is omitted, it shows all network interfaces. Output can be varies by OS but they commonly show link media type, MAC address, IPv4 and IPv6 of each interface. ping – Use to check network reachability to a host “ping host” sends an ICMP packet to query a machine “host”, “host” can be specified as either hostname or host’s IP. Target host will send an ICMP response back to the querying host. Ping will show querying result which is used to indicate the connectivity between your machine and that target host. Press Ctrl+c to stop ping. Check IP of your machine using ifconfig command. # ifconfig Ping to your machine using IP gather from previous step # ping your_machine_ip Ping to servers in SFC, Japan. # ping 202.249.25.193 # ping www.soi.wide.ad.jp
  • 11. traceroute - Print the route a packet takes to network host “traceroute host” will print the network route from your machine to “host”, “host” can be specified as either hostname or host’s IP. Traceroute to your machine using IP gather from previous step # traceroute your_machine_ip Traceroute to servers in SFC, Japan. # traceroute 202.249.25.193 # traceroute www.soi.wide.ad.jp tcpdump – Dump traffic on network “tcpdump –i ifname” prints out the headers of all packets on a network interface “ifname”. “tcpdump –i ifname expression” prints out packets matching expression. The “expression” can be specified in many ways, please use “man tcpdump” to check how to use it. You need to be root to be able to run this command. Press Ctrl+c to stop tcpdump. Check interface name and IP of your machine using ifconfig command. # ifconfig Tcpdump to see all packets on interface by using following command. Replace your_interface_name by your machine interface name. # tcpdump –i your_interface_name Tcpdump to see packets that source and destination address is your machine. Replace your_interface_name by your machine interface name and replace your_machine_ip with your machine’s IP gathered from ifconfig command. # tcpdump –i your_interface_name host your_machine_ip Tcpdump to see multicast packets and ipv6 packets # tcpdump –i your_interface_name ip multicast # tcpdump –i your_interface_name ip6