Terminal

Terminal Terminal

Introduction to the Terminallink image 134

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 post console images for every action I take, I have created the following function that receives 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 that 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

First commands to navigate the terminallink image 136

ls (list directory)link image 137

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

	
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"\t 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('\n')
print('\n'.join(result_split[:max_lines_output]))
print("\t ...")
print('\n'.join(result_split[-5:]))
else:
print(result)
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 can usually 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 that gives us easier to read 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 them 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 it to show us the files sorted alphabetically but in reverse 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 see that they change

	
terminal('cd /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

If instead of giving cd the directory we want to move to, we give it the character -, it will return to the previous directory where it was.

	
terminal('cd -')
Copy
	
terminal('cd -')
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, just entering cd in the terminal will take us there.

	
terminal('cd')
Copy

pwd (print working directory)link image 139

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

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

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

	
terminal('cd /home/wallabot/Documentos/')
Copy
	
terminal('cd /home/wallabot/Documentos/')
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 provide the address from the point where we are located.

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

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

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

If instead of .. we use ., we are referring to the directory we are currently in. That is, if we use cd ., we will not move because we are telling the terminal to go to the directory we are in.

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

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

	
terminal('cd web/portafolio/posts/')
Copy
	
terminal('cd web/portafolio/posts/')
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

Information of files with filelink image 140

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

	
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 first to the home.

	
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('cd /home/wallabot/Documentos/')
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 the files from the path we are in, making it a bit hard to read. However, with the L option, we can specify how many levels we want it to go deep.

	
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, whereas previously it indicated 873 directories, 119679 files.

Create directories with mkdir (make directory)link image 143

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

	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/")
Copy
	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/")
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 we want to create a directory with spaces in the name, we need to put the name in 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 inside the prueba folder that we have created, to continue viewing the terminal there.

	
terminal("cd prueba")
Copy

Create files with touchlink image 144

In case we want to create a file, the command we have to use is touch

	
terminal("cd prueba")
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

Move 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 also helps us rename files, as moving them within the same directory but giving them a different name ultimately renames the file.

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

Delete 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
	

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

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

	
terminal("cd ..")
Copy
	
terminal("cd ..")
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 we need to add the flag -i (interactive)

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

Synchronize files using rsynclink image 150

So far we have seen how to copy, move, and delete files, but let's suppose we have a folder and we copy those files to another one. Now let's suppose we modify a file in the first folder and we want the second one to have the changes. We have two options, copy all the files again, or synchronize them 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 which is the one we are going to synchronize with the first one.

	
!mkdir sourcefolder
!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3
!mkdir syncfolder
Copy
	
!mkdir sourcefolder
!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3
!mkdir syncfolder
!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 must also add the -r (recursive) flag.

	
!rsync -r sourcefolder/ syncfolder/
Copy
	
!rsync -r sourcefolder/ syncfolder/
!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
	
!touch sourcefolder/file4
!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 from happening and to copy only the ones that have been modified, you need to use the -u flag.

	
!touch sourcefolder/file5
Copy
	
!touch sourcefolder/file5
!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

What happens if I create a new file in syncfolder?

	
!touch syncfolder/file6
Copy
	
!touch syncfolder/file6
!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 sync it, 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 subdirectories and files.* -v: This flag activates verbose output, which shows the files being copied and the progress of the operation. * -r: This flag is used to copy recursively, which means it copies all subfolders and files within a directory. * -u: This flag is used to copy only the new or modified files. If a file already exists at the destination and is more recent than the source file, it is not copied. * -n: This flag is used to perform a dry run, which means 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 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 Content of the Fileslink image 151

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

	
!rm -r sourcefolder syncfolder
terminal("cd prueba")
Copy
	
!rm -r sourcefolder syncfolder
terminal("cd prueba")
terminal("cp ../2021-02-11-Introduccion-a-Python.ipynb .")
Copy
	
	
terminal("ls")
Copy
	
2021-02-11-Introduccion-a-Python.ipynb

File Header with headlink image 152

The first command to be able to look inside a text file is head, which allows us to see the first 10 lines of a file, but if you use the -n flag you can indicate 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": {

End of a file with taillink image 153

In case you want to see 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 see the latest lines of a file, for example, we want to continuously monitor a LOG file to see events, we add the -f flag, this will make the terminal continuously check the file, and each 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

	
Copy
	
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.

	
Copy
	
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 to view 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
}

Being inside a notebook, you can't really see what happens when using less, but when we use it, we enter the document, and we can navigate through it using the keyboard or the mouse. If we want to search for something within the document, we write the character / and what we want to search for. To switch between the different instances it has found, we press the n key, and if we want to go back in the searches, we press shift+n. To exit, just press q

The cat viewerlink image 155

It does not allow you to browse 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 file's default editor, we need to use xdg-open

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

File manager nautiluslink image 157

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

	
terminal("nautilus")
Copy
	

And if what we want is for it to open in a specific path, the path is included.

	
terminal("nautilus ~/")
Copy
	

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

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

	
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 commandlink image 159

A command can be four things* An executable program, these are usually stored in the /usr/bin path* 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 ourselves, it is defined using the alias command. For example, we are going to create the alias l that will perform ls -h

	
!alias l='ls -l'
Copy

When we execute l, it shows us the result of ls -h.

	
!alias l='ls -l'
!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 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, as 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, as info uses less as the information viewer.

Information about 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 help us perform special searches. For example, if I want to search for all files ending 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 characters *link image 167

Let's now search for all .txt files

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

Let's now search for all that start with the word datos

	
!ls datos*
Copy
	
datos1 datos123

Numbers ?link image 168

But what if we actually want to show all the files that start with the word datos but are followed only by a number? We need to use a question mark ?.

	
!ls datos?
Copy
	
datos1

If what we want is for it to have three numbers, then we have 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.

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

Classeslink image 171

By using brackets, we can create classes; thus, 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

Redirections: 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 through the keyboard, a standard output, which by default is the text that comes out on the console, and a standard error which is also by default a text that comes out on the console, but has 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 current directory with 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, and if lista.txt does not exist, it creates it.

	
!ls > lista.txt
Copy

We see that the file has been created and we see what is inside.

	
!ls > lista.txt
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 lista.txt appears within lista.txt, that's 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

	
!ls ../ > lista.txt
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 overwritten

If what we want is to concatenate the content, we should use >>

	
!ls > lista.txt
Copy
	
!ls > lista.txt
!ls ../ >> lista.txt
Copy
	
!ls > lista.txt
!ls ../ >> 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
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 we redirect a command that gives 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, that's because we haven't redirected the standard error to lista.txt, but the standard output. As we have seen in the image, there are two standard outputs in a command, the first one is the standard output and the second one is the standard error, so to redirect the standard error you have to indicate it with 2>. Let's proceed this way now.

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

As we can see, it has now been redirected

Redirecting 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 look inside lista.txt

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

If we now execute a command without errors

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

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

	
!ls . >> lista.txt 2>&1
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 you can see, both standard error and 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 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 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 Sequentiallylink 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, the ls command was executed first, 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 sequentially.

	
!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 you can see, in the first ls, secuential.txt does not appear, while in the second one it does. This means that the commands were executed sequentially, one after the other.

Parallel Commandslink image 179

If what we want is for the commands to be executed in parallel, we must use the & operator. This will create a new process for each command.

Let's look at the previous example

	
!rm secuential.txt
Copy
	
!rm secuential.txt
!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 you can see that they have not been executed sequentially, since the echos have been executed first, which will take the least time, and then the rest.

Conditional Commandslink image 180

Andlink image 181

Using the && operator, a command will execute when the previous one has successfully run

	
!rm secuential.txt
Copy
	
!rm secuential.txt
!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 it has been executed one after another, that is, a command does not start until the previous one ends

But then, what's the difference between ; and &&?

In the first case, the sequential ;, one command is executed first and then the other, but for a command to be executed, it doesn't matter if the previous one was executed successfully.

	
!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 you can see, first rm prueba is executed, an error occurs, and ls -lha prueba is still executed.

In the conditional manner &&, if a command does not execute successfully, the next one will not be executed.

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

As you can see ls -lha prueba does not execute because rm prueba has given an error

Orlink image 182

Unlike &&, the 'or' will execute all processes regardless of their result. 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 Managedlink image 183

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

	
!mkdir subdirectorio
Copy
	
!mkdir subdirectorio
!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

First, let's see what types of files there are. * -: Regular file* d: Directory* l: Symbolic link* b: Special block file. These are files that manage data block information, such as a USB

Later we will see the types of mode:

<table border="1">
      ``````markdown
      <header>
      ```<tr><th scope="col" colspan="3">Owner</th><th scope="col" colspan="3">Group</th><th scope="col" colspan="3">Mundo</th>```markdown
          	</tr>
      ```	</header><body>		<tr><th scope="row" colspan="3">rwx</th><th scope="row" colspan="3">r-x</th><th scope="row" colspan="3">r-x</th>		</tr>		<tr>			<th scope="row">1</th><th scope="row">1</th>			<th scope="row">1</th><th scope="row">1</th><th scope="row">0</th>			<th scope="row">1</th>			<th scope="row">1</th><th scope="row">0</th><th scope="row">1</th>		</tr>		<tr>			<th scope="row" colspan="3">7</th>			<th scope="row" colspan="3">5</th>			<th scope="row" colspan="3">5</th>		</tr><body></table>
      * r: read* w: write * x: execute
      

Symbolic mode:* u: User-only* g: Group only* o: Only for others (world)* a: For all

Modifying Permissions in the Terminallink image 184

We create a new file

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

Let's see 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 the rest (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 need to set the user's permissions first in octal, then the group's, and lastly the others'.

	
!chmod 755 mitexto.txt
Copy
	
!chmod 755 mitexto.txt
!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 only for my user. To change only the permissions for a user, we use the symbolic identifier, a + if we want to add permissions or a - if we want to remove them or a = if we want to reset them followed by the type of permission

	
!chmod u-r mitexto.txt
Copy
	
!chmod u-r mitexto.txt
!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 will grant the read permission again

	
!chmod u+r mitexto.txt
Copy
	
!chmod u+r mitexto.txt
!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 so by separating each permission with a ,

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

As can be seen, execution permission has been removed for 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 find out who we are, we can use the whoami (who am I) command.

	
!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

Change of user with the su (switch user) commandlink 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 changes and now indicates that we are the user root.

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 am going to create a file in the folder where I previously created the mitexto.txt file.

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

I change 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

	
!cd /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio
!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 owner and group of the file rootfile.txt is the user root

If I, now that I am the user wallabot, 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, as it belongs to another user.

Change a User's Passwordlink image 189

If I want to modify the password of the currently active user, I use the passwd (password) command.

First, I check which user I am

	
!whoami
Copy
	
wallabot

And now we 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

	
!ln -s /home/wallabot/Documentos/web web
!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 pointing to /home/wallabot/Documentos/web:

I can now go to web

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

Set environment variableslink image 191

Viewing 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 see a specific environment variable, we can do it 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's 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
	

We return to see what's inside PATH

	
!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 subdirectory directory 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 go to the home folder

	
terminal("cd /home/wallabot")
Copy

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

	
terminal("cd /home/wallabot")
!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 file that contains 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 each time a new one is opened, so if we edit the PATH variable in it, this change will persist for all new terminal windows 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 it also happened that they were lost every time we closed a terminal session. To prevent this, we also add them to the .bashrc configuration file. For example, in my case, I have added the following lines. alias ll='ls -l'alias la='ls -a'bash alias lh='ls -h'

alias
      

Search Commandslink image 197

Searching for Binaries with whichlink image 198

The first search command we will see is which which allows us to find the path of the 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

File Search with findlink image 199

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

	
!which cd
!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 plus the copy that I have created in this notebook and saved in the prueba folder

One very 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 do not want it to distinguish between uppercase and lowercase, we must use the -iname flag. For example, if we search 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 distinguished 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 search for 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 am going to search for all folders named subdirectorio

	
!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

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

	
!find ~/ -name subdirectorio -type d
!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 Search Commandlink image 200

grep is a very powerful search command, that's 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, let's search for all the times the text MaximoFN appears within the file 2021-02-11-Introduccion-a-Python.ipynb

	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/prueba")
Copy
	
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/prueba")
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\\n"
"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, that is, it searches the text exactly as you have entered it, differentiating between uppercase and lowercase. If we don't want this, we need to introduce the -i flag.

	
!grep maximofn 2021-02-11-Introduccion-a-Python.ipynb
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\\n"
"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 use the -c flag

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

If we don't care if 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 now we want all the times in which 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 information about all the network interfaces of 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 obtain information about our network interfaces is by using 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 help us see if we have a connection to a specific IP. For example, Google's IP is 142.250.200.78, so we do a ping to see if it responds. The ping command in Linux pings continuously, so it never ends until we 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 Google's html.

	
!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> &raquo;</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%">&nbsp;</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&amp;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&amp;hl=ca&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&amp;hl=gl&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&amp;hl=eu&amp;source=homepage&amp;sa=X&amp;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&amp;prev=https://www.google.es/&amp;sig=K_a2UXepORMQOw5-SHU8h4noB_VWk%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">&copy; 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 see if it has 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> &raquo;</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%">&nbsp;</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&amp;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&amp;hl=ca&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&amp;hl=gl&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&amp;hl=eu&amp;source=homepage&amp;sa=X&amp;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&amp;prev=https://www.google.es/&amp;sig=K_8O8QHBmoai9DOT5YZxMWevJK8VI%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">&copy; 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>

Download 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 has it named.

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

Path Debugging with traceroutelink image 207

A very useful command is to see the route to a destination, for this we use traceroute, for example, let's see all the sites I have to pass 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

Route Debugging with mtrlink image 208

Another debugging tool is mtr, which is an improved version of traceroute. It provides information for each hop, such as response time, packet loss percentage, 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 you can see in hop 5, almost 50% of the packets are lost, which would help me call my phone company and ask them to try routing me through a different 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

Default gateway information with route -nlink image 210

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 of 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

Information about our network with netstatslink image 212

The last utility command is netstats, this command gives us the status of our network, and with the -i flag 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
	
; <<>> DiG 9.16.1-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- 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

```;; ANSWER SECTION:google.com.       283     IN      A       142.250.184.14```
      Therefore, the query has given us Google's IP
      

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

	
!dig @1.1.1.1 google.com
Copy
	
; <<>> DiG 9.16.1-Ubuntu <<>> @1.1.1.1 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- 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 Cloudflare's 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 except the tocompress folder itself has been copied because we did not use the -r flag in the cp command. But what happened is what we wanted.

Compress with tarlink image 215

The first command we are going to use to compress is tar to which we will add the -c flag for compress, -v for verbose, so it will show us what it is doing, and the -f flag for file, followed by the name we want for the compressed file 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 the file tocompress.tar has been created.

Now we are going to repeat the process, but adding the -z flag, which compresses in the gzip format, 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 you can see, the file tocompress.tar occupies 340 kB, while the file tocompress.tar.gz occupies only 52 kB.

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

First, we delete the original folder

	
!rm -r tocompress
Copy

We decompress

	
!rm -r tocompress
!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 gzip

	
!rm -r tocompress
Copy
	
!rm -r tocompress
!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 is zip. To compress, you only need to add the -r (recursive) flag, the name you want for the compressed file, 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 unzip, the unzip command is used followed by the name of the file you want to unzip. First, we delete the tocompress folder.

	
!rm -r tocompress
Copy
	
!rm -r tocompress
!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

Pause a Process and Send It to the Background with CTRL+Zlink image 218

When we run a process in the terminal, it may not stop executing and we might 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 be 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 stop the process for a moment 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 have put it in the background.

Viewing Background Processes with jobslink image 219

To see which 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 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, it will not give us the ping information, since 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 is no background process in this terminal and ps only returns the information of bash (the terminal itself) and the ps command executed.

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, simply typing fg is enough; otherwise, you need to specify the job number.

Let's take another look at the processes we had in the background

	
!jobs
Copy
	
[1]+ Detenido ping localhost

We can bring this process to the foreground by just typing fg or indicating 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 says that the process has been stopped, so if we want to browse with Firefox now, we can't, as it is stopped.

To be able to launch Firefox and have it in the background so that it doesn't block our terminal, you need to write an & at the end of the command

	
!firefox &
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 stays running in the background

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

	
!jobs
Copy
	
[1]+ Ejecutando firefox &

Terminate a background processlink image 223

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

	
!jobs
Copy
	
[1]+ Ejecutando firefox &

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

	
!kill %1
Copy
	

It doesn't respond anything to us, 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
	

Terminal-independent background processeslink image 224

So far we have seen how to execute background processes dependent on the terminal, this means that if we send a process to the background and close the terminal, it will send a termination message to all the 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 is possible that it comes pre-installed, so to install it you have 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 for us, which is actually a tmux session

Within 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 see, we have recovered the previous ping

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

Process Managementlink image 225

To manage 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 &
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 look at 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 show us all the 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< 23:06 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 23:06 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I< 23:06 0:00 [netns]
root 7 0.0 0.0 0 0 ? I< 23:06 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< 23:06 0:00 [kworker/0:1H-events_highpri]
root 10 0.0 0.0 0 0 ? I< 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 that my user is running, I can do it 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<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&uid=e1be826f-73fb-46c2-a439-9bb52643ccc1&iid=e1be826f-73fb-46c2-a439-9bb52643ccc1&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 Manager toplink image 227

With top we can see all the processes of the operating system. It will show the information with less, so, as explained before, when you want to stop top, entering 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 you can see, 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 need to enter kill and its PID.

The good thing about top is that it gives us many more utilities; if we press h it will display 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,&,<,> . Locate: 'L'/'&' find/again; Move sort column: '<'/'>' 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 <Esc> to continue

To exit, press ESC or q

As shown in the help, if u is entered we can filter by user, I enter my user (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 Manager htoplink image 228

It is similar to top but more powerful You probably don't have it installed, so to install it enter the command

``````markdown
      sudo apt install htop
      

o

````sudo snap install htop`
      

Process Manager glanceslink image 229

It is similar to top but more powerful You probably don't have it installed, so to install it enter the command

```sudo apt install glances```
      

RAM Memory Managementlink image 230

If we only want to get information from 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 flag -h (human), to make it easier to read.

	
!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 obtain information from the hard drive, we use the du command. If we only input this command in the terminal, it will give us the information of all the folders on our machine. Therefore, to avoid obtaining too much information, it is necessary to provide 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/

As before, we add the -h (human) flag 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 start in 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 prompt.

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

	
!tty
Copy
	
/dev/pts/0

Package Managementlink image 233

PPA Repositories (Personal Package Archives)link 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 fetch the binaries.

This list of repositories is located in /etc/apt/sources.list and inside the /etc/apt/sources.list.d folder. 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 through the network or a USB. From here on, various lines starting with deb or deb-src will appear. Binaries are found in deb and source code is found in deb-src. Every valid repository address has one of these formats:

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 (Free and Open-Source Software). 2. Universo Like Main, Universe also offers FOSS. The difference is that in this repository it is not Ubuntu that guarantees regular security updates, but rather the community that takes care of its support. It is 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 can we find in "Universe"? I would say most of the worthwhile software, such as VLC and OpenShot.
      3. Multiverse
      From here onwards come the Ubuntu repositories with less freedom. `Multiverse` contains software that is no longer `FOSS` and Ubuntu cannot activate 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:
      ``` bash
      ```markdown
      sudo add-apt-repository multiverse
  1. Restringido

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

```markdown
      sudo add-apt-repository restricted
      
  1. Partner

This repository contains proprietary software compiled by Ubuntu from its partners. 6. Third-party Ubuntu repositories Lastly, we have third-party repositories. Ubuntu always aims to provide the best user experience, and that 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 that reason, they create their own repositories.

Adding repositorieslink image 235

If we are on Ubuntu, we can add a repository using the command add-apt-repository <repository>. But as in other distributions that are not Ubuntu, we don't have this command.

Update the repositorieslink image 236

With the apt update command we will be able to update the latest versions of the packages we have in our repository.

Update packageslink image 237

Using the apt upgrade command, we will be able to update the programs we have installed and of which we have previously updated the repository.

Updating the Kernellink image 238

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

Warning!: Updating kernel packages may cause some packages to break Reminder: When updating kernel packages, it is necessary to restart the computer 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 which packages we have installed, we can use dpkg -l, this will give us a list of all the packages we have 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 we have a package 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 Packages Downloaded and Not from Repositorieslink image 241

On some occasions, 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

Active User Information with idlink image 243

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. Users in Debian-based distributions are given an id starting from 1000, while the root user is assigned the id 0.

Active user information with whoamilink image 244

Another command to know which user I am is whoami

	
!whoami
Copy
	
wallabot

File with information on all userslink image 245

The user information is in the /etc/passwd file

	
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 need to use the command passwd <user> <password>. If the user is not specified, it will use the output of the whoami command.

Create users with useraddlink image 247

To create a new user, use the command useradd <user name>, let's create a new user

	
!sudo useradd usertest1
Copy
	

Let's see if it is 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 with id 1001 has been created, which is the next one after my user wallabot, which was the last one.

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

	
!ls /home
Copy
	
wallabot

Only the wallabot user's folder exists, but not the test1 user's folder.

Create Users with adduserlink image 248

Therefore, we are going to see another command to create 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 in 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 for it has been created in home

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

	
!sudo userdel usertest1
Copy
	
	
!sudo userdel usertest2
Copy
	

Let's see 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.

	
!cat /etc/passwd | grep usertest
!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

Create an Admin 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 see 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 noadmin group, 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 more groups, including one called sudo. Users who have access to this group have administrative powers, so to give the new user we have created 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

Let's now see which groups the user noadmin belongs to

	
!groups noadmin
Copy
	
noadmin : noadmin sudo

As we can see, they already belong to the sudo group, so they already have administrator privileges.

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

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

We see that noadmin no longer belongs to 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 return to see 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 history command 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 execute one of the commands from the history, we do it using !<num command>, for example, if I want to execute 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 the history is to enter CTRL+r. By doing this, the following message will appear in the console

	
!reverse-i-search)`':
Copy
	

So as you type, commands that match what you've entered will appear. For example, if I type if, the last time I used ifconfig will appear. If we press CTRL+r again, older matches will start to appear

Delete Commands from Historylink image 253

There are commands like ls, cd, pwd that don't contribute much by being in the history, so it can be configured not to save them 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 ufw firewall installed, but to check it we use the following command

	
!sudo ufw status
Copy
	
Estado: inactivo

As we can see by default it is inactive, so we are going to create a set of rules. For example, let's start by opening port 22 (SSH), for 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. Now let's 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 ufw status command.

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

We can also tell it to show us the numbered rules 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

As we have them numbered, we can remove 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 see the state 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 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 the 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 more rules

To disable the firewall, 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 audit your system, you need to use the command lynis audit system. This will start scanning the entire system and report it to you.

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

Command Programminglink image 257

Scheduling Periodic Commands with cronlink image 258

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

	
!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 / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

As you can see, in this file, there are a series of commands that are executed periodically. The format of these commands is as follows <minute> <hour> <day of the month> <month> <day of the week> <user> <command>

To correctly create the date on which you want the command to be executed, there are a lot of 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 we don't want it to be executed periodically, instead only once, we can use the at command. For example, you turn on an Azure or Amazon machine, which charges you, and you want to be sure it will turn off and not surprise you on the bill, you can schedule it to turn off at night. That way, even if you forget to turn it off, it will turn off automatically.

We run an ls in 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 let's program the creation of a new file in /tmp in 5 minutes

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

As we can see, it is necessary to write at <time> and on the next line the command we want to run.

Let's now see the files 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 has been created at 09:55

Keyboard Shortcutslink image 260

Below are some useful keyboard shortcuts for 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, deleting the character immediately before the cursor's position.* Ctrl+w: deletes the word immediately before the cursor.* Alt+d or Esc+d: deletes the next word after the cursor.* Ctrl+p: sets the command line with the last entered command.* Ctrl+r: starts the search for previously used commands by typing part of a previously executed command including the options and parameters. Once a search is done, pressing the key combination again will find previous matches.* Ctrl+c: terminates the currently running process, 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 positions 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: move the cursor to the beginning of the next word on the line, same as Ctrl+right in the GNOME terminal. * Alt+b: moves the cursor to the beginning of the previous word on the line, the same as Ctrl+left in the GNOME terminal.* Tab: autocompletes commands or directory/file paths. * Ctrl+Shift+f: opens a dialog to search for text in the terminal output.* Ctrl+Shift+g: search for the next occurrence of the previous search in the terminal. * Ctrl+Shift+h: search for the previous occurrence of the previous search in the terminal.* Ctrl+Shift+c: copies the selected text from the terminal to the clipboard.* Ctrl+Shift+v: pastes the clipboard text into the command line.* Up: sets the previous command from the history in the command line, same as Ctrl+p.* Down: sets the next command from the history in the command line.* Left Mouse: selects lines of terminal text.* Ctrl+Left Mouse: selects blocks of text from the terminal.

Folder System in Linuxlink image 261

In the following image, we can see what the folder system looks like in Linux carpetas_linux This image has been taken from the post on LinkedIn by Roberto Morais

content_filter_results: {'hate': {'filtered': False, 'severity': 'safe'}, 'self_harm': {'filtered': False, 'severity': 'safe'}, 'sexual': {'filtered': True, 'severity': 'medium'}, 'violence': {'filtered': False, 'severity': 'safe'}} message_content: None

You forgot to use sudolink image 262

Have you ever gone to use a command that you needed to run with sudo, but forgot to type sudo? Well, after receiving the corresponding error, if you do sudo !! the previous command will be executed 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 you can see, when running sudo update it gives us an error, but if we now execute sudo !! it will run sudo apt update.

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

Kernel Messageslink image 263

With the dmesg (display kernel ring buffer messages) command we can see kernel messages. For example, this is very useful to see if a USB device has been connected, or to debug HW 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 in real-time the new messages that are generated

!dmesg --follow
      
[    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 264

With lshw we can see hardware information of our computer

	
!dmesg --follow
!lshw
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
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 265

There is a command called cowsay to which you pass a text as a parameter and it draws a cow saying that text. It is possible that you don't have it installed, so to install it, you need to enter the command

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

If you add the -f dragon flag, it is said by 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 266

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

	
!rm -r prueba
Copy

Continue reading

DoLa – Decoding by Contrasting Layers Improves Factuality in Large Language Models

DoLa – Decoding by Contrasting Layers Improves Factuality in Large Language Models

Have you ever talked to an LLM and they answered you something that sounds like they've been drinking machine coffee all night long 😂 That's what we call a hallucination in the LLM world! But don't worry, because it's not that your language model is crazy (although it can sometimes seem that way 🤪). The truth is that LLMs can be a bit... creative when it comes to generating text. But thanks to DoLa, a method that uses contrast layers to improve the feasibility of LLMs, we can keep our language models from turning into science fiction writers 😂. In this post, I'll explain how DoLa works and show you a code example so you can better understand how to make your LLMs more reliable and less prone to making up stories. Let's save our LLMs from insanity and make them more useful! 🚀

Last posts -->

Have you seen these projects?

Subtify

Subtify Subtify

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.

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 -->