Changes between Version 1 and Version 2 of Csle2022/Agenda/linuxhandson


Ignore:
Timestamp:
Nov 24, 2022, 7:02:04 AM (2 years ago)
Author:
dushmantha
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Csle2022/Agenda/linuxhandson

    v1 v2  
    99•       '''pwd''' : Print Working Directory (Will tell you the location you are currently working)
    1010•       '''cd''' : You can change your current directory with the cd command
    11 o       cd : shortcut to get back into your home directory. Just typing cd without a target directory, will put you in your home directory
     11o cd : shortcut to get back into your home directory. Just typing cd without a target directory, will put you in your home directory
    1212o       cd .. : To go to the parent directory (the one just above your current directory in the directory tree)
    1313o       cd - : To go to the previous directory
     
    1616o       ls -l : to display the contents of the directory in different formats or to display different parts of the directory.
    1717o       ls -lh : shows the numbers (file sizes) in a more human readable format.
    18 •       mkdir : Create new directories
    19 •       mkdir -p: To create parent directories as needed
    20 •       rmdir: To remove the directory. (Directory has to be empty)
     18•       '''mkdir''' : Create new directories
     19•       '''mkdir -p:''' To create parent directories as needed
     20•       '''rmdir''': To remove the directory. (Directory has to be empty)
    2121
    2222
     
    229229
    230230
    231 Exercise
     231'''Exercise'''
    232232
    233233Create numbers.txt (Containing ten lines of numbers one to ten) file with cat command.
     
    245245Cat
    246246
     247
     248{{{
    247249$ cat numbers.txt
    248250one
     
    256258nine
    257259ten
     260}}}
     261
    258262
    259263less
     
    265269View first four lines and last four lines using head and tail commands
    266270
     271
     272{{{
    267273$ head -n 4 numbers.txt
    268274one
     
    275281nine
    276282ten
     283}}}
     284
    277285Create another file numbers2.txt(with lines contain eleven to fifteen)
    278286
     287
     288{{{
    279289$ cat > numbers2.txt
    280290eleven
     
    283293fourteen
    284294fifteen
     295}}}
     296
    285297
    286298Combine numbers.txt and numbers2.txt and create numbers3.txt. and view the file.
    287299
     300
     301{{{
    288302$ cat numbers.txt numbers2.txt > numbers3.txt
    289303$ cat numbers3.txt
     
    304318fourteen
    305319fifteen
     320}}}
     321
    306322
    307323Check the file format of the newly created file
     
    312328Copy all the created files to the test directory. and verify
    313329
     330
     331{{{
    314332$ cp numbers.txt numbers2.txt numbers3.txt test/
    315333$ cd test
    316334$ ls
    317335numbers2.txt  numbers3.txt  numbers.txt  one
     336}}}
     337
    318338
    319339Make a copy of test directory as newtest and rename it to numbers
     340
     341{{{
    320342$ cd
    321343$ cp -r test/ newtest
    322344$ mv newtest/ numbers
     345}}}
     346
    323347
    324348Delete the test directory
    325349
     350
     351{{{
    326352$ rm -rf test
     353}}}
     354
    327355
    328356
     
    340368If you look at files in a directory using "ls -al" you will see the permissions for each file and directories. Here is an example:
    341369
     370
     371{{{
    342372drwxr-xr-x  6 test   radius 4096 Oct 16 18:18 .
    343373drwxr-xr-x  3 root   root   4096 Sep 21 12:29 ..
     374}}}
     375
    344376
    345377So, the directory has r (read), w (write), x (execute) access for the User and Group. For Other it has r (read) and x (execute) access. The file has read/write/execute access for User and read only access for everyone else (Group and Other).
     
    370402Go to the numbers directory and get a detailed list
    371403
     404
     405{{{
    372406cd numbers
    373407ls -al
     
    380414drwxr-xr-x      3       test test 4096 Oct 17 13:08 one
    381415
     416}}}
     417
    382418
    383419Change file permission as follows
     
    449485Checking the network connectivity
    450486
     487
     488{{{
    451489Ping 8.8.8.8
    452490Ping google.com
     491}}}
     492
    453493
    454494The tracepath command in Linux allows to trace the path to the destination path determining MTU along this path using UDP port or any other ports that will not require any superuser permissions.
     
    458498nslookup is the name of a program that lets an Internet server administrator or any computer user enter a host name (for example, "whatis.com") and find out the corresponding IP address or domain name system (DNS) record.
    459499
    460         nslookup ac.lk
     500        '''nslookup ac.lk'''
    461501
    462502 
     
    465505The dig (domain information groper) command is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the queried name server(s).
    466506
    467 dig ac.lk
     507'''dig ac.lk'''
    468508
    469509 
     
    471511traceroute command in Linux prints the route that a packet takes to reach the host. This command is useful when you want to know about the route and about all the hops that a packet takes.
    472512
    473         traceroute ac.lk
     513        '''traceroute ac.lk'''
    474514
    475515On a Windows machine, this command is called tracert; on Linux and Mac, it's called traceroute.