Changes between Version 1 and Version 2 of Csle2022/Agenda/linuxhandson
- Timestamp:
- Nov 24, 2022, 7:02:04 AM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Csle2022/Agenda/linuxhandson
v1 v2 9 9 • '''pwd''' : Print Working Directory (Will tell you the location you are currently working) 10 10 • '''cd''' : You can change your current directory with the cd command 11 o 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 12 12 o cd .. : To go to the parent directory (the one just above your current directory in the directory tree) 13 13 o cd - : To go to the previous directory … … 16 16 o ls -l : to display the contents of the directory in different formats or to display different parts of the directory. 17 17 o ls -lh : shows the numbers (file sizes) in a more human readable format. 18 • mkdir: Create new directories19 • mkdir -p:To create parent directories as needed20 • 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) 21 21 22 22 … … 229 229 230 230 231 Exercise 231 '''Exercise''' 232 232 233 233 Create numbers.txt (Containing ten lines of numbers one to ten) file with cat command. … … 245 245 Cat 246 246 247 248 {{{ 247 249 $ cat numbers.txt 248 250 one … … 256 258 nine 257 259 ten 260 }}} 261 258 262 259 263 less … … 265 269 View first four lines and last four lines using head and tail commands 266 270 271 272 {{{ 267 273 $ head -n 4 numbers.txt 268 274 one … … 275 281 nine 276 282 ten 283 }}} 284 277 285 Create another file numbers2.txt(with lines contain eleven to fifteen) 278 286 287 288 {{{ 279 289 $ cat > numbers2.txt 280 290 eleven … … 283 293 fourteen 284 294 fifteen 295 }}} 296 285 297 286 298 Combine numbers.txt and numbers2.txt and create numbers3.txt. and view the file. 287 299 300 301 {{{ 288 302 $ cat numbers.txt numbers2.txt > numbers3.txt 289 303 $ cat numbers3.txt … … 304 318 fourteen 305 319 fifteen 320 }}} 321 306 322 307 323 Check the file format of the newly created file … … 312 328 Copy all the created files to the test directory. and verify 313 329 330 331 {{{ 314 332 $ cp numbers.txt numbers2.txt numbers3.txt test/ 315 333 $ cd test 316 334 $ ls 317 335 numbers2.txt numbers3.txt numbers.txt one 336 }}} 337 318 338 319 339 Make a copy of test directory as newtest and rename it to numbers 340 341 {{{ 320 342 $ cd 321 343 $ cp -r test/ newtest 322 344 $ mv newtest/ numbers 345 }}} 346 323 347 324 348 Delete the test directory 325 349 350 351 {{{ 326 352 $ rm -rf test 353 }}} 354 327 355 328 356 … … 340 368 If you look at files in a directory using "ls -al" you will see the permissions for each file and directories. Here is an example: 341 369 370 371 {{{ 342 372 drwxr-xr-x 6 test radius 4096 Oct 16 18:18 . 343 373 drwxr-xr-x 3 root root 4096 Sep 21 12:29 .. 374 }}} 375 344 376 345 377 So, 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). … … 370 402 Go to the numbers directory and get a detailed list 371 403 404 405 {{{ 372 406 cd numbers 373 407 ls -al … … 380 414 drwxr-xr-x 3 test test 4096 Oct 17 13:08 one 381 415 416 }}} 417 382 418 383 419 Change file permission as follows … … 449 485 Checking the network connectivity 450 486 487 488 {{{ 451 489 Ping 8.8.8.8 452 490 Ping google.com 491 }}} 492 453 493 454 494 The 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. … … 458 498 nslookup 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. 459 499 460 nslookup ac.lk500 '''nslookup ac.lk''' 461 501 462 502 … … 465 505 The 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). 466 506 467 dig ac.lk 507 '''dig ac.lk''' 468 508 469 509 … … 471 511 traceroute 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. 472 512 473 traceroute ac.lk513 '''traceroute ac.lk''' 474 514 475 515 On a Windows machine, this command is called tracert; on Linux and Mac, it's called traceroute.