Skip to main content

Lab: Learn Bash Commands

  • pwd: Display the current directory
  • ls: List the files and directories
  • echo: Display a non-terminal message
  • echo "Hello World" > helloworld.txt: Direct to the output of the echo in a file
  • echo "Hello World" >> helloworld.txt: Concatenates an output to an existing file
  • cat helloworld.txt: Show the content of file
  • ls -l: Show information about the files and pastes of the current directory
  • ls -la: Show information about the files and folders of the current directory, including hidden files and folders
  • man: Linux help command, Displays a manual about the desired command
  • whoami: Displays the name of the user
  • cd "directory": Enter a directory
  • cd ..: Return to the previous directory
  • mkdir: Create a directory
  • rmdir: Delete empty directory
  • rm: Delete file
  • rm -r: Delete a directory recursively
  • cp abc.txt xyz.txt: Copy abc.txt file
  • mv: Move or rename a file
  • cp -r: Copy or directory recursively
  • zip -r: Zip a directory
  • unzip: Unzip here zipped
  • tar -cz: Compact and zip the file in tar.gz format
  • tar -xzf: Decompresses a tar.gz file and redirects to the output of the file

Common tasks you should be able to do:

  1. Create a folder/file
  2. Rename folder/file
  3. Update a file
  4. Update file/folder permissions
  5. Delete a folder/file
  6. List files in a folder
  7. Move a folder/file
  8. Copy a folder/file
  9. Print folder/file tree
  10. Print file content
  11. Print current path