YALC

Terminal Basics

October 27, 2024

what is a command?

A command is a program that you can run from the terminal, it is also a utility of the shell, a shell function, or an alias. A command can receive arguments and options.

what is a command line (shell)?

A shell is a command line interpreter, it is a program that reads commands from the keyboard and executes them.

what is a terminal?

A terminal is a program that allows you to interact with the shell.

Commands

ls

tree : list files in a tree format

cd [path]

pwd (print working directory)

managing files

touch

cp

mv

mkdir

cat head tail less

less

file

rm

xdg-open / open

nautilus

type

alias

help

This is a built-in command that prints help for other commands.

man

user manual for commands

info

whatis

wildcards

Allows us to match patterns in filenames.

redirection

A redirection is a way to redirect the output of a command to a file or another command. file descriptor (0-1-2).

pipes

A pipe is a way to connect the output of one command to the input of another command.

control operators

A control operator is a way to control the execution of a command. The execution is run in a subshell. (synchronous ”;”)

permissions

A permission is a way to control access to a file or directory.

Kind of permissions

ownergroupother
rwxr-xr-x
111101101
755

simbolik mode

u : user g : group o : other a : all chmod u=rwx,g=rwx,o=rwx file : set permissions to 777

change password

passwd : change password

managing permissions

environment variables

A environment variable is a way to store information that can be accessed by programs. ln simbolik link (direct access to file) -s (simbolik).

how to modify environment variables?

export PATH=$PATH:/home/user/bin : add /home/user/bin to PATH environment variable

Searching command

A search command is a way to search for a command.

managing directories

A directory is a way to manage directories.

whereis

A whereis is a way to find files.

ln

ln -s : create symbolic links

find

find . -name “.txt” : find files with .txt extension find . -name “.txt” -exec grep “foo” {} ; : find files with .txt extension and grep for “foo” find . -name “.txt” -exec grep “foo” {} ; -print : find files with .txt extension and grep for “foo”, print results find . -name “.txt” -exec grep “foo” {} ; -print -exec rm {} ; : find files with .txt extension and grep for “foo”, print results, remove files —>

grep

A grep is a way to search for a pattern in a file.

red utilities

A red utility is a way to manage processes.

compression

A compression is a way to compress files.

process management

A process is a way to manage processes.

background processes

A background process is a way to run a process in the background.

sleep 1000 & : sleep for 1000 seconds in the background jobs : print background processes fg : bring the most recent background process to the foreground fg 1 : bring the first background process to the foreground bg : run the most recent background process in the background bg 1 : run the first background process in the background cat > mi_nota.txt & : write to mi_nota.txt in the background ctrl + z : stop the current process kill %1 : kill the first background process kill % : kill all background processes

vim

customize the terminal

References