Skip to content

Concepts

Christopher Vardakis edited this page Nov 24, 2022 · 5 revisions

Concepts

terminal

In Linux systems, the terminal (used as a placeholder for the terms "terminal" "console" and "shell". For the difference and proper use click here) is a way to communicate with your computer using commands. It has some build in commands and also packages bundled in your os for many uses. you can also install new packages or write your own programms. To run a command you type the name of the command and hit enter. then you see the result on the terminal. To run a command not installed in your system PATH you have to run it using the full path of the app (see directories below).

directories

Directories = Folders. there are also basic directories . -> the current directory .. -> the directory above ~-> the home directory / -> the root directory this is the start (root) of the filesystem. Everything else is a directory inside this directory. This means deleting this or overwriting its content deletes EVERYTHING! (known meme is to make someone run sudo rm -rf /. We hope in the end you can figure out what this does (dont try this !!))(more : rm switches sudo man)

for example let's say we are in a directory "folder2" inside a directory "folder1" inside our home directory. lets say we are also the user kali, the default user of kali linux. Then : ~ -> /home/kali .. -> ~/folder1 -> /home/kali/folder1 . -> ../folder2 -> /home/kali/folder1/folder2

So when we run something using ./command what we actually do is type the path of the file, and if it can be executed as a program it will run. See more about it in permissions below. To run commands from every directory we have to add them in our PATH

permissions

there are 3 permissions: r -> read (allows you to read the content of a file) w -> write (allows you to change content of a file) x -> execute (allows you to run the file as a program) we can change permissions of a file using chmods

terminal operators

Operators are used to redirect text (outputs from one command to another) | -> use output as input for another command >> -> append output to file > -> send output to file < -> get input from file to file

> command1
out1

> command2 
: out1
out2

> command1 | command 2
out2

> command1
out1

> command1 >> file
> cat file
out1

> command2 < file
out2

(more : cat) Operators are also used to run many commands in one line & -> run commands in parallel ; -> run commands sequentially && -> run second if first succeeds || -> run second if first fails

hidden files

All files that start with . are hidden files

switches

Are used as options for commands. Usually start with a - if they are one letter and -- if they are words For example ls -> shows content of file ls -a -> shows content of file including hidden files same as ls --all ls -l -> shows content of file in a list ls -la -> shows content of file in a list including hidden files You can find the options of a command using man (more : ls)

sudo

Used to run commands as root (same as Administrator on windows). for example mkdir /new_dir (creates a new directory inside / (aka root) directory) fails. but sudo mkdir /new_dir succeeds

Clone this wiki locally