In this article i will introduce you the book “linux basics for hackers”. I will not dug deeper and just copy-paste this amazing book, I’ll use this as a way to memorize better the concepts and core arguments.

Important therms

  • Binaries: this term refers to file that can be executed, like windows .exe files. They generally reside in the usr/bin or user/sbin folders (examples: ps, cat, ls, ifconfig, google…).
  • Linux is case sensitive: desktop is different from Desktop
  • Home: Every user has a home directory
  • Root: administrator privileges
  • Shell: an environment and interpreter for running commands on linux. The most used is called bash

Linux Filesystem

the Linux filesystem is structured as if it were an upside down tree, the top is called root (/): here are some of the most important:

  • /root: home dir of root user
  • /etc: it generally contains Linux config files
  • /home: user home directory
  • /mnt: where other filesystem are connected or mounted
  • /media: where CD and USB are mounted into the filesystem
  • /bin: where binaries reside
  • /lib: where I’ll find libraries (shared programs that are similar to windows DDLs)

basic commands

  • pwd: (print working directory)
  • whoami
  • cd
  • ls
  • man (command info)
  • locate (file location)
  • whereis (find a binary)
  • which (shows search result query from PATH variable)
  • find (the most powerful for searching, You can do a deeper scan with other parameters like creation date)
  • grep (can be used as a filter to search for keywords)
  • ps (used to find and display info about running processes)

Modifying files and directories

  • cat (generally used for dispaying the contents of a file but it can olso create a file)
  • touch (edit or create a file)
  • mkdir (create a directory)
  • cp oldfile /root/folder/newfile (copy a file in a new destination)
  • mv filename filename2 (move command as the same concept as cp, it can also rename a file)
  • rm (remove a file)
  • rmdir (remove a directory)

redirect character (>)

file creation with cat example:

cat > helloworld.txt
#interacrive mode: "hello"

when you press enter, Linux will go in interactive mode, you can now write content to that file. To exit just press ctrl-d

append character (»)

cat >> helloworld.txt
#interactive mode: " world!"

You’ll be prompted to the interactive mode again

final result

cat helloworld.txt
hello world!

for overwriting you can use again the “>” character