Terminal

Terminal Terminal

Disclaimer: This post has been translated to English using a machine translation model. Please, let me know if you find any mistakes.

Post formatlink image 135

To avoid having to insert console images for each action I perform, I have created the following function that takes the terminal command we want to execute and returns the output that the terminal would give us.

Sometimes I will use this function, and other times I will use ! before each command, which in notebooks means you are going to run a terminal command.

	
import subprocess
import os
last_directory = ''
def terminal(command, max_lines_output=None):
global last_directory
debug = False
str = command.split()
# Check if there are " or ' characters
for i in range(len(str)):
if debug: print(f"i = {i}, str[i] = {str[i]}")
if len(str[i]) > 0:
if str[i][0] == '"' or str[i][0] == "'":
for j in range(i+1,len(str)):
if debug: print(f" j = {j}, str[j] = {str[j]}")
if str[j][-1] == '"' or str[j][-1] == "'":
for k in range(i+1,j+1):
if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")
str[i] = str[i] + " " + str[k]
if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")
str[j:] = [""]
str[i] = str[i].replace('"','')
# Remove empty strings
str = [x for x in str if x != ""]
if debug:
print(str)
return
if str[0] == "cd":
last_dir = os.getcwd()
if len(str) == 1:
os.chdir('/home/wallabot')
else:
if str[1] == "-":
os.chdir(last_directory)
else:
os.chdir(str[1])
last_directory = last_dir
else:
result = subprocess.run(str, stdout=subprocess.PIPE).stdout.decode('utf-8')
if max_lines_output is not None:
result_split = result.split(' ')
print(' '.join(result_split[:max_lines_output]))
print(" ...")
print(' '.join(result_split[-5:]))
else:
print(result)
Copy

ls (list directory)link image 137

The first command we are going to look at is ls (list directory), which is used to list all the files in the folder we are in.

	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
__pycache__
ssh.ipynb
test.html
test.ipynb

Commands usually can receive options (flags), which are introduced with the character -, for example let's look at ls -l which returns the list of files in the directory we are in, but with more information.

	
terminal('ls -l')
Copy
	
total 4512
-rw-rw-r-- 1 wallabot wallabot 285898 nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 78450 nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb
-rw-rw-r-- 1 wallabot wallabot 484213 nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb
-rw-rw-r-- 1 wallabot wallabot 320810 dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb
-rw-rw-r-- 1 wallabot wallabot 320594 dic 6 00:04 2022-09-12 Introduccion a la terminal.txt
-rw-rw-r-- 1 wallabot wallabot 119471 oct 3 16:13 command-line-cheat-sheet.pdf
-rw-rw-r-- 1 wallabot wallabot 2660 sep 18 03:32 CSS.ipynb
-rw-rw-r-- 1 wallabot wallabot 699225 nov 27 04:16 Docker.html
-rw-rw-r-- 1 wallabot wallabot 509125 sep 22 16:48 Docker.ipynb
-rw-rw-r-- 1 wallabot wallabot 156193 nov 27 04:21 Expresiones regulares.html
-rw-rw-r-- 1 wallabot wallabot 53094 oct 2 04:57 Expresiones regulares.ipynb
drwxrwxr-x 2 wallabot wallabot 4096 nov 28 14:39 html_files
-rw-rw-r-- 1 wallabot wallabot 14775 sep 18 03:29 html.ipynb
drwxrwxr-x 3 wallabot wallabot 4096 nov 12 01:51 introduccion_python
-rw-rw-r-- 1 wallabot wallabot 446172 oct 2 04:39 movies.csv
-rw-rw-r-- 1 wallabot wallabot 522197 oct 2 04:33 movies.dat
drwxrwxr-x 2 wallabot wallabot 4096 nov 28 14:39 notebooks_translated
drwxrwxr-x 2 wallabot wallabot 4096 ago 27 03:25 __pycache__
-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb
-rw-rw-r-- 1 wallabot wallabot 292936 nov 9 01:46 test.html
-rw-rw-r-- 1 wallabot wallabot 260227 nov 9 01:13 test.ipynb

As we can see, we have how many bytes each file occupies, but when we have files that take up a lot of space, this is not very easy to read, so we can add the h (human) option which gives us more readable information.

	
terminal('ls -lh')
Copy
	
total 4,5M
-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb
-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt
-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf
-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb
-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html
-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb
-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html
-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files
-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynb
drwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python
-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv
-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translated
drwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__
-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb
-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html
-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb

If we want to see hidden files, we can use the a option, which will show us all the files in a directory.

	
terminal('ls -lha')
Copy
	
total 4,5M
drwxrwxr-x 6 wallabot wallabot 4,0K dic 6 00:04 .
drwxrwxr-x 5 wallabot wallabot 4,0K oct 2 03:10 ..
-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb
-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt
-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf
-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb
-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html
-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb
-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html
-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files
-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynb
drwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python
-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv
-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translated
drwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__
-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb
-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html
-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb

If what we want is for it to sort by size, we can use the S option.

	
terminal('ls -lhS')
Copy
	
total 4,5M
-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html
-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat
-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb
-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb
-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt
-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html
-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb
-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html
-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf
-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb
-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb
-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynb
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files
drwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translated
drwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__
-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb
-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb

If we want the files to be displayed in reverse alphabetical order, we must use the -r option.

	
terminal('ls -lhr')
Copy
	
total 4,5M
-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb
-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html
-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb
drwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translated
-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat
-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv
drwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python
-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynb
drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files
-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb
-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html
-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb
-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html
-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb
-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt
-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb
-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb
-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb
-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb

cd (change directory)link image 138

The second command will be cd (change directory) which allows us to change directories.

	
terminal('cd /home/wallabot/Documentos/')
Copy

If we now use ls again to see the files we have, we notice that they change.

	
terminal('ls')
Copy
	
aprendiendo-git.pdf
balena-etcher-electron-1.7.9-linux-x64
camerasIP
Documentacion
gstreamer
gstreamer_old
jetsonNano
kaggle
Libros
nerf
prueba.txt
pytorch
wallabot
web

If you give cd the character - instead of the directory you want to move to, it will return to the previous directory where you were.

	
terminal('cd -')
Copy
	
terminal('ls')
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
__pycache__
ssh.ipynb
test.html
test.ipynb

If we wanted to move to the home directory by only typing cd in the terminal, it will take us there.

	
terminal('cd')
Copy

pwd (print working directory)link image 139

To get the directory we are in, we can use pwd (print working directory)

	
terminal('pwd')
Copy
	
/home/wallabot

We can move using the cd command through relative paths and absolute paths. For example, let's move to a directory using an absolute path.

	
terminal('cd /home/wallabot/Documentos/')
Copy
	
terminal('pwd')
Copy
	
/home/wallabot/Documentos
	
terminal('ls')
Copy
	
aprendiendo-git.pdf
balena-etcher-electron-1.7.9-linux-x64
camerasIP
Documentacion
gstreamer
gstreamer_old
jetsonNano
kaggle
Libros
nerf
prueba.txt
pytorch
wallabot
web

We can move using relative paths if we only put the address starting from the point where we are.

	
terminal('cd web')
Copy
	
terminal('pwd')
Copy
	
/home/wallabot/Documentos/web

We can also go up one directory using relative paths with ..

	
terminal('cd ..')
Copy
	
terminal('pwd')
Copy
	
/home/wallabot/Documentos

If we use . instead of .., we are referring to the directory we are currently in, that is, if we type cd ., we won't move, as we are telling the terminal to go to the directory we are in.

	
terminal('cd .')
Copy
	
terminal('pwd')
Copy
	
/home/wallabot/Documentos

Let's move to a path where we have files to demonstrate the following command

	
terminal('cd web/portafolio/posts/')
Copy
	
terminal('ls')
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
__pycache__
ssh.ipynb
test.html
test.ipynb

File information with filelink image 140

If I don't know what type of file a particular one is, by using the file command I can get a description.

	
terminal('file 2021-02-11-Introduccion-a-Python.ipynb')
Copy
	
2021-02-11-Introduccion-a-Python.ipynb: UTF-8 Unicode text, with very long lines

Manipulating files and directorieslink image 141

Let's move to the home first.

	
terminal('cd /home/wallabot/Documentos/')
Copy

Directory tree with treelink image 142

We can see the entire structure of the folder we are in using the tree command.

	
terminal('tree', max_lines_output=20)
Copy
	
.
├── aprendiendo-git.pdf
├── balena-etcher-electron-1.7.9-linux-x64
│   └── balenaEtcher-1.7.9-x64.AppImage
├── camerasIP
│   ├── camerasIP.py
│   ├── camerasIP.sh
│   ├── config.py
│   ├── __pycache__
│   │   ├── config.cpython-38.pyc
│   │   └── config.cpython-39.pyc
│   └── README.md
├── Documentacion
│   ├── Curriculum Vitae (5).pdf
│   ├── Firma Pris.PNG
│   └── Firma.png
├── gstreamer
│   ├── basic_tutorial_c
│   │   ├── basic_tutorial_1_hello_world
│   │   │   ├── basic-tutorial-1
...
├── upload_page.py
└── utils.py
873 directories, 119679 files

But at the output we have too many lines, and this is because tree is a command that shows all files from the path we are in, so it's a bit difficult to read. However, with the L option we can tell it how many levels deep we want it to go.

	
terminal('tree -L 2')
Copy
	
.
├── aprendiendo-git.pdf
├── balena-etcher-electron-1.7.9-linux-x64
│   └── balenaEtcher-1.7.9-x64.AppImage
├── camerasIP
│   ├── camerasIP.py
│   ├── camerasIP.sh
│   ├── config.py
│   ├── __pycache__
│   └── README.md
├── Documentacion
│   ├── Curriculum Vitae (5).pdf
│   ├── Firma Pris.PNG
│   └── Firma.png
├── gstreamer
│   ├── basic_tutorial_c
│   └── README.md
├── gstreamer_old
│   ├── basic_tutorial_c
│   └── basic_tutorial_python
├── jetsonNano
│   ├── apuntes-Jetson-Nano
│   ├── deepstream_apps
│   ├── deepstream_nano
│   └── Digital zoom
├── kaggle
│   └── hubmap
├── Libros
│   └── aprendiendo-git.pdf
├── nerf
│   └── instant-ngp
├── prueba.txt
├── pytorch
│   └── Curso_Pytorch
├── wallabot
│   ├── Microfono - Blue Yeti X
│   ├── placa base - Asus prime x570-p
│   └── Silla - Corsair T3 Rush
└── web
├── jupyter-to-html
├── jupyter-translator
├── portafolio
└── wordpress_api_rest
30 directories, 12 files

We can see that it shows there are 30 directories and 12 files, while before it indicated 873 directories and 119679 files.

Creating Folders with mkdir (make directory)link image 143

If we want to create a new directory, we can use the mkdir (make directory) command and a name.

	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/")
Copy
	
terminal('mkdir prueba')
Copy
	
	
terminal('ls')
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
__pycache__
ssh.ipynb
test.html
test.ipynb

If what we want is to create a directory with spaces in the name, we have to put the name between quotes.

	
terminal('mkdir "directorio prueba"')
Copy
	
	
terminal('ls')
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
directorio prueba
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
__pycache__
ssh.ipynb
test.html
test.ipynb

Let's go into the prueba folder we've created to continue working there with the terminal.

	
terminal("cd prueba")
Copy

Creating files with touchlink image 144

If we want to create a file, the command we need to use is touch

	
terminal("touch prueba.txt")
Copy
	
	
terminal("ls")
Copy
	
prueba.txt

Copy files with cp (copy)link image 145

If we want to copy a file, we do it using the cp (copy) command.

	
terminal("cp prueba.txt prueba_copy.txt")
Copy
	
	
terminal("ls")
Copy
	
prueba_copy.txt
prueba.txt

Moving files with mv (move)link image 146

If what we want is to move it, what we use is the mv (move) command.

	
terminal("mv prueba.txt ../prueba.txt")
Copy
	
	
terminal("ls")
Copy
	
prueba_copy.txt
	
terminal("ls ../")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
directorio prueba
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
prueba.txt
__pycache__
ssh.ipynb
test.html
test.ipynb

Rename files with mv (move)link image 147

The mv command is also useful for renaming files, since if what we do is move it within the same directory but give it a different name, in the end that is renaming the file.

	
terminal("mv prueba_copy.txt prueba_move.txt")
Copy
	
	
terminal("ls")
Copy
	
prueba_move.txt

Deleting files with rm (remove)link image 148

To delete files or directories we use the rm (remove) command

	
terminal("rm prueba_move.txt")
Copy
	
	
terminal("ls")
Copy
	

Remove directories with rm -r (remove recursive)link image 149

If we want to remove a directory with files inside, we must use the -r flag.

	
terminal("cd ..")
Copy
	
terminal('rm -r "directorio prueba"')
Copy
	
	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
prueba.txt
__pycache__
ssh.ipynb
test.html
test.ipynb

As you can see, it never asks if we are sure. To make it ask, you need to add the -i (interactive) flag.

	
terminal("rm -i prueba.txt")
Copy
	
rm: ¿borrar el fichero regular vacío 'prueba.txt'? (s/n) s

Synchronizing files using rsynclink image 150

So far we have seen how to copy, move, and delete files, but let's say we have a folder and we copy those files to another one. Now suppose we modify a file in the first folder and we want the second folder to have the changes. We have two options: either copy all the files again, or synchronize using rsync

First, let's create a new folder in which we will create several files

	
!mkdir sourcefolder
!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3
Copy

Now we create a second folder that is the one we are going to synchronize with the first one.

	
!mkdir syncfolder
Copy
	
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
Copy
	
ls sourcefolder:
file1 file2 file3
ls syncfolder:

We synchronize the two folders with rsync, the first time it will only copy the files from the first folder to the second. To do this, we also need to add the -r (recursive) flag.

	
!rsync -r sourcefolder/ syncfolder/
Copy
	
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
Copy
	
ls sourcefolder:
file1 file2 file3
ls syncfolder:
file1 file2 file3

If I now create a new file in sourcefolder and sync again, only that file will be copied to syncfolder. To see that only one file is copied, we can use the -v (verbose) flag.

	
!touch sourcefolder/file4
Copy
	
!rsync -r -v sourcefolder/ syncfolder/
Copy
	
sending incremental file list
file1
file2
file3
file4
sent 269 bytes received 92 bytes 722.00 bytes/sec
total size is 0 speedup is 0.00

But it seems that it has copied all the files, so to prevent this and copy only the ones that have been modified, you need to use the -u flag.

	
!touch sourcefolder/file5
Copy
	
!rsync -r -v -u sourcefolder/ syncfolder/
Copy
	
sending incremental file list
file5
sent 165 bytes received 35 bytes 400.00 bytes/sec
total size is 0 speedup is 0.00
	
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
Copy
	
ls sourcefolder:
file1 file2 file3 file4 file5
ls syncfolder:
file1 file2 file3 file4 file5

And what happens if I create a new file in syncfolder?

	
!touch syncfolder/file6
Copy
	
!rsync -r -v -u sourcefolder/ syncfolder/
Copy
	
sending incremental file list
sent 122 bytes received 12 bytes 268.00 bytes/sec
total size is 0 speedup is 0.00
	
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
Copy
	
ls sourcefolder:
file1 file2 file3 file4 file5
ls syncfolder:
file1 file2 file3 file4 file5 file6

It doesn't synchronize, so it's important to keep this in mind.

Some important flags to keep in mind are:

  • -a: This flag is a shortcut for several options, including -r (recursive), -l (copy symbolic links), -p (preserve permissions), -t (preserve modification time) and -g (preserve group). This option is useful for making an exact copy of a directory, including all its subfolders and files.
  • -v: This flag enables verbose output, which shows the files being copied and the progress of the operation.
  • -r: This flag is used for recursive copying, which means it copies all subfolders and files within a directory.
  • -u: This flag is used to copy only new or modified files. If a file already exists in the destination and is more recent than the source file, it will not be copied.* -n: This flag is used to perform a copy test, meaning that no changes are made to the destination.
  • --exclude: This flag is used to exclude specific files or folders from the copy operation. You can specify multiple files or folders to exclude by using this option multiple times.
  • -z: This flag is used to compress the data during transfer, which reduces the bandwidth used and speeds up the transfer rate.
  • -h: this flag is used to display the information in a more readable format, especially when working with large amounts of data or large file sizes.

We delete the two created folders

	
!rm -r sourcefolder syncfolder
Copy

Exploring the contents of fileslink image 151

To avoid having to open a file from a graphical interface, we have several options. First, I will copy a text file into this folder.

	
terminal("cd prueba")
Copy
	
terminal("cp ../2021-02-11-Introduccion-a-Python.ipynb .")
Copy
	
	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb

File headers with headlink image 152

The first command to be able to view inside a text file is head, which allows you to see the first 10 lines of a file, but if you add the -n flag, you can specify the number of lines.

	
terminal("head 2021-02-11-Introduccion-a-Python.ipynb")
Copy
	
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "dsaKCKL0IxZl"
},
"source": [
"# Introducción a Python"
]
	
terminal("head -n 5 2021-02-11-Introduccion-a-Python.ipynb")
Copy
	
{
"cells": [
{
"cell_type": "markdown",
"metadata": {

Tail of a File with taillink image 153

To view the last lines, we use tail

	
terminal("tail 2021-02-11-Introduccion-a-Python.ipynb")
Copy
	
},
"vscode": {
"interpreter": {
"hash": "d5745ab6aba164e1152437c779991855725055592b9f2bdb41a4825db7168d26"
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
	
terminal("tail -n 5 2021-02-11-Introduccion-a-Python.ipynb")
Copy
	
}
},
"nbformat": 4,
"nbformat_minor": 0
}

If we want to continuously view the latest lines of a file, for example, if we want to constantly monitor a LOG file to see events, we add the -f flag. This will make the terminal continuously check the file, and every time a new line appears in it, it will display it.

For example, if I monitor the login log on my machine

	
!tail -f /var/log/auth.log
Copy
	
Dec 1 16:27:22 wallabot gcr-prompter[1457]: Gcr: calling the PromptDone method on /org/gnome/keyring/Prompt/p2@:1.26, and ignoring reply
Dec 1 16:27:22 wallabot gnome-keyring-daemon[1178]: asked to register item /org/freedesktop/secrets/collection/login/10, but it's already registered
Dec 1 16:27:26 wallabot systemd-logind[835]: Watching system buttons on /dev/input/event28 (Logitech Wireless Mouse MX Master 3)
Dec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: 10 second inactivity timeout, quitting
Dec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: unregistering prompter
Dec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: disposing prompter
Dec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: finalizing prompter
Dec 1 16:27:34 wallabot polkitd(authority=local): Operator of unix-session:1 successfully authenticated as unix-user:wallabot to gain TEMPORARY authorization for action org.debian.apt.install-or-remove-packages for system-bus-name::1.96 [/usr/bin/python3 /usr/bin/update-manager --no-update --no-focus-on-map] (owned by unix-user:wallabot)
Dec 1 16:27:42 wallabot systemd-logind[835]: Watching system buttons on /dev/input/event30 (T9-R (AVRCP))
Dec 1 16:27:49 wallabot gnome-keyring-daemon[1178]: asked to register item /org/freedesktop/secrets/collection/login/2, but it's already registered

We see in the last two lines my login when I turned on my computer today.

Now I connect to my own machine via SSH

	
!ssh localhost
Copy
	
wallabot@localhost's password:
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-53-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
1 device has a firmware upgrade available.
Run `fwupdmgr get-upgrades` for more information.
Se pueden aplicar 0 actualizaciones de forma inmediata.
Your Hardware Enablement Stack (HWE) is supported until April 2025.
*** System restart required ***
Last login: Sun May 8 02:18:09 2022 from 192.168.1.147

In the console where I was monitoring the login, two new lines have appeared.

	
Dec 1 16:32:23 wallabot sshd[25647]: Accepted password for wallabot from 127.0.0.1 port 54668 ssh2
Dec 1 16:32:23 wallabot sshd[25647]: pam_unix(sshd:session): session opened for user wallabot by (uid=0)
Dec 1 16:32:23 wallabot systemd-logind[835]: New session 4 of user wallabot.

And when I close the SSH session, two new lines appear.

	
Dec 1 16:33:52 wallabot sshd[25647]: pam_unix(sshd:session): session closed for user wallabot
Dec 1 16:33:52 wallabot systemd-logind[835]: Session 4 logged out. Waiting for processes to exit.
Dec 1 16:33:52 wallabot systemd-logind[835]: Removed session 4.

The most powerful file viewer: lesslink image 154

One of the most powerful commands for viewing inside files is less

	
terminal("less 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
Copy
	
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "dsaKCKL0IxZl"
},
"source": [
"# Introducción a Python"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Ho_8zgIiI0We"
},
"source": [
"## 1. Resumen"
]
},
...
},
"nbformat": 4,
"nbformat_minor": 0
}

When inside a notebook, you can't really see what happens when using less, but when we use it, we enter the document and can navigate through it using the keyboard or the mouse.

If we want to search for something within the document, we type the character / followed by what we want to search for. To navigate between the different instances found, press the key n, and if you want to go back in the searches, press shift+n.

To exit, just press q

The cat viewerlink image 155

It does not allow you to navigate through the file or perform searches.

	
terminal("cat 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
Copy
	
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "dsaKCKL0IxZl"
},
"source": [
"# Introducción a Python"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Ho_8zgIiI0We"
},
"source": [
"## 1. Resumen"
]
},
...
},
"nbformat": 4,
"nbformat_minor": 0
}

Default system editor xdg-openlink image 156

If we want to open it with the default file editor, we have to use xdg-open

	
terminal("xdg-open 2021-02-11-Introducción-a-Python.ipynb")
Copy
	

File browser nautiluslink image 157

If what we want is to open the folder we are in, we use nautilus

	
terminal("nautilus")
Copy
	

And if we want it to open at a specific path, the path is included.

	
terminal("nautilus ~/")
Copy
	

Word count of a file with wc (word count)link image 158

Lastly, a very useful command is wc (word count), which shows you how many lines, words, and bytes a file contains.

	
terminal("wc 2021-02-11-Introduccion-a-Python.ipynb")
Copy
	
11678 25703 285898 2021-02-11-Introduccion-a-Python.ipynb

As we can see, the file has 11678 lines, 25703 words, and occupies 285898 bytes.

What is a command?link image 159

A command can be four things

  • An executable program, these are usually saved in the path /usr/bin
  • A shell command* A shell function
  • An alias

To see which class a command belongs to, we use type

	
!type cd
Copy
	
cd is a shell builtin
	
!type mkdir
Copy
	
mkdir is /usr/bin/mkdir
	
!type ls
Copy
	
ls is /usr/bin/ls

What is an alias?link image 160

An alias is a command that we define, it is defined using the alias command. For example, let's create the alias l which will run ls -h.

	
!alias l='ls -l'
Copy

When we run l it shows the result of ls -h

	
!l
Copy
	
2021-02-11-Introducción-a-Python.ipynb

But this has the problem that when we close the terminal, the alias disappears. Later on, we will learn how to create permanent alias.

Command Helplink image 161

Help with helplink image 162

With many shell commands, we can get their help using the help command.

	
!help cd
Copy
	
cd: cd [-L|[-P [-e]]] [dir]
Modifica el directorio de trabajo del shell.
Modifica el directorio actual a DIR. DIR por defecto es el valor de la
variable de shell HOME.
La variable CDPATH define la ruta de búsqueda para el directorio que
contiene DIR. Los nombres alternativos de directorio en CDPATH se
separan con dos puntos (:). Un nombre de directorio nulo es igual que
el directorio actual. Si DIR comienza con una barra inclinada (/),
entonces no se usa CDPATH.
Si no se encuentra el directorio, y la opción del shell "cdable_vars"
está activa, entonces se trata la palabra como un nombre de variable.
Si esa variable tiene un valor, se utiliza su valor para DIR.
Opciones:
-L fuerza a seguir los enlaces simbólicos: resuelve los enlaces
simbólicos en DIR después de procesar las instancias de ".."
-P usa la estructura física de directorios sin seguir los enlaces
simbólicos: resuelve los enlaces simbólicos en DIR antes de procesar
las instancias de ".."
-e si se da la opción -P y el directorio actual de trabajo no se
puede determinar con éxito, termina con un estado diferente de cero.
La acción por defecto es seguir los enlaces simbólicos, como si se
especificara "-L".
".." se procesa quitando la componente del nombre de la ruta inmediatamente
anterior hasta una barra inclinada o el comienzo de DIR.
Estado de Salida:
Devuelve 0 si se cambia el directorio, y si $PWD está definido como
correcto cuando se emplee -P; de otra forma es diferente a cero.

Manual with manlink image 163

Another command is man, which refers to the user manual.

	
terminal("man ls", max_lines_output=20)
Copy
	
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐
fied.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
...
Full documentation at: <https://www.gnu.org/software/coreutils/ls>
or available locally via: info '(coreutils) ls invocation'
GNU coreutils 8.30 September 2019 LS(1)

To exit, press q, since man uses less as the manual viewer

Information with infolink image 164

Another command is info

	
terminal("info ls", max_lines_output=20)
Copy
	
File: coreutils.info, Node: ls invocation, Next: dir invocation, Up: Directory listing
10.1 ‘ls’: List directory contents
==================================
The ‘ls’ program lists information about files (of any type, including
directories). Options and file arguments can be intermixed arbitrarily,
as usual.
For non-option command-line arguments that are directories, by
default ‘ls’ lists the contents of directories, not recursively, and
omitting files with names beginning with ‘.’. For other non-option
arguments, by default ‘ls’ lists just the file name. If no non-option
argument is specified, ‘ls’ operates on the current directory, acting as
if it had been invoked with a single argument of ‘.’.
By default, the output is sorted alphabetically, according to the
locale settings in effect.(1) If standard output is a terminal, the
output is in columns (sorted vertically) and control characters are
output as question marks; otherwise, the output is listed one per line
...
‘--show-control-chars’
Print nongraphic characters as-is in file names. This is the
default unless the output is a terminal and the program is ‘ls’.

To exit, press q, since info uses less as the information viewer

Information of a command with whatislink image 165

Another command is whatis

	
terminal("whatis ls")
Copy
	
ls (1) - list directory contents

Wildcardslink image 166

Wildcards are special characters that we can use to perform special searches. For example, if I want to search for all files that end in .txt. Let's create a few files to see them.

	
terminal("touch file.txt dot.txt dot2.txt index.html datos1 datos123 Abc")
Copy
	
	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
Abc
datos1
datos123
dot2.txt
dot.txt
file.txt
index.html

All the characters *link image 167

Let's now look for all the .txt files

	
!ls *.txt
Copy
	
dot2.txt dot.txt file.txt

Let's now look for all those that start with the word data

	
!ls datos*
Copy
	
datos1 datos123

Numbers ?link image 168

But what if what we actually want is to show all files that start with the word datos followed only by a number, we have to put a question mark ?

	
!ls datos?
Copy
	
datos1

If we want it to have three numbers, then we need to put three question marks ???

	
!ls datos???
Copy
	
datos123

Uppercase [[:upper:]]link image 169

If we want it to search for files that start with uppercase letters

	
!ls [[:upper:]]*
Copy
	
Abc

Lowercase [[:lower:]]link image 170

For files that start with lowercase letters.

	
!ls [[:lower:]]*
Copy
	
datos1 datos123 dot2.txt dot.txt file.txt index.html

Classeslink image 171

By using brackets we can create classes, so if we want to search for files that start with the letters d or f followed by any character

	
!ls [df]*
Copy
	
datos1 datos123 dot2.txt dot.txt file.txt

Redirects: How the Shell Workslink image 172

A command works as follows

pipeline command

It has a standard input, which by default is the text we enter via the keyboard, a standard output, which by default is the text that appears on the console, and a standard error which is also, by default, text that appears on the console but with a different format.

Redirecting standard outputlink image 173

But with the character >, we can modify the standard output of a command. For example, if we want to list the files in the folder we are in using ls, but we don't want the result to be printed on the screen, instead we want it to be saved in a file, we would do the following: ls > lista.txt. This writes the list to lista.txt. Additionally, if lista.txt does not exist, it creates it.

	
!ls > lista.txt
Copy

We see that you have created the file and we check what is inside

	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
Abc
datos1
datos123
dot2.txt
dot.txt
file.txt
index.html
lista.txt
	
terminal("cat lista.txt")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
Abc
datos1
datos123
dot2.txt
dot.txt
file.txt
index.html
lista.txt

We see that within lista.txt appears lista.txt, this is because it first creates the file and then executes the command

We do the same, but with the parent folder

	
!ls ../ > lista.txt
Copy

If we look inside lista.txt again

	
terminal("cat lista.txt")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
__pycache__
ssh.ipynb
test.html
test.ipynb

We see that the content is being overwritten

If what we want is for the content to be concatenated, we should use >>

	
!ls > lista.txt
Copy
	
!ls ../ >> lista.txt
Copy
	
terminal("cat lista.txt")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb
Abc
datos1
datos123
dot2.txt
dot.txt
file.txt
index.html
lista.txt
2021-02-11-Introduccion-a-Python.ipynb
2021-04-23-Calculo-matricial-con-Numpy.ipynb
2021-06-15-Manejo-de-datos-con-Pandas.ipynb
2022-09-12 Introduccion a la terminal.ipynb
2022-09-12 Introduccion a la terminal.txt
command-line-cheat-sheet.pdf
CSS.ipynb
Docker.html
Docker.ipynb
Expresiones regulares.html
Expresiones regulares.ipynb
html_files
html.ipynb
introduccion_python
movies.csv
movies.dat
notebooks_translated
prueba
__pycache__
ssh.ipynb
test.html
test.ipynb

Now the information has been concatenated.

This is very useful for creating log files

Redirecting standard errorlink image 174

If we perform an incorrect operation, we get an error. Let's see what happens when redirecting a command that produces an error.

	
!ls fjhdsalkfs > lista.txt
Copy
	
ls: no se puede acceder a 'fjhdsalkfs': No existe el archivo o el directorio

As we can see, it has given an error, but if we now look inside lista.txt

	
terminal("cat lista.txt")
Copy
	

We see that the file is empty, this is because we have not redirected the standard error to lista.txt, but rather the standard output. As shown in the image, there are two standards of output in a command: the first is the standard output and the second is the standard error, so to redirect the standard error, it must be specified using 2>. Let's do it this way now.

	
!ls kjhsfskjd 2> lista.txt
Copy
	
terminal("cat lista.txt")
Copy
	
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio

As we can see, the redirection has now been successful.

Redirection of standard output and standard errorlink image 175

If we want to redirect both, we use the following

	
!ls kjhsfskjd > lista.txt 2>&1
Copy

Let's take a look inside lista.txt

	
terminal("cat lista.txt")
Copy
	
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio

If we now run a command without errors

	
!ls . >> lista.txt 2>&1
Copy

Let's check inside lista.txt (**note**, now we have concatenated)

	
terminal("cat lista.txt")
Copy
	
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio
2021-02-11-Introduccion-a-Python.ipynb
Abc
datos1
datos123
dot2.txt
dot.txt
file.txt
index.html
lista.txt

As can be seen, both the standard error and the standard output have been redirected to the same file.

Pipelineslink image 176

We can create pipelines by making the standard output of one command become the standard input of another. For example, let's make the output of ls -lha be the input of grep, which we will see later, but it is a command for searching.

	
!ls -lha | grep -i "txt"
Copy
	
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt

As we can see, what we have done is to pipe the output of ls to grep, with which we have searched for any file with txt in the name.

Control operators - chaining commandslink image 177

Commands in sequencelink image 178

One way to chain commands sequentially is to separate them using ;. This creates different threads for each task

	
!ls; echo 'Hola'; cal
Copy
	
2021-02-11-Introduccion-a-Python.ipynb datos123 file.txt
Abc dot2.txt index.html
datos1 dot.txt lista.txt
Hola
Diciembre 2022
do lu ma mi ju vi sá
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

As we can see, first the command ls was executed, then Hello was printed thanks to the command echo "Hola", and finally a calendar was printed thanks to the command cal.

Let's now do another example to see that they execute in a sequential manner.

	
!echo "Before touch;"; ls -lha; touch secuential.txt; echo "After touch:"; ls -lha
Copy
	
Before touch;
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:04 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
After touch:
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:07 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:07 secuential.txt

As can be seen, in the first ls sequential.txt does not appear, while in the second it does. This means that the commands were executed in order, one after the other.

Commands in parallellink image 179

If we want the commands to run in parallel, we need to use the & operator. This will create a new process for each command.

Let's look at the previous example

	
!rm secuential.txt
Copy
	
!echo "Before touch;" & ls -lha & touch secuential.txt & echo "After touch:" & ls -lha
Copy
	
Before touch;
After touch:
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

Now it can be seen that they were not executed sequentially, as the echos were executed first, which will be the ones that take the least time, and then the rest.

Conditional Commandslink image 180

Andlink image 181

Using the && operator, a command will run only if the previous one has been executed successfully.

	
!rm secuential.txt
Copy
	
!echo "Before touch;" && ls -lha && touch secuential.txt && echo "After touch:" && ls -lha
Copy
	
Before touch;
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
After touch:
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

Here we can see how they have been executed one after the other, that is, a command does not start until the previous one finishes.

But then, what is the difference between ; and &&?

In the first one, the sequential ;, the first command is executed and then the second one, but for the second command to execute it doesn't matter whether the previous one was successful.

	
!rm prueba ; ls -lha
Copy
	
rm: no se puede borrar 'prueba': No existe el archivo o el directorio
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

As can be seen, first rm prueba is executed, it gives an error, and yet ls -lha prueba is still executed.

In the conditional form &&, if a command does not execute successfully, the following one is not executed.

	
!rm prueba && ls -lha
Copy
	
rm: no se puede borrar 'prueba': No existe el archivo o el directorio

As can be seen, ls -lha prueba is not executed because rm prueba has given an error.

Orlink image 182

Unlike &&, the 'or' will execute all processes regardless of their outcome. The || operator should be used.

	
!rm prueba || ls -lha
Copy
	
rm: no se puede borrar 'prueba': No existe el archivo o el directorio
total 292K
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .
drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

The difference between this and ; is that || (or) does not create a new thread for each command

How permissions are handledlink image 183

When listing the files in a directory with the -l (long) flag, some symbols appear next to each file.

	
!mkdir subdirectorio
Copy
	
!ls -l
Copy
	
total 288
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:10 subdirectorio

This gives us information about each file

Let's first see what types of files there are

  • -: Normal file
  • d: Directory* l: Symbolic link
  • b: Special block file. These are files that handle data block information, such as a USB.

We will then look at the types of modes:

Owner Group World
rwx r-x r-x
1 1 11 0 1 1 0 1
7 5 5
  • r: read
  • w: write
  • x: execute

Symbolic mode:

  • u: For the user only
  • g: Only for the group* o: Only for others (world)
  • a: For everyone

Modifying permissions in the terminallink image 184

We create a new file

	
terminal("cd subdirectorio")
Copy
	
!echo "hola mundo" > mitexto.txt
Copy
	
!cat mitexto.txt
Copy
	
hola mundo

Let's check the permissions it has.

	
!ls -l
Copy
	
total 4
-rw-rw-r-- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt

As we can see, it has read and write permissions for my user and the group, and only read permissions for others (world).

Changing permissions with chmod (change mode)link image 185

To change the permissions of a file we use the chmod (change mode) command, where we have to put the user permissions in octal, then the group's, and finally those of others.

	
!chmod 755 mitexto.txt
Copy
	
!ls -l
Copy
	
total 4
-rwxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt

We see that now my user has read, write, and execute permissions, while the group and the rest of the world have read and execute permissions.

We are going to remove the read permissions for only my user. To change only the permissions of a user, we use the symbolic identifier, a + if we want to add permissions or a - if we want to remove them, or an = if we want to reset them, followed by the type of permission.

	
!chmod u-r mitexto.txt
Copy
	
!ls -l
Copy
	
total 4
--wxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
	
!cat mitexto.txt
Copy
	
cat: mitexto.txt: Permiso denegado

As we can see, by removing read permissions for my user, we cannot read the file.

We give it the read permission again

	
!chmod u+r mitexto.txt
Copy
	
!ls -l
Copy
	
total 4
-rwxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
	
!cat mitexto.txt
Copy
	
hola mundo

If we want to add or remove permissions for more than one user, we do this by separating each permission with a ,

	
!chmod u-x,go=w mitexto.txt
Copy
	
!ls -l
Copy
	
total 4
-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt

As can be seen, the execution permission has been removed from the user and write-only permission has been set for the group and the rest of the world.

User Identification with whoamilink image 186

To know who we are, we can use the command whoami (who am I)

	
!whoami
Copy
	
wallabot

User information with idlink image 187

Another way, which also provides more information, is the id command

	
!id
Copy
	
uid=1000(wallabot) gid=1000(wallabot) grupos=1000(wallabot),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),998(docker)

This command tells us that our user ID is 1000, the group ID is 1000, and that we belong to the groups wallabot, adm, cdrom, sudo, dip, plugdev, lpadmin, lxd, sambashare, and docker.

User Switching with the su Command (switch user)link image 188

If we want to switch users, we use the su (switch user) command. For certain users, we need to use sudo (superuser do).

	
!sudo su root
Copy
	
root@wallabot:/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio#

As we can see, the prompt has changed and now indicates that we are the root user.

Let's go to the home folder

	
!cd
Copy
	
root@wallabot:~#

But in Linux there is a home folder for each user, we can see this if we run the command pwd

	
!pwd
Copy
	
/root

I will create a file in the folder where I previously created the file *mitexto.txt*

	
!touch /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt
Copy
	

I switch back to my user

	
!su wallabot
Copy
	
wallabot@wallabot:

And I go to the directory where the files I have created are located.

	
!cd /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio
Copy

We see the files that are there and their permissions

	
!ls -l
Copy
	
total 4
-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
-rw-r--r-- 1 root root 0 dic 6 01:22 rootfile.txt

As we can see, the user and group of the file *rootfile.txt* is the user root

Yes, now that I am the user *wallabot*, I try to delete the file rootfile.txt

	
!rm rootfile.txt
Copy
	
rm: ¿borrar el fichero regular vacío 'rootfile.txt' protegido contra escritura? (s/n)

As we can see, it asks us if we want to delete it, since it belongs to another user.

Change a user's passwordlink image 189

If I want to change the password of the user that is currently active, I use the command passwd (password)

First I check which user I am

	
!whoami
Copy
	
wallabot

And now let's try to change the password

	
!passwd
Copy
	
$ passwd
Cambiando la contraseña de wallabot.
Contraseña actual de :
Nueva contraseña:
Vuelva a escribir la nueva contraseña

As we can see, it asks for the current password in order to change it.

We can create symbolic links to a specific path using the ln (link) command followed by the -s (symbolic) flag, the directory, and the name of the link.

	
!ln -s /home/wallabot/Documentos/web web
Copy

If we now list the files

	
!ls -l
Copy
	
total 4
-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
-rw-r--r-- 1 root root 0 dic 6 01:22 rootfile.txt
lrwxrwxrwx 1 wallabot wallabot 29 dic 6 01:28 web -> /home/wallabot/Documentos/web

We see the symbolic link web that points to /home/wallabot/Documents/web:

I can now go to web

	
terminal("cd web")
Copy
	
!pwd
Copy
	
/home/wallabot/Documentos/web

Setting up the environment variableslink image 191

View environment variables with printenvlink image 192

With the printenv command we can see all the environment variables

	
!printenv
Copy
	
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
VSCODE_CWD=/home/wallabot
LESSOPEN=| /usr/bin/lesspipe %s
CONDA_PROMPT_MODIFIER=(base)
PYTHONIOENCODING=utf-8
USER=wallabot
VSCODE_NLS_CONFIG={"locale":"es","availableLanguages":{"*":"es"},"_languagePackId":"b07c40c9acb9e1d7b3ca14b06f814803.es","_translationsConfigFile":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/tcf.json","_cacheRoot":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es","_resolvedLanguagePackCoreLocation":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/6261075646f055b99068d3688932416f2346dd3b","_corruptedFile":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/corrupted.info","_languagePackSupport":true}
VSCODE_HANDLES_UNCAUGHT_ERRORS=true
MPLBACKEND=module://ipykernel.pylab.backend_inline
SSH_AGENT_PID=1373
XDG_SESSION_TYPE=x11
SHLVL=0
HOME=/home/wallabot
CHROME_DESKTOP=code-url-handler.desktop
CONDA_SHLVL=1
DESKTOP_SESSION=ubuntu
GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/code.desktop
VSCODE_IPC_HOOK=/run/user/1000/vscode-26527400-1.73.1-main.sock
PYTHONUNBUFFERED=1
GTK_MODULES=gail:atk-bridge
GNOME_SHELL_SESSION_MODE=ubuntu
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=true
PAGER=cat
MANAGERPID=1153
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
GIO_LAUNCHED_DESKTOP_FILE_PID=3897
_CE_M=
IM_CONFIG_PHASE=1
LOGNAME=wallabot
_=/home/wallabot/anaconda3/bin/python
JOURNAL_STREAM=8:52662
XDG_SESSION_CLASS=user
USERNAME=wallabot
TERM=xterm-color
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
_CE_CONDA=
WINDOWPATH=2
PATH=/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
SESSION_MANAGER=local/wallabot:@/tmp/.ICE-unix/1410,unix/wallabot:/tmp/.ICE-unix/1410
INVOCATION_ID=73bba2d15f2e492fa6c16538996a2556
VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcess
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=gnome-
GDK_BACKEND=x11
DISPLAY=:0
LANG=es_ES.UTF-8
XDG_CURRENT_DESKTOP=Unity
XAUTHORITY=/run/user/1000/gdm/Xauthority
XDG_SESSION_DESKTOP=ubuntu
XMODIFIERS=@im=ibus
LS_COLORS=
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
ORIGINAL_XDG_CURRENT_DESKTOP=ubuntu:GNOME
CONDA_PYTHON_EXE=/home/wallabot/anaconda3/bin/python
SHELL=/bin/bash
ELECTRON_RUN_AS_NODE=1
QT_ACCESSIBILITY=1
GDMSESSION=ubuntu
LESSCLOSE=/usr/bin/lesspipe %s %s
CONDA_DEFAULT_ENV=base
PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING=1
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
GJS_DEBUG_OUTPUT=stderr
QT_IM_MODULE=ibus
GIT_PAGER=cat
PWD=/home/wallabot/Documentos/web
CLICOLOR=1
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
VSCODE_CODE_CACHE_PATH=/home/wallabot/.config/Code/CachedData/6261075646f055b99068d3688932416f2346dd3b
CONDA_EXE=/home/wallabot/anaconda3/bin/conda
CONDA_PREFIX=/home/wallabot/anaconda3
VSCODE_PID=3897

View an environment variable with the echo commandlink image 193

To view a specific environment variable, we can do so by using the echo command followed by the $ symbol and the name of the variable.

	
!echo $HOME
Copy
	
/home/wallabot

Modify an environment variable for a terminal sessionlink image 194

We can modify an environment variable for the active terminal session, for example, let's add a new path to the PATH variable. First, let's see what is in it.

	
!echo $PATH
Copy
	
/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Now we add a new directory

	
!PATH=$PATH:"subdirectorio
Copy
	

Let's check what's inside PATH again

	
!echo $PATH
Copy
	
/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:subdirectorio

We see that the directory subdirectory has been added.

The problem with this method is that when we open a new terminal, this change in PATH will not be maintained.

Modify an environment variable for all terminal sessionslink image 195

We are going to the home folder

	
terminal("cd /home/wallabot")
Copy

Here, in the home, we list all files with the -a (all) flag.

	
!ls -a
Copy
	
. .eclipse .pki
.. Escritorio Plantillas
.afirma .gitconfig .platformio
anaconda3 .gnupg .profile
.audacity-data Imágenes .psensor
.bash_history .ipython Público
.bash_logout .java .python_history
.bashrc .jupyter snap
.cache .lesshst .ssh
.conda Lightworks .sudo_as_admin_successful
.config .Lightworks.thereCanBeOnlyOne .thunderbird
.cortex-debug .local Vídeos
.cyberghost logiops .vnc
.dbus .MCTranscodingSDK .vscode
Descargas .mozilla .wget-hsts
.docker Música
Documentos .nv

We see that there is a file called .bashrc, this file is the one that has the configuration of our bash

	
terminal("cat .bashrc", max_lines_output=3)
Copy
	
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
...
fi
unset __conda_setup
# <<< conda initialize <<<

This file configures the terminal every time a new one is opened, so if we edit the PATH variable in it, this change will persist for all new terminal windows that we open.

To modify the PATH variable within the configuration file, we need to add the following line to the file

PATH=$PATH:"subdirectory"

Create aliases for all sessionslink image 196

We already saw how to create command aliases, but they also got lost every time we closed a terminal session. To prevent this, we add them to the configuration file .bashrc as well. For example, in my case, I have added the following lines

alias ll='ls -l'
alias la='ls -a'
alias lh='ls -h'
alias lha='ls -lha'

Searching for binaries with whichlink image 198

The first search command we are going to look at is which, which allows us to find the path of binaries.

	
!which python
Copy
	
/home/wallabot/anaconda3/bin/python

However, if we look for something that is not in any of the PATH routes, which will not be able to tell us the path.

	
!which cd
Copy

To search for a file with find, we need to specify the path from which we want to start the search, followed by the -name flag and the name of the file we want to find.

	
!find ~ -name "2021-02-11-Introduccion-a-Python.ipynb"
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/prueba/2021-02-11-Introduccion-a-Python.ipynb
/home/wallabot/Documentos/web/portafolio/posts/2021-02-11-Introduccion-a-Python.ipynb

As we can see, it is in its directory, along with the copy I created in this notebook and saved in the folder prueba

One powerful thing about find is that we can use wildcards, for example, if I want to search for all text files in my web folder.

	
!find ~/Documentos/web/ -name *.txt
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/2022-09-12 Introduccion a la terminal.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/lista.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/dot.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/dot2.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/secuential.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/mitexto.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/file.txt
/home/wallabot/Documentos/web/wordpress_api_rest/page.txt

If we don't want to distinguish between uppercase and lowercase, we should use the -iname flag. For example, if we are looking for all files that contain the text FILE, but using the -iname flag.

	
!find ~/Documentos/web/ -iname *FILE*
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/html_files
/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/file.txt

We see that all the results contain file and not FILE, that is, it has not made a distinction between uppercase and lowercase.

We can specify the file type with the -type flag. It only accepts two types: f for files and d for directories.

	
!find ~/Documentos/nerf -name image*
Copy
	
/home/wallabot/Documentos/nerf/instant-ngp/configs/image
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/benchmarks/image
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/cutlass/media/images
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/fmt/doc/bootstrap/mixins/image.less
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/data/images
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/dlss/NVIDIAImageScaling/samples/media/images
/home/wallabot/Documentos/nerf/instant-ngp/data/nerf/fox/images
/home/wallabot/Documentos/nerf/instant-ngp/data/image
	
!find ~/Documentos/nerf -name image* -type d
Copy
	
/home/wallabot/Documentos/nerf/instant-ngp/configs/image
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/benchmarks/image
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/cutlass/media/images
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/data/images
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/dlss/NVIDIAImageScaling/samples/media/images
/home/wallabot/Documentos/nerf/instant-ngp/data/nerf/fox/images
/home/wallabot/Documentos/nerf/instant-ngp/data/image
	
!find ~/Documentos/nerf -name image* -type f
Copy
	
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/fmt/doc/bootstrap/mixins/image.less

If we want to filter by file size, we can use the -size flag, for example, if we want to find all files larger than 200 MB

	
!find ~/Documentos/ -type f -size +200M
Copy
	
/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_final_model.pth
/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_final_model.pth
/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_final_model.pth
/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_best_model.pth
/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_early_stopping.pth
/home/wallabot/Documentos/kaggle/hubmap/models/efficientnet-b7-dcc49843.pth
/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_early_stopping.pth
/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_early_stopping.pth
/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_best_model.pth
/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_best_model.pth

If we want to perform operations after the search, we use the -exec flag

For example, I will look for all folders with the name subdirectory

	
!find ~/ -name subdirectorio -type d
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio

I can make them delete with the -exec flag

	
!find ~/ -name subdirectorio -type d -exec rm -r {} ;
Copy
	
rm: ¿borrar el fichero regular vacío '/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt' protegido contra escritura? (s/n) s
find: ‘/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio’: No existe el archivo o el directorio
	
!find ~/ -name subdirectorio -type d
Copy

Lastly, if we use the character ! we will be indicating that it should find everything that does not match what we have specified.

	
!find ~/Documentos/web/portafolio/posts/prueba ! -name *.txt
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/prueba
/home/wallabot/Documentos/web/portafolio/posts/prueba/index.html
/home/wallabot/Documentos/web/portafolio/posts/prueba/Abc
/home/wallabot/Documentos/web/portafolio/posts/prueba/datos1
/home/wallabot/Documentos/web/portafolio/posts/prueba/2021-02-11-Introduccion-a-Python.ipynb
/home/wallabot/Documentos/web/portafolio/posts/prueba/datos123

As we can see, it has found everything that is not a .txt

grep is a very powerful search command, which is why we dedicate a section to it alone. The grep command uses regular expressions, so if you want to learn about them, I leave you a link to a post where I explain them.

Let's start to see the power of this command, we are going to search for all occurrences of the text MaximoFN within the file 2021-02-11-Introduccion-a-Python.ipynb

	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/prueba")
Copy
	
terminal("grep MaximoFN 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
Copy
	
"a = 'MaximoFN' ",
"'MaximoFN'"
"string = "MaximoFN" ",
"'MaximoFN'"
"string = 'MaximoFN' ",
"'MaximoFN'"
"Este es el blog de "MaximoFN" "
"print("Este es el blog de \"MaximoFN\"")"
"Este es el blog de 'MaximoFN' "
"print('Este es el blog de \'MaximoFN\'')"
"Este es el blog de \MaximoFN\ "
"print('Este es el blog de \\MaximoFN\\')"
"MaximoFN "
"print('Este es el blog de \nMaximoFN')"
"Este es el blog de MaximoFN "
"print('Esto no se imprimirá \rEste es el blog de MaximoFN')"
"Este es el blog de MaximoFN "
"print('Este es el blog de \tMaximoFN')"
"Este es el blog deMaximoFN "
"print('Este es el blog de \bMaximoFN')"
...
"funcion2_del_modulo('MaximoFN')"
"MaximoFN ",
" print('MaximoFN') ",
" variable = 'MaximoFN' ",

However, if we perform the same search for the text maximofn

	
!grep maximofn 2021-02-11-Introduccion-a-Python.ipynb
Copy

No results appear, this is because grep is case sensitive, meaning it searches for the text exactly as you have entered it, distinguishing between uppercase and lowercase letters. If we don't want this, we need to add the -i flag.

	
terminal("grep -i MaximoFN 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
Copy
	
"a = 'MaximoFN' ",
"'MaximoFN'"
"string = "MaximoFN" ",
"'MaximoFN'"
"string = 'MaximoFN' ",
"'MaximoFN'"
"Este es el blog de "MaximoFN" "
"print("Este es el blog de \"MaximoFN\"")"
"Este es el blog de 'MaximoFN' "
"print('Este es el blog de \'MaximoFN\'')"
"Este es el blog de \MaximoFN\ "
"print('Este es el blog de \\MaximoFN\\')"
"MaximoFN "
"print('Este es el blog de \nMaximoFN')"
"Este es el blog de MaximoFN "
"print('Esto no se imprimirá \rEste es el blog de MaximoFN')"
"Este es el blog de MaximoFN "
"print('Este es el blog de \tMaximoFN')"
"Este es el blog deMaximoFN "
"print('Este es el blog de \bMaximoFN')"
...
"funcion2_del_modulo('MaximoFN')"
"MaximoFN ",
" print('MaximoFN') ",
" variable = 'MaximoFN' ",

If what we want is for it to return the number of times it appears, we introduce the flag -c

	
!grep -c MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
Copy
	
105

If we don't care whether it appears in uppercase or lowercase, we can add the -i flag again, but there's no need to separate it from the -c flag; they can be introduced together.

	
!grep -ci MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
Copy
	
105

If we now want all the times when the word MáximoFN does **not** appear, we introduce the -v flag.

	
!grep -cv MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
Copy
	
11573

Network Utilitieslink image 201

Network Interface Information with ifconfiglink image 202

The first command will be ifconfig, which shows us information about our network interfaces.

	
!ifconfig
Copy
	
br-470e52ae2708: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:ac:d0:b9:eb txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:5d:15:1c:e9 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.144 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::7dc2:6944:3fbe:c18e prefixlen 64 scopeid 0x20<link>
ether 24:4b:fe:5c:f6:59 txqueuelen 1000 (Ethernet)
RX packets 144369 bytes 123807349 (123.8 MB)
RX errors 0 dropped 2056 overruns 0 frame 0
TX packets 100672 bytes 55678042 (55.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Bucle local)
RX packets 10748 bytes 1832545 (1.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10748 bytes 1832545 (1.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp5s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 4c:77:cb:1d:66:cc txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

As we can see, we have the information of all network interfaces on my computer, but if I want to know only one, it is specified by adding its name.

	
!ifconfig enp6s0
Copy
	
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.144 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::7dc2:6944:3fbe:c18e prefixlen 64 scopeid 0x20<link>
ether 24:4b:fe:5c:f6:59 txqueuelen 1000 (Ethernet)
RX packets 144467 bytes 123842258 (123.8 MB)
RX errors 0 dropped 2060 overruns 0 frame 0
TX packets 100786 bytes 55749109 (55.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Network interface information with iplink image 203

Another way to get information about our network interfaces is through the ip command, adding a gives us information about all interfaces.

	
!ip a
Copy
	
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 24:4b:fe:5c:f6:59 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.144/24 brd 192.168.1.255 scope global dynamic noprefixroute enp6s0
valid_lft 80218sec preferred_lft 80218sec
inet6 fe80::7dc2:6944:3fbe:c18e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 4c:77:cb:1d:66:cc brd ff:ff:ff:ff:ff:ff
4: br-470e52ae2708: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:ac:d0:b9:eb brd ff:ff:ff:ff:ff:ff
inet 172.18.0.1/16 brd 172.18.255.255 scope global br-470e52ae2708
valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:5d:15:1c:e9 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever

Communication test with pinglink image 204

Another useful command is ping, which can be used to check if we have a connection with a specific IP. For example, the IP of Google is 142.250.200.78, so we can send a ping to see if it responds. The ping command in Linux sends continuous pings, so it never stops until you stop it. To prevent this, we add the -c flag and the number of attempts.

	
!ping 142.250.200.132 -c 4
Copy
	
PING 142.250.200.132 (142.250.200.132) 56(84) bytes of data.
64 bytes from 142.250.200.132: icmp_seq=1 ttl=117 time=3.46 ms
64 bytes from 142.250.200.132: icmp_seq=2 ttl=117 time=3.77 ms
64 bytes from 142.250.200.132: icmp_seq=3 ttl=117 time=2.81 ms
64 bytes from 142.250.200.132: icmp_seq=4 ttl=117 time=2.86 ms
--- 142.250.200.132 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 2.812/3.227/3.773/0.405 ms

The same would have happened if we had done it directly on google.com

	
!ping www.google.com -c 4
Copy
	
PING www.google.com (142.250.200.132) 56(84) bytes of data.
64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=1 ttl=117 time=2.74 ms
64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=2 ttl=117 time=3.96 ms
64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=3 ttl=117 time=3.56 ms
64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=4 ttl=117 time=2.87 ms
--- www.google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 2.741/3.283/3.962/0.499 ms

Download source files with curllink image 205

We can obtain a text file from a given address using the curl command, for example, we can download the HTML of Google

	
!curl https://www.google.com
Copy
	
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="es"><head><meta content="Google.es permite acceder a la informaci�n mundial en castellano, catal�n, gallego, euskara e ingl�s." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google={kEI:'M5GOY6PeLr-jkdUP1pir0AE',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,5367,1123753,1197713,688,380089,16115,28684,22430,1362,12312,17587,4998,13228,3847,10622,22741,5081,1593,1279,2742,149,1103,840,1983,214,4100,3514,606,2023,2297,14670,3227,2845,7,4773,28997,1850,15757,3,346,230,6459,149,13975,4,1528,2304,7039,27731,7357,13658,4437,16786,5815,2542,4094,4052,3,3541,1,14262,27892,2,14022,6248,19490,5680,1021,2380,28741,4569,6255,23421,1252,5835,14967,4333,7484,11406,15676,8155,7381,15970,873,14804,1,4828,7,1922,5784,12208,10330,587,12192,4832,26504,5796,3,14433,3890,751,13384,1499,3,679,1622,1779,1886,338,1627,1119,6,8909,80,243,458,3438,1763,722,1020,813,91,1133,10,280,2306,44,77,1420,3,562,402,314,275,2095,440,399,138,384,1033,334,2667,2,723,444,79,403,501,929,3,785,2,240,78,2022,284,196,732,175,342,244,617,335,1,841,1275,14,979,57,857,446,2,1900,838,251,227,50,21,8,3,442,57,40,936,697,773,95,121,643,1502,163,355,702,195,1,452,50,334,687,109,1,19,109,134,546,80,5,36,124,68,135,131,415,47,27,266,563,48,231,742,15,527,2,6,495,1,495,5,62,1627,441,262,5,3,648,3,6,4,13,39,538,792,337,9,115,98,180,148,308,401,1240,2,726,243,2044,5286450,84,19,32,115,11,70,5995534,2803414,3311,141,795,19735,1,1,346,1755,1004,41,342,1,189,14,1,10,8,1,5,4,2,1,3,2,2,1,3,1,3,1,4,3,1,3,2,2,23947076,511,21,11,4041599,1964,1007,2087,13579,3102,303,5595,11,3835,3637,2623,9,136,1524825',kBL:'p9Xv'};google.sn='webhp';google.kHL='es';})();(function(){
var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}
function n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google.erd={jsr:1,bv:1698,de:true};
var h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=
a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split(" ")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>B�squeda</b> <a class=gb1 href="https://www.google.es/imghp?hl=es&tab=wi">Im�genes</a> <a class=gb1 href="https://maps.google.es/maps?hl=es&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=es&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">Noticias</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.es/intl/es/about/products?tab=wh"><u>M�s</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.es/history/optout?hl=es" class=gb4>Historial web</a> | <a href="/preferences?hl=es" class=gb4>Ajustes</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=es&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Iniciar sesi�n</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="es" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Buscar con Google" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Buscar con Google" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="Voy a tener suerte" name="btnI" type="submit"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var id='tsuid_1';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}
else top.location='/doodles/';};})();</script><input value="AJiK0e8AAAAAY46fQwdyVrbrgW6gkEtVkGfp2nyO0ZXL" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=es&authuser=0">B�squeda avanzada</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="gws-output-pages-elements-homepage_additional_languages__als"><style>#gws-output-pages-elements-homepage_additional_languages__als{font-size:small;margin-bottom:24px}#SIvCob{color:#3c4043;display:inline-block;line-height:28px;}#SIvCob a{padding:0 3px;}.H6sW5{display:inline-block;margin:0 2px;white-space:nowrap}.z4hgWe{display:inline-block;margin:0 2px}</style><div id="SIvCob">Ofrecido por Google en: <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=ca&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=gl&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=eu&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAc">euskara</a> </div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="http://www.google.es/intl/es/services/">Soluciones Empresariales</a><a href="/intl/es/about.html">Todo acerca de Google</a><a href="https://www.google.com/setprefdomain?prefdom=ES&prev=https://www.google.es/&sig=K_a2UXepORMQOw5-SHU8h4noB_VWk%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">© 2022 - <a href="/intl/es/policies/privacy/">Privacidad</a> - <a href="/intl/es/policies/terms/">T�rminos</a></p></span></center><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){google.xjs={ck:'xjs.hp.oxai9SxkIQY.L.X.O',cs:'ACT90oEGh-_ImDfBjn6aD_ABGaOlD2MqVw',excm:[]};})();</script> <script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var u='/xjs/_/js/k=xjs.hp.en.9b-uVUIpJU8.O/am=AADoBABQAGAB/d=1/ed=1/rs=ACT90oG-6KYVksw4jxVvNcwan406xE6qVw/m=sb_he,d';var amd=0;
var d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};
function m(){var a=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}
function p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=a instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}
function _F_installCss(c){}
(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc='{"d":{},"sb_he":{"agen":true,"cgen":true,"client":"heirloom-hp","dh":true,"ds":"","fl":true,"host":"google.com","jsonp":true,"lm":true,"msgs":{"cibl":"Borrar b�squeda","dym":"Quiz�s quisiste decir:","lcky":"Voy a tener suerte","lml":"M�s informaci�n","psrc":"Esta b�squeda se ha eliminado de tu \u003Ca href=\"/history\"\u003Ehistorial web\u003C/a\u003E.","psrl":"Eliminar","sbit":"Buscar por imagen","srch":"Buscar con Google"},"ovr":{},"pq":"","rfs":[],"sbas":"0 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)","stok":"gh8wSanWNWQy8f-PH0wGTjDkvYQ"}}';google.pmc=JSON.parse(pmc);})();</script> </body></html>

We can also create a pipeline to save it to a file

	
!curl https://www.google.com > google.html
Copy
	
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15168 0 15168 0 0 135k 0 --:--:-- --:--:-- --:--:-- 137k

Now we can check if it has been saved correctly

	
!cat google.html
Copy
	
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="es"><head><meta content="Google.es permite acceder a la informaci�n mundial en castellano, catal�n, gallego, euskara e ingl�s." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google={kEI:'R5GOY-LZHLegkdUP_IqzoAE',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,5367,1123753,1197777,380713,16115,28684,22430,1362,283,12036,17580,4998,13228,516,3331,10622,22741,5081,1593,1279,2742,149,1103,840,1983,4,210,4100,3514,606,2023,2299,14668,3229,2843,7,4773,826,23475,4696,1851,15756,3,346,230,6459,149,13975,4,1528,2304,7039,20309,7422,7357,13658,4437,16786,5812,2545,4094,4052,3,3541,1,11943,30211,2,8984,1,5037,6249,19490,5679,1020,2378,28745,4568,6258,23418,1252,5835,14967,4333,4239,3245,27082,239,7916,7381,15969,874,19633,6,1923,5784,3995,21779,1120,8423,4832,26080,423,107,5690,3,14433,3890,751,14879,3,683,217,1405,1779,1854,31,1966,1119,6,8909,323,5659,1741,814,1224,10,280,2346,82,1419,3,565,401,519,68,970,1125,440,398,156,367,1034,333,3392,526,396,3,1431,3,785,2,312,2312,196,907,342,244,618,314,1,293,568,171,1104,14,89,891,56,857,306,14,509,154,246,1110,219,628,249,229,49,8,8,3,55,4,399,55,39,1072,49,43,2,468,782,83,123,641,1502,166,350,707,195,5,140,358,329,692,109,1,20,108,134,547,67,5,49,93,31,77,124,79,355,160,27,829,236,764,12,35,118,98,803,1,65,436,5,5,54,2065,262,5,3,647,3,8,2,14,39,65,380,80,14,790,346,115,99,1323,4,711,242,2,723,2286,5280608,12,5934,147,81,8798948,3311,141,795,19735,1,1,346,1755,1004,41,342,1,189,14,9,4,6,3,3,4,1,2,2,3,2,2,2,1,2,5,2,2,1,2,2,2,23947077,512,18,13,2737921,1303678,1964,3094,13579,3405,5595,11,3835,1923,3208,1069,1480676,40778',kBL:'p9Xv'};google.sn='webhp';google.kHL='es';})();(function(){
var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}
function n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google.erd={jsr:1,bv:1698,de:true};
var h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=
a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split(" ")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>B�squeda</b> <a class=gb1 href="https://www.google.es/imghp?hl=es&tab=wi">Im�genes</a> <a class=gb1 href="https://maps.google.es/maps?hl=es&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=es&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">Noticias</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.es/intl/es/about/products?tab=wh"><u>M�s</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.es/history/optout?hl=es" class=gb4>Historial web</a> | <a href="/preferences?hl=es" class=gb4>Ajustes</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=es&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Iniciar sesi�n</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="es" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Buscar con Google" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Buscar con Google" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="Voy a tener suerte" name="btnI" type="submit"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var id='tsuid_1';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}
else top.location='/doodles/';};})();</script><input value="AJiK0e8AAAAAY46fV7gpXBHCT6KAebFZAqGv1l-4BtIR" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=es&authuser=0">B�squeda avanzada</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="gws-output-pages-elements-homepage_additional_languages__als"><style>#gws-output-pages-elements-homepage_additional_languages__als{font-size:small;margin-bottom:24px}#SIvCob{color:#3c4043;display:inline-block;line-height:28px;}#SIvCob a{padding:0 3px;}.H6sW5{display:inline-block;margin:0 2px;white-space:nowrap}.z4hgWe{display:inline-block;margin:0 2px}</style><div id="SIvCob">Ofrecido por Google en: <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=ca&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=gl&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=eu&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAc">euskara</a> </div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="http://www.google.es/intl/es/services/">Soluciones Empresariales</a><a href="/intl/es/about.html">Todo acerca de Google</a><a href="https://www.google.com/setprefdomain?prefdom=ES&prev=https://www.google.es/&sig=K_8O8QHBmoai9DOT5YZxMWevJK8VI%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">© 2022 - <a href="/intl/es/policies/privacy/">Privacidad</a> - <a href="/intl/es/policies/terms/">T�rminos</a></p></span></center><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){google.xjs={ck:'xjs.hp.oxai9SxkIQY.L.X.O',cs:'ACT90oEGh-_ImDfBjn6aD_ABGaOlD2MqVw',excm:[]};})();</script> <script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var u='/xjs/_/js/k=xjs.hp.en.9b-uVUIpJU8.O/am=AADoBABQAGAB/d=1/ed=1/rs=ACT90oG-6KYVksw4jxVvNcwan406xE6qVw/m=sb_he,d';var amd=0;
var d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};
function m(){var a=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}
function p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=a instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}
function _F_installCss(c){}
(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc='{"d":{},"sb_he":{"agen":true,"cgen":true,"client":"heirloom-hp","dh":true,"ds":"","fl":true,"host":"google.com","jsonp":true,"lm":true,"msgs":{"cibl":"Borrar b�squeda","dym":"Quiz�s quisiste decir:","lcky":"Voy a tener suerte","lml":"M�s informaci�n","psrc":"Esta b�squeda se ha eliminado de tu \u003Ca href=\"/history\"\u003Ehistorial web\u003C/a\u003E.","psrl":"Eliminar","sbit":"Buscar por imagen","srch":"Buscar con Google"},"ovr":{},"pq":"","rfs":[],"sbas":"0 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)","stok":"GYSMF2y7hymT0L3W0W4RPVIsSrU"}}';google.pmc=JSON.parse(pmc);})();</script> </body></html>

Downloading files with wgetlink image 206

Another similar command is wget, however, unlike curl, wget downloads the file directly.

	
!wget https://www.google.com
Copy
	
--2022-12-06 01:49:19-- https://www.google.com/
Resolviendo www.google.com (www.google.com)... 142.250.200.68, 2a00:1450:4003:80c::2004
Conectando con www.google.com (www.google.com)[142.250.200.68]:443... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: no especificado [text/html]
Guardando como: “index.html.1”
index.html.1 [ <=> ] 14,76K --.-KB/s en 0,002s
2022-12-06 01:49:19 (7,17 MB/s) - “index.html.1” guardado [15117]
	
!ls -l
Copy
	
total 316
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

We see that it has been saved as index.html, which is how Google names it

If we want to save it with a specific name, we can use the -O flag

	
!wget https://www.google.com -O google2.html
Copy
	
--2022-12-06 01:49:37-- https://www.google.com/
Resolviendo www.google.com (www.google.com)... 142.250.200.68, 2a00:1450:4003:80c::2004
Conectando con www.google.com (www.google.com)[142.250.200.68]:443... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: no especificado [text/html]
Guardando como: “google2.html”
google2.html [ <=> ] 14,78K --.-KB/s en 0,003s
2022-12-06 01:49:37 (5,27 MB/s) - “google2.html” guardado [15131]
	
!ls -l
Copy
	
total 332
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

Tracing the Route with traceroutelink image 207

A very useful command is to see the path to a destination, for this we use traceroute, for example, let's see all the sites I have to go through to connect to Google

	
!traceroute www.google.com
Copy
	
traceroute to www.google.com (142.250.200.68), 64 hops max
1 192.168.1.1 0,435ms 0,154ms 0,133ms
2 188.127.176.1 3,979ms 2,914ms 3,397ms
3 10.15.0.77 3,600ms 3,914ms 2,669ms
4 10.15.246.6 3,567ms 3,713ms 2,926ms
5 * * *
6 72.14.209.84 3,981ms 2,914ms 2,993ms
7 * * *
8 142.251.54.148 3,856ms 2,916ms 2,905ms
9 142.250.200.68 2,908ms 2,949ms 3,037ms

Tracing the Route with mtrlink image 208

Another debugging tool is mtr, which is an enhanced version of traceroute. It provides information for each hop, such as response time, percentage of lost packets, etc.

	
!mtr -n maximofn.com
Copy
	
wallabot (192.168.178.144)
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. 192.168.178.1 0.0% 345 0.3 0.3 0.3 0.3 0.0
2. 192.168.0.1 0.0% 344 0.8 1.1 1.1 1.1 0.0
3. (waiting for reply)
4. 10.183.52.41 0.0% 344 2.8 2.5 2.5 2.5 0.0
5. 172.29.0.161 47.7% 344 2.3 3.1 3.1 23.1 0.0
6. (waiting for reply)
7. 193.149.1.97 0.0% 344 3.6 3.6 3.6 38.6 0.0
8. (waiting for reply)
9. 185.125.78.197 2.9% 344 6.9 6.9 6.9 6.9 0.0

As can be seen in hop 5, almost 50% of the packets are lost, so it would serve to call my phone company and tell them to try routing me through another path.

Name of our machine with hostnamelink image 209

If we want to know the name of our machine, we can use hostname, which is useful if we want to connect to our machine from another one.

	
!hostname
Copy
	
wallabot

If we want to know our default gateway, we use the command route -n

	
!route -n
Copy
	
Tabla de rutas IP del núcleo
Destino Pasarela Genmask Indic Métric Ref Uso Interfaz
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp6s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp6s0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-470e52ae2708
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp6s0

IP Information for a Domain with nslookuplink image 211

If we want to know the IP of a domain, we can find it out using the nslookup command.

	
!nslookup google.com
Copy
	
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: google.com
Address: 142.250.185.14
Name: google.com
Address: 2a00:1450:4003:808::200e

This tells us that Google's IPv4 is 172.217.168.174 and its IPv6 is 2a00:1450:4003:803::200e

Network Information with netstatslink image 212

The last utility command is netstats, this command gives us the status of our network, additionally, with the flag -i it returns our network interfaces.

	
!netstat -i
Copy
	
Tabla de la interfaz del núcleo
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
br-470e5 1500 0 0 0 0 0 0 0 0 BMU
docker0 1500 0 0 0 0 0 0 0 0 BMU
enp6s0 1500 148385 0 2182 0 106135 0 0 0 BMRU
lo 65536 11674 0 0 0 11674 0 0 0 LRU
wlp5s0 1500 0 0 0 0 0 0 0 0 BMU

DNS Queries with diglink image 213

With the command dig <domain> we can make DNS queries, for example, let's make a query to Google

	
!dig google.com
Copy
	
; &lt;&lt;&gt;&gt; DiG 9.16.1-Ubuntu &lt;&lt;&gt;&gt; google.com
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 20527
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 283 IN A 142.250.184.14
;; Query time: 8 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: dom sep 24 01:32:07 CEST 2023
;; MSG SIZE rcvd: 55

It can be seen

markdown

;; ANSWER SECTION:

google.com.		283	IN	A	142.250.184.14

Therefore, the query has given us Google's IP.

We can query a specific DNS server with dig @<DNS server> <domain>

	
!dig @1.1.1.1 google.com
Copy
	
; &lt;&lt;&gt;&gt; DiG 9.16.1-Ubuntu &lt;&lt;&gt;&gt; @1.1.1.1 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 15633
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 190 IN A 142.250.184.14
;; Query time: 8 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: dom sep 24 01:33:40 CEST 2023
;; MSG SIZE rcvd: 44

We have made the same query, but we have made it to the Cloudflare DNS.

Compressing fileslink image 214

Before compressing and decompressing, let's see what we are going to compress. First, we print our path and list the files.

	
!pwd; ls -l
Copy
	
/home/wallabot/Documentos/web/portafolio/posts/prueba
total 332
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt

Let's create a new folder and copy everything that is inside the current folder into it.

	
!mkdir tocompress; cp * tocompress; ls -l
Copy
	
cp: -r not specified; omitting directory 'tocompress'
total 336
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:52 tocompress

As we can see, everything has been copied except the tocompress folder itself, since we didn't use the -r flag in the cp command. But what happened is exactly what we wanted.

Compress with tarlink image 215

The first command we are going to use for compressing is tar, to which we will add the -c flag for compress, -v for verbose, so it will show us what it's doing, and the -f flag for file, followed by the name we want the compressed file to have and the name of the file we want to compress.

	
!tar -cvf tocompress.tar tocompress
Copy
	
tocompress/
tocompress/lista.txt
tocompress/dot.txt
tocompress/google.html
tocompress/index.html
tocompress/Abc
tocompress/google2.html
tocompress/dot2.txt
tocompress/secuential.txt
tocompress/index.html.1
tocompress/file.txt
tocompress/datos1
tocompress/2021-02-11-Introduccion-a-Python.ipynb
tocompress/datos123
	
!ls -l
Copy
	
total 676
-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 348160 dic 6 01:53 tocompress.tar

We see that you have created the file tocompress.tar

Now we are going to repeat the process, but adding the flag -z. This compresses in the gzip format, which is a more efficient compression algorithm.

	
!tar -cvzf tocompress.tar.gz tocompress
Copy
	
tocompress/
tocompress/lista.txt
tocompress/dot.txt
tocompress/google.html
tocompress/index.html
tocompress/Abc
tocompress/google2.html
tocompress/dot2.txt
tocompress/secuential.txt
tocompress/index.html.1
tocompress/file.txt
tocompress/datos1
tocompress/2021-02-11-Introduccion-a-Python.ipynb
tocompress/datos123
	
!ls -lh
Copy
	
total 728K
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar
-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz

As can be seen, the file tocompress.tar takes up 340 kB, while the file tocompress.tar.gz takes up only 52 kB.

Now we are going to decompress the files. To decompress, the same command is used, only changing the flag -c to the flag -x

First we delete the original folder

	
!rm -r tocompress
Copy

We decompress

	
!tar -xvf tocompress.tar
Copy
	
tocompress/
tocompress/lista.txt
tocompress/dot.txt
tocompress/google.html
tocompress/index.html
tocompress/Abc
tocompress/google2.html
tocompress/dot2.txt
tocompress/secuential.txt
tocompress/index.html.1
tocompress/file.txt
tocompress/datos1
tocompress/2021-02-11-Introduccion-a-Python.ipynb
tocompress/datos123
	
!ls -lh
Copy
	
total 728K
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar
-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz

We do the same with the gzip

	
!rm -r tocompress
Copy
	
!tar -xvzf tocompress.tar.gz
Copy
	
tocompress/
tocompress/lista.txt
tocompress/dot.txt
tocompress/google.html
tocompress/index.html
tocompress/Abc
tocompress/google2.html
tocompress/dot2.txt
tocompress/secuential.txt
tocompress/index.html.1
tocompress/file.txt
tocompress/datos1
tocompress/2021-02-11-Introduccion-a-Python.ipynb
tocompress/datos123
	
!ls -lh
Copy
	
total 728K
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar
-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz

Compress with ziplink image 216

Another command to compress with zip, to compress you just need to add the -r (recursive) flag, the name you want the compressed file to have, and the file you want to compress.

	
!zip -r tocompress.zip tocompress
Copy
	
adding: tocompress/ (stored 0%)
adding: tocompress/lista.txt (deflated 23%)
adding: tocompress/dot.txt (stored 0%)
adding: tocompress/google.html (deflated 56%)
adding: tocompress/index.html (stored 0%)
adding: tocompress/Abc (stored 0%)
adding: tocompress/google2.html (deflated 56%)
adding: tocompress/dot2.txt (stored 0%)
adding: tocompress/secuential.txt (stored 0%)
adding: tocompress/index.html.1 (deflated 56%)
adding: tocompress/file.txt (stored 0%)
adding: tocompress/datos1 (stored 0%)
adding: tocompress/2021-02-11-Introduccion-a-Python.ipynb (deflated 85%)
adding: tocompress/datos123 (stored 0%)
	
!ls -lh
Copy
	
total 792K
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar
-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz
-rw-rw-r-- 1 wallabot wallabot 64K dic 6 01:53 tocompress.zip

To decompress, use the unzip command followed by the name of the file you want to decompress. First, delete the folder tocompress.

	
!rm -r tocompress
Copy
	
!unzip tocompress.zip
Copy
	
Archive: tocompress.zip
creating: tocompress/
inflating: tocompress/lista.txt
extracting: tocompress/dot.txt
inflating: tocompress/google.html
extracting: tocompress/index.html
extracting: tocompress/Abc
inflating: tocompress/google2.html
extracting: tocompress/dot2.txt
extracting: tocompress/secuential.txt
inflating: tocompress/index.html.1
extracting: tocompress/file.txt
extracting: tocompress/datos1
inflating: tocompress/2021-02-11-Introduccion-a-Python.ipynb
extracting: tocompress/datos123
	
!ls -lh
Copy
	
total 792K
-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html
-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1
-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
drwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress
-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar
-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz
-rw-rw-r-- 1 wallabot wallabot 64K dic 6 01:53 tocompress.zip

Background and foreground processeslink image 217

Pausing a process and moving it to the background with CTRL+Zlink image 218

When we run a process in the terminal, it might not stop executing and we may want to continue using the terminal. To solve this, we can move the process to the background by pressing CTRL+Z

For example, I can ping myself without specifying the number of attempts, so this will keep running until I stop the process by pressing CTRL+C

	
!ping localhost
Copy
	
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.024 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.024 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.036 ms
^C
--- localhost ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5127ms
rtt min/avg/max/mdev = 0.024/0.027/0.036/0.004 ms

However, if what we want is to pause the process for a moment to be able to continue using the terminal, we need to enter Ctrl+Z

	
!ping localhost
Copy
	
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.020 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.017 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.021 ms
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.055 ms
^Z
[1]+ Detenido ping localhost

As indicated, the process has been stopped, it is not running while I move it to the background

View background processes with jobslink image 219

To see what processes are in the background, we have two commands; on one hand, we can use jobs

	
!jobs
Copy
	
jobs
[1]+ Detenido ping localhost

This command gives us the process and the job number. This number will be the one we need to use to bring the process to the foreground.

View background processes with pslink image 220

Another command we can use is ps (processes)

	
!ps
Copy
	
PID TTY TIME CMD
16232 pts/3 00:00:00 bash
17070 pts/3 00:00:00 ping
18376 pts/3 00:00:00 ps

This command not only gives us information about the processes running in the background, but also about all the processes running in the terminal.

It is important to emphasize that if we open a new terminal and use any of these commands, we will not get the ping information, as we executed it in another terminal.

	
!ps
Copy
	
PID TTY TIME CMD
18993 pts/2 00:00:00 bash
19290 pts/2 00:00:00 ps

As we can see, jobs does not return anything because there are no background processes in this terminal, and ps only returns the information about bash (the terminal itself) and the ps command that was run.

Bringing a Background Process to the Foregroundlink image 221

To bring a process to the foreground, you need to use the fg command. If you want to bring the last process that was sent to the background, just typing fg is enough. Otherwise, you need to specify the job number.

Let's go back to the processes we had in the background

	
!jobs
Copy
	
[1]+ Detenido ping localhost

We can bring this process to the foreground by simply writing fg or specifying the job number with fg %1

	
!fg %1
Copy
	
ping localhost
64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.032 ms
64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.036 ms
64 bytes from localhost (127.0.0.1): icmp_seq=9 ttl=64 time=0.045 ms
64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.035 ms
64 bytes from localhost (127.0.0.1): icmp_seq=11 ttl=64 time=0.031 ms

Running a process directly in the backgroundlink image 222

Let's relaunch the Firefox browser now by typing firefox in the terminal and pressing CTRL+Z to send it to the background.

	
!firefox
Copy
	
[GFX1-]: glxtest: VA-API test failed: failed to initialise VAAPI connection.
[2022-11-29T06:16:17Z ERROR glean_core::metrics::ping] Invalid reason code startup for ping background-update
^Z
[1]+ Detenido firefox

As we can see, it states that the process has been stopped, so if we now want to browse with Firefox, we can't, since it is stopped.

To launch Firefox and have it run in the background so it doesn't block the terminal, you need to add a & at the end of the command.

	
!firefox &amp;
Copy
	
[1] 23663
$ [GFX1-]: glxtest: VA-API test failed: failed to initialise VAAPI connection.
[2022-11-29T06:19:40Z ERROR glean_core::metrics::ping] Invalid reason code startup for ping background-update
$

Now we launch Firefox, it tells us its job number and runs in the background.

In fact, if we now look at the processes, we can see that the state of Firefox is *Running*

	
!jobs
Copy
	
[1]+ Ejecutando firefox &amp;

Killing a Background Processlink image 223

Since we have Firefox running in the background, if we want to terminate it, we need to use kill and the job number of the process. Let's use jobs to see the job number of Firefox.

	
!jobs
Copy
	
[1]+ Ejecutando firefox &amp;

Your job number is 1, so we use that number to finish the process.

	
!kill %1
Copy
	

It doesn't respond with anything, but if we use jobs again to see the processes in the background

	
!jobs
Copy
	
[1]+ Terminado firefox

We see that it tells us Firefox has finished; if we run jobs again, nothing will appear.

	
!jobs
Copy
	

Background processes independent of the terminallink image 224

So far we have seen how to run background processes dependent on the terminal, which means that if we send a process to the background and close the terminal, it will send an end message to all processes in its background and they will terminate.

But there are times when we want the process to stay in the background, be able to close the terminal, open another one, and recover that process. For this, we will use tmux, which is a terminal multiplexer.

It may already be installed, so to install it you need to enter the following

sudo apt install tmux

Once installed, we can create a new tmux session using tmux new -s <name>

tmux new -s session1

This will open a new terminal, which is actually a tmux session.

Inside it we can launch a process, for example a ping to ourselves

	
!ping localhost
Copy
	
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.019 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.031 ms

We can close that terminal

If we open a new one, we can see all the open tmux sessions with the command tmux ls

	
!tmux ls
Copy
	
session1: 1 windows (created Tue Nov 29 08:15:22 2022)

And we can enter a session using the command tmux, followed by a (attach), -t (tag) and the name of the session

	
!tmux a -t session1
Copy
	
64 bytes from localhost (127.0.0.1): icmp_seq=146 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=147 ttl=64 time=0.022 ms
64 bytes from localhost (127.0.0.1): icmp_seq=148 ttl=64 time=0.026 ms
64 bytes from localhost (127.0.0.1): icmp_seq=149 ttl=64 time=0.013 ms
64 bytes from localhost (127.0.0.1): icmp_seq=150 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=151 ttl=64 time=0.019 ms

As we can see, we have recovered the ping from before

When we are inside a session, we can exit it (killing it) by typing CTRL+D or writing exit

Process Managementlink image 225

To handle the processes of our system we have several options

Process handler pslink image 226

As we have seen before, ps gives us the processes that are running in our terminal. For example, we run a process in the background and see the processes with ps.

	
!firefox &amp;
Copy
	
[1] 50555

We now see the processes

	
!ps
Copy
	
PID TTY TIME CMD
36660 pts/3 00:00:00 bash
50555 pts/3 00:00:02 firefox
50613 pts/3 00:00:00 Socket Process
50635 pts/3 00:00:00 Privileged Cont
50683 pts/3 00:00:00 WebExtensions
50741 pts/3 00:00:00 Web Content
50743 pts/3 00:00:00 Web Content
50748 pts/3 00:00:00 Web Content
50840 pts/3 00:00:00 ps

Once we know its PID, we can kill the process

	
!kill 50555
Copy
	

We now see the processes

	
!ps
Copy
	
PID TTY TIME CMD
36660 pts/3 00:00:00 bash
51132 pts/3 00:00:00 ps

But as we have said, the downside of ps is that it only shows the processes of its terminal

To display all system processes, we need to add aux

	
terminal("ps aux", max_lines_output=10)
Copy
	
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.0 169936 13172 ? Ss 23:06 0:01 /sbin/init splash
root 2 0.0 0.0 0 0 ? S 23:06 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [netns]
root 7 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [kworker/0:1H-events_highpri]
root 10 0.0 0.0 0 0 ? I&lt; 23:06 0:00 [mm_percpu_wq]
root 11 0.0 0.0 0 0 ? S 23:06 0:00 [rcu_tasks_rude_]
...
wallabot 11094 0.0 0.2 1184730916 65900 ? Sl 23:19 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=76 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=781545948 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 11428 0.3 0.2 38136100 75812 ? Sl 23:21 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/main --node-ipc --clientProcessId=8508
root 11508 0.0 0.0 0 0 ? I 23:21 0:00 [kworker/4:1-events]
wallabot 11683 0.0 0.0 14192 3380 ? R 23:22 0:00 ps aux

Now, if what I want is to search only for the processes running under my user, I can do this by creating a pipe and searching with grep

	
!ps aux | grep wallabot
Copy
	
avahi 802 0.0 0.0 8536 3912 ? Ss 23:06 0:00 avahi-daemon: running [wallabot.local]
wallabot 1153 0.0 0.0 19856 10624 ? Ss 23:06 0:00 /lib/systemd/systemd --user
wallabot 1154 0.0 0.0 170004 3680 ? S 23:06 0:00 (sd-pam)
wallabot 1159 0.1 0.0 2569384 22808 ? S&lt;sl 23:06 0:01 /usr/bin/pulseaudio --daemonize=no --log-target=journal
wallabot 1161 0.1 0.1 591424 37248 ? SNsl 23:06 0:02 /usr/libexec/tracker-miner-fs
wallabot 1164 0.0 0.0 390744 8664 ? SLl 23:06 0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
wallabot 1168 0.0 0.0 166804 6616 tty2 Ssl+ 23:06 0:00 /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu
wallabot 1173 0.0 0.0 8904 6012 ? Ss 23:06 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
wallabot 1181 0.0 0.0 242628 7884 ? Ssl 23:06 0:00 /usr/libexec/gvfsd
wallabot 1196 0.0 0.0 378348 5544 ? Sl 23:06 0:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
wallabot 1203 0.0 0.0 316896 9540 ? Ssl 23:06 0:00 /usr/libexec/gvfs-udisks2-volume-monitor
wallabot 1209 0.0 0.0 319540 8920 ? Ssl 23:06 0:00 /usr/libexec/gvfs-afc-volume-monitor
wallabot 1215 0.0 0.0 238612 5476 ? Ssl 23:06 0:00 /usr/libexec/gvfs-mtp-volume-monitor
wallabot 1220 0.0 0.0 239456 6988 ? Ssl 23:06 0:00 /usr/libexec/gvfs-goa-volume-monitor
wallabot 1224 0.0 0.2 707176 69244 ? SLl 23:06 0:00 /usr/libexec/goa-daemon
wallabot 1231 0.0 0.0 317692 9068 ? Sl 23:06 0:00 /usr/libexec/goa-identity-service
wallabot 1237 0.0 0.0 240888 6244 ? Ssl 23:06 0:00 /usr/libexec/gvfs-gphoto2-volume-monitor
wallabot 1308 0.0 0.0 190872 13688 tty2 Sl+ 23:06 0:00 /usr/libexec/gnome-session-binary --systemd --systemd --session=ubuntu
wallabot 1375 0.0 0.0 6040 452 ? Ss 23:06 0:00 /usr/bin/ssh-agent /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu
wallabot 1394 0.0 0.0 305428 6572 ? Ssl 23:06 0:00 /usr/libexec/at-spi-bus-launcher
wallabot 1399 0.0 0.0 7380 4240 ? S 23:06 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
wallabot 1405 0.0 0.0 92852 4228 ? Ssl 23:06 0:00 /usr/libexec/gnome-session-ctl --monitor
wallabot 1412 0.0 0.0 414004 16532 ? Ssl 23:06 0:00 /usr/libexec/gnome-session-binary --systemd-service --session=ubuntu
wallabot 1426 3.7 1.2 5576364 425284 ? Rsl 23:06 0:41 /usr/bin/gnome-shell
wallabot 1476 0.0 0.0 387612 8436 ? Sl 23:06 0:00 ibus-daemon --panel disable --xim
wallabot 1480 0.0 0.0 165628 7060 ? Sl 23:06 0:00 /usr/libexec/ibus-memconf
wallabot 1481 0.0 0.0 276012 29224 ? Sl 23:06 0:00 /usr/libexec/ibus-extension-gtk3
wallabot 1483 0.0 0.0 196832 24676 ? Sl 23:06 0:00 /usr/libexec/ibus-x11 --kill-daemon
wallabot 1486 0.0 0.0 239400 7244 ? Sl 23:06 0:00 /usr/libexec/ibus-portal
wallabot 1498 0.0 0.0 162916 6508 ? Sl 23:06 0:00 /usr/libexec/at-spi2-registryd --use-gnome-session
wallabot 1502 0.0 0.0 238512 5936 ? Ssl 23:06 0:00 /usr/libexec/xdg-permission-store
wallabot 1504 0.0 0.0 862476 24084 ? Sl 23:06 0:00 /usr/libexec/gnome-shell-calendar-server
wallabot 1513 0.0 0.0 618416 32636 ? Ssl 23:06 0:00 /usr/libexec/evolution-source-registry
wallabot 1521 0.0 0.0 156476 5716 ? Sl 23:06 0:00 /usr/libexec/dconf-service
wallabot 1524 0.0 0.0 165712 7076 ? Ssl 23:06 0:00 /usr/libexec/gvfsd-metadata
wallabot 1535 0.0 0.1 1680828 49932 ? Ssl 23:06 0:00 /usr/libexec/evolution-calendar-factory
wallabot 1551 0.0 0.0 676260 30636 ? Ssl 23:06 0:00 /usr/libexec/evolution-addressbook-factory
wallabot 1585 0.0 0.0 2933212 27180 ? Sl 23:06 0:00 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notifications
wallabot 1597 0.0 0.0 316920 7980 ? Sl 23:06 0:00 /usr/libexec/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0
wallabot 1612 0.0 0.0 312652 6796 ? Ssl 23:06 0:00 /usr/libexec/gsd-a11y-settings
wallabot 1613 0.0 0.0 587548 27164 ? Ssl 23:06 0:00 /usr/libexec/gsd-color
wallabot 1614 0.0 0.0 376604 16508 ? Ssl 23:06 0:00 /usr/libexec/gsd-datetime
wallabot 1616 0.0 0.0 314840 7876 ? Ssl 23:06 0:00 /usr/libexec/gsd-housekeeping
wallabot 1619 0.0 0.0 344796 25276 ? Ssl 23:06 0:00 /usr/libexec/gsd-keyboard
wallabot 1623 0.0 0.0 900140 28012 ? Ssl 23:06 0:00 /usr/libexec/gsd-media-keys
wallabot 1627 0.0 0.0 418936 25736 ? Ssl 23:06 0:00 /usr/libexec/gsd-power
wallabot 1629 0.0 0.0 251196 11384 ? Ssl 23:06 0:00 /usr/libexec/gsd-print-notifications
wallabot 1630 0.0 0.0 459940 6088 ? Ssl 23:06 0:00 /usr/libexec/gsd-rfkill
wallabot 1632 0.0 0.0 238348 6344 ? Ssl 23:06 0:00 /usr/libexec/gsd-screensaver-proxy
wallabot 1633 0.0 0.0 467776 11088 ? Ssl 23:06 0:00 /usr/libexec/gsd-sharing
wallabot 1634 0.0 0.0 318156 10452 ? Ssl 23:06 0:00 /usr/libexec/gsd-smartcard
wallabot 1636 0.0 0.0 322344 9400 ? Ssl 23:06 0:00 /usr/libexec/gsd-sound
wallabot 1637 0.0 0.0 461692 7252 ? Ssl 23:06 0:00 /usr/libexec/gsd-usb-protection
wallabot 1640 0.0 0.0 344332 24372 ? Ssl 23:06 0:00 /usr/libexec/gsd-wacom
wallabot 1643 0.0 0.0 390820 8260 ? Ssl 23:06 0:00 /usr/libexec/gsd-wwan
wallabot 1644 0.0 0.0 345572 25980 ? Ssl 23:06 0:00 /usr/libexec/gsd-xsettings
wallabot 1649 0.0 0.2 1227284 75100 ? Sl 23:06 0:00 /usr/libexec/evolution-data-server/evolution-alarm-notify
wallabot 1673 0.0 0.1 413288 60304 ? Sl 23:06 0:00 /usr/bin/python3 /usr/bin/solaar
wallabot 1692 0.0 0.0 231804 5972 ? Sl 23:06 0:00 /usr/libexec/gsd-disk-utility-notify
wallabot 1730 0.0 0.0 165620 7028 ? Sl 23:06 0:00 /usr/libexec/ibus-engine-simple
wallabot 1739 0.0 0.0 438456 19104 ? Sl 23:06 0:00 /usr/libexec/gvfsd-http --spawner :1.4 /org/gtk/gvfs/exec_spaw/1
wallabot 1748 0.4 0.6 1242548 217144 ? Sl 23:06 0:04 /snap/snap-store/599/usr/bin/snap-store --gapplication-service
wallabot 1760 0.0 0.0 345020 15016 ? Sl 23:06 0:00 /usr/libexec/gsd-printer
wallabot 1797 0.0 0.0 608052 6664 ? Ssl 23:06 0:00 /usr/libexec/xdg-document-portal
wallabot 2170 0.0 0.0 612960 11060 ? Ssl 23:06 0:00 /usr/libexec/xdg-desktop-portal
wallabot 2174 0.0 0.0 493648 26488 ? Ssl 23:06 0:00 /usr/libexec/xdg-desktop-portal-gtk
wallabot 4839 0.0 0.0 420020 28340 ? Sl 23:07 0:00 update-notifier
wallabot 5019 0.0 0.0 436628 21644 ? Sl 23:08 0:00 /usr/libexec/gvfsd-google --spawner :1.4 /org/gtk/gvfs/exec_spaw/2
wallabot 5072 3.2 1.1 34219664 391492 ? SLl 23:08 0:32 /opt/google/chrome/chrome
wallabot 5077 0.0 0.0 10844 580 ? S 23:08 0:00 cat
wallabot 5078 0.0 0.0 10844 516 ? S 23:08 0:00 cat
wallabot 5080 0.0 0.0 33576132 3140 ? Sl 23:08 0:00 /opt/google/chrome/chrome_crashpad_handler --monitor-self --monitor-self-annotation=ptype=crashpad-handler --database=/home/wallabot/.config/google-chrome/Crash Reports --url=https://clients2.google.com/cr/report --annotation=channel= --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Chrome_Linux --annotation=ver=108.0.5359.71 --initial-client-fd=5 --shared-client-connection
wallabot 5082 0.0 0.0 33567920 2952 ? Sl 23:08 0:00 /opt/google/chrome/chrome_crashpad_handler --no-periodic-tasks --monitor-self-annotation=ptype=crashpad-handler --database=/home/wallabot/.config/google-chrome/Crash Reports --url=https://clients2.google.com/cr/report --annotation=channel= --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Chrome_Linux --annotation=ver=108.0.5359.71 --initial-client-fd=4 --shared-client-connection
wallabot 5088 0.0 0.1 33854440 59168 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --no-zygote-sandbox --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable
wallabot 5089 0.0 0.1 33854436 59068 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable
wallabot 5090 0.0 0.0 33568428 5024 ? S 23:08 0:00 /opt/google/chrome/nacl_helper
wallabot 5093 0.0 0.0 33854460 16384 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable
wallabot 5123 6.0 0.8 34211392 285560 ? Sl 23:08 1:00 /opt/google/chrome/chrome --type=gpu-process --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --shared-files --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5124 0.6 0.3 33918264 119584 ? Sl 23:08 0:06 /opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=es --service-sandbox-type=none --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5136 0.0 0.1 33895840 52500 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=utility --utility-sub-type=storage.mojom.StorageService --lang=es --service-sandbox-type=utility --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5155 0.1 0.4 1184797648 132208 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121160165 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5171 4.5 0.6 1188020280 229028 ? Sl 23:08 0:44 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=27 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121254783 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5228 0.0 0.2 1184772236 89352 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121309474 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5247 0.0 0.2 1184788292 86368 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=7 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121342017 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5274 0.3 0.4 1184796488 155056 ? Sl 23:08 0:03 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=8 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121354013 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5294 0.1 0.3 1184797648 123536 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=9 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121366454 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5300 0.0 0.2 1184771900 88048 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=10 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121370528 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5325 0.0 0.1 34023608 34500 ? S 23:08 0:00 /opt/google/chrome/chrome --type=broker
wallabot 5343 0.0 0.3 1184780096 98820 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=45 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121454617 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5381 0.0 0.0 197896 29728 ? Sl 23:08 0:00 /usr/bin/python3 /usr/bin/chrome-gnome-shell chrome-extension://gphhapmejobijbbhgpjhcjognlahblep/
wallabot 5467 0.8 0.5 1185857508 194536 ? Sl 23:08 0:08 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=48 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=122388284 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5547 0.0 0.2 34155852 77000 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=utility --utility-sub-type=audio.mojom.AudioService --lang=es --service-sandbox-type=none --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5584 0.0 0.3 1184798704 126008 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=40 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127275168 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5590 0.1 0.4 1184799064 148824 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=28 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127276723 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5592 8.3 0.8 1187976688 283688 ? Sl 23:08 1:22 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=30 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127278497 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5636 0.0 0.3 1184805876 122780 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=51 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127293028 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5753 0.0 0.3 1184796632 104664 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=52 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=129692647 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5788 3.0 0.8 1185884504 276332 ? Sl 23:08 0:29 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=19 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=130329055 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5828 1.9 0.9 1184827212 309156 ? Sl 23:08 0:19 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=22 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=131345480 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 5846 0.6 0.6 1184844960 207484 ? Sl 23:08 0:06 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=36 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=131537892 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 6066 0.5 0.6 1184828968 220584 ? Sl 23:08 0:05 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=35 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=135569943 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 6120 0.0 0.0 43992 6552 ? Ss 23:08 0:00 /usr/lib/bluetooth/obexd
wallabot 6134 0.4 0.7 1184856952 230428 ? Sl 23:08 0:04 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=34 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=136358048 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 6524 0.4 0.6 1184857312 226988 ? Sl 23:08 0:04 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=33 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=139865567 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 8034 0.0 0.1 1064452 54580 ? Sl 23:10 0:00 /usr/bin/gnome-calendar --gapplication-service
wallabot 8158 0.7 0.7 3981248 239132 ? Sl 23:10 0:07 /snap/spotify/60/usr/share/spotify/spotify
wallabot 8242 0.0 0.2 647244 77376 ? S 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=zygote --no-zygote-sandbox --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log
wallabot 8243 0.0 0.2 647244 77100 ? S 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=zygote --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log
wallabot 8259 0.1 0.3 2041284 114252 ? Sl 23:10 0:01 /snap/spotify/60/usr/share/spotify/spotify --type=gpu-process --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --gpu-preferences=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABgAAAAAAAAAGAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072
wallabot 8274 0.0 0.1 868700 34104 ? Sl 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=utility --utility-sub-type=storage.mojom.StorageService --lang=en-US --service-sandbox-type=utility --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072
wallabot 8279 0.0 0.3 1148480 99680 ? Sl 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072
wallabot 8319 0.5 0.5 31646352 187140 ? Sl 23:10 0:05 /snap/spotify/60/usr/share/spotify/spotify --type=renderer --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --disable-spell-checking --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --no-sandbox --log-file=/snap/spotify/60/usr/share/spotify/debug.log --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --launch-time-ticks=210215195 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072
wallabot 8377 0.5 0.4 38371288 161752 ? SLl 23:10 0:05 /usr/share/code/code --unity-launch --enable-crashpad
wallabot 8391 0.0 0.1 33775112 48516 ? S 23:10 0:00 /usr/share/code/code --type=zygote --no-zygote-sandbox --enable-crashpad --enable-crashpad
wallabot 8392 0.0 0.1 33775096 48304 ? S 23:10 0:00 /usr/share/code/code --type=zygote --enable-crashpad --enable-crashpad
wallabot 8394 0.0 0.0 33775124 12448 ? S 23:10 0:00 /usr/share/code/code --type=zygote --enable-crashpad --enable-crashpad
wallabot 8407 0.0 0.0 33575984 3384 ? Sl 23:10 0:00 /usr/share/code/chrome_crashpad_handler --monitor-self-annotation=ptype=crashpad-handler --no-rate-limit --database=/home/wallabot/.config/Code/Crashpad --url=appcenter://code?aid=fba07a4d-84bd-4fc8-a125-9640fc8ce171&amp;uid=e1be826f-73fb-46c2-a439-9bb52643ccc1&amp;iid=e1be826f-73fb-46c2-a439-9bb52643ccc1&amp;sid=e1be826f-73fb-46c2-a439-9bb52643ccc1 --annotation=_companyName=Microsoft --annotation=_productName=VSCode --annotation=_version=1.73.1 --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Electron --annotation=ver=19.0.17 --initial-client-fd=43 --shared-client-connection
wallabot 8425 1.5 0.5 33985512 195464 ? Sl 23:10 0:14 /usr/share/code/code --type=gpu-process --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --shared-files --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess
wallabot 8429 0.0 0.2 33840968 66520 ? Sl 23:10 0:00 /usr/share/code/code --type=utility --utility-sub-type=network.mojom.NetworkService --lang=es --service-sandbox-type=none --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --enable-crashpad
wallabot 8439 0.0 0.0 33851528 23624 ? S 23:10 0:00 /usr/share/code/code --type=broker
wallabot 8449 8.5 1.1 61424852 390980 ? Sl 23:10 1:16 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --no-sandbox --no-zygote --enable-blink-features=HighlightAPI --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=4 --launch-time-ticks=217445761 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:13905479-a7dd-4e24-9b88-cf580c42a25d --enable-crashpad
wallabot 8508 1.4 0.8 59175788 268364 ? Sl 23:10 0:12 /usr/share/code/code --ms-enable-electron-run-as-node --inspect-port=0 /usr/share/code/resources/app/out/bootstrap-fork --type=extensionHost --skipWorkspaceStorageLock
wallabot 8566 0.1 0.2 38136100 81468 ? Sl 23:10 0:01 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/kisstkondoros.vscode-gutter-preview-0.30.0/dist/server.js --node-ipc --clientProcessId=8508
wallabot 8575 0.6 0.4 46670736 139408 ? Sl 23:10 0:05 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --no-sandbox --no-zygote --node-integration-in-worker --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --launch-time-ticks=219833707 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:be96c98d-9154-449a-b127-c0211495f4ef --vscode-window-kind=shared-process --enable-crashpad
wallabot 8593 0.0 0.2 38177772 78236 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/out/bootstrap-fork --type=ptyHost --logsPath /home/wallabot/.config/Code/logs/20221202T231016
wallabot 8632 0.0 0.2 38185752 94568 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/out/bootstrap-fork --type=fileWatcher
wallabot 8656 0.6 0.5 42430176 182480 ? Sl 23:10 0:05 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --enable-sandbox --enable-blink-features=HighlightAPI --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --launch-time-ticks=220495638 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:13905479-a7dd-4e24-9b88-cf580c42a25d
wallabot 8716 1.4 0.5 38140204 169984 ? Sl 23:10 0:12 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:3646d9eb9edaa1bd82425403564df0006a57a0df01 --node-ipc --clientProcessId=8508
wallabot 8744 0.1 0.3 38140204 104772 ? Sl 23:10 0:01 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:f832ffa59d80abd5b35e8851e94332c285b2c3f9bb --node-ipc --clientProcessId=8508
wallabot 8781 0.1 0.2 480956 77852 ? Sl 23:10 0:01 /home/wallabot/anaconda3/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"c6d890f5-5fb6-41d8-9a66-32d953505406" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/wallabot/.local/share/jupyter/runtime/kernel-v2-8508kHWtNFMgKsBL.json
wallabot 8788 0.0 0.0 116624 29744 ? Sl 23:10 0:00 /bin/python3 /home/wallabot/.vscode/extensions/ms-python.isort-2022.8.0/bundled/tool/server.py
wallabot 8898 0.6 0.4 38144304 146508 ? Sl 23:10 0:05 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:f57d6ea9bb6b4fa6ae2a6938661d2443c126a7b3df --node-ipc --clientProcessId=8508
wallabot 8911 0.0 0.2 38136100 70604 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=8508
wallabot 8932 0.0 0.0 13648 5412 pts/0 Ss+ 23:10 0:00 /usr/bin/bash --init-file /usr/share/code/resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
wallabot 9112 0.0 0.1 816596 50392 ? Ssl 23:10 0:00 /usr/libexec/gnome-terminal-server
wallabot 9120 0.0 0.0 13628 5212 pts/1 Ss+ 23:10 0:00 bash
wallabot 10927 0.0 0.3 1184807108 117996 ? Sl 23:19 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=72 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=743183717 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 11428 0.1 0.2 38136100 74884 ? Sl 23:21 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/main --node-ipc --clientProcessId=8508
wallabot 12009 0.0 0.2 1184730916 65832 ? Sl 23:24 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=80 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=1081580044 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072
wallabot 12109 0.0 0.0 2616 596 pts/2 Ss+ 23:25 0:00 /usr/bin/sh -c ps aux | grep wallabot
wallabot 12110 0.0 0.0 14192 3560 pts/2 R+ 23:25 0:00 ps aux
wallabot 12111 0.0 0.0 11668 660 pts/2 S+ 23:25 0:00 grep wallabot

Process handler toplink image 227

With top we can see all the processes of the operating system. It will display the information with less, so, just like explained before, when you want to stop top, pressing q will stop it.

	
!top
Copy
	
top - 09:31:32 up 3:21, 1 user, load average: 2,42, 2,79, 2,48
Tareas: 382 total, 1 ejecutar, 381 hibernar, 0 detener, 0 zombie
%Cpu(s): 14,2 usuario, 1,5 sist, 0,0 adecuado, 84,3 inact, 0,0 en espera, 0,
MiB Mem : 32006,4 total, 20281,8 libre, 6229,0 usado, 5495,6 búfer/caché
MiB Intercambio: 2048,0 total, 2048,0 libre, 0,0 usado. 24979,1 dispon
PID USUARIO PR NI VIRT RES SHR S %CPU %MEM HORA+ ORDEN
10192 wallabot 20 0 3347636 388848 84140 S 137,5 1,2 282:24.59 python
44161 wallabot 20 0 30,2g 217208 100148 S 12,5 0,7 0:40.92 spotify
76 root 20 0 0 0 0 S 6,2 0,0 0:00.12 ksoftir+
1105 root -51 0 0 0 0 S 6,2 0,0 2:54.29 irq/125+
43990 wallabot 20 0 3998836 246260 145800 S 6,2 0,8 0:53.69 spotify
44101 wallabot 20 0 1995108 130316 89848 S 6,2 0,4 0:08.34 spotify
51510 wallabot 20 0 14876 4088 3288 R 6,2 0,0 0:00.01 top
1 root 20 0 169736 13188 8380 S 0,0 0,0 0:01.51 systemd
2 root 20 0 0 0 0 S 0,0 0,0 0:00.00 kthreadd
3 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 rcu_par+
5 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 netns
7 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 kworker+
9 root 0 -20 0 0 0 I 0,0 0,0 0:00.03 kworker+
10 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 mm_perc+
11 root 20 0 0 0 0 S 0,0 0,0 0:00.00 rcu_tas+
12 root 20 0 0 0 0 S 0,0 0,0 0:00.00 rcu_tas+

As can be seen, the PID 44161 is Spotify, which I am currently using to play music, but we didn't see it with ps.

Just like before, if we want to kill a process, we must enter kill and its PID

The good thing about top is that it provides many more utilities; if we press h it will show the help

	
!h
Copy
	
Help for Interactive Commands - procps-ng 3.3.16
Window 1:Def: Cumulative mode Apagado. System: Delay 3,0 secs; Secure mode Apag
Z,B,E,e Global: 'Z' colors; 'B' bold; 'E'/'e' summary/task memory scale
l,t,m Toggle Summary: 'l' load avg; 't' task/cpu stats; 'm' memory info
0,1,2,3,I Toggle: '0' zeros; '1/2/3' cpus or numa node views; 'I' Irix mode
f,F,X Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-width
L,&amp;,&lt;,&gt; . Locate: 'L'/'&amp;' find/again; Move sort column: '&lt;'/'&gt;' left/right
R,H,J,C . Toggle: 'R' Sort; 'H' Threads; 'J' Num justify; 'C' Coordinates
c,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justify
x,y . Toggle highlights: 'x' sort field; 'y' running tasks
z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
u,U,o,O . Filter by: 'u'/'U' effective/any user; 'o'/'O' other criteria
n,#,^O . Set: 'n'/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)
V,v . Toggle: 'V' forest view; 'v' hide/show forest view children
k,r Gestiona tareas: «k» detener; «r» reiniciar
d o s Establece intervalo de actualización
W,Y Write configuration file 'W'; Inspect other output 'Y'
q Quit
( commands shown with '.' require a visible task display window )
Press 'h' or '?' for help with Windows,
Type 'q' or &lt;Esc&gt; to continue

To exit, press ESC or q

As shown in the help, if we enter u we can filter by user, we enter my username (wallabot) and I can see only my processes.

	
!u
Copy
	
top - 09:35:57 up 3:25, 1 user, load average: 1,02, 2,27, 2,39
Tareas: 378 total, 1 ejecutar, 377 hibernar, 0 detener, 0 zombie
%Cpu(s): 13,4 usuario, 0,4 sist, 0,0 adecuado, 86,1 inact, 0,1 en espera, 0,
MiB Mem : 32006,4 total, 20288,0 libre, 6212,0 usado, 5506,4 búfer/caché
MiB Intercambio: 2048,0 total, 2048,0 libre, 0,0 usado. 24989,1 dispon
PID USUARIO PR NI VIRT RES SHR S %CPU %MEM HORA+ ORDEN
10192 wallabot 20 0 3347636 388848 84140 S 148,2 1,2 288:46.50 python
43990 wallabot 20 0 3998836 246552 146092 S 2,7 0,8 0:59.55 spotify
1384 wallabot 20 0 4909848 453700 133164 S 1,7 1,4 11:14.02 gnome-s+
1119 wallabot 9 -11 3093876 24504 17836 S 1,3 0,1 0:48.99 pulseau+
32462 wallabot 20 0 1134,0g 643412 128632 S 1,3 2,0 7:39.91 chrome
44161 wallabot 20 0 30,2g 217112 100488 S 1,3 0,7 0:44.87 spotify
10135 wallabot 20 0 826220 58164 41648 S 1,0 0,2 0:14.56 gnome-t+
6635 wallabot 20 0 33,0g 647936 436252 S 0,3 2,0 4:01.80 chrome
6679 wallabot 20 0 32,4g 125564 94016 S 0,3 0,4 0:52.19 chrome
8010 wallabot 20 0 1130,9g 232800 116092 S 0,3 0,7 0:13.70 chrome
44101 wallabot 20 0 1995108 130444 89916 S 0,3 0,4 0:09.19 spotify
1113 wallabot 20 0 19880 10528 8096 S 0,0 0,0 0:00.38 systemd
1114 wallabot 20 0 169792 3636 12 S 0,0 0,0 0:00.00 (sd-pam)
1121 wallabot 39 19 591436 37256 16676 S 0,0 0,1 0:03.19 tracker+
1124 wallabot 20 0 390740 8688 7416 S 0,0 0,0 0:00.45 gnome-k+
1128 wallabot 20 0 166804 6596 5956 S 0,0 0,0 0:00.00 gdm-x-s+
1134 wallabot 20 0 9152 6144 3796 S 0,0 0,0 0:01.81 dbus-da+

Another way to look at this to be able to filter by user would be to create a pipeline and use grep

	
!top | grep wallabot
Copy
	
1440 wallabot 20 0 4684708 505432 118024 S 6,7 1,5 2:05.92 gnome-s+
25326 wallabot 20 0 1133,0g 527912 123732 S 1,7 1,6 1:31.73 chrome
1440 wallabot 20 0 4684708 505476 118024 S 1,3 1,5 2:05.96 gnome-s+
6199 wallabot 20 0 1131,0g 266068 116164 S 0,3 0,8 0:15.23 chrome
17606 wallabot 20 0 818228 52096 39488 S 0,3 0,2 0:02.59 gnome-t+
34284 wallabot 20 0 14876 4376 3308 R 0,3 0,0 0:00.02 top

Process handler htoplink image 228

It's similar to top but more powerful

You probably don't have it installed, so to install it, enter the command

sudo apt install htop

o

sudo snap install htop

Process handler glanceslink image 229

It's similar to top but more powerful

You probably don't have it installed, so to install it, enter the command

sudo apt install glances

Memory Management RAMlink image 230

If we only want to get information about the memory, we can use the free command.

	
!free
Copy
	
total usado libre compartido búfer/caché disponible
Memoria: 32774516 6563544 20091804 276296 6119168 25479600
Swap: 2097148 0 2097148

But since this information is not very easy to digest, we add the -h (human) flag to make it more readable.

	
!free -h
Copy
	
total usado libre compartido búfer/caché disponible
Memoria: 31Gi 6,3Gi 19Gi 270Mi 5,8Gi 24Gi
Swap: 2,0Gi 0B 2,0Gi

Hard drive managementlink image 231

To get information about the hard drive, we use the du command. If we only enter this command in the terminal, it will provide information about all the folders on our machine. Therefore, to avoid getting too much information, it is necessary to specify a path that we want to scan.

	
!du ~/Documentos/web/portafolio/posts/
Copy
	
8 /home/wallabot/Documentos/web/portafolio/posts/__pycache__
1648 /home/wallabot/Documentos/web/portafolio/posts/notebooks_translated
4288 /home/wallabot/Documentos/web/portafolio/posts/html_files
336 /home/wallabot/Documentos/web/portafolio/posts/prueba/tocompress
1132 /home/wallabot/Documentos/web/portafolio/posts/prueba
16 /home/wallabot/Documentos/web/portafolio/posts/introduccion_python/__pycache__
28 /home/wallabot/Documentos/web/portafolio/posts/introduccion_python
11232 /home/wallabot/Documentos/web/portafolio/posts/

Just like before, we add the flag -h (human) to make it easier to read

	
!du ~/Documentos/web/portafolio/posts/ -h
Copy
	
8,0K /home/wallabot/Documentos/web/portafolio/posts/__pycache__
1,7M /home/wallabot/Documentos/web/portafolio/posts/notebooks_translated
4,2M /home/wallabot/Documentos/web/portafolio/posts/html_files
336K /home/wallabot/Documentos/web/portafolio/posts/prueba/tocompress
1,2M /home/wallabot/Documentos/web/portafolio/posts/prueba
16K /home/wallabot/Documentos/web/portafolio/posts/introduccion_python/__pycache__
28K /home/wallabot/Documentos/web/portafolio/posts/introduccion_python
11M /home/wallabot/Documentos/web/portafolio/posts/

Interface Managementlink image 232

In Ubuntu, by default we boot into a graphical interface, but we can open other interfaces, which will not be graphical, by entering CTRL+ALT+F<num> where the number can range from 1 to 6. Only 2 will have the graphical interface and 1 will be the login screen.

When handling multiple interfaces, we might not know which one we are on, so by entering the command tty it will tell us which one we are on.

	
!tty
Copy
	
/dev/pts/0

Package Managementlink image 233

PPA (Personal Package Archives) Repositorieslink image 234

In Linux, package management is done through repositories. This is a list of addresses where the binaries of our programs are located. So, when we want to update or install our programs (we will explain how later), what the operating system will do is check the list of these repositories and go to the indicated addresses to look for the binaries.

This list of repositories is located in /etc/apt/sources.list and within the folder /etc/apt/sources.list.d. Let's take a look at this list.

	
terminal("cat /etc/apt/sources.list", max_lines_output=10)
Copy
	
# deb cdrom:[Ubuntu 20.04.2.0 LTS _Focal Fossa_ - Release amd64 (20210209.1)]/ focal main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://es.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://es.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://es.archive.ubuntu.com/ubuntu/ focal-updates main restricted
...
deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /
# deb-src https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /
deb https://apt.kitware.com/ubuntu/ focal main
# deb-src https://apt.kitware.com/ubuntu/ focal main

The first lines that include the word cd-rom are references to the installation CD, they always come with the words deb cdrom: even if it was installed via the network or from a USB.

From here on, various lines starting with deb or deb-src begin to appear. In deb, binaries are found, and in deb-src, the source code is found.

Every valid repository address has one of these formats:

  • deb http://server_address/folder_name version_name (main or universe or multiverse or main restricted, etc)
  • deb-src http://server_address/folder_name version_name (main or universe or multiverse or main restricted, etc)

The six types of Ubuntu repositories are:

  1. Main

The Main repository is enabled by default and contains only free and open-source software or FOSS for short (Free and Open-Source Software).

  1. Universe

Like Main, Universe also offers FOSS. The difference is that in this repository it is not Ubuntu who guarantees regular security updates, but rather the community is responsible for its support. It comes enabled by default, but not always. Some operating systems have it disabled by default and we might need to enable it if we are running a Live Session. If we don't have it added, we can do so with this command:

sudo add-apt-repository universe

What do we find in «Universe»? I would say most of the worthwhile software, between what we have like VLC and OpenShot.

  1. Multiverse

From here on out, the Ubuntu repositories have less freedom. Multiverse contains software that is no longer FOSS, and Ubuntu cannot enable this repository by default due to legal and licensing issues. Additionally, it cannot provide patches and updates. With this in mind, we need to evaluate whether to add it or not, something we can do with this command:

sudo add-apt-repository multiverse
  1. Restricted

In the Ubuntu repositories, we can find free and open-source software, but this is not possible when it comes to anything related to hardware. In the Restricted repositories, we will find drivers, such as those for graphics cards, touchpads, or network cards.

sudo add-apt-repository restricted
  1. Partner

This repository contains proprietary software compiled by Ubuntu from its partners.

  1. Third-party Ubuntu repositories

Finally, we have third-party repositories. Ubuntu aims to always offer the best user experience, and this is one of the reasons why it rejects certain software. There are also developers who prefer to have full control over what they offer, and for this reason, they create their own repositories.

Add repositorieslink image 235

If we are on Ubuntu, we can add a repository using the command add-apt-repository <repository>. However, in other distributions that are not Ubuntu, this command is not available.

Update the repositorieslink image 236

With the command apt update we can update to the latest versions of the packages in our repository.

Update the packageslink image 237

By using the command apt upgrade we can update the programs that we have installed and for which we have previously updated their repository.

Update the kernellink image 238

If we use the command apt dist-upgrade, it will also upgrade kernel packages.

Beware!: Updating kernel packages can lead to some packages breaking

Reminder: When updating kernel packages, a restart of the computer is necessary for the changes to take effect.

With the command apt search <package> we can find packages

	
terminal("apt search vlc", max_lines_output=10)
Copy
	
Ordenando...
Buscar en todo el texto...
anacrolix-dms/focal 1.1.0-1 amd64
Go UPnP DLNA Digital Media Server with basic video transcoding
cubemap/focal 1.4.3-1build1 amd64
scalable video reflector, designed to be used with VLC
dvblast/focal 3.4-1 amd64
Simple and powerful dvb-streaming application
...
x264/focal 2:0.155.2917+git0a84d98-2 amd64
video encoder for the H.264/MPEG-4 AVC standard

List of installed packageslink image 240

To see what packages we have installed, we can use dpkg -l, this will give us a list of all the packages installed on our computer.

	
terminal("dpkg -l", max_lines_output=10)
Copy
	
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)
| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo
|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)
||/ Nombre Versión Arquitectura Descripción
+++-==========================================-=====================================-============-===========================================================================================================================================================================================================================================================================================================================================================================================================================================
ii accountsservice 0.6.55-0ubuntu12~20.04.5 amd64 query and manipulate user account information
ii acl 2.2.53-6 amd64 access control list - utilities
ii acpi-support 0.143 amd64 scripts for handling many ACPI events
ii acpid 1:2.0.32-1ubuntu1 amd64 Advanced Configuration and Power Interface event daemon
ii adduser 3.118ubuntu2 all add and remove users and groups
...
ii zip 3.0-11build1 amd64 Archiver for .zip files
ii zlib1g:amd64 1:1.2.11.dfsg-2ubuntu1.5 amd64 compression library - runtime
ii zlib1g:i386 1:1.2.11.dfsg-2ubuntu1.5 i386 compression library - runtime
ii zlib1g-dev:amd64 1:1.2.11.dfsg-2ubuntu1.5 amd64 compression library - development

If we want to check if a package is installed, we can use the previous command and create a pipe to search for the package name with grep

	
terminal("dpkg -l | grep vlc")
Copy
	
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)
| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo
|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)
||/ Nombre Versión Arquitectura Descripción
+++-==============-============-============-=================================
ii grep 3.4-1 amd64 GNU grep, egrep and fgrep
ii vlc 3.0.9.2-1 amd64 multimedia player and streamer

Install downloaded packages and not from repositorieslink image 241

Sometimes, when you want to install a program, they give you a .deb file, so to install it, we use the command dpkg -i <file.deb>

User Managerlink image 242

Information of the active user with idlink image 243

By using the id command, I can see which user I am

	
!id
Copy
	
uid=1000(wallabot) gid=1000(wallabot) grupos=1000(wallabot),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),998(docker)

With this command I can see my id, the group ID gid and the groups I belong to. In Debian-based distributions, users are given an ID starting from 1000, while the root user is assigned the ID 0.

Information of the active user with whoamilink image 244

Another command to know which user I am is whoami

	
!whoami
Copy
	
wallabot

File with information of all userslink image 245

The user information is in the file /etc/passwd

	
terminal("cat /etc/passwd", max_lines_output=10)
Copy
	
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
...
sshd:x:126:65534::/run/sshd:/usr/sbin/nologin
nvidia-persistenced:x:127:135:NVIDIA Persistence Daemon,,,:/nonexistent:/usr/sbin/nologin
fwupd-refresh:x:128:136:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
glances:x:129:137::/var/lib/glances:/usr/sbin/nologin

Change a user's passwordlink image 246

If you want to change a user's password, you should use the command passwd <user> <password>. If the user is not specified, it will take what the whoami command returns.

Creating users with useraddlink image 247

To create a new user, the command useradd <user name> is used. Let's create a new user.

	
!sudo useradd usertest1
Copy
	

Let's check if it's in the file with all the users

	
!cat /etc/passwd | grep usertest
Copy
	
usertest1:x:1001:1001::/home/usertest1:/bin/sh

As we can see, the user has been created with the id 1001, the next one after my user wallabot, which was the last.

However, when creating this user, it did not ask us to assign a password. Additionally, if we look inside home

	
!ls /home
Copy
	
wallabot

Only the wallabot user folder is present, but not the test1 user folder.

Creating users with adduserlink image 248

Therefore, we are going to look at another command for creating users that does ask for a password and does create a folder in home. This command is adduser

	
!sudo adduser usertest2
Copy
	
[sudo] contraseña para wallabot:
Añadiendo el usuario `usertest2' ...
Añadiendo el nuevo grupo `usertest2' (1002) ...
Añadiendo el nuevo usuario `usertest2' (1002) con grupo `usertest2' ...
Creando el directorio personal `/home/usertest2' ...
Copiando los ficheros desde `/etc/skel' ...
Nueva contraseña:
Vuelva a escribir la nueva contraseña:
passwd: contraseña actualizada correctamente
Cambiando la información de usuario para usertest2
Introduzca el nuevo valor, o presione INTRO para el predeterminado
Nombre completo []:
Número de habitación []:
Teléfono del trabajo []:
Teléfono de casa []:
Otro []:
¿Es correcta la información? [S/n] s

If we look at the file with all the users

	
!cat /etc/passwd | grep usertest
Copy
	
usertest1:x:1001:1001::/home/usertest1:/bin/sh
usertest2:x:1002:1002:,,,:/home/usertest2:/bin/bash

We see that the user usertest2 has been created.

	
!ls /home
Copy
	
usertest2 wallabot

And we see that a folder has been created for him in home

To delete a user, you must use the command userdel <username>

	
!sudo userdel usertest1
Copy
	
	
!sudo userdel usertest2
Copy
	

Let's check if they are in the file with all the users.

	
!cat /etc/passwd | grep usertest
Copy

We see that nothing appears anymore, in fact we see the end of that file.

	
!tail /etc/passwd
Copy
	
geoclue:x:122:127::/var/lib/geoclue:/usr/sbin/nologin
pulse:x:123:128:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
gnome-initial-setup:x:124:65534::/run/gnome-initial-setup/:/bin/false
gdm:x:125:130:Gnome Display Manager:/var/lib/gdm3:/bin/false
wallabot:x:1000:1000:wallabot,,,:/home/wallabot:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
sshd:x:126:65534::/run/sshd:/usr/sbin/nologin
nvidia-persistenced:x:127:135:NVIDIA Persistence Daemon,,,:/nonexistent:/usr/sbin/nologin
fwupd-refresh:x:128:136:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
glances:x:129:137::/var/lib/glances:/usr/sbin/nologin

Making an Administrator Userlink image 249

First, we are going to create a new user, who will not be an administrator at the beginning.

	
!sudo adduser noadmin
Copy
	
Añadiendo el usuario `noadmin' ...
Añadiendo el nuevo grupo `noadmin' (1001) ...
Añadiendo el nuevo usuario `noadmin' (1001) con grupo `noadmin' ...
Creando el directorio personal `/home/noadmin' ...
Copiando los ficheros desde `/etc/skel' ...
Nueva contraseña:
Vuelva a escribir la nueva contraseña:
passwd: contraseña actualizada correctamente
Cambiando la información de usuario para noadmin
Introduzca el nuevo valor, o presione INTRO para el predeterminado
Nombre completo []:
Número de habitación []:
Teléfono del trabajo []:
Teléfono de casa []:
Otro []:
¿Es correcta la información? [S/n] s

Let's check which groups the user we just created belongs to, for this we use the command groups <user>

	
!groups noadmin
Copy
	
noadmin : noadmin

As we can see, it is only in the group noadmin, which is a group that was created when the user was created.

Let's see which groups my user belongs to

	
!groups wallabot
Copy
	
wallabot : wallabot adm cdrom sudo dip plugdev lpadmin lxd sambashare docker

As we can see, my user belongs to several additional groups, including one called sudo. Users who have access to this group have administrative powers, so for the new user we created to have these powers, we need to add them to the sudo group.

To add a user to a group there are two ways: one is with the command gpasswd -a <user> <group>

	
!sudo gpasswd -a noadmin sudo
Copy
	
Añadiendo al usuario noadmin al grupo sudo

We now see which groups the user noadmin belongs to.

	
!groups noadmin
Copy
	
noadmin : noadmin sudo

As we can see, it already belongs to the sudo group, so it would already have administrative powers.

We remove the user noadmin from the group sudo with the command gpasswd -d <user> <group>

	
!sudo gpasswd -d noadmin sudo
Copy
	
Eliminando al usuario noadmin del grupo sudo

We see that noadmin is no longer part of the sudo group

	
!groups noadmin
Copy
	
noadmin : noadmin

The second command to add a user to a group is usermod -aG <group> <user>

	
!sudo usermod -aG sudo noadmin
Copy
	

We check again which groups the user noadmin belongs to.

	
!groups noadmin
Copy
	
noadmin : noadmin sudo

We remove the user noadmin from the sudo group and delete it.

	
!sudo gpasswd -d noadmin sudo
Copy
	
Eliminando al usuario noadmin del grupo sudo
	
!sudo userdel noadmin
Copy
	

Command Historylink image 250

historylink image 251

If we enter the command history in the terminal, we see a history of the commands used.

	
!history
Copy
	
1009 docker build . nvidia/cuda
1010 docker build --help
1011 docker build --build-arg nvidia/cuda
1012 docker build --build-arg [nvidia/cuda]
1013 cd ../docker/
1014 docker ps -a
1015 docker rm boring_wescoff
1016 docker compose up -d
1017 docker compose exec deepstream61 bash
1018 cd ..
....
1996 ps
1997 ps aux
1998 camerasIP.sh
1999 sudo su
2000 sudo useradd usertest
2001 sudo userdel usertest
2002 sudo useradd usertest
2003 sudo userdel usertest
2004 sudo su
2005 sudo apt install history
2006 history
2007 clear
2008 history

If we want to run one of the commands from the history, we do it using !<num command>, for example, if I want to run the command 1996 again.

	
! !1996
Copy
	
PID TTY TIME CMD
6610 pts/0 00:00:00 bash
20826 pts/0 00:00:00 ps

A more refined way to search through the history is to press CTRL+r. When you do this, the following message will appear in the console

	
!reverse-i-search)`':
Copy
	

So as you type, commands that match what you have entered will appear. For example, if I enter if, the last time I used ifconfig will appear.

If we press CTRL+r again, older matches will start appearing.

Remove commands from historylink image 253

There are commands like ls, cd, pwd that don't add much value to being in the history, so we can configure them not to be saved in the history. To do this, we modify the ~/.bashrc file and add the line HISTIGNORE="pwd:ls:cd"

Securitylink image 254

Firewall ufwlink image 255

Ubuntu comes with the firewall ufw installed, but to check it we use the following command

	
!sudo ufw status
Copy
	
Estado: inactivo

As we can see, it is inactive by default, so we are going to create a set of rules. For example, let's start by opening port 22 (SSH). To do this, we use the command sudo allow <port> comment "<comment>", with which we open a port and add a comment.

	
!sudo ufw allow 22 comment 'ssh'
Copy
	
Regla añadida
Regla añadida (v6)

As we can see, it has opened port 22 for IPv4 and IPv6. Let's now activate ufw with the command ufw enable

	
!sudo ufw enable
Copy
	
El cortafuegos está activo y habilitado en el arranque del sistema

If we want to see the rules we have in the firewall, we use the command ufw status

	
!sudo ufw enable
Copy
	
Hasta Acción Desde
----- ------ -----
22 ALLOW Anywhere # ssh
22 (v6) ALLOW Anywhere (v6) # ssh

We can also ask it to show the rules numbered with the command ufw status numbered

	
!sudo ufw status numbered
Copy
	
Estado: activo
Hasta Acción Desde
----- ------ -----
[ 1] 22 ALLOW IN Anywhere # ssh
[ 2] 22 (v6) ALLOW IN Anywhere (v6) # ssh

Since they are numbered, we can delete one using the command ufw delete <rule number>, so to delete the rule for IPv6 we do

	
!sudo ufw delete 2
Copy
	
Estado: activo
Borrando:
allow 22 comment 'ssh'
¿Continuar con la operación (s|n)? s
Regla eliminada (v6)

We check the status again

	
!sudo ufw status numbered
Copy
	
Estado: activo
Hasta Acción Desde
----- ------ -----
[ 1] 22 ALLOW IN Anywhere # ssh

We see that rule number 2 has indeed been removed.

If we want to enable the SSH connection from a single IP, we use the flag from <IP>

	
!sudo ufw allow from 192.168.1.103 proto tcp to any port 22 comment 'ssh ip'
Copy
	
Regla añadida

We check the rules again

	
!sudo ufw status numbered
Copy
	
Estado: activo
Hasta Acción Desde
----- ------ -----
[ 1] 22 ALLOW IN Anywhere # ssh
[ 2] 22/tcp ALLOW IN 192.168.1.103 # ssh ip

If we want to delete all rules, we use the reset command

	
!sudo ufw reset
Copy
	
Estado: activo
Reiniciando todas las reglas a sus valores predeterminados instalados.
¿Continuar con la operación (s|n)? s
Respaldando «user.rules» en «/etc/ufw/user.rules.20221205_171730»
Respaldando «before.rules» en «/etc/ufw/before.rules.20221205_171730»
Respaldando «after.rules» en «/etc/ufw/after.rules.20221205_171730»
Respaldando «user6.rules» en «/etc/ufw/user6.rules.20221205_171730»
Respaldando «before6.rules» en «/etc/ufw/before6.rules.20221205_171730»
Respaldando «after6.rules» en «/etc/ufw/after6.rules.20221205_171730»

We check the status again

	
!sudo ufw status numbered
Copy
	
Estado: inactivo

We see that there are no rules left.

To disable the firewall we use the command ufw disable

	
!sudo ufw disable
Copy
	
El cortafuegos está detenido y deshabilitado en el arranque del sistema

We check the status again

	
!sudo ufw status
Copy
	
Estado: inactivo

Security Audit with Lynislink image 256

To install Lynis you have to use the command sudo apt install lynis

To perform an audit of your system, you need to use the command lynis audit system. This starts scanning the entire system and reports it to you.

I will not show the result of my system scan to avoid exposing my vulnerabilities on the internet.

Command Programminglink image 257

Programming periodic commands with cronlink image 258

With the cron command, we can schedule commands to run periodically. To do this, we need to edit the /etc/crontab file.

	
!cat /etc/crontab
Copy
	
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
17 * * * * root cd / &amp;&amp; run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.monthly )
#

As can be seen, in this file there is a series of commands that are executed periodically. The format of these commands is as follows

<minute> <hour> <day of month> <month> <day of week> <user> <command>

To create the date when you want the command to be executed, there are many online pages that help you write it correctly, such as crontab guru

Scheduling One-Time Commands with atlink image 259

When we want a command to be executed in the future, but not periodically, and only once, we can use the at command. For example, if you turn on an Azure or Amazon machine for which you are charged, and you want to make sure it will shut down so you don't get a surprise on your bill, you can schedule it to shut down at night. This way, even if you forget to turn it off, it will shut itself down.

We do a ls to the /tmp folder

	
!ls -l /tmp
Copy
	
total 60
-rw------- 1 wallabot wallabot 0 sep 24 08:51 config-err-QM3AAe
-rw-r--r-- 1 root root 2049 sep 24 08:51 glances-root.log
drwx------ 2 wallabot wallabot 4096 sep 24 09:06 pyright-9853-BG3nXEXw0Tao
drwxrwxr-x 3 wallabot wallabot 4096 sep 24 09:06 python-languageserver-cancellation
drwx------ 3 root root 4096 sep 24 08:51 snap-private-tmp
drwx------ 2 wallabot wallabot 4096 sep 24 08:51 ssh-mHjlSPPoqCp7
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-colord.service-rpjPri
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-fwupd.service-FzPoQf
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-geoclue.service-F6pMWi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-ModemManager.service-Orf6Bi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-switcheroo-control.service-1QXRqj
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-logind.service-lL35tg
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-resolved.service-iaswSi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-timesyncd.service-Yet8lj
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-upower.service-oTL7Gg
drwx------ 2 wallabot wallabot 4096 sep 24 09:31 tracker-extract-files.1000

Now we are going to program that a new file is created in /tmp within 5 minutes

	
!at 09:55 touch /tmp/at.txt
Copy
	
warning: commands will be executed using /bin/sh
at&gt; touch /tmp/at.txt
at&gt; &lt;EOT&gt;
job 1 at Sun Sep 24 09:55:00 2023

As we can see, we need to write at <time> and on the next line the command we want to execute.

We now see the files that are in /tmp

	
!ls -l /tmp
Copy
	
total 60
-rw-rw-r-- 1 wallabot wallabot 0 sep 24 09:55 at.txt
-rw------- 1 wallabot wallabot 0 sep 24 08:51 config-err-QM3AAe
-rw-r--r-- 1 root root 2049 sep 24 08:51 glances-root.log
drwx------ 2 wallabot wallabot 4096 sep 24 09:06 pyright-9853-BG3nXEXw0Tao
drwxrwxr-x 3 wallabot wallabot 4096 sep 24 09:06 python-languageserver-cancellation
drwx------ 3 root root 4096 sep 24 08:51 snap-private-tmp
drwx------ 2 wallabot wallabot 4096 sep 24 08:51 ssh-mHjlSPPoqCp7
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-colord.service-rpjPri
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-fwupd.service-FzPoQf
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-geoclue.service-F6pMWi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-ModemManager.service-Orf6Bi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-switcheroo-control.service-1QXRqj
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-logind.service-lL35tg
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-resolved.service-iaswSi
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-timesyncd.service-Yet8lj
drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-upower.service-oTL7Gg
drwx------ 2 wallabot wallabot 4096 sep 24 09:31 tracker-extract-files.1000

As we can see, there is an at.txt that was created at 09:55

Keyboard Shortcutslink image 260

The following are some useful keyboard shortcuts when using the terminal

  • Ctrl+a: moves the cursor to the beginning of the command line.
  • Ctrl+e: moves the cursor to the end of the command line.
  • Ctrl+l: clears the terminal, similar to what the clear command does.
  • Ctrl+u: clears from the cursor position to the beginning of the line. If at the end, it clears the entire line.
  • Ctrl+k: clears from the cursor position to the end of the line. If at the beginning, it clears the entire line.
  • Ctrl+h: does the same as the backspace key, it deletes the character immediately before the cursor position.
  • Ctrl+w: deletes the word immediately before the cursor.
  • Alt+d or Esc+d: deletes the word following the cursor.
  • Ctrl+p: sets the command line with the last command entered.
  • Ctrl+r: initiates the search for previously used commands by typing part of a command we have executed before, including options and parameters. By pressing the key combination again, we can cycle through previous matches.
  • Ctrl+c: terminates the process that is running, useful for regaining control of the system.
  • Ctrl+d: exits the terminal, similar to the exit command.
  • Ctrl+z: suspends the execution of the running process and puts it in the background; with the fg command, we can resume its execution.
  • Ctrl+t: swaps the position of the two characters before the cursor, useful for correcting typos.
  • Esc+t: swaps the position of the two words before the cursor, useful for correcting typos.
  • Alt+f: moves the cursor to the beginning of the next word on the line, similar to Ctrl+right in the GNOME terminal.
  • Alt+b: moves the cursor to the beginning of the previous word on the line, similar to Ctrl+left in the GNOME terminal.
  • Tab: autocompletes commands or directory or file paths.
  • Ctrl+Shift+f: opens a dialog to perform a text search in the terminal output.
  • Ctrl+Shift+g: find the next occurrence of the previous search in the terminal.
  • Ctrl+Shift+h: find the previous occurrence of the previous search in the terminal.
  • Ctrl+Shift+c: copy the selected text from the terminal to the clipboard.
  • Ctrl+Shift+v: paste the text from the clipboard into the command line.
  • Up: sets the previous command from history on the command line, just like Ctrl+p.
  • Down: sets on the command line the next command from the history.
  • Left Mouse: select lines of text from the terminal.
  • Ctrl+Left Mouse: select blocks of text from the terminal.

Folder system in Linuxlink image 261

In the following image we can see how the folder system looks in Linux

carpetas_linux

This image has been taken from the post on LinkedIn by Roberto Morais

Fricadelslink image 262

You forgot to use sudolink image 263

Have you ever been in a situation where you needed to run a command with sudo, but forgot to type sudo? Well, after receiving the corresponding error, if you do sudo !!, it will execute the previous command with sudo.

	
!apt update
Copy
	
Leyendo lista de paquetes... Hecho
E: No se pudo abrir el fichero de bloqueo «/var/lib/apt/lists/lock» - open (13: Permiso denegado)
E: No se pudo bloquear el directorio /var/lib/apt/lists/
W: Se produjo un problema al desligar el fichero /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permiso denegado)
W: Se produjo un problema al desligar el fichero /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permiso denegado)

As can be seen, when we run sudo update we get an error, but if we now run sudo !! it will execute sudo apt update

	
!sudo !!
Copy
	
[sudo] contraseña para wallabot:

Kernel Messageslink image 264

With the dmesg command (display kernel ring buffer messages), we can view kernel messages. For example, this is very useful for checking if a USB device has been connected, or for debugging hardware errors on our computer.

	
!dmesg | tail
Copy
	
[ 35.812312] input: LogiOps Virtual Input as /devices/virtual/input/input33
[ 35.916406] input: LogiOps Virtual Input as /devices/virtual/input/input34
[ 36.002064] input: LogiOps Virtual Input as /devices/virtual/input/input35
[ 63.879806] input: MX Master 3 as /devices/virtual/misc/uhid/0005:046D:B023.0006/input/input36
[ 63.879931] logitech-hidpp-device 0005:046D:B023.0006: input,hidraw3: BLUETOOTH HID v0.15 Keyboard [MX Master 3] on 4c:77:cb:1d:66:d0
[ 63.902120] logitech-hidpp-device 0005:046D:B023.0006: HID++ 4.5 device connected.
[ 69.604899] input: MX Keys Keyboard as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input37
[ 69.605221] input: MX Keys Mouse as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input38
[ 69.606204] hid-generic 0005:046D:B35B.0007: input,hidraw4: BLUETOOTH HID v0.13 Keyboard [MX Keys] on 4c:77:cb:1d:66:d0
[ 188.285030] input: T9 (AVRCP) as /devices/virtual/input/input40

With the --follow flag, we can see new messages in real time as they are generated.

	
!dmesg --follow
Copy
	
[ 0.000000] Linux version 5.15.0-84-generic (buildd@lcy02-amd64-005) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #93~20.04.1-Ubuntu SMP Wed Sep 6 16:15:40 UTC 2023 (Ubuntu 5.15.0-84.93~20.04.1-generic 5.15.116)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-84-generic root=UUID=59002381-d88d-44a6-b83d-8c5a226ce058 ro quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000000a0000-0x00000000000fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000009d01fff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000009d02000-0x0000000009ffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x000000000a000000-0x000000000a1fffff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000a200000-0x000000000a20bfff] ACPI NVS
[ 0.000000] BIOS-e820: [mem 0x000000000a20c000-0x00000000b8983fff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000b8984000-0x00000000b8acdfff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000b8ace000-0x00000000b8c56fff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x00000000b8c57000-0x00000000b9107fff] ACPI NVS
[ 0.000000] BIOS-e820: [mem 0x00000000b9108000-0x00000000ba55cfff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000ba55d000-0x00000000bcffffff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000bd000000-0x00000000bfffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
...
[ 35.916406] input: LogiOps Virtual Input as /devices/virtual/input/input34
[ 36.002064] input: LogiOps Virtual Input as /devices/virtual/input/input35
[ 63.879806] input: MX Master 3 as /devices/virtual/misc/uhid/0005:046D:B023.0006/input/input36
[ 63.879931] logitech-hidpp-device 0005:046D:B023.0006: input,hidraw3: BLUETOOTH HID v0.15 Keyboard [MX Master 3] on 4c:77:cb:1d:66:d0
[ 63.902120] logitech-hidpp-device 0005:046D:B023.0006: HID++ 4.5 device connected.
[ 69.604899] input: MX Keys Keyboard as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input37
[ 69.605221] input: MX Keys Mouse as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input38
[ 69.606204] hid-generic 0005:046D:B35B.0007: input,hidraw4: BLUETOOTH HID v0.13 Keyboard [MX Keys] on 4c:77:cb:1d:66:d0
[ 188.285030] input: T9 (AVRCP) as /devices/virtual/input/input40
	
^C

Hardware Informationlink image 265

With lshw we can view information about the hardware of our computer

	
!lshw
Copy
	
AVISO: debería ejecutar este programa como superusuario.
wallabot
descripción: Computer
anchura: 64 bits
capacidades: smp vsyscall32
*-core
descripción: Motherboard
id físico: 0
*-memory
descripción: Memoria de sistema
id físico: 0
tamaño: 32GiB
...
producto: PnP device PNP0501
id físico: 6
capacidades: pnp
configuración: driver=serial
*-pnp00:05
producto: PnP device PNP0c02
id físico: 7
capacidades: pnp
configuración: driver=system
AVISO: la salida puede ser incompleta o imprecisa, debería ejecutar este programa como superusuario.

Cowsaylink image 266

There is a command called cowsay to which you pass a text as a parameter and it draws a cow saying that text.

It may not be installed, so to install it, you have to enter the command

sudo apt install cowsay
	
terminal("cowsay MaximoFN")
Copy
	
__________
< MaximoFN >
----------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

If you add the flag -f dragon the one who says it is a dragon.

	
terminal("cowsay -f dragon MaximoFN")
Copy
	
__________
< MaximoFN >
----------
\ / \ //\
\ |\___/| / \// \\
/0 0 \__ / // | \ \
/ / \/_/ // | \ \
@_^_@'/ \/_ // | \ \
//_^_/ \/_ // | \ \
( //) | \/// | \ \
( / /) _|_ / ) // | \ _\
( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
(( / / )) ,-{ _ `-.|.-~-. .~ `.
(( // / )) '/\ / ~-. _ .-~ .-~^-. \
(( /// )) `. { } / \ \
(( / )) .----~-.\ \-' .~ \ `. \^-.
///.----..> \ _ -~ `. ^-` ^-_
///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
/.-~
	
terminal("cowsay -f dragon-and-cow MaximoFN")
Copy
	
__________
< MaximoFN >
----------
\ ^ /^
\ / \ // \
\ |\___/| / \// .\
\ /O O \__ / // | \ \ *----*
/ / \/_/ // | \ \ \ |
@___@` \/_ // | \ \ \/\ \
0/0/| \/_ // | \ \ \ \
0/0/0/0/| \/// | \ \ | |
0/0/0/0/0/_|_ / ( // | \ _\ | /
0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
,-} _ *-.|.-~-. .~ ~
\ \__/ `/\ / ~-. _ .-~ /
\____(oo) *. } { /
( (--) .----~-.\ \-` .~
//__\\ \__ Ack! ///.----..< \ _ -~
// \\ ///-._ _ _ _ _ _ _{^ - - - - ~

Cleaninglink image 267

Since the folder prueba has been created, we delete it to leave everything as we found it.

	
!rm -r prueba
Copy

Continue reading

Stream Information in MCP: Complete Guide to Real-time Progress Updates with FastMCP

Stream Information in MCP: Complete Guide to Real-time Progress Updates with FastMCP

Learn how to implement real-time streaming in MCP (Model Context Protocol) applications using FastMCP. This comprehensive guide shows you how to create MCP servers and clients that support progress updates and streaming information for long-running tasks. You'll build streaming-enabled tools that provide real-time feedback during data processing, file uploads, monitoring tasks, and other time-intensive operations. Discover how to use StreamableHttpTransport, implement progress handlers with Context, and create visual progress bars that enhance user experience when working with MCP applications that require continuous feedback.

Last posts -->

Have you seen these projects?

Horeca chatbot

Horeca chatbot Horeca chatbot
Python
LangChain
PostgreSQL
PGVector
React
Kubernetes
Docker
GitHub Actions

Chatbot conversational for cooks of hotels and restaurants. A cook, kitchen manager or room service of a hotel or restaurant can talk to the chatbot to get information about recipes and menus. But it also implements agents, with which it can edit or create new recipes or menus

Subtify

Subtify Subtify
Python
Whisper
Spaces

Subtitle generator for videos in the language you want. Also, it puts a different color subtitle to each person

View all projects -->

Do you want to apply AI in your project? Contact me!

Do you want to improve with these tips?

Last tips -->

Use this locally

Hugging Face spaces allow us to run models with very simple demos, but what if the demo breaks? Or if the user deletes it? That's why I've created docker containers with some interesting spaces, to be able to use them locally, whatever happens. In fact, if you click on any project view button, it may take you to a space that doesn't work.

Flow edit

Flow edit Flow edit

FLUX.1-RealismLora

FLUX.1-RealismLora FLUX.1-RealismLora
View all containers -->

Do you want to apply AI in your project? Contact me!

Do you want to train your model with these datasets?

short-jokes-dataset

Dataset with jokes in English

opus100

Dataset with translations from English to Spanish

netflix_titles

Dataset with Netflix movies and series

View more datasets -->