SlideShare a Scribd company logo
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 (20)

Shell scripting
Shell scriptingShell scripting
Shell scripting
simha.dev.lin
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Mufaddal Haidermota
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
Tushar B Kute
 
Linux shell env
Linux shell envLinux shell env
Linux shell env
Rahul Pola
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
Narendra Sisodiya
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
jinal thakrar
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Geeks Anonymes
 
Unix shell scripting tutorial
Unix shell scripting tutorialUnix shell scripting tutorial
Unix shell scripting tutorial
Prof. Dr. K. Adisesha
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
Amit Ghosh
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
Ohgyun Ahn
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
Simon Su
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Gaurav Shinde
 
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
GauravRaikar3
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Shell programming in ubuntu
Shell programming in ubuntuShell programming in ubuntu
Shell programming in ubuntu
baabtra.com - No. 1 supplier of quality freshers
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
Ameer Sameer
 
Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
Constantine Nosovsky
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 

Viewers also liked (20)

10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
Gina Gu
 
Brain and language
Brain and languageBrain and language
Brain and language
Yudi Rahmatullah
 
PMSight References
PMSight ReferencesPMSight References
PMSight References
Paul 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 2012
Bachir El-Nakib, CAMS
 
Cassandra basic
Cassandra basicCassandra basic
Cassandra basic
zqhxuyuan
 
Documentary codes and conventions
Documentary codes and conventionsDocumentary codes and conventions
Documentary codes and conventions
PaulJohannesAshcroft
 
Theory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheoryTheory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheory
Stephanie Lynch
 
Mekanika teknik II
Mekanika teknik IIMekanika teknik II
Mekanika teknik II
Sylvester Saragih
 
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
primero_mining
 
Evaluation
EvaluationEvaluation
Evaluation
entwistlesophie8064
 
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
chittaranjang
 
Assignment 9 final
Assignment 9  finalAssignment 9  final
Assignment 9 final
debbie14
 
Omega City Plots on NH8
Omega City Plots on NH8Omega City Plots on NH8
Omega City Plots on NH8
aurusconsulting
 
PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011
Dermot 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
 
Sentence types
Sentence typesSentence types
Sentence types
astikristina
 
Q2 report website
Q2 report websiteQ2 report website
Q2 report website
primero_mining
 
Vijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation CardVijay Bhavsar - Marriage Invitation Card
Vijay Bhavsar - Marriage Invitation Card
vijay_soft2u
 
Primero pms geneva presentation final
Primero pms geneva presentation finalPrimero pms geneva presentation final
Primero pms geneva presentation final
primero_mining
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
Gina Gu
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
Gina Gu
 
PMSight References
PMSight ReferencesPMSight References
PMSight References
Paul 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 2012
Bachir El-Nakib, CAMS
 
Cassandra basic
Cassandra basicCassandra basic
Cassandra basic
zqhxuyuan
 
Theory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheoryTheory# Slideshow for OrgTheory
Theory# Slideshow for OrgTheory
Stephanie 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 c5mf92
primero_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 Siting
chittaranjang
 
Assignment 9 final
Assignment 9  finalAssignment 9  final
Assignment 9 final
debbie14
 
PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011PCK&Wiki_WaikatoUni_07-12-2011
PCK&Wiki_WaikatoUni_07-12-2011
Dermot 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 Card
vijay_soft2u
 
Primero pms geneva presentation final
Primero pms geneva presentation finalPrimero pms geneva presentation final
Primero pms geneva presentation final
primero_mining
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
Gina Gu
 

Similar to Unix commands (20)

Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
SaileshB5
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
MarsMox
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
 
11 unix osx_commands
11 unix osx_commands11 unix osx_commands
11 unix osx_commands
Macinfosoft
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
duquoi
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
homeworkping3
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
GowthamRaju15
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
Harsha Patel
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
Harsha Patel
 
Linux
LinuxLinux
Linux
merlin deepika
 
Linux
LinuxLinux
Linux
Yuvaraja Rajenderan
 
Linux
LinuxLinux
Linux
HAINIRMALRAJ
 
Linux
LinuxLinux
Linux
merlin deepika
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command Line
Liz Henry
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
poornima sugumaran
 
Linux commands
Linux commandsLinux commands
Linux commands
U.P Police
 
Assignment OS LAB 2022
Assignment OS LAB 2022Assignment OS LAB 2022
Assignment OS LAB 2022
INFOTAINMENTCHANNEL1
 

Recently uploaded (20)

[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
Samarth QUIZ 2024-25_ FINAL ROUND QUESTIONS
Samarth  QUIZ 2024-25_ FINAL ROUND QUESTIONSSamarth  QUIZ 2024-25_ FINAL ROUND QUESTIONS
Samarth QUIZ 2024-25_ FINAL ROUND QUESTIONS
Anand Kumar
 
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Sandeep Swamy
 
How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdfUnit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
ChatanBawankar
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academyGeographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Sandeep Swamy
 
Sri Guru Arjun Dev Ji .
Sri Guru Arjun Dev Ji                   .Sri Guru Arjun Dev Ji                   .
Sri Guru Arjun Dev Ji .
Balvir Singh
 
What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
ChatanBawankar
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
How to Configure Credit Card in Odoo 18 Accounting
How to Configure Credit Card in Odoo 18 AccountingHow to Configure Credit Card in Odoo 18 Accounting
How to Configure Credit Card in Odoo 18 Accounting
Celine George
 
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Rajdeep Bavaliya
 
The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Philosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum DesigningPhilosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum Designing
Ankit Choudhary
 
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
Samarth QUIZ 2024-25_ FINAL ROUND QUESTIONS
Samarth  QUIZ 2024-25_ FINAL ROUND QUESTIONSSamarth  QUIZ 2024-25_ FINAL ROUND QUESTIONS
Samarth QUIZ 2024-25_ FINAL ROUND QUESTIONS
Anand Kumar
 
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Understanding-the-Weather.pdf/7th class/social/ 2nd chapter/Samyans Academy n...
Sandeep Swamy
 
How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdfUnit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
ChatanBawankar
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academyGeographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Sandeep Swamy
 
Sri Guru Arjun Dev Ji .
Sri Guru Arjun Dev Ji                   .Sri Guru Arjun Dev Ji                   .
Sri Guru Arjun Dev Ji .
Balvir Singh
 
What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
ChatanBawankar
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
How to Configure Credit Card in Odoo 18 Accounting
How to Configure Credit Card in Odoo 18 AccountingHow to Configure Credit Card in Odoo 18 Accounting
How to Configure Credit Card in Odoo 18 Accounting
Celine George
 
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Rajdeep Bavaliya
 
The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Philosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum DesigningPhilosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum Designing
Ankit Choudhary
 

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