Skip to content

Latest commit

 

History

History

0x00-shell_basics

img

shell basics

rtfm

Intro

In this session, we will introduce shell scripriting and have a look at the most basic scripting commands. Hang tight.

Resources

  1. What is the shell?
  2. Navigation
  3. Looking around
  4. A guided tour
  5. Manipulating files
  6. Working with commands
  7. Reading man pages
  8. Keyboard shortcuts
  9. LTS
  10. Shebang

Man or help

  • cd
  • ls
  • pwd
  • less
  • file
  • ln
  • cp
  • mv
  • rm
  • mkdir
  • type
  • which
  • help
  • man

Learning objectives

By the end of this project, you should be able to explain to anyone Without the help of google the following concepts

General Objectives

  • What does RTFM mean?
  • What is shebang?

What is the shell?

  • What is the shell
  • What is the difference between a terminal and a shell
  • What is the shell prompt
  • How to use the history (the basics)

Navigation

  • What do the commands or built-ins cd, pwd, ls do
  • How to navigate the filesystem What are the . and .. directories
  • What is the working directory, how to print it and how to change it
  • What is the root directory
  • What is the home directory, and how to go there
  • What is the difference between the root directory and the home directory of the user root
  • What are the characteristics of hidden files and how to list them
  • What does the command cd - do

Looking around

  • What do the commands ls, less, file do
  • How do you use options and arguments with commands
  • Understand the ls long format and how to display it
  • A Guided Tour
  • What does the ln command do
  • What do you find in the most common/important directories
  • What is a symbolic link
  • What is a hard link
  • What is the difference between a hard link and a symbolic link

Manipulating files

  • What do the commands cp, mv, rm, mkdir do
  • What are wildcards and how do they work
  • How to use wildcards

Working with commands

  • What do type, which, help, man commands do
  • What are the different kinds of commands
  • What is an alias
  • When do you use the command help instead of man

Reading man pages

  • How to read a man page
  • What are man page sections
  • What are the section numbers for User commands, System calls and Library functions

Keboard shortcuts for bash

  • Common shortcuts for Bash

Tasks

  1. Where am I? : A script that prints the absolute path of the current working directory.
  2. What's in there? : A script that displays the contents of your current directory.
  3. There is no place like home : A script that changes the working directory to the user's home directory.
  4. The long format : A script that displays the current directory contents in a long format.
  5. Hidden files : A script that displays the current directory contents including hidden files.
  6. I loce numbers : A script that displays the current directory contents, using long format, while displaying group IDs in numeral and show hidden files.
  7. Welcome holberton : A script that will create a directory named holberton in the /tmp/ directory.
  8. Betty in Holberton : A scipt that will move a file called betty from home to the new directory created above.
  9. Bye bye Betty : A script that will delete file betty from the new location.
  10. Bye bye Holberton : A script that will delete the directory holberton that is in the /tmp/ directory path.
  11. Back to the future Change working directory to the previous one.
  12. Lists List all files (even ones with names beginning with a period character, which are normally hidden) in the current directory and the parent of the working directory and the /boot directory (in this order), in long format.
  13. File type A script that prints the type of the named file iamafile. The iamafile will be in the /tmp/ directory when we will run your script.
  14. We are symbols, and inhabit symbols Create a symbolic link to /bin/ls, named __ls__. The symbolic link should be created in the current working directory.
  15. Copy HTML files Create a script that copies all html files from the current working directory to the parent working directory while only copying files that did not exist.
  16. Let's move A script that moves all files beginning with an uppercase letter to the directory /tmp/u.
  17. Clean Emacs A script that deletes all files in the current directory that end with the character ~.
  18. Tree A script that creates the directory welcome/, welcome/to/ and welcome/to/holberton.
  19. Life is a series of commas, not periods A script that lists all the files and directories of the current directory separated by commas ,.
  20. File type: Holberton Create a magic file holberton.mgc that can be used with the command file to detect Holberton data files always contain the string HOLBERTON at offset 0.